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

TOMOYO Linux Cross Reference
Linux/arch/x86/boot/cmdline.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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/x86/boot/cmdline.c (Version linux-6.12-rc7) and /arch/sparc/boot/cmdline.c (Version linux-4.10.17)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /* -*- linux-c -*- ---------------------------    
  3  *                                                
  4  *   Copyright (C) 1991, 1992 Linus Torvalds      
  5  *   Copyright 2007 rPath, Inc. - All Rights R    
  6  *                                                
  7  * -------------------------------------------    
  8                                                   
  9 /*                                                
 10  * Simple command-line parser for early boot.     
 11  */                                               
 12                                                   
 13 #include "boot.h"                                 
 14                                                   
 15 static inline int myisspace(u8 c)                 
 16 {                                                 
 17         return c <= ' ';        /* Close enoug    
 18 }                                                 
 19                                                   
 20 /*                                                
 21  * Find a non-boolean option, that is, "option    
 22  * with standard Linux practice, if this optio    
 23  * the last instance on the command line.         
 24  *                                                
 25  * Returns the length of the argument (regardl    
 26  * truncated to fit in the buffer), or -1 on n    
 27  */                                               
 28 int __cmdline_find_option(unsigned long cmdlin    
 29 {                                                 
 30         addr_t cptr;                              
 31         char c;                                   
 32         int len = -1;                             
 33         const char *opptr = NULL;                 
 34         char *bufptr = buffer;                    
 35         enum {                                    
 36                 st_wordstart,   /* Start of wo    
 37                 st_wordcmp,     /* Comparing t    
 38                 st_wordskip,    /* Miscompare,    
 39                 st_bufcpy       /* Copying thi    
 40         } state = st_wordstart;                   
 41                                                   
 42         if (!cmdline_ptr)                         
 43                 return -1;      /* No command     
 44                                                   
 45         cptr = cmdline_ptr & 0xf;                 
 46         set_fs(cmdline_ptr >> 4);                 
 47                                                   
 48         while (cptr < 0x10000 && (c = rdfs8(cp    
 49                 switch (state) {                  
 50                 case st_wordstart:                
 51                         if (myisspace(c))         
 52                                 break;            
 53                                                   
 54                         /* else */                
 55                         state = st_wordcmp;       
 56                         opptr = option;           
 57                         fallthrough;              
 58                                                   
 59                 case st_wordcmp:                  
 60                         if (c == '=' && !*oppt    
 61                                 len = 0;          
 62                                 bufptr = buffe    
 63                                 state = st_buf    
 64                         } else if (myisspace(c    
 65                                 state = st_wor    
 66                         } else if (c != *opptr    
 67                                 state = st_wor    
 68                         }                         
 69                         break;                    
 70                                                   
 71                 case st_wordskip:                 
 72                         if (myisspace(c))         
 73                                 state = st_wor    
 74                         break;                    
 75                                                   
 76                 case st_bufcpy:                   
 77                         if (myisspace(c)) {       
 78                                 state = st_wor    
 79                         } else {                  
 80                                 if (len < bufs    
 81                                         *bufpt    
 82                                 len++;            
 83                         }                         
 84                         break;                    
 85                 }                                 
 86         }                                         
 87                                                   
 88         if (bufsize)                              
 89                 *bufptr = '\0';                   
 90                                                   
 91         return len;                               
 92 }                                                 
 93                                                   
 94 /*                                                
 95  * Find a boolean option (like quiet,noapic,no    
 96  *                                                
 97  * Returns the position of that option (starts    
 98  * or 0 on not found                              
 99  */                                               
100 int __cmdline_find_option_bool(unsigned long c    
101 {                                                 
102         addr_t cptr;                              
103         char c;                                   
104         int pos = 0, wstart = 0;                  
105         const char *opptr = NULL;                 
106         enum {                                    
107                 st_wordstart,   /* Start of wo    
108                 st_wordcmp,     /* Comparing t    
109                 st_wordskip,    /* Miscompare,    
110         } state = st_wordstart;                   
111                                                   
112         if (!cmdline_ptr)                         
113                 return -1;      /* No command     
114                                                   
115         cptr = cmdline_ptr & 0xf;                 
116         set_fs(cmdline_ptr >> 4);                 
117                                                   
118         while (cptr < 0x10000) {                  
119                 c = rdfs8(cptr++);                
120                 pos++;                            
121                                                   
122                 switch (state) {                  
123                 case st_wordstart:                
124                         if (!c)                   
125                                 return 0;         
126                         else if (myisspace(c))    
127                                 break;            
128                                                   
129                         state = st_wordcmp;       
130                         opptr = option;           
131                         wstart = pos;             
132                         fallthrough;              
133                                                   
134                 case st_wordcmp:                  
135                         if (!*opptr)              
136                                 if (!c || myis    
137                                         return    
138                                 else              
139                                         state     
140                         else if (!c)              
141                                 return 0;         
142                         else if (c != *opptr++    
143                                 state = st_wor    
144                         break;                    
145                                                   
146                 case st_wordskip:                 
147                         if (!c)                   
148                                 return 0;         
149                         else if (myisspace(c))    
150                                 state = st_wor    
151                         break;                    
152                 }                                 
153         }                                         
154                                                   
155         return 0;       /* Buffer overrun */      
156 }                                                 
157                                                   

~ [ 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