~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/cgroup/cgroup_event_listener.c

Version: ~ [ linux-5.15-rc1 ] ~ [ linux-5.14.5 ] ~ [ linux-5.13.18 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.66 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.147 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.206 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.246 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.282 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.283 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/cgroup/cgroup_event_listener.c (Version linux-5.15-rc1) and /tools/cgroup/cgroup_event_listener.c (Version linux-5.13.5)


** Warning: Cannot open xref database.

  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  * cgroup_event_listener.c - Simple listener o    
  4  *                                                
  5  * Copyright (C) Kirill A. Shutemov <kirill@sh    
  6  */                                               
  7                                                   
  8 #include <assert.h>                               
  9 #include <err.h>                                  
 10 #include <errno.h>                                
 11 #include <fcntl.h>                                
 12 #include <libgen.h>                               
 13 #include <limits.h>                               
 14 #include <stdio.h>                                
 15 #include <string.h>                               
 16 #include <unistd.h>                               
 17                                                   
 18 #include <sys/eventfd.h>                          
 19                                                   
 20 #define USAGE_STR "Usage: cgroup_event_listene    
 21                                                   
 22 int main(int argc, char **argv)                   
 23 {                                                 
 24         int efd = -1;                             
 25         int cfd = -1;                             
 26         int event_control = -1;                   
 27         char event_control_path[PATH_MAX];        
 28         char line[LINE_MAX];                      
 29         int ret;                                  
 30                                                   
 31         if (argc != 3)                            
 32                 errx(1, "%s", USAGE_STR);         
 33                                                   
 34         cfd = open(argv[1], O_RDONLY);            
 35         if (cfd == -1)                            
 36                 err(1, "Cannot open %s", argv[    
 37                                                   
 38         ret = snprintf(event_control_path, PAT    
 39                         dirname(argv[1]));        
 40         if (ret >= PATH_MAX)                      
 41                 errx(1, "Path to cgroup.event_    
 42                                                   
 43         event_control = open(event_control_pat    
 44         if (event_control == -1)                  
 45                 err(1, "Cannot open %s", event    
 46                                                   
 47         efd = eventfd(0, 0);                      
 48         if (efd == -1)                            
 49                 err(1, "eventfd() failed");       
 50                                                   
 51         ret = snprintf(line, LINE_MAX, "%d %d     
 52         if (ret >= LINE_MAX)                      
 53                 errx(1, "Arguments string is t    
 54                                                   
 55         ret = write(event_control, line, strle    
 56         if (ret == -1)                            
 57                 err(1, "Cannot write to cgroup    
 58                                                   
 59         while (1) {                               
 60                 uint64_t result;                  
 61                                                   
 62                 ret = read(efd, &result, sizeo    
 63                 if (ret == -1) {                  
 64                         if (errno == EINTR)       
 65                                 continue;         
 66                         err(1, "Cannot read fr    
 67                 }                                 
 68                 assert(ret == sizeof(result));    
 69                                                   
 70                 ret = access(event_control_pat    
 71                 if ((ret == -1) && (errno == E    
 72                         puts("The cgroup seems    
 73                         break;                    
 74                 }                                 
 75                                                   
 76                 if (ret == -1)                    
 77                         err(1, "cgroup.event_c    
 78                                                   
 79                 printf("%s %s: crossed\n", arg    
 80         }                                         
 81                                                   
 82         return 0;                                 
 83 }                                                 
 84                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp