From 9da068a5dc3b507276552980fc9c6459aef0a02d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 11 Jan 2011 23:01:07 +0100 Subject: [PATCH 01/34] * grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32): Apply loadmask before doing any calculations. Use correct type for offset. (grub_linux_load64): Likewise. --- ChangeLog | 6 ++++++ grub-core/loader/powerpc/ieee1275/linux.c | 16 +++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 56a8db213..05e2ec8c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-11 Vladimir Serbinenko + + * grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32): Apply + loadmask before doing any calculations. Use correct type for offset. + (grub_linux_load64): Likewise. + 2011-01-11 Colin Watson * util/grub-mklayout.c (console_grub_equivalences_shift): Terminate diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c index a99310cfd..0cf0eb825 100644 --- a/grub-core/loader/powerpc/ieee1275/linux.c +++ b/grub-core/loader/powerpc/ieee1275/linux.c @@ -152,7 +152,8 @@ grub_linux_load32 (grub_elf_t elf) Elf32_Addr base_addr; grub_addr_t seg_addr; grub_uint32_t align; - int offset; + grub_uint32_t offset; + Elf32_Addr entry; linux_size = grub_elf32_size (elf, &base_addr, &align); if (linux_size == 0) @@ -160,9 +161,12 @@ grub_linux_load32 (grub_elf_t elf) /* Pad it; the kernel scribbles over memory beyond its load address. */ linux_size += 0x100000; - offset = elf->ehdr.ehdr32.e_entry - base_addr; + /* Linux's entry point incorrectly contains a virtual address. */ + entry = elf->ehdr.ehdr32.e_entry & ~ELF32_LOADMASK; + /* Linux's incorrectly contains a virtual address. */ base_addr &= ~ELF32_LOADMASK; + offset = entry - base_addr; /* On some systems, firmware occupies the memory we're trying to use. * Happily, Linux can be loaded anywhere (it relocates itself). Iterate @@ -196,7 +200,8 @@ grub_linux_load64 (grub_elf_t elf) Elf64_Addr base_addr; grub_addr_t seg_addr; grub_uint64_t align; - int offset; + grub_uint64_t offset; + Elf64_Addr entry; linux_size = grub_elf64_size (elf, &base_addr, &align); if (linux_size == 0) @@ -204,9 +209,10 @@ grub_linux_load64 (grub_elf_t elf) /* Pad it; the kernel scribbles over memory beyond its load address. */ linux_size += 0x100000; - offset = elf->ehdr.ehdr64.e_entry - base_addr; - /* Linux's incorrectly contains a virtual address. */ base_addr &= ~ELF64_LOADMASK; + entry = elf->ehdr.ehdr64.e_entry & ~ELF64_LOADMASK; + offset = entry - base_addr; + /* Linux's incorrectly contains a virtual address. */ /* On some systems, firmware occupies the memory we're trying to use. * Happily, Linux can be loaded anywhere (it relocates itself). Iterate From 51fa856c58720eeb6b018a2181716a5458e5fbae Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 11 Jan 2011 17:49:27 -0600 Subject: [PATCH 02/34] * configure.ac: Fall back to `true' if `makeinfo' does not exist. --- ChangeLog | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 05e2ec8c7..e14a33968 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-11 Colin Watson + + * configure.ac: Fall back to `true' if `makeinfo' does not exist. + 2011-01-11 Vladimir Serbinenko * grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32): Apply diff --git a/configure.ac b/configure.ac index a9ca130b4..055c65e67 100644 --- a/configure.ac +++ b/configure.ac @@ -246,7 +246,7 @@ else fi # These are not a "must". -AC_PATH_PROG(MAKEINFO, makeinfo) +AC_PATH_PROGS(MAKEINFO, makeinfo true) # # Checks for host programs. From b44a558c9a133f398364bc953ba540e1909c1f31 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 12 Jan 2011 11:26:28 +0100 Subject: [PATCH 03/34] Use alias->path rather than buggy "canon". * grub-core/disk/ieee1275/ofdisk.c (ofdisk_hash_add_real): New function. (ofdisk_hash_add): New argument curcan. All users updated. --- ChangeLog | 7 +++++++ grub-core/disk/ieee1275/ofdisk.c | 34 ++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index e14a33968..958850421 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-12 Vladimir Serbinenko + + Use alias->path rather than buggy "canon". + + * grub-core/disk/ieee1275/ofdisk.c (ofdisk_hash_add_real): New function. + (ofdisk_hash_add): New argument curcan. All users updated. + 2011-01-11 Colin Watson * configure.ac: Fall back to `true' if `makeinfo' does not exist. diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 85c34609e..0a935d5c2 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -62,11 +62,10 @@ ofdisk_hash_find (const char *devpath) } static struct ofdisk_hash_ent * -ofdisk_hash_add (char *devpath) +ofdisk_hash_add_real (char *devpath) { + struct ofdisk_hash_ent *p; struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)]; - struct ofdisk_hash_ent *p, *pcan; - char *curcan; p = grub_malloc(sizeof (*p)); if (!p) @@ -76,17 +75,27 @@ ofdisk_hash_add (char *devpath) p->next = *head; p->shortest = 0; *head = p; + return p; +} + +static struct ofdisk_hash_ent * +ofdisk_hash_add (char *devpath, char *curcan) +{ + struct ofdisk_hash_ent *p, *pcan; + + p = ofdisk_hash_add_real (devpath); + + grub_dprintf ("disk", "devpath = %s, canonical = %s\n", devpath, curcan); - curcan = grub_ieee1275_canonicalise_devname (devpath); if (!curcan) { - grub_errno = GRUB_ERR_NONE; + p->shortest = devpath; return p; } pcan = ofdisk_hash_find (curcan); if (!pcan) - pcan = ofdisk_hash_add (curcan); + pcan = ofdisk_hash_add_real (curcan); else grub_free (curcan); @@ -118,17 +127,22 @@ scan (void) return 0; grub_dprintf ("disk", "disk name = %s\n", alias->name); + grub_dprintf ("disk", "disk name = %s, path = %s\n", alias->name, + alias->path); - op = ofdisk_hash_find (alias->path); + op = ofdisk_hash_find (alias->name); if (!op) { char *name = grub_strdup (alias->name); - if (!name) + char *can = grub_strdup (alias->path); + if (!name || !can) { grub_errno = GRUB_ERR_NONE; + grub_free (name); + grub_free (can); return 0; } - op = ofdisk_hash_add (name); + op = ofdisk_hash_add (name, can); } return 0; } @@ -247,7 +261,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) struct ofdisk_hash_ent *op; op = ofdisk_hash_find (devpath); if (!op) - op = ofdisk_hash_add (devpath); + op = ofdisk_hash_add (devpath, NULL); else grub_free (devpath); if (!op) From b8494fbe5c6b816dc7386eb7dc60a3922b86fdb7 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 12 Jan 2011 11:52:51 +0100 Subject: [PATCH 04/34] * grub-core/normal/context.c (grub_env_context_close): Silence spurious warning. * grub-core/normal/menu.c (grub_menu_execute_entry): Likewise. * grub-core/partmap/msdos.c (pc_partition_map_embed): Use unsigned counter. --- ChangeLog | 8 ++++++++ grub-core/normal/context.c | 3 ++- grub-core/normal/menu.c | 2 +- grub-core/partmap/msdos.c | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 958850421..6efb466bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-01-12 Vladimir Serbinenko + + * grub-core/normal/context.c (grub_env_context_close): Silence spurious + warning. + * grub-core/normal/menu.c (grub_menu_execute_entry): Likewise. + * grub-core/partmap/msdos.c (pc_partition_map_embed): Use unsigned + counter. + 2011-01-12 Vladimir Serbinenko Use alias->path rather than buggy "canon". diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c index b73161d0b..108679913 100644 --- a/grub-core/normal/context.c +++ b/grub-core/normal/context.c @@ -148,7 +148,7 @@ grub_env_context_close (void) grub_err_t grub_env_extractor_close (int source) { - grub_menu_t menu, menu2; + grub_menu_t menu = NULL; grub_menu_entry_t *last; grub_err_t err; @@ -161,6 +161,7 @@ grub_env_extractor_close (int source) if (source) { + grub_menu_t menu2; menu2 = grub_env_get_menu (); last = &menu2->entry_list; diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index 6a123a6de..e62482122 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -159,7 +159,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) { grub_err_t err = GRUB_ERR_NONE; int errs_before; - grub_menu_t menu; + grub_menu_t menu = NULL; char *optr, *buf, *oldchosen = NULL, *olddefault = NULL; const char *ptr, *chosen, *def; grub_size_t sz = 0; diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c index f99e27a6e..d411c4405 100644 --- a/grub-core/partmap/msdos.c +++ b/grub-core/partmap/msdos.c @@ -234,7 +234,7 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, if (end >= *nsectors + 1) { - int i; + unsigned i; *nsectors = end - 1; *sectors = grub_malloc (*nsectors * sizeof (**sectors)); if (!*sectors) From 8fc0a24576669f28e98f9ccc1b40b8e742f95aad Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 12 Jan 2011 11:55:52 +0100 Subject: [PATCH 05/34] * grub-core/Makefile.core.def (ieee1275_fb): Disable on sparc. It doesn't work well there. --- ChangeLog | 5 +++++ grub-core/Makefile.core.def | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6efb466bb..915fd2619 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-12 Vladimir Serbinenko + + * grub-core/Makefile.core.def (ieee1275_fb): Disable on sparc. + It doesn't work well there. + 2011-01-12 Vladimir Serbinenko * grub-core/normal/context.c (grub_env_context_close): Silence spurious diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 094bbc835..2cca4fa95 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1463,7 +1463,6 @@ module = { name = ieee1275_fb; ieee1275 = video/ieee1275.c; enable = powerpc; - enable = sparc64; }; module = { From f8f479dbbbd908551f2c691b3b7d35997f3a1a7b Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 12 Jan 2011 12:49:16 +0100 Subject: [PATCH 06/34] * util/grub-mkfont.c (write_font_pf2): Use appropriate type for data variable. Fixes problem on big endian platforms. --- ChangeLog | 5 +++++ util/grub-mkfont.c | 17 ++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 915fd2619..254fc2c6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-12 Vladimir Serbinenko + + * util/grub-mkfont.c (write_font_pf2): Use appropriate type for data + variable. Fixes problem on big endian platforms. + 2011-01-12 Vladimir Serbinenko * grub-core/Makefile.core.def (ieee1275_fb): Disable on sparc. diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index 983ac7065..3108d4694 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -859,7 +859,7 @@ void write_font_pf2 (struct grub_font_info *font_info, char *output_file) { FILE *file; - grub_uint32_t leng, data; + grub_uint32_t leng; char style_name[20], *font_name; int offset; struct grub_glyph_info *cur; @@ -959,12 +959,14 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file) for (cur = font_info->glyphs_sorted; cur < font_info->glyphs_sorted + font_info->num_glyphs; cur++) { - data = grub_cpu_to_be32 (cur->char_code); - grub_util_write_image ((char *) &data, 4, file); - data = 0; - grub_util_write_image ((char *) &data, 1, file); - data = grub_cpu_to_be32 (offset); - grub_util_write_image ((char *) &data, 4, file); + grub_uint32_t data32; + grub_uint8_t data8; + data32 = grub_cpu_to_be32 (cur->char_code); + grub_util_write_image ((char *) &data32, 4, file); + data8 = 0; + grub_util_write_image ((char *) &data8, 1, file); + data32 = grub_cpu_to_be32 (offset); + grub_util_write_image ((char *) &data32, 4, file); offset += 10 + cur->bitmap_size; } @@ -976,6 +978,7 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file) for (cur = font_info->glyphs_sorted; cur < font_info->glyphs_sorted + font_info->num_glyphs; cur++) { + grub_uint16_t data; data = grub_cpu_to_be16 (cur->width); grub_util_write_image ((char *) &data, 2, file); data = grub_cpu_to_be16 (cur->height); From 173b71e9fea74cb2edfab96418f92bc589a17dc4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 12 Jan 2011 19:51:19 +0100 Subject: [PATCH 07/34] * util/grub.d/00_header.in (load_video): Handle the case when no video drivers available. Thanks to: Axel Beckert. --- ChangeLog | 6 ++++++ util/grub.d/00_header.in | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 254fc2c6f..74c6affff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-12 Vladimir Serbinenko + + * util/grub.d/00_header.in (load_video): Handle the case when no video + drivers available. + Thanks to: Axel Beckert. + 2011-01-12 Vladimir Serbinenko * util/grub-mkfont.c (write_font_pf2): Use appropriate type for data diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index a596e9c4a..420b3f32c 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -84,11 +84,16 @@ if [ -n "${GRUB_VIDEO_BACKEND}" ]; then EOF else # Insert all available backends; GRUB will use the most appropriate. + have_video=0; for backend in $(cat "${GRUB_PREFIX}/video.lst"); do + have_video=1; cat < Date: Wed, 12 Jan 2011 19:58:32 +0100 Subject: [PATCH 08/34] * util/ieee1275/ofpath.c (grub_util_devname_to_ofpath): Use the realpath'ed device string. Handle floppy (somewhat). Issue error in unknown case rather than garbage. Reported by: Axel Beckert. --- ChangeLog | 8 ++++++++ util/ieee1275/ofpath.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 74c6affff..7a3f3f63a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-01-12 Vladimir Serbinenko + + * util/ieee1275/ofpath.c (grub_util_devname_to_ofpath): Use the + realpath'ed device string. + Handle floppy (somewhat). + Issue error in unknown case rather than garbage. + Reported by: Axel Beckert. + 2011-01-12 Vladimir Serbinenko * util/grub.d/00_header.in (load_video): Handle the case when no video diff --git a/util/ieee1275/ofpath.c b/util/ieee1275/ofpath.c index fa0d48cf9..1a433345d 100644 --- a/util/ieee1275/ofpath.c +++ b/util/ieee1275/ofpath.c @@ -377,8 +377,8 @@ grub_util_devname_to_ofpath (const char *devname) if (! name_buf) grub_util_error ("cannot get the real path of `%s'", devname); - device = get_basename (devname); - devnode = strip_trailing_digits (devname); + device = get_basename (name_buf); + devnode = strip_trailing_digits (name_buf); devicenode = strip_trailing_digits (device); ofpath = xmalloc (OF_PATH_MAX); @@ -391,6 +391,13 @@ grub_util_devname_to_ofpath (const char *devname) else if (device[0] == 'v' && device[1] == 'd' && device[2] == 'i' && device[3] == 's' && device[4] == 'k') of_path_of_vdisk(ofpath, name_buf, device, devnode, devicenode); + else if (device[0] == 'f' && device[1] == 'd' + && device[2] == '0' && device[3] == '\0') + /* All the models I've seen have a devalias "floppy". + New models have no floppy at all. */ + strcpy (ofpath, "floppy"); + else + grub_util_error ("unknown device type %s\n", device); free (devnode); free (devicenode); From f1632d4dd050baee3d2a41730c45ab21f741c62f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 13 Jan 2011 22:23:49 +0100 Subject: [PATCH 09/34] Fix compilation on cygwin. * conf/Makefile.common (STRIPFLAGS_KERNEL): Add -F elf32-i386 and -R .drectve on cygwin. * conf/i386-pc-cygwin-img-ld.sc: Merge rdata and pdata into data. * configure.ac: Use $(top_builddir) in TARGET_OBJ2ELF. (COND_CYGWIN): New condition. * grub-core/Makefile.am (%.mod): Set TARGET_OBJ2ELF. * grub-core/genmod.sh.in: Use ${TARGET_OBJ2ELF} and not @TARGET_OBJ2ELF@. * util/grub-pe2elf.c (write_symbol_table): Use pe_symtab->type and not type to determine whether aux is to be used. --- ChangeLog | 15 +++++++++++++++ conf/Makefile.common | 4 ++++ conf/i386-pc-cygwin-img-ld.sc | 6 ------ configure.ac | 3 ++- grub-core/Makefile.am | 2 +- grub-core/genmod.sh.in | 4 ++-- util/grub-pe2elf.c | 2 +- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a3f3f63a..696da1215 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2011-01-13 Vladimir Serbinenko + + Fix compilation on cygwin. + + * conf/Makefile.common (STRIPFLAGS_KERNEL): Add -F elf32-i386 and + -R .drectve on cygwin. + * conf/i386-pc-cygwin-img-ld.sc: Merge rdata and pdata into data. + * configure.ac: Use $(top_builddir) in TARGET_OBJ2ELF. + (COND_CYGWIN): New condition. + * grub-core/Makefile.am (%.mod): Set TARGET_OBJ2ELF. + * grub-core/genmod.sh.in: Use ${TARGET_OBJ2ELF} and + not @TARGET_OBJ2ELF@. + * util/grub-pe2elf.c (write_symbol_table): Use pe_symtab->type and not + type to determine whether aux is to be used. + 2011-01-12 Vladimir Serbinenko * util/ieee1275/ofpath.c (grub_util_devname_to_ofpath): Use the diff --git a/conf/Makefile.common b/conf/Makefile.common index 2df8465c0..32ca76d08 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -67,7 +67,11 @@ CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib -Wl,-N -static-libgcc CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) +if COND_CYGWIN +STRIPFLAGS_KERNEL = -F elf32-i386 -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve +else STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment +endif CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib -Wl,-N,-r,-d diff --git a/conf/i386-pc-cygwin-img-ld.sc b/conf/i386-pc-cygwin-img-ld.sc index a41cac75e..3b579d344 100644 --- a/conf/i386-pc-cygwin-img-ld.sc +++ b/conf/i386-pc-cygwin-img-ld.sc @@ -13,15 +13,9 @@ SECTIONS __data_start__ = . ; *(.data) __data_end__ = . ; - } - .rdata : - { __rdata_start__ = . ; *(.rdata) __rdata_end__ = . ; - } - .pdata : - { *(.pdata) edata = . ; } diff --git a/configure.ac b/configure.ac index 055c65e67..0b9207ea2 100644 --- a/configure.ac +++ b/configure.ac @@ -454,7 +454,7 @@ fi # For platforms where ELF is not the default link format. AC_MSG_CHECKING([for command to convert module to ELF format]) case "${host_os}" in - cygwin) TARGET_OBJ2ELF='$(grub_utildir)/grub-pe2elf'; + cygwin) TARGET_OBJ2ELF='$(top_builddir)/grub-pe2elf'; # FIXME: put proper test here NEED_REGISTER_FRAME_INFO=1 ;; @@ -964,6 +964,7 @@ AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1]) AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes]) AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1]) +AM_CONDITIONAL([COND_CYGWIN], [test x$host_os = xcygwin]) # Output files. grub_CHECK_LINK_DIR diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index fcf3fc42d..94f7f3ffe 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -303,7 +303,7 @@ platform_DATA += moddep.lst CLEANFILES += config.log syminfo.lst moddep.lst $(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) - sh $^ $@ + TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@ platform_DATA += $(MOD_FILES) CLEANFILES += $(MOD_FILES) diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index b97f3e1c7..023cd1062 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -52,8 +52,8 @@ fi rm -f $t1 $t2 if test x@TARGET_APPLE_CC@ != x1; then - if ! test -z "@TARGET_OBJ2ELF@"; then - ./@TARGET_OBJ2ELF@ $tmpfile || exit 1 + if ! test -z "${TARGET_OBJ2ELF}"; then + ./${TARGET_OBJ2ELF} $tmpfile || exit 1 fi if test x@platform@ != xemu; then @STRIP@ --strip-unneeded \ diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c index f370bbfa8..cf690841f 100644 --- a/util/grub-pe2elf.c +++ b/util/grub-pe2elf.c @@ -337,7 +337,7 @@ write_symbol_table (FILE* fp, char *image, else bind = STB_LOCAL; - if ((type != STT_FUNC) && (pe_symtab->num_aux)) + if ((pe_symtab->type != GRUB_PE32_DT_FUNCTION) && (pe_symtab->num_aux)) { if (! pe_symtab->value) type = STT_SECTION; From 4fbf185232d53acc65599720b6d304acb012e968 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 13 Jan 2011 22:25:56 +0100 Subject: [PATCH 10/34] * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Quote bootpath and diskdevid. --- ChangeLog | 5 +++++ grub-core/fs/zfs/zfsinfo.c | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 696da1215..b57c6f229 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-13 Vladimir Serbinenko + + * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Quote bootpath and + diskdevid. + 2011-01-13 Vladimir Serbinenko Fix compilation on cygwin. diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c index 5a7b5ec44..224a97792 100644 --- a/grub-core/fs/zfs/zfsinfo.c +++ b/grub-core/fs/zfs/zfsinfo.c @@ -364,12 +364,14 @@ grub_cmd_zfs_bootfs (grub_command_t cmd __attribute__ ((unused)), int argc, grub_free (nv); grub_free (nvlist); - bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu%s%s%s%s", + bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu%s%s%s%s%s%s", poolname, (unsigned long long) mdnobj, - bootpath ? ",bootpath=" : "", - bootpath ? : "", - devid ? ",diskdevid=" : "", - devid ? : ""); + bootpath ? ",bootpath=\"" : "", + bootpath ? : "", + bootpath ? "\"" : "", + devid ? ",diskdevid=\"" : "", + devid ? : "", + devid ? "\"" : ""); if (!bootfs) return grub_errno; if (argc >= 2) From 1d955d0098b02d77ccec93cd425568a7fa95c913 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 14 Jan 2011 19:21:06 +0100 Subject: [PATCH 11/34] * grub-core/Makefile.core.def (fwstart): Add lost LDFLAGS. --- ChangeLog | 4 ++++ grub-core/Makefile.core.def | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index b57c6f229..4822910dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-13 Vladimir Serbinenko + + * grub-core/Makefile.core.def (fwstart): Add lost LDFLAGS. + 2011-01-13 Vladimir Serbinenko * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Quote bootpath and diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2cca4fa95..ce7d0b0c2 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -324,6 +324,7 @@ image = { name = fwstart; mips_yeeloong = boot/mips/yeeloong/fwstart.S; objcopyflags = '-O binary'; + ldflags = '-static-libgcc -lgcc -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; enable = mips_yeeloong; }; From 46c9db88cda310ec22344fcf4cfb055c1a317a28 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 14 Jan 2011 19:23:34 +0100 Subject: [PATCH 12/34] * grub-core/kern/mips/yeeloong/init.c (grub_machine_init): Init boot module. --- ChangeLog | 7 ++++++- grub-core/kern/mips/yeeloong/init.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4822910dd..69534abe2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2011-01-13 Vladimir Serbinenko +2011-01-14 Vladimir Serbinenko + + * grub-core/kern/mips/yeeloong/init.c (grub_machine_init): Init boot + module. + +2011-01-14 Vladimir Serbinenko * grub-core/Makefile.core.def (fwstart): Add lost LDFLAGS. diff --git a/grub-core/kern/mips/yeeloong/init.c b/grub-core/kern/mips/yeeloong/init.c index cadb10773..7a48d69f5 100644 --- a/grub-core/kern/mips/yeeloong/init.c +++ b/grub-core/kern/mips/yeeloong/init.c @@ -41,6 +41,7 @@ extern void grub_at_keyboard_init (void); extern void grub_serial_init (void); extern void grub_terminfo_init (void); extern void grub_keylayouts_init (void); +extern void grub_boot_init (void); /* FIXME: use interrupt to count high. */ grub_uint64_t @@ -210,6 +211,8 @@ grub_machine_init (void) grub_terminfo_init (); grub_serial_init (); + + grub_boot_init (); } void From 043603376e933098adea34156b0898814221c734 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 15 Jan 2011 21:58:21 +0100 Subject: [PATCH 13/34] * util/grub-mkimage.c (generate_image): Check fwstart.img checksum for safety. --- ChangeLog | 5 +++++ util/grub-mkimage.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ChangeLog b/ChangeLog index 69534abe2..d275fd9b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-15 Vladimir Serbinenko + + * util/grub-mkimage.c (generate_image): Check fwstart.img checksum + for safety. + 2011-01-14 Vladimir Serbinenko * grub-core/kern/mips/yeeloong/init.c (grub_machine_init): Init boot diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index 53e867602..0375d3ed5 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -1167,11 +1168,34 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], size_t rom_size; char *boot_path, *boot_img; size_t boot_size; + grub_uint8_t context[GRUB_MD_SHA512->contextsize]; + /* fwstart.img is the only part which can't be testes by using *-elf + target. Check it against the checksum. This checksum is obtained with + sha512sum utility after compiling on Gnewsense. + */ + const grub_uint8_t fwstart_good_hash[] = + { 0x75, 0xbf, 0xa3, 0x0e, 0x7c, 0xd1, 0x03, 0x82, + 0xe1, 0x34, 0x55, 0xd7, 0x09, 0x1e, 0x6c, 0xcc, + 0xef, 0x08, 0x61, 0xc1, 0x3c, 0xd8, 0xc7, 0x9f, + 0xe8, 0x2d, 0x3d, 0xb2, 0xda, 0x41, 0xd3, 0x83, + 0xd7, 0xb8, 0xe3, 0xd7, 0x13, 0xec, 0x9b, 0xf6, + 0xf6, 0xae, 0x6b, 0x32, 0x29, 0xc1, 0x69, 0x82, + 0xfa, 0x65, 0x2d, 0x97, 0x3e, 0x83, 0x6e, 0x6c, + 0xce, 0x34, 0x10, 0x59, 0x74, 0x0e, 0x96, 0x26 }; boot_path = grub_util_get_path (dir, "fwstart.img"); boot_size = grub_util_get_image_size (boot_path); boot_img = grub_util_read_image (boot_path); + grub_memset (context, 0, sizeof (context)); + GRUB_MD_SHA512->init (context); + GRUB_MD_SHA512->write (context, boot_img, boot_size); + GRUB_MD_SHA512->final (context); + if (grub_memcmp (GRUB_MD_SHA512->read (context), fwstart_good_hash, + GRUB_MD_SHA512->mdlen) != 0) + grub_util_warn ("fwstart.img doesn't match the known good version. " + "Proceed at your own risk"); + rom_size = ALIGN_UP (core_size + boot_size, 512 * 1024); rom_img = xmalloc (rom_size); From 646ada34d11f26484ffe33e0cc80bcd06219ec8c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 16 Jan 2011 12:54:03 +0100 Subject: [PATCH 14/34] * configure.ac: Bump version to 1.99~rc1. --- ChangeLog | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d275fd9b6..8c39f7ba5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-16 Vladimir Serbinenko + + * configure.ac: Bump version to 1.99~rc1. + 2011-01-15 Vladimir Serbinenko * util/grub-mkimage.c (generate_image): Check fwstart.img checksum diff --git a/configure.ac b/configure.ac index 0b9207ea2..c660ac41e 100644 --- a/configure.ac +++ b/configure.ac @@ -32,7 +32,7 @@ dnl type, so there is no conflict. Variables with the prefix "TARGET_" dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target dnl type. -AC_INIT([GRUB],[1.99~beta0],[bug-grub@gnu.org]) +AC_INIT([GRUB],[1.99~rc1],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) From 5e79d66a547bd1e616defefef4cc5ab44d198a1e Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 17 Jan 2011 12:48:07 +0000 Subject: [PATCH 15/34] * .bzrignore: Remove nonexistent grub-pbkdf2. --- .bzrignore | 1 - ChangeLog | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.bzrignore b/.bzrignore index 0cbb3f17f..a3e6f9dd2 100644 --- a/.bzrignore +++ b/.bzrignore @@ -44,7 +44,6 @@ grub-kbdcomp grub-macho2img grub-menulst2cfg grub-mk* -grub-pbkdf2 grub-pe2elf grub-probe grub_probe_init.c diff --git a/ChangeLog b/ChangeLog index 8c39f7ba5..a2d11d828 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-17 Colin Watson + + * .bzrignore: Remove nonexistent grub-pbkdf2. + 2011-01-16 Vladimir Serbinenko * configure.ac: Bump version to 1.99~rc1. From 81431e2b020371b57f747e2b3decdfbb00ed183e Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 22 Jan 2011 01:11:56 +0000 Subject: [PATCH 16/34] * docs/grub.texi (Simple configuration): Document GRUB_PRELOAD_MODULES. --- ChangeLog | 5 +++++ docs/grub.texi | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index a2d11d828..75c713b9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-22 Colin Watson + + * docs/grub.texi (Simple configuration): Document + GRUB_PRELOAD_MODULES. + 2011-01-17 Colin Watson * .bzrignore: Remove nonexistent grub-pbkdf2. diff --git a/docs/grub.texi b/docs/grub.texi index daf48da13..a47389f1e 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1181,6 +1181,11 @@ directly to @ref{play}. If this option is set, GRUB will issue a @ref{badram} command to filter out specified regions of RAM. +@item GRUB_PRELOAD_MODULES +This option may be set to a list of GRUB module names separated by spaces. +Each module will be loaded as early as possible, at the start of +@file{grub.cfg}. + @end table For more detailed customisation of @command{grub-mkconfig}'s output, you may From 96e0a6ea9795fd2068d8f8e308d398fd3cb0e314 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 22 Jan 2011 01:26:49 +0000 Subject: [PATCH 17/34] * util/grub-mkconfig_lib.in (is_path_readable_by_grub): Consider a path unreadable if `grub-probe -t abstraction' fails, for example if memberlist fails on an LVM volume group. Reported by: Darius Jahandarie. --- ChangeLog | 7 +++++++ util/grub-mkconfig_lib.in | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index 75c713b9d..062f3c5a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-22 Colin Watson + + * util/grub-mkconfig_lib.in (is_path_readable_by_grub): Consider a + path unreadable if `grub-probe -t abstraction' fails, for example if + memberlist fails on an LVM volume group. + Reported by: Darius Jahandarie. + 2011-01-22 Colin Watson * docs/grub.texi (Simple configuration): Document diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 2a48fb260..628ea34d4 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -61,6 +61,12 @@ is_path_readable_by_grub () return 1 fi + # ... or if we can't figure out the abstraction module, for example if + # memberlist fails on an LVM volume group. + if ${grub_probe} -t abstraction $path > /dev/null 2>&1 ; then : ; else + return 1 + fi + return 0 } From e489601ad0594bde0dc17257802beb7076976849 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 13:18:05 +0100 Subject: [PATCH 18/34] * grub-core/disk/raid.c (insert_array): Ensure uniqueness of p->number even if some elements have a name. Reported by: Alexander GQ Gerasiov. --- ChangeLog | 6 ++++++ grub-core/disk/raid.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 062f3c5a8..cb499bb01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/disk/raid.c (insert_array): Ensure uniqueness of p->number + even if some elements have a name. + Reported by: Alexander GQ Gerasiov. + 2011-01-22 Colin Watson * util/grub-mkconfig_lib.in (is_path_readable_by_grub): Consider a diff --git a/grub-core/disk/raid.c b/grub-core/disk/raid.c index c789fea50..3972e1632 100644 --- a/grub-core/disk/raid.c +++ b/grub-core/disk/raid.c @@ -570,7 +570,7 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array, { for (p = array_list; p != NULL; p = p->next) { - if (! p->name && p->number == array->number) + if (p->number == array->number) break; } } From 5d4f4dd51b159de457a989c731c0012d0bbbac98 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 13:22:46 +0100 Subject: [PATCH 19/34] * grub-core/disk/scsi.c (grub_scsi_read): Fix binary and check and make logical expression more readable. --- ChangeLog | 5 +++++ grub-core/disk/scsi.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cb499bb01..16be610ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/disk/scsi.c (grub_scsi_read): Fix binary and check and make + logical expression more readable. + 2011-01-22 Vladimir Serbinenko * grub-core/disk/raid.c (insert_array): Ensure uniqueness of p->number diff --git a/grub-core/disk/scsi.c b/grub-core/disk/scsi.c index 902ab12c3..a40de278f 100644 --- a/grub-core/disk/scsi.c +++ b/grub-core/disk/scsi.c @@ -506,7 +506,7 @@ grub_scsi_read (grub_disk_t disk, grub_disk_addr_t sector, if (scsi->blocksize != GRUB_DISK_SECTOR_SIZE) { unsigned spb = scsi->blocksize >> GRUB_DISK_SECTOR_BITS; - if (! (spb != 0 && (scsi->blocksize & GRUB_DISK_SECTOR_SIZE) == 0)) + if (spb == 0 || (scsi->blocksize & (GRUB_DISK_SECTOR_SIZE - 1)) != 0) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "unsupported SCSI block size"); From 80f23be71fa11304d11e3dc549f1a20d0a492673 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 14:11:19 +0100 Subject: [PATCH 20/34] * grub-core/script/argv.c (round_up_exp): unsigned is 32-bit on all supported platforms. Put a compile time assert for this rather than generate a warning with 32-bit shift. --- ChangeLog | 6 ++++++ grub-core/script/argv.c | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16be610ea..9e4ea21dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/script/argv.c (round_up_exp): unsigned is 32-bit on all + supported platforms. Put a compile time assert for this rather than + generate a warning with 32-bit shift. + 2011-01-22 Vladimir Serbinenko * grub-core/disk/scsi.c (grub_scsi_read): Fix binary and check and make diff --git a/grub-core/script/argv.c b/grub-core/script/argv.c index 50f810fcf..856828d7b 100644 --- a/grub-core/script/argv.c +++ b/grub-core/script/argv.c @@ -25,6 +25,8 @@ static unsigned round_up_exp (unsigned v) { + COMPILE_TIME_ASSERT (sizeof (v) == 4); + v--; v |= v >> 1; v |= v >> 2; @@ -32,9 +34,6 @@ round_up_exp (unsigned v) v |= v >> 8; v |= v >> 16; - if (sizeof (v) > 4) - v |= v >> 32; - v++; v += (v == 0); From ffc8f4d8bce3586d4dcd714c84eea558c902c8a8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 14:15:17 +0100 Subject: [PATCH 21/34] * grub-core/partmap/bsdlabel.c: Include grub/emu/misc.h and not grub/util/misc.h. (iterate_real): Don't rely on partition being non-NULL. --- ChangeLog | 5 +++++ grub-core/partmap/bsdlabel.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e4ea21dd..6593c4891 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/partmap/bsdlabel.c: Include grub/emu/misc.h and not grub/util/misc.h. + (iterate_real): Don't rely on partition being non-NULL. + 2011-01-22 Vladimir Serbinenko * grub-core/script/argv.c (round_up_exp): unsigned is 32-bit on all diff --git a/grub-core/partmap/bsdlabel.c b/grub-core/partmap/bsdlabel.c index 09ecd935a..4dec3851c 100644 --- a/grub-core/partmap/bsdlabel.c +++ b/grub-core/partmap/bsdlabel.c @@ -26,7 +26,7 @@ #include #ifdef GRUB_UTIL -#include +#include #endif static struct grub_partition_map grub_bsdlabel_partition_map; @@ -101,7 +101,8 @@ iterate_real (grub_disk_t disk, grub_disk_addr_t sector, int freebsd, #ifdef GRUB_UTIL char *partname; /* disk->partition != NULL as 0 < delta */ - partname = grub_partition_get_name (disk->partition); + partname = disk->partition ? grub_partition_get_name (disk->partition) + : ""; grub_util_warn ("Discarding improperly nested partition (%s,%s,%s%d)", disk->name, partname, p.partmap->name, p.number + 1); grub_free (partname); From 03a4ccb5134770375d5b8ed95e11ef6bfc296730 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 14:26:18 +0100 Subject: [PATCH 22/34] * grub-core/bus/bonito.c (write_bases): Fix direction of the shift. --- ChangeLog | 4 ++++ grub-core/bus/bonito.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6593c4891..f44a91c6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/bus/bonito.c (write_bases): Fix direction of the shift. + 2011-01-22 Vladimir Serbinenko * grub-core/partmap/bsdlabel.c: Include grub/emu/misc.h and not grub/util/misc.h. diff --git a/grub-core/bus/bonito.c b/grub-core/bus/bonito.c index 3f794c45a..c2e0cd6ff 100644 --- a/grub-core/bus/bonito.c +++ b/grub-core/bus/bonito.c @@ -38,7 +38,7 @@ write_bases (void) for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++) reg |= (((base_win[i] >> GRUB_MACHINE_PCI_WIN_SHIFT) & GRUB_MACHINE_PCI_WIN_MASK) - >> (i * GRUB_MACHINE_PCI_WIN_MASK_SIZE)); + << (i * GRUB_MACHINE_PCI_WIN_MASK_SIZE)); GRUB_MACHINE_PCI_IO_CTRL_REG = reg; } From 37f4f60828307e35cac458e5b832d4a36aaa0471 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 15:10:29 +0100 Subject: [PATCH 23/34] * util/grub-install.in: Ignore install device on platforms where it doesn't make sense. Always use UUIDs except on pc, efi and sparc64. Reported by: Daniel Kahn Gillmor. --- ChangeLog | 7 +++++++ util/grub-install.in | 26 ++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index f44a91c6b..ce6b6f7cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-22 Vladimir Serbinenko + + * util/grub-install.in: Ignore install device on platforms + where it doesn't make sense. Always use UUIDs except on pc, efi and + sparc64. + Reported by: Daniel Kahn Gillmor. + 2011-01-22 Vladimir Serbinenko * grub-core/bus/bonito.c (write_bases): Fix direction of the shift. diff --git a/util/grub-install.in b/util/grub-install.in index 90360c279..1ae00b2fd 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -270,6 +270,11 @@ if test "x$install_device" = x && ([ "${target_cpu}-${platform}" = "i386-pc" ] \ exit 1 fi +if ! ([ "${target_cpu}-${platform}" = "i386-pc" ] \ + || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then + install_device= +fi + # If the debugging feature is enabled, print commands. setup_verbose= if test x"$debug" = xyes; then @@ -516,27 +521,24 @@ if [ "x${devabstraction_module}" = "x" ] ; then # Strip partition number grub_partition="`echo "${grub_drive}" | sed -e 's/^[^,]*[,)]//; s/)$//'`" grub_drive="`echo "${grub_drive}" | sed -e s/,[a-z0-9,]*//g`" - if [ "$disk_module" = ata ] ; then + if [ "$disk_module" = ata ] || [ "x${grub_drive}" != "x${install_drive}" ] || ([ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]) ; then # generic method (used on coreboot and ata mod) uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`" if [ "x${uuid}" = "x" ] ; then - echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 + if [ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]; then + echo "UUID needed with $platform, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 + elif [ "$disk_module" = ata ]; then + echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 + else + echo "UUID needed with cross-disk installs, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 + fi + exit 1 fi echo "search.fs_uuid ${uuid} root " >> "${grubdir}/load.cfg" echo 'set prefix=($root)'"${relative_grubdir}" >> "${grubdir}/load.cfg" config_opt="-c ${grubdir}/load.cfg " modules="$modules search_fs_uuid" - elif [ "x${grub_drive}" != "x${install_drive}" ] ; then - uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`" - if [ "x${uuid}" = "x" ] ; then - echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 - exit 1 - fi - echo "search.fs_uuid ${uuid} root " >> ${grubdir}/load.cfg - echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg - config_opt="-c ${grubdir}/load.cfg " - modules="$modules search_fs_uuid" elif [ "x$platform" = xefi ] || [ "x$platform" = xpc ]; then # we need to hardcode the partition number in the core image's prefix. if [ x"$grub_partition" = x ]; then From 5d4c5f891446f913ced217af1712a8d903449fe0 Mon Sep 17 00:00:00 2001 From: Anthony DeRobertis Date: Sat, 22 Jan 2011 15:20:08 +0100 Subject: [PATCH 24/34] * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Check super_offset field. --- grub-core/disk/mdraid1x_linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c index 155210df3..f2e7555cb 100644 --- a/grub-core/disk/mdraid1x_linux.c +++ b/grub-core/disk/mdraid1x_linux.c @@ -143,7 +143,8 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, &sb)) return grub_errno; - if (grub_le_to_cpu32 (sb.magic) != SB_MAGIC) + if (grub_le_to_cpu32 (sb.magic) != SB_MAGIC + || grub_le_to_cpu64 (sb.super_offset) != sector) continue; { From 73ae4f4ff55b39739352daf133ac4e9562e7f98e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 15:30:48 +0100 Subject: [PATCH 25/34] Add missing ChangeLog entry --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index ce6b6f7cf..ba611afad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-22 Anthony DeRobertis + + * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Check + super_offset field. + 2011-01-22 Vladimir Serbinenko * util/grub-install.in: Ignore install device on platforms From 3533413cd5efc9630436511b57d77f24c6afd0a3 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 15:37:05 +0100 Subject: [PATCH 26/34] * grub-core/kern/emu/getroot.c: Include config-util.h explicitly. --- ChangeLog | 4 ++++ grub-core/kern/emu/getroot.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index ba611afad..edb7d46f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/kern/emu/getroot.c: Include config-util.h explicitly. + 2011-01-22 Anthony DeRobertis * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Check diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index aedef9e0e..110e58b14 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -17,7 +17,9 @@ * along with GRUB. If not, see . */ +#include #include + #include #include #include From 3281d3d6d43ac50dab55cbed9b337ac4d8e17dac Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 24 Jan 2011 02:44:27 +0100 Subject: [PATCH 27/34] * util/grub-mkimage.c (generate_image): Refuse to create the images bigger than the actual flash (512K) in Loongson machines. 512K is also the biggest chip supported by them. --- ChangeLog | 6 ++++++ util/grub-mkimage.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index edb7d46f7..514ce4ef8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-24 Vladimir Serbinenko + + * util/grub-mkimage.c (generate_image): Refuse to create the images + bigger than the actual flash (512K) in Loongson machines. 512K is also + the biggest chip supported by them. + 2011-01-22 Vladimir Serbinenko * grub-core/kern/emu/getroot.c: Include config-util.h explicitly. diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index 0375d3ed5..876e9c9b2 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -1196,7 +1196,9 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], grub_util_warn ("fwstart.img doesn't match the known good version. " "Proceed at your own risk"); - rom_size = ALIGN_UP (core_size + boot_size, 512 * 1024); + if (core_size + boot_size > 512 * 1024) + grub_util_error ("firmware image is too big"); + rom_size = 512 * 1024; rom_img = xmalloc (rom_size); memset (rom_img, 0, rom_size); From 800f188183cf4d45bbd13eb94e1c2419888b76b2 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 28 Jan 2011 17:01:28 +0000 Subject: [PATCH 28/34] * docs/grub.texi (Making a GRUB bootable CD-ROM): Update to describe grub-mkrescue. --- ChangeLog | 5 +++++ docs/grub.texi | 48 +++++++++++++++++++++++------------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 514ce4ef8..019a6746c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-28 Colin Watson + + * docs/grub.texi (Making a GRUB bootable CD-ROM): Update to describe + grub-mkrescue. + 2011-01-24 Vladimir Serbinenko * util/grub-mkimage.c (generate_image): Refuse to create the images diff --git a/docs/grub.texi b/docs/grub.texi index a47389f1e..c815bcbbe 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -651,15 +651,22 @@ using BIOS functions.}. This means that you can use the whole CD-ROM from GRUB and you don't have to make a floppy or hard disk image file, which can cause compatibility problems. -For booting from a CD-ROM, GRUB uses a special Stage 2 called -@file{stage2_eltorito}. The only GRUB files you need to have in your -bootable CD-ROM are this @file{stage2_eltorito} and optionally a config file -@file{grub.cfg}. You don't need to use @file{stage1} or @file{stage2}, -because El Torito is quite different from the standard boot process. +For booting from a CD-ROM, GRUB uses a special image called +@file{cdboot.img}, which is concatenated with @file{core.img}. The +@file{core.img} used for this should be built with at least the +@samp{iso9660} and @samp{biosdisk} modules. Your bootable CD-ROM will +usually also need to include a configuration file @file{grub.cfg} and some +other GRUB modules. -Here is an example of procedures to make a bootable CD-ROM -image. First, make a top directory for the bootable image, say, -@samp{iso}: +To make a simple generic GRUB rescue CD, you can use the +@command{grub-mkrescue} program: + +@example +$ @kbd{grub-mkrescue -o grub.iso} +@end example + +You will often need to include other files in your image. To do this, first +make a top directory for the bootable image, say, @samp{iso}: @example $ @kbd{mkdir iso} @@ -671,33 +678,24 @@ Make a directory for GRUB: $ @kbd{mkdir -p iso/boot/grub} @end example -Copy the file @file{stage2_eltorito}: - -@example -$ @kbd{cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub} -@end example - If desired, make the config file @file{grub.cfg} under @file{iso/boot/grub} (@pxref{Configuration}), and copy any files and directories for the disc to the directory @file{iso/}. -Finally, make a ISO9660 image file like this: +Finally, make the image: @example -$ @kbd{mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \ - -boot-load-size 4 -boot-info-table -o grub.iso iso} +$ @kbd{grub-mkrescue -o grub.iso iso} @end example This produces a file named @file{grub.iso}, which then can be burned -into a CD (or a DVD). @kbd{mkisofs} has already set up the disc to boot -from the @kbd{boot/grub/stage2_eltorito} file, so there is no need to -setup GRUB on the disc. (Note that the @kbd{-boot-load-size 4} bit is -required for compatibility with the BIOS on many older machines.) +into a CD (or a DVD), or written to a USB mass storage device. -You can use the device @samp{(cd)} to access a CD-ROM in your -config file. This is not required; GRUB automatically sets the root device -to @samp{(cd)} when booted from a CD-ROM. It is only necessary to refer to -@samp{(cd)} if you want to access other drives as well. +The root device will be set up appropriately on entering your +@file{grub.cfg} configuration file, so you can refer to file names on the CD +without needing to use an explicit device name. This makes it easier to +produce rescue images that will work on both optical drives and USB mass +storage devices. @node Device map From 7e735e4349c2c408dd5420882ed206d8d34d78ce Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 8 Feb 2011 13:21:13 +0000 Subject: [PATCH 29/34] * include/grub/file.h (not_easly_seekable): Rename to ... (not_easily_seekable): ... this. Update all users. --- ChangeLog | 5 +++++ grub-core/fs/i386/pc/pxe.c | 2 +- grub-core/io/bufio.c | 2 +- grub-core/io/gzio.c | 2 +- grub-core/io/xzio.c | 2 +- include/grub/file.h | 6 +++--- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 019a6746c..d3325ac6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-02-08 Colin Watson + + * include/grub/file.h (not_easly_seekable): Rename to ... + (not_easily_seekable): ... this. Update all users. + 2011-01-28 Colin Watson * docs/grub.texi (Making a GRUB bootable CD-ROM): Update to describe diff --git a/grub-core/fs/i386/pc/pxe.c b/grub-core/fs/i386/pc/pxe.c index e2b53d637..a3b055f3d 100644 --- a/grub-core/fs/i386/pc/pxe.c +++ b/grub-core/fs/i386/pc/pxe.c @@ -281,7 +281,7 @@ grub_pxefs_open (struct grub_file *file, const char *name) } file->data = data; - file->not_easly_seekable = 1; + file->not_easily_seekable = 1; grub_memcpy (file_int, file, sizeof (struct grub_file)); curr_file = file_int; diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c index 8a72ecd79..891fb78e9 100644 --- a/grub-core/io/bufio.c +++ b/grub-core/io/bufio.c @@ -74,7 +74,7 @@ grub_bufio_open (grub_file_t io, int size) file->data = bufio; file->read_hook = 0; file->fs = &grub_bufio_fs; - file->not_easly_seekable = io->not_easly_seekable; + file->not_easily_seekable = io->not_easily_seekable; return file; } diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c index f563d7b92..47df23833 100644 --- a/grub-core/io/gzio.c +++ b/grub-core/io/gzio.c @@ -1136,7 +1136,7 @@ grub_gzio_open (grub_file_t io) file->data = gzio; file->read_hook = 0; file->fs = &grub_gzio_fs; - file->not_easly_seekable = 1; + file->not_easily_seekable = 1; if (! test_header (file)) { diff --git a/grub-core/io/xzio.c b/grub-core/io/xzio.c index 37be1790f..3daf6a3fe 100644 --- a/grub-core/io/xzio.c +++ b/grub-core/io/xzio.c @@ -200,7 +200,7 @@ grub_xzio_open (grub_file_t io) file->read_hook = 0; file->fs = &grub_xzio_fs; file->size = GRUB_FILE_SIZE_UNKNOWN; - file->not_easly_seekable = 1; + file->not_easily_seekable = 1; if (grub_file_tell (xzio->file) != 0) grub_file_seek (xzio->file, 0); diff --git a/include/grub/file.h b/include/grub/file.h index 72cd45468..3adb1706f 100644 --- a/include/grub/file.h +++ b/include/grub/file.h @@ -39,8 +39,8 @@ struct grub_file /* The file size. */ grub_off_t size; - /* If file is not easly seekable. Should be set by underlying layer. */ - int not_easly_seekable; + /* If file is not easily seekable. Should be set by underlying layer. */ + int not_easily_seekable; /* Filesystem-specific data. */ void *data; @@ -123,7 +123,7 @@ grub_file_tell (const grub_file_t file) static inline int grub_file_seekable (const grub_file_t file) { - return !file->not_easly_seekable; + return !file->not_easily_seekable; } #endif /* ! GRUB_FILE_HEADER */ From 22b28eb3fe78a38e1be478d70bd8da1a75f784de Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 9 Feb 2011 11:23:11 +0000 Subject: [PATCH 30/34] * util/grub-install.in: Remove unnecessary brackets from tr arguments. * util/grub.d/10_hurd.in: Likewise. * util/grub.d/10_kfreebsd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/grub.d/20_linux_xen.in: Likewise. Reported by: Jamie Heilman. Fixes Debian bug #612564. --- ChangeLog | 10 ++++++++++ util/grub-install.in | 2 +- util/grub.d/10_hurd.in | 2 +- util/grub.d/10_kfreebsd.in | 2 +- util/grub.d/10_linux.in | 2 +- util/grub.d/20_linux_xen.in | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3325ac6b..6517450ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-02-09 Colin Watson + + * util/grub-install.in: Remove unnecessary brackets from tr + arguments. + * util/grub.d/10_hurd.in: Likewise. + * util/grub.d/10_kfreebsd.in: Likewise. + * util/grub.d/10_linux.in: Likewise. + * util/grub.d/20_linux_xen.in: Likewise. + Reported by: Jamie Heilman. Fixes Debian bug #612564. + 2011-02-08 Colin Watson * include/grub/file.h (not_easly_seekable): Rename to ... diff --git a/util/grub-install.in b/util/grub-install.in index 1ae00b2fd..af3034e03 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -64,7 +64,7 @@ if test -f "${sysconfdir}/default/grub" ; then . "${sysconfdir}/default/grub" fi -bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr '[A-Z]' '[a-z]' | cut -d' ' -f1)" +bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr 'A-Z' 'a-z' | cut -d' ' -f1)" if test -z "$bootloader_id"; then bootloader_id=grub fi diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index eeb441aa4..8c54eab97 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -28,7 +28,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU else OS="${GRUB_DISTRIBUTOR} GNU/Hurd" - CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}" + CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}" fi at_least_one=false diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index b026812a7..dce5e945c 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -31,7 +31,7 @@ CLASS="--class os" case "${GRUB_DISTRIBUTOR}" in Debian) OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" - CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}" + CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}" ;; *) OS="FreeBSD" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index a09c3e687..491d2b5ce 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -32,7 +32,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU/Linux else OS="${GRUB_DISTRIBUTOR} GNU/Linux" - CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}" + CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}" fi # loop-AES arranges things so that /dev/loop/X can be our root device, but diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index ee49cd903..356219e1d 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -32,7 +32,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU/Linux else OS="${GRUB_DISTRIBUTOR} GNU/Linux" - CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}" + CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}" fi # loop-AES arranges things so that /dev/loop/X can be our root device, but From 97286eb54770ce840063ee0740c4a4923aaa28de Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 9 Feb 2011 12:14:10 +0000 Subject: [PATCH 31/34] * docs/grub.texi (Kernel): Add reference to grub-mkrescue. (Making a GRUB bootable CD-ROM): Likewise. (Invoking grub-mkrescue): New section. Reported by: Yann Dirson. Fixes Debian bug #612585. --- ChangeLog | 7 ++++++ docs/grub.texi | 62 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6517450ce..56498af1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-02-09 Colin Watson + + * docs/grub.texi (Kernel): Add reference to grub-mkrescue. + (Making a GRUB bootable CD-ROM): Likewise. + (Invoking grub-mkrescue): New section. + Reported by: Yann Dirson. Fixes Debian bug #612585. + 2011-02-09 Colin Watson * util/grub-install.in: Remove unnecessary brackets from tr diff --git a/docs/grub.texi b/docs/grub.texi index c815bcbbe..590e6afb7 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -36,6 +36,7 @@ Invariant Sections. * grub-install: (grub)Invoking grub-install. Install GRUB on your drive * grub-mkconfig: (grub)Invoking grub-mkconfig. Generate GRUB configuration * grub-mkpasswd-pbkdf2: (grub)Invoking grub-mkpasswd-pbkdf2. +* grub-mkrescue: (grub)Invoking grub-mkrescue. Make a GRUB rescue image @end direntry @setchapternewpage odd @@ -94,6 +95,7 @@ This edition documents version @value{VERSION}. * Invoking grub-mkconfig:: Generate a GRUB configuration file * Invoking grub-mkpasswd-pbkdf2:: Generate GRUB password hashes +* Invoking grub-mkrescue:: Make a GRUB rescue image * Obtaining and Building GRUB:: How to obtain and build GRUB * Reporting bugs:: Where you should send a bug report * Future:: Some future plans on GRUB @@ -659,7 +661,7 @@ usually also need to include a configuration file @file{grub.cfg} and some other GRUB modules. To make a simple generic GRUB rescue CD, you can use the -@command{grub-mkrescue} program: +@command{grub-mkrescue} program (@pxref{Invoking grub-mkrescue}): @example $ @kbd{grub-mkrescue -o grub.iso} @@ -3609,6 +3611,64 @@ Length of the salt. Defaults to 64. @end table +@node Invoking grub-mkrescue +@chapter Invoking grub-mkrescue + +The program @command{grub-mkrescue} generates a bootable GRUB rescue image +(@pxref{Making a GRUB bootable CD-ROM}). + +@example +grub-mkrescue -o grub.iso +@end example + +All arguments not explicitly listed as @command{grub-mkrescue} options are +passed on directly to @command{xorriso} in @command{mkisofs} emulation mode. +Options passed to @command{xorriso} will normally be interpreted as +@command{mkisofs} options; if the option @samp{--} is used, then anything +after that will be interpreted as native @command{xorriso} options. + +Non-option arguments specify additional source directories. This is +commonly used to add extra files to the image: + +@example +mkdir -p disk/boot/grub +@r{(add extra files to @file{disk/boot/grub})} +grub-mkrescue -o grub.iso disk +@end example + +@command{grub-mkrescue} accepts the following options: + +@table @option +@item --help +Print a summary of the command-line options and exit. + +@item --version +Print the version number of GRUB and exit. + +@item -o @var{file} +@itemx --output=@var{file} +Save output in @var{file}. This "option" is required. + +@item --modules=@var{modules} +Pre-load the named GRUB modules in the image. Multiple entries in +@var{modules} should be separated by whitespace (so you will probably need +to quote this for your shell). + +@item --rom-directory=@var{dir} +If generating images for the QEMU or Coreboot platforms, copy the resulting +@file{qemu.img} or @file{coreboot.elf} files respectively to the @var{dir} +directory as well as including them in the image. + +@item --xorriso=@var{file} +Use @var{file} as the @command{xorriso} program, rather than the built-in +default. + +@item --grub-mkimage=@var{file} +Use @var{file} as the @command{grub-mkimage} program, rather than the +built-in default. +@end table + + @node Obtaining and Building GRUB @appendix How to obtain and build GRUB From fee7cdd4e1bdc0618e01307477e5c115ee76a6dc Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 11 Feb 2011 13:00:54 +0000 Subject: [PATCH 32/34] * util/grub.d/20_linux_xen.in: Bail out early if linux_list is empty, since in that case we can only generate either nothing or a syntactically invalid configuration file. Reported by: Michal Suchanek. Fixes Debian bug #612898. --- ChangeLog | 7 +++++++ util/grub.d/20_linux_xen.in | 3 +++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 56498af1b..6e9ab5758 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-02-11 Colin Watson + + * util/grub.d/20_linux_xen.in: Bail out early if linux_list is + empty, since in that case we can only generate either nothing or a + syntactically invalid configuration file. + Reported by: Michal Suchanek. Fixes Debian bug #612898. + 2011-02-09 Colin Watson * docs/grub.texi (Kernel): Add reference to grub-mkrescue. diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 356219e1d..e71fc1458 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -98,6 +98,9 @@ linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do version=$(echo $basename | sed -e "s,^[^0-9]*-,,g") if grub_file_is_not_garbage "$i" && grep -qx "CONFIG_XEN_DOM0=y" /boot/config-${version} 2> /dev/null ; then echo -n "$i " ; fi done` +if [ "x${linux_list}" = "x" ] ; then + exit 0 +fi xen_list=`for i in /boot/xen*; do if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi done` From d998657dcf8be2a6d4e93f004519e63b66af22cd Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 12 Feb 2011 09:59:04 +0300 Subject: [PATCH 33/34] * grub-core/partmap/msdos.c (pc_partition_map_embed): Fix off by one error. --- ChangeLog | 5 +++++ grub-core/partmap/msdos.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e9ab5758..3a695b25a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-02-12 Vladimir Serbinenko + + * grub-core/partmap/msdos.c (pc_partition_map_embed): Fix off by one + error. + 2011-02-11 Colin Watson * util/grub.d/20_linux_xen.in: Bail out early if linux_list is diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c index d411c4405..31a0a0707 100644 --- a/grub-core/partmap/msdos.c +++ b/grub-core/partmap/msdos.c @@ -232,10 +232,10 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, break; } - if (end >= *nsectors + 1) + if (end >= *nsectors + 2) { unsigned i; - *nsectors = end - 1; + *nsectors = end - 2; *sectors = grub_malloc (*nsectors * sizeof (**sectors)); if (!*sectors) return grub_errno; From 028501a0e06877f14e2445f73a8969bced63c10f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 12 Feb 2011 10:22:55 +0300 Subject: [PATCH 34/34] Workaround yet another IEEE1275 bug. * include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): New enum value GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS. * grub-core/kern/ieee1275/mmap.c (grub_machine_mmap_iterate): Ignore adress_cells and size:cells if GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS is set. * grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS on powermacs. --- ChangeLog | 12 ++++++++++++ grub-core/kern/ieee1275/cmain.c | 3 +++ grub-core/kern/ieee1275/mmap.c | 6 ++++++ include/grub/ieee1275/ieee1275.h | 6 ++++++ 4 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3a695b25a..72d718b08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-02-12 Vladimir Serbinenko + + Workaround yet another IEEE1275 bug. + + * include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): New enum value + GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS. + * grub-core/kern/ieee1275/mmap.c (grub_machine_mmap_iterate): Ignore + adress_cells and size:cells if GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS + is set. + * grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set + GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS on powermacs. + 2011-02-12 Vladimir Serbinenko * grub-core/partmap/msdos.c (pc_partition_map_embed): Fix off by one diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c index 30eacbbdd..2fbe809b2 100644 --- a/grub-core/kern/ieee1275/cmain.c +++ b/grub-core/kern/ieee1275/cmain.c @@ -84,6 +84,9 @@ grub_ieee1275_find_options (void) if (rc >= 0 && !grub_strcmp (tmp, "Emulated PC")) is_qemu = 1; + if (grub_strncmp (tmp, "PowerMac", sizeof ("PowerMac") - 1) == 0) + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS); + if (is_smartfirmware) { /* Broken in all versions */ diff --git a/grub-core/kern/ieee1275/mmap.c b/grub-core/kern/ieee1275/mmap.c index 942e5a354..2e4e085bb 100644 --- a/grub-core/kern/ieee1275/mmap.c +++ b/grub-core/kern/ieee1275/mmap.c @@ -50,6 +50,12 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't examine /memory/available property"); + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS)) + { + address_cells = 1; + size_cells = 1; + } + /* Decode each entry and call `hook'. */ i = 0; available_size /= sizeof (grub_uint32_t); diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 2592dd348..4c56cc20f 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -106,6 +106,12 @@ enum grub_ieee1275_flag /* OLPC / XO firmware has the cursor ON/OFF routines. */ GRUB_IEEE1275_FLAG_HAS_CURSORONOFF, + + /* Some PowerMacs claim to use 2 address cells but in fact use only 1. + Other PowerMacs claim to use only 1 and really do so. Always assume + 1 address cell is used on PowerMacs. + */ + GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);