summaryrefslogtreecommitdiffstats
path: root/lib/cmdline.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-01 23:51:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-01 23:51:12 -0400
commit16b76293c5c81e6345323d7aef41b26e8390f62d (patch)
treef2bfdff7e795865c3254cb0ad97ebc66a7c5d212 /lib/cmdline.c
parent3dee9fb2a4ced89a13a4d4b72b0b7360b701e566 (diff)
parentda63b6b20077469bd6bd96e07991ce145fc4fbc4 (diff)
Merge branch 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 boot updates from Ingo Molnar: "The biggest changes in this cycle were: - reworking of the e820 code: separate in-kernel and boot-ABI data structures and apply a whole range of cleanups to the kernel side. No change in functionality. - enable KASLR by default: it's used by all major distros and it's out of the experimental stage as well. - ... misc fixes and cleanups" * 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (63 commits) x86/KASLR: Fix kexec kernel boot crash when KASLR randomization fails x86/reboot: Turn off KVM when halting a CPU x86/boot: Fix BSS corruption/overwrite bug in early x86 kernel startup x86: Enable KASLR by default boot/param: Move next_arg() function to lib/cmdline.c for later reuse x86/boot: Fix Sparse warning by including required header file x86/boot/64: Rename start_cpu() x86/xen: Update e820 table handling to the new core x86 E820 code x86/boot: Fix pr_debug() API braindamage xen, x86/headers: Add <linux/device.h> dependency to <asm/xen/page.h> x86/boot/e820: Simplify e820__update_table() x86/boot/e820: Separate the E820 ABI structures from the in-kernel structures x86/boot/e820: Fix and clean up e820_type switch() statements x86/boot/e820: Rename the remaining E820 APIs to the e820__*() prefix x86/boot/e820: Remove unnecessary #include's x86/boot/e820: Rename e820_mark_nosave_regions() to e820__register_nosave_regions() x86/boot/e820: Rename e820_reserve_resources*() to e820__reserve_resources*() x86/boot/e820: Use bool in query APIs x86/boot/e820: Document e820__reserve_setup_data() x86/boot/e820: Clean up __e820__update_table() et al ...
Diffstat (limited to 'lib/cmdline.c')
-rw-r--r--lib/cmdline.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/cmdline.c b/lib/cmdline.c
index 8f13cf73c2ec..3c6432df7e63 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -15,6 +15,7 @@
15#include <linux/export.h> 15#include <linux/export.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/ctype.h>
18 19
19/* 20/*
20 * If a hyphen was found in get_option, this will handle the 21 * If a hyphen was found in get_option, this will handle the
@@ -189,3 +190,59 @@ bool parse_option_str(const char *str, const char *option)
189 190
190 return false; 191 return false;
191} 192}
193
194/*
195 * Parse a string to get a param value pair.
196 * You can use " around spaces, but can't escape ".
197 * Hyphens and underscores equivalent in parameter names.
198 */
199char *next_arg(char *args, char **param, char **val)
200{
201 unsigned int i, equals = 0;
202 int in_quote = 0, quoted = 0;
203 char *next;
204
205 if (*args == '"') {
206 args++;
207 in_quote = 1;
208 quoted = 1;
209 }
210
211 for (i = 0; args[i]; i++) {
212 if (isspace(args[i]) && !in_quote)
213 break;
214 if (equals == 0) {
215 if (args[i] == '=')
216 equals = i;
217 }
218 if (args[i] == '"')
219 in_quote = !in_quote;
220 }
221
222 *param = args;
223 if (!equals)
224 *val = NULL;
225 else {
226 args[equals] = '\0';
227 *val = args + equals + 1;
228
229 /* Don't include quotes in value. */
230 if (**val == '"') {
231 (*val)++;
232 if (args[i-1] == '"')
233 args[i-1] = '\0';
234 }
235 }
236 if (quoted && args[i-1] == '"')
237 args[i-1] = '\0';
238
239 if (args[i]) {
240 args[i] = '\0';
241 next = args + i + 1;
242 } else
243 next = args + i;
244
245 /* Chew up trailing spaces. */
246 return skip_spaces(next);
247 //return next;
248}