]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/x86/lib/cmdline.c
945a639c02dd94a74ce7058c4d16ced841f3c0b9
2 * This file is part of the Linux kernel, and is made available under
3 * the terms of the GNU General Public License version 2.
5 * Misc librarized functions for cmdline poking.
7 #include <linux/kernel.h>
8 #include <linux/string.h>
9 #include <linux/ctype.h>
10 #include <asm/setup.h>
12 static inline int myisspace(u8 c
)
14 return c
<= ' '; /* Close enough approximation */
18 * Find a boolean option (like quiet,noapic,nosmp....)
20 * @cmdline: the cmdline string
21 * @option: option string to look for
23 * Returns the position of that @option (starts counting with 1)
24 * or 0 on not found. @option will only be found if it is found
25 * as an entire word in @cmdline. For instance, if @option="car"
26 * then a cmdline which contains "cart" will not match.
28 int cmdline_find_option_bool(const char *cmdline
, const char *option
)
31 int pos
= 0, wstart
= 0;
32 const char *opptr
= NULL
;
34 st_wordstart
= 0, /* Start of word/after whitespace */
35 st_wordcmp
, /* Comparing this word */
36 st_wordskip
, /* Miscompare, skip */
37 } state
= st_wordstart
;
40 return -1; /* No command line */
43 * This 'pos' check ensures we do not overrun
44 * a non-NULL-terminated 'cmdline'
46 while (pos
< COMMAND_LINE_SIZE
) {
47 c
= *(char *)cmdline
++;
54 else if (myisspace(c
))
65 * We matched all the way to the end of the
66 * option we were looking for. If the
67 * command-line has a space _or_ ends, then
70 if (!c
|| myisspace(c
))
73 * We hit the end of the option, but _not_
74 * the end of a word on the cmdline. Not
79 * Hit the NULL terminator on the end of
83 } else if (c
== *opptr
++) {
85 * We are currently matching, so continue
86 * to the next character on the cmdline.
96 else if (myisspace(c
))
102 return 0; /* Buffer overrun */