diff --git a/ChangeLog b/ChangeLog index 39a6b5146..f9e24a808 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +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 + definitions. + + * grub-core/commands/menuentry.c (setparams_prefix): Use single + quotes for arguments. + * grub-core/lib/legacy_parse.c (grub_legacy_escape): Use + grub_strchrsub function instead. + + * include/grub/misc.h (grub_strchrsub): New function. + +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 + 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/debian/changelog b/debian/changelog index 70f4de781..6d82bcb19 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ -grub2 (1.99~20101124-2) UNRELEASED; urgency=low +grub2 (1.99~20101126-1) UNRELEASED; urgency=low + * New Bazaar snapshot (mipsel build fix, LVM-on-RAID probing fix). * Fix comma-separation in handling of grub-pc/install_devices. -- Colin Watson Fri, 26 Nov 2010 12:23:06 +0000 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; }; diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c index 9718d1eab..4dab1783a 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); @@ -235,17 +221,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++] = '"'; - i = strescpy (result + i, args[j], escape_characters) - result; - result[i++] = '"'; + *p++ = ' '; + *p++ = '\''; + p = grub_strchrsub (p, 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..fe421af35 100644 --- a/grub-core/lib/legacy_parse.c +++ b/grub-core/lib/legacy_parse.c @@ -322,30 +322,23 @@ struct legacy_command legacy_commands[] = char * grub_legacy_escape (const char *in, grub_size_t len) { - const char *ptr; - char *ret, *outptr; + char *ptr; + char *ret; + char saved; int overhead = 0; - for (ptr = in; ptr < in + len && *ptr; ptr++) + + for (ptr = (char*)in; ptr < in + len && *ptr; ptr++) if (*ptr == '\'') overhead += 3; ret = grub_malloc (ptr - in + overhead + 1); if (!ret) return NULL; - outptr = ret; - for (ptr = in; ptr < in + len && *ptr; ptr++) - { - if (*ptr == '\'') - { - *outptr++ = '\''; - *outptr++ = '\\'; - *outptr++ = '\''; - *outptr++ = '\''; - continue; - } - - *outptr++ = *ptr; - } - *outptr++ = 0; + + ptr = (char*)in; + saved = ptr[len]; + ptr[len] = '\0'; + grub_strchrsub (ret, ptr, '\'', "'\\''"); + ptr[len] = saved; return ret; } diff --git a/include/grub/misc.h b/include/grub/misc.h index 27f15e44a..6fcaa148b 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 EOS address of `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/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; 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)