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

TOMOYO Linux Cross Reference
Linux/arch/um/os-Linux/execvp.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/um/os-Linux/execvp.c (Version linux-6.12-rc7) and /arch/ppc/os-Linux/execvp.c (Version linux-4.13.16)


  1 /* Copyright (C) 2006 by Paolo Giarrusso - mod      1 
  2    Original copyright notice follows:             
  3                                                   
  4    Copyright (C) 1991,92,1995-99,2002,2004 Fre    
  5    This file is part of the GNU C Library.        
  6                                                   
  7    The GNU C Library is free software; you can    
  8    modify it under the terms of the GNU Lesser    
  9    License as published by the Free Software F    
 10    version 2.1 of the License, or (at your opt    
 11                                                   
 12    The GNU C Library is distributed in the hop    
 13    but WITHOUT ANY WARRANTY; without even the     
 14    MERCHANTABILITY or FITNESS FOR A PARTICULAR    
 15    Lesser General Public License for more deta    
 16                                                   
 17    You should have received a copy of the GNU     
 18    License along with the GNU C Library; if no    
 19    Software Foundation, Inc., 59 Temple Place,    
 20    02111-1307 USA.  */                            
 21 #include <unistd.h>                               
 22                                                   
 23 #include <stdbool.h>                              
 24 #include <stdlib.h>                               
 25 #include <string.h>                               
 26 #include <errno.h>                                
 27 #include <limits.h>                               
 28                                                   
 29 #ifndef TEST                                      
 30 #include <um_malloc.h>                            
 31 #else                                             
 32 #include <stdio.h>                                
 33 #define um_kmalloc malloc                         
 34 #endif                                            
 35 #include <os.h>                                   
 36                                                   
 37 /* Execute FILE, searching in the `PATH' envir    
 38    no slashes, with arguments ARGV and environ    
 39 int execvp_noalloc(char *buf, const char *file    
 40 {                                                 
 41         if (*file == '\0') {                      
 42                 return -ENOENT;                   
 43         }                                         
 44                                                   
 45         if (strchr (file, '/') != NULL) {         
 46                 /* Don't search when it contai    
 47                 execv(file, argv);                
 48         } else {                                  
 49                 int got_eacces;                   
 50                 size_t len, pathlen;              
 51                 char *name, *p;                   
 52                 char *path = getenv("PATH");      
 53                 if (path == NULL)                 
 54                         path = ":/bin:/usr/bin    
 55                                                   
 56                 len = strlen(file) + 1;           
 57                 pathlen = strlen(path);           
 58                 /* Copy the file name at the t    
 59                 name = memcpy(buf + pathlen +     
 60                 /* And add the slash.  */         
 61                 *--name = '/';                    
 62                                                   
 63                 got_eacces = 0;                   
 64                 p = path;                         
 65                 do {                              
 66                         char *startp;             
 67                                                   
 68                         path = p;                 
 69                         //Let's avoid this GNU    
 70                         //p = strchrnul (path,    
 71                         p = strchr(path, ':');    
 72                         if (!p)                   
 73                                 p = strchr(pat    
 74                                                   
 75                         if (p == path)            
 76                                 /* Two adjacen    
 77                                    of `PATH' m    
 78                                 startp = name     
 79                         else                      
 80                                 startp = memcp    
 81                                                   
 82                         /* Try to execute this    
 83                         execv(startp, argv);      
 84                                                   
 85                         /*                        
 86                         if (errno == ENOEXEC)     
 87                         }                         
 88                         */                        
 89                                                   
 90                         switch (errno) {          
 91                                 case EACCES:      
 92                                         /* Rec    
 93                                            up     
 94                                            tha    
 95                                         got_ea    
 96                                         break;    
 97                                 case ENOENT:      
 98                                 case ESTALE:      
 99                                 case ENOTDIR:     
100                                         /* Tho    
101                                            by     
102                                            dir    
103                                 case ENODEV:      
104                                 case ETIMEDOUT    
105                                         /* Som    
106                                            str    
107                                            any    
108                                 case ENOEXEC:     
109                                         /* We     
110                                          * if     
111                                          * ker    
112                                          * for    
113                                         break;    
114                                                   
115                                 default:          
116                                         /* Som    
117                                            som    
118                                            cal    
119                                         return    
120                         }                         
121                 } while (*p++ != '\0');           
122                                                   
123                 /* We tried every element and     
124                 if (got_eacces)                   
125                         /* At least one failur    
126                            error.  */             
127                         return -EACCES;           
128         }                                         
129                                                   
130         /* Return the error from the last atte    
131         return -errno;                            
132 }                                                 
133 #ifdef TEST                                       
134 int main(int argc, char**argv)                    
135 {                                                 
136         char buf[PATH_MAX];                       
137         int ret;                                  
138         argc--;                                   
139         if (!argc) {                              
140                 os_warn("Not enough arguments\    
141                 return 1;                         
142         }                                         
143         argv++;                                   
144         if (ret = execvp_noalloc(buf, argv[0],    
145                 errno = -ret;                     
146                 perror("execvp_noalloc");         
147         }                                         
148         return 0;                                 
149 }                                                 
150 #endif                                            
151                                                   

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php