From 9acdcbf3254277b44d4558cfe73fde272b7d6e91 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Fri, 19 Nov 2010 10:15:25 +0530 Subject: [PATCH 01/15] use single quotes in menuentry setparams command --- grub-core/commands/menuentry.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c index 9718d1eab..7a07698d8 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -206,20 +206,6 @@ setparams_prefix (int argc, char **args) char *p; char *result; grub_size_t len = 10; - static const char *escape_characters = "\"\\"; - - auto char *strescpy (char *, const char *, const char *); - char * strescpy (char *d, const char *s, const char *escapes) - { - while (*s) - { - if (grub_strchr (escapes, *s)) - *d++ = '\\'; - *d++ = *s++; - } - *d = '\0'; - return d; - } /* Count resulting string length */ for (i = 0; i < argc; i++) @@ -227,7 +213,7 @@ setparams_prefix (int argc, char **args) len += 3; /* 3 = 1 space + 2 quotes */ p = args[i]; while (*p) - len += grub_strchr (escape_characters, *p++) ? 2 : 1; + len += (*p++ == '\'' ? 3 : 1); } result = grub_malloc (len + 2); @@ -240,9 +226,18 @@ setparams_prefix (int argc, char **args) for (j = 0; j < argc; j++) { result[i++] = ' '; - result[i++] = '"'; - i = strescpy (result + i, args[j], escape_characters) - result; - result[i++] = '"'; + result[i++] = '\''; + p = args[j]; + while (*p) { + result[i++] = *p; + if (*p == '\'') { + result[i++] = '\\'; + result[i++] = '\''; + result[i++] = '\''; + } + p++; + } + result[i++] = '\''; } result[i++] = '\n'; result[i] = '\0'; From 7e623b0d743d2311ee94185995622b3f47eaa322 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Fri, 19 Nov 2010 10:17:16 +0530 Subject: [PATCH 02/15] add changelog entry --- ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index d839afb65..b53b396b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-11-19 BVK Chaitanya + + Fix quoting in setparams in handling menuentry command. + + * grub-core/commands/menuentry.c (setparams_prefix): Use single + quotes for arguments. + 2010-11-18 Vladimir Serbinenko * grub-core/normal/menu_entry.c (print_up): Fix displacement of up From f866fe808bc574a9304a2ed184ab5c2f0c4b2eee Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Fri, 19 Nov 2010 19:08:44 +0530 Subject: [PATCH 03/15] reuse code from legacy parser --- ChangeLog | 7 +++++++ grub-core/commands/menuentry.c | 24 ++++++++---------------- grub-core/lib/legacy_parse.c | 25 ++++++------------------- grub-core/script/script.c | 21 +++++++++++++++++++++ include/grub/script_sh.h | 3 +++ 5 files changed, 45 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index b53b396b5..eb8064188 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,13 @@ * grub-core/commands/menuentry.c (setparams_prefix): Use single quotes for arguments. + * grub-core/lib/legacy_parse.c (grub_legacy_escape): Use + grub_script_escape_squotes function instead. + + * include/grub/script_sh.h (grub_script_escape_squotes): New + prototype. + * grub-core/script/script.c (grub_script_escape_squotes): New + function. 2010-11-18 Vladimir Serbinenko diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c index 7a07698d8..f64378724 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -24,6 +24,7 @@ #include #include #include +#include static const struct grub_arg_option options[] = { @@ -221,26 +222,17 @@ setparams_prefix (int argc, char **args) return 0; grub_strcpy (result, "setparams"); - i = 9; + p = result + 9; for (j = 0; j < argc; j++) { - result[i++] = ' '; - result[i++] = '\''; - p = args[j]; - while (*p) { - result[i++] = *p; - if (*p == '\'') { - result[i++] = '\\'; - result[i++] = '\''; - result[i++] = '\''; - } - p++; - } - result[i++] = '\''; + *p++ = ' '; + *p++ = '\''; + p = grub_script_escape_squotes (p, args[j], grub_strlen (args[j])); + *p++ = '\''; } - result[i++] = '\n'; - result[i] = '\0'; + *p++ = '\n'; + *p = '\0'; return result; } diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c index 5a359ff1c..8fe60b03d 100644 --- a/grub-core/lib/legacy_parse.c +++ b/grub-core/lib/legacy_parse.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -323,30 +324,16 @@ char * grub_legacy_escape (const char *in, grub_size_t len) { const char *ptr; - char *ret, *outptr; + char *outptr; int overhead = 0; for (ptr = in; ptr < in + len && *ptr; ptr++) if (*ptr == '\'') overhead += 3; - ret = grub_malloc (ptr - in + overhead + 1); - if (!ret) + outptr = grub_malloc (ptr - in + overhead + 1); + if (!outptr) return NULL; - outptr = ret; - for (ptr = in; ptr < in + len && *ptr; ptr++) - { - if (*ptr == '\'') - { - *outptr++ = '\''; - *outptr++ = '\\'; - *outptr++ = '\''; - *outptr++ = '\''; - continue; - } - - *outptr++ = *ptr; - } - *outptr++ = 0; - return ret; + grub_script_escape_squotes (outptr, in, len); + return outptr; } static char * diff --git a/grub-core/script/script.c b/grub-core/script/script.c index ad3018357..45c3222b2 100644 --- a/grub-core/script/script.c +++ b/grub-core/script/script.c @@ -22,6 +22,27 @@ #include #include +/* Escape single quotes in first `len' characters of `in' into a GRUB + script argument form into `out'; return address of the end in + `out'. */ +char * +grub_script_escape_squotes (char *out, const char *in, grub_size_t len) +{ + while (*in && len--) + { + *out++ = *in; + if (*in == '\'') + { + *out++ = '\\'; + *out++ = '\''; + *out++ = '\''; + } + in++; + } + *out = '\0'; + return out; +} + /* It is not possible to deallocate the memory when a syntax error was found. Because of that it is required to keep track of all memory allocations. The memory is freed in case of an error, or assigned diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h index 6d31fca5a..f5dcd881e 100644 --- a/include/grub/script_sh.h +++ b/include/grub/script_sh.h @@ -382,6 +382,9 @@ grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *c grub_err_t grub_normal_parse_line (char *line, grub_reader_getline_t getline); +char * +grub_script_escape_squotes (char *out, const char *in, grub_size_t len); + static inline struct grub_script * grub_script_ref (struct grub_script *script) { From bf16e98e3c93890c32cea3d612913d9bdf544378 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 23 Nov 2010 12:52:40 +0000 Subject: [PATCH 04/15] * grub-core/Makefile.am (command.lst): Adjust sed expression ordering so that extended and priority commands aren't treated as ordinary commands. --- ChangeLog | 6 ++++++ grub-core/Makefile.am | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 815004080..4a09faca4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-11-23 Colin Watson + + * grub-core/Makefile.am (command.lst): Adjust sed expression + ordering so that extended and priority commands aren't treated as + ordinary commands. + 2010-11-23 Colin Watson * include/grub/gpt_partition.h (GRUB_GPT_PARTITION_TYPE_BIOS_BOOT): diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 9792dd974..131fa5fd7 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -237,9 +237,9 @@ command.lst: $(MARKER_FILES) (for pp in $^; do \ b=`basename $$pp .marker`; \ sed -n \ - -e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" \ -e "/EXTCOMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \ - -e "/P1COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" $$pp; \ + -e "/P1COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \ + -e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \ done) | sort -u > $@ platform_DATA += command.lst CLEANFILES += command.lst From 038b3ce8dc10e598b95aa8f92a243bdfaa078e84 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 23 Nov 2010 13:00:05 +0000 Subject: [PATCH 05/15] * grub-core/Makefile.am (gentrigtables): Put -lm after $<; some linkers are picky about this. --- ChangeLog | 5 +++++ grub-core/Makefile.am | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4a09faca4..5f38faf42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-11-23 Colin Watson + + * grub-core/Makefile.am (gentrigtables): Put -lm after $<; some + linkers are picky about this. + 2010-11-23 Colin Watson * grub-core/Makefile.am (command.lst): Adjust sed expression diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 131fa5fd7..073ce37f6 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -30,7 +30,7 @@ CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM) # gentrigtables gentrigtables: gentrigtables.c - $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(CPPFLAGS) -lm $< + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(CPPFLAGS) $< -lm CLEANFILES += gentrigtables # trigtables.c From 5225f3288296190e8fa16a34560b1b7bf2ae4a6b Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 23 Nov 2010 15:56:18 +0000 Subject: [PATCH 06/15] * Makefile.util.def (grub-menulst2cfg): List libraries in ldadd, not ldflags, to fix link line ordering. --- ChangeLog | 5 +++++ Makefile.util.def | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5f38faf42..9b01330d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-11-23 Colin Watson + + * Makefile.util.def (grub-menulst2cfg): List libraries in ldadd, not + ldflags, to fix link line ordering. + 2010-11-23 Colin Watson * grub-core/Makefile.am (gentrigtables): Put -lm after $<; some diff --git a/Makefile.util.def b/Makefile.util.def index 748bb1c59..3e8ae16f5 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -620,5 +620,5 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; }; From b7fbac1214cfb38fd81f2d2555b34064456a1424 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 23 Nov 2010 17:42:06 +0000 Subject: [PATCH 07/15] * util/deviceiter.c (compare_devices): If the by-id link for a device couldn't be resolved, fall back to sorting by the by-id link rather than segfaulting. Reported and tested by: Daniel Mierswa. --- ChangeLog | 7 +++++++ util/deviceiter.c | 15 +++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b01330d5..c6bbffd99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-11-23 Colin Watson + + * util/deviceiter.c (compare_devices): If the by-id link for a + device couldn't be resolved, fall back to sorting by the by-id link + rather than segfaulting. + Reported and tested by: Daniel Mierswa. + 2010-11-23 Colin Watson * Makefile.util.def (grub-menulst2cfg): List libraries in ldadd, not diff --git a/util/deviceiter.c b/util/deviceiter.c index 34d34b7bb..1de8e54df 100644 --- a/util/deviceiter.c +++ b/util/deviceiter.c @@ -485,12 +485,15 @@ compare_devices (const void *a, const void *b) { const struct device *left = (const struct device *) a; const struct device *right = (const struct device *) b; - int ret; - ret = strcmp (left->kernel, right->kernel); - if (ret) - return ret; - else - return strcmp (left->stable, right->stable); + + if (left->kernel && right->kernel) + { + int ret = strcmp (left->kernel, right->kernel); + if (ret) + return ret; + } + + return strcmp (left->stable, right->stable); } #endif /* __linux__ */ From 3030d8ec490c87a85ac1fd9fbff7b9eecfb8cfec Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 24 Nov 2010 12:07:14 +0000 Subject: [PATCH 08/15] * grub-core/Makefile.core.def (kernel): Add kern/emu/cache.S for emu platforms. (grub-emu-lite): Remove kern/emu/cache.S. --- ChangeLog | 6 ++++++ grub-core/Makefile.core.def | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c6bbffd99..39a6b5146 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-11-24 Colin Watson + + * grub-core/Makefile.core.def (kernel): Add kern/emu/cache.S for emu + platforms. + (grub-emu-lite): Remove kern/emu/cache.S. + 2010-11-23 Colin Watson * util/deviceiter.c (compare_devices): If the by-id link for a diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 46c65adac..098df91dc 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -162,6 +162,7 @@ kernel = { emu = disk/host.c; emu = gnulib/progname.c; emu = gnulib/error.c; + emu = kern/emu/cache.S; emu = kern/emu/console.c; emu = kern/emu/getroot.c; emu = kern/emu/hostdisk.c; @@ -208,7 +209,6 @@ program = { name = grub-emu-lite; emu = kern/emu/lite.c; - emu = kern/emu/cache.S; emu_nodist = symlist.c; ldadd = 'kernel.img$(EXEEXT)'; From 5a4072785bbaec011b37e0d46a3d2bcd0127a150 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 24 Nov 2010 19:32:49 +0000 Subject: [PATCH 09/15] * grub-core/Makefile.core.def (xz_decompress): Move -lgcc from ldflags to ldadd, to fix link line ordering. (none_decompress): Likewise. --- ChangeLog | 6 ++++++ grub-core/Makefile.core.def | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 39a6b5146..f29ade31c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-11-24 Colin Watson + + * grub-core/Makefile.core.def (xz_decompress): Move -lgcc from + ldflags to ldadd, to fix link line ordering. + (none_decompress): Likewise. + 2010-11-24 Colin Watson * grub-core/Makefile.core.def (kernel): Add kern/emu/cache.S for emu diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 098df91dc..ce10ba372 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -300,7 +300,8 @@ image = { mips_cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1 -DGRUB_MACHINE_LINK_ADDR=0x80200000'; objcopyflags = '-O binary'; - ldflags = '-lgcc -static-libgcc -Wl,-Ttext,0x80100000'; + ldflags = '-static-libgcc -Wl,-Ttext,0x80100000'; + ldadd = '-lgcc'; cflags = '-static-libgcc'; enable = mips; }; @@ -313,7 +314,8 @@ image = { mips_cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1 -DGRUB_MACHINE_LINK_ADDR=0x80200000'; objcopyflags = '-O binary'; - ldflags = '-lgcc -static-libgcc -Wl,-Ttext,0x80100000'; + ldflags = '-static-libgcc -Wl,-Ttext,0x80100000'; + ldadd = '-lgcc'; cflags = '-static-libgcc'; enable = mips; }; From 74f72a6415a450219afe51fa0f2c17ffdb085e61 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 24 Nov 2010 19:43:32 +0000 Subject: [PATCH 10/15] * util/deviceiter.c (grub_util_iterate_devices): Save a bit of effort by skipping "." and ".." entries up-front. Suggested by: Michael Lazarev. --- ChangeLog | 6 ++++++ util/deviceiter.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index f29ade31c..6bc7f1b9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-11-24 Colin Watson + + * util/deviceiter.c (grub_util_iterate_devices): Save a bit of + effort by skipping "." and ".." entries up-front. + Suggested by: Michael Lazarev. + 2010-11-24 Colin Watson * grub-core/Makefile.core.def (xz_decompress): Move -lgcc from diff --git a/util/deviceiter.c b/util/deviceiter.c index 1de8e54df..30c18beea 100644 --- a/util/deviceiter.c +++ b/util/deviceiter.c @@ -536,6 +536,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int), necessary. */ for (entry = readdir (dir); entry; entry = readdir (dir)) { + /* Skip current and parent directory entries. */ + if (strcmp (entry->d_name, ".") == 0 || + strcmp (entry->d_name, "..") == 0) + continue; /* Skip partition entries. */ if (strstr (entry->d_name, "-part")) continue; From d7647bb6702570b0916e2fe83be980c936b7bb6f Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Thu, 25 Nov 2010 18:25:26 +0530 Subject: [PATCH 11/15] better changelog message --- ChangeLog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index eb8064188..29eb61fd5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2010-11-19 BVK Chaitanya - Fix quoting in setparams in handling menuentry command. + Fix cmdline argument quotes for setparams command of menuentry + definitions. * grub-core/commands/menuentry.c (setparams_prefix): Use single quotes for arguments. From 5b080620834f8c8df4972d5af761d7d3a768964a Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Thu, 25 Nov 2010 18:56:20 +0530 Subject: [PATCH 12/15] replaced with grub_strchrsub function --- grub-core/commands/menuentry.c | 2 +- grub-core/lib/legacy_parse.c | 13 ++++++++++--- grub-core/script/script.c | 21 --------------------- include/grub/misc.h | 20 ++++++++++++++++++++ include/grub/script_sh.h | 3 --- 5 files changed, 31 insertions(+), 28 deletions(-) diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c index f64378724..c0743d1ed 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -228,7 +228,7 @@ setparams_prefix (int argc, char **args) { *p++ = ' '; *p++ = '\''; - p = grub_script_escape_squotes (p, args[j], grub_strlen (args[j])); + p = grub_strchrsub (p, args[j], '\'', "'\\''"); *p++ = '\''; } *p++ = '\n'; diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c index 8fe60b03d..d3a133591 100644 --- a/grub-core/lib/legacy_parse.c +++ b/grub-core/lib/legacy_parse.c @@ -323,16 +323,23 @@ struct legacy_command legacy_commands[] = char * grub_legacy_escape (const char *in, grub_size_t len) { - const char *ptr; + char saved; + char *ptr; char *outptr; int overhead = 0; - for (ptr = in; ptr < in + len && *ptr; ptr++) + + for (ptr = (char*)in; ptr < in + len && *ptr; ptr++) if (*ptr == '\'') overhead += 3; outptr = grub_malloc (ptr - in + overhead + 1); if (!outptr) return NULL; - grub_script_escape_squotes (outptr, in, len); + + ptr = (char*)in; + saved = ptr[len]; + ptr[len] = '\0'; + grub_strchrsub (outptr, in, '\'', "'\\''"); + ptr[len] = saved; return outptr; } diff --git a/grub-core/script/script.c b/grub-core/script/script.c index 45c3222b2..ad3018357 100644 --- a/grub-core/script/script.c +++ b/grub-core/script/script.c @@ -22,27 +22,6 @@ #include #include -/* Escape single quotes in first `len' characters of `in' into a GRUB - script argument form into `out'; return address of the end in - `out'. */ -char * -grub_script_escape_squotes (char *out, const char *in, grub_size_t len) -{ - while (*in && len--) - { - *out++ = *in; - if (*in == '\'') - { - *out++ = '\\'; - *out++ = '\''; - *out++ = '\''; - } - in++; - } - *out = '\0'; - return out; -} - /* It is not possible to deallocate the memory when a syntax error was found. Because of that it is required to keep track of all memory allocations. The memory is freed in case of an error, or assigned diff --git a/include/grub/misc.h b/include/grub/misc.h index 27f15e44a..4980281a6 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -193,6 +193,26 @@ grub_strncasecmp (const char *s1, const char *s2, grub_size_t n) return (int) grub_tolower (*s1) - (int) grub_tolower (*s2); } +/* Replace all `ch' characters of `input' with `with' and copy the + result into `output'; return address of the end in `output'. */ +static inline char * +grub_strchrsub (char *output, const char *input, char ch, const char *with) +{ + grub_size_t grub_strlen (const char *s); + while (*input) + { + if (*input == ch) + { + grub_strcpy (output, with); + output += grub_strlen (with); + input++; + continue; + } + *output++ = *input++; + } + *output = '\0'; + return output; +} unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base); unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, char **end, int base); diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h index f5dcd881e..6d31fca5a 100644 --- a/include/grub/script_sh.h +++ b/include/grub/script_sh.h @@ -382,9 +382,6 @@ grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *c grub_err_t grub_normal_parse_line (char *line, grub_reader_getline_t getline); -char * -grub_script_escape_squotes (char *out, const char *in, grub_size_t len); - static inline struct grub_script * grub_script_ref (struct grub_script *script) { From 7955bea0d8b7cfff626dbc74496845a4db6cf8cb Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Thu, 25 Nov 2010 19:05:16 +0530 Subject: [PATCH 13/15] fix changelog and doc --- ChangeLog | 7 ++----- grub-core/commands/menuentry.c | 1 - grub-core/lib/legacy_parse.c | 13 ++++++------- include/grub/misc.h | 2 +- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 29eb61fd5..e13489f15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,12 +6,9 @@ * grub-core/commands/menuentry.c (setparams_prefix): Use single quotes for arguments. * grub-core/lib/legacy_parse.c (grub_legacy_escape): Use - grub_script_escape_squotes function instead. + grub_strchrsub function instead. - * include/grub/script_sh.h (grub_script_escape_squotes): New - prototype. - * grub-core/script/script.c (grub_script_escape_squotes): New - function. + * include/grub/misc.h (grub_strchrsub): New function. 2010-11-18 Vladimir Serbinenko diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c index c0743d1ed..4dab1783a 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -24,7 +24,6 @@ #include #include #include -#include static const struct grub_arg_option options[] = { diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c index d3a133591..f7f86c105 100644 --- a/grub-core/lib/legacy_parse.c +++ b/grub-core/lib/legacy_parse.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include @@ -323,24 +322,24 @@ struct legacy_command legacy_commands[] = char * grub_legacy_escape (const char *in, grub_size_t len) { - char saved; char *ptr; - char *outptr; + char saved; + char *ret; int overhead = 0; for (ptr = (char*)in; ptr < in + len && *ptr; ptr++) if (*ptr == '\'') overhead += 3; - outptr = grub_malloc (ptr - in + overhead + 1); - if (!outptr) + ret = grub_malloc (ptr - in + overhead + 1); + if (!ret) return NULL; ptr = (char*)in; saved = ptr[len]; ptr[len] = '\0'; - grub_strchrsub (outptr, in, '\'', "'\\''"); + grub_strchrsub (ret, ptr, '\'', "'\\''"); ptr[len] = saved; - return outptr; + return ret; } static char * diff --git a/include/grub/misc.h b/include/grub/misc.h index 4980281a6..6fcaa148b 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -194,7 +194,7 @@ grub_strncasecmp (const char *s1, const char *s2, grub_size_t n) } /* Replace all `ch' characters of `input' with `with' and copy the - result into `output'; return address of the end in `output'. */ + result into `output'; return EOS address of `output'. */ static inline char * grub_strchrsub (char *output, const char *input, char ch, const char *with) { From dfda224dd8807fe8ad79356dc354215ed9b9b9e3 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Thu, 25 Nov 2010 19:07:02 +0530 Subject: [PATCH 14/15] variable ordering --- grub-core/lib/legacy_parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c index f7f86c105..fe421af35 100644 --- a/grub-core/lib/legacy_parse.c +++ b/grub-core/lib/legacy_parse.c @@ -323,8 +323,8 @@ char * grub_legacy_escape (const char *in, grub_size_t len) { char *ptr; - char saved; char *ret; + char saved; int overhead = 0; for (ptr = (char*)in; ptr < in + len && *ptr; ptr++) From 9be57a0dad345ef19b6eeaea68b8b8562116b937 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 26 Nov 2010 12:26:37 +0000 Subject: [PATCH 15/15] Fix LVM-on-RAID probing. * util/grub-probe.c (probe): Remember which disk was detected as RAID (perhaps an LVM physical volume). Use that disk's raidname rather than that of the top-level disk. --- ChangeLog | 8 ++++++++ util/grub-probe.c | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 05bf3b270..f9e24a808 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-11-26 Colin Watson + + Fix LVM-on-RAID probing. + + * util/grub-probe.c (probe): Remember which disk was detected as + RAID (perhaps an LVM physical volume). Use that disk's raidname + rather than that of the top-level disk. + 2010-11-25 BVK Chaitanya Fix cmdline argument quotes for setparams command of menuentry diff --git a/util/grub-probe.c b/util/grub-probe.c index 1d00a7db3..0d5dac902 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -142,6 +142,7 @@ probe (const char *path, char *device_name) int is_raid5 = 0; int is_raid6 = 0; int raid_level; + grub_disk_t raid_disk; raid_level = probe_raid_level (dev->disk); if (raid_level >= 0) @@ -149,6 +150,7 @@ probe (const char *path, char *device_name) is_raid = 1; is_raid5 |= (raid_level == 5); is_raid6 |= (raid_level == 6); + raid_disk = dev->disk; } if ((is_lvm) && (dev->disk->dev->memberlist)) @@ -161,6 +163,7 @@ probe (const char *path, char *device_name) is_raid = 1; is_raid5 |= (raid_level == 5); is_raid6 |= (raid_level == 6); + raid_disk = list->disk; } tmp = list->next; @@ -175,8 +178,8 @@ probe (const char *path, char *device_name) printf ("raid5rec "); if (is_raid6) printf ("raid6rec "); - if (dev->disk->dev->raidname) - printf ("%s ", dev->disk->dev->raidname (dev->disk)); + if (raid_disk->dev->raidname) + printf ("%s ", raid_disk->dev->raidname (raid_disk)); } if (is_lvm)