From 71b6a2b7a2d9d71cff26b39a941b0f7191bcea42 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 6 Jan 2011 11:09:17 +0000 Subject: [PATCH 01/75] * grub-core/kern/emu/getroot.c (find_root_device_from_mountinfo): Fix prefix check to handle the case where dir ends with a slash (most significantly, "/" itself). Reported by: Michael Vogt. --- ChangeLog | 7 +++++++ grub-core/kern/emu/getroot.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0159aab3d..a6d62da6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-06 Colin Watson + + * grub-core/kern/emu/getroot.c (find_root_device_from_mountinfo): + Fix prefix check to handle the case where dir ends with a slash + (most significantly, "/" itself). + Reported by: Michael Vogt. + 2011-01-05 Vladimir Serbinenko Run terminfo_cls on initing terminfo output to clear the screen and diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index 5356685e9..aedef9e0e 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -135,8 +135,12 @@ find_root_device_from_mountinfo (const char *dir) continue; /* only a subtree is mounted */ enc_path_len = strlen (enc_path); + /* Check that enc_path is a prefix of dir. The prefix must either be + the entire string, or end with a slash, or be immediately followed + by a slash. */ if (strncmp (dir, enc_path, enc_path_len) != 0 || - (dir[enc_path_len] && dir[enc_path_len] != '/')) + (enc_path_len && dir[enc_path_len - 1] != '/' && + dir[enc_path_len] && dir[enc_path_len] != '/')) continue; /* This is a parent of the requested directory. /proc/self/mountinfo From 415502c26a4544292046fbb0b580b352cb346f5f Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 6 Jan 2011 13:24:38 +0000 Subject: [PATCH 02/75] * tests/util/grub-shell.in: Set serial terminfo type to `dumb', to avoid causing test failures by clearing the screen. --- ChangeLog | 5 +++++ tests/util/grub-shell.in | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index a6d62da6c..a727bd4ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-06 Colin Watson + + * tests/util/grub-shell.in: Set serial terminfo type to `dumb', to + avoid causing test failures by clearing the screen. + 2011-01-06 Colin Watson * grub-core/kern/emu/getroot.c (find_root_device_from_mountinfo): diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index e35d6bc65..0213376d0 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -119,6 +119,7 @@ cat <${cfgfile} grubshell=yes insmod serial serial +terminfo serial dumb terminal_input serial terminal_output serial EOF From 014b68068d4136812f2e3dc16c986351e6fb2779 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 7 Jan 2011 13:27:34 +0100 Subject: [PATCH 03/75] =?UTF-8?q?=09*=20util/grub-setup.c=20(setup):=20Han?= =?UTF-8?q?dle=20NetBSD=20and=20OpenBSD=20disklabels.=20=09Reported=20and?= =?UTF-8?q?=20tested=20by:=20Gr=C3=A9goire=20Sutre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 5 +++++ util/grub-setup.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index a727bd4ec..d734d86b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-07 Vladimir Serbinenko + + * util/grub-setup.c (setup): Handle NetBSD and OpenBSD disklabels. + Reported and tested by: Grégoire Sutre. + 2011-01-06 Colin Watson * tests/util/grub-shell.in: Set serial terminfo type to `dumb', to diff --git a/util/grub-setup.c b/util/grub-setup.c index 5f9b29f25..b4749b433 100644 --- a/util/grub-setup.c +++ b/util/grub-setup.c @@ -49,6 +49,7 @@ #include #include "progname.h" #include +#include #define _GNU_SOURCE 1 #include @@ -339,6 +340,12 @@ setup (const char *dir, { if (p->parent != container) return 0; + /* NetBSD and OpenBSD subpartitions have metadata inside a partition, + so they are safe to ignore. + */ + if (grub_strcmp (p->partmap->name, "netbsd") == 0 + || grub_strcmp (p->partmap->name, "openbsd") == 0) + return 0; if (dest_partmap == NULL) { dest_partmap = p->partmap; @@ -352,6 +359,15 @@ setup (const char *dir, grub_partition_iterate (dest_dev->disk, identify_partmap); + if (container && grub_strcmp (container->partmap->name, "msdos") == 0 + && dest_partmap + && (container->msdostype == GRUB_PC_PARTITION_TYPE_NETBSD + || container->msdostype == GRUB_PC_PARTITION_TYPE_OPENBSD)) + { + grub_util_warn (_("Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem. This is not supported yet.")); + goto unable_to_embed; + } + fs = grub_fs_probe (dest_dev); if (!fs) grub_errno = GRUB_ERR_NONE; From 0ca09e6c528885b5af9b2f614d62f50f79fc413a Mon Sep 17 00:00:00 2001 From: Doug Nazar Date: Fri, 7 Jan 2011 14:41:44 +0100 Subject: [PATCH 04/75] * grub-core/disk/raid5_recover.c (grub_raid5_recover): Add missing array->members[i].start_sector. * grub-core/disk/raid6_recover.c (grub_raid6_recover): Likewise. --- ChangeLog | 6 ++++++ grub-core/disk/raid5_recover.c | 4 +++- grub-core/disk/raid6_recover.c | 18 +++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d734d86b6..c5cc7afa6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-07 Doug Nazar + + * grub-core/disk/raid5_recover.c (grub_raid5_recover): Add missing + array->members[i].start_sector. + * grub-core/disk/raid6_recover.c (grub_raid6_recover): Likewise. + 2011-01-07 Vladimir Serbinenko * util/grub-setup.c (setup): Handle NetBSD and OpenBSD disklabels. diff --git a/grub-core/disk/raid5_recover.c b/grub-core/disk/raid5_recover.c index 2cda67533..349eb0291 100644 --- a/grub-core/disk/raid5_recover.c +++ b/grub-core/disk/raid5_recover.c @@ -45,7 +45,9 @@ grub_raid5_recover (struct grub_raid_array *array, int disknr, if (i == disknr) continue; - err = grub_disk_read (array->members[i].device, sector, 0, size, buf2); + err = grub_disk_read (array->members[i].device, + array->members[i].start_sector + sector, + 0, size, buf2); if (err) { diff --git a/grub-core/disk/raid6_recover.c b/grub-core/disk/raid6_recover.c index 01daa2c79..dfaa60ea4 100644 --- a/grub-core/disk/raid6_recover.c +++ b/grub-core/disk/raid6_recover.c @@ -119,7 +119,8 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p, else { if ((array->members[pos].device) && - (! grub_disk_read (array->members[pos].device, sector, + (! grub_disk_read (array->members[pos].device, + array->members[i].start_sector + sector, 0, size, buf))) { grub_raid_block_xor (pbuf, buf, size); @@ -150,7 +151,9 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p, { /* One bad device */ if ((array->members[p].device) && - (! grub_disk_read (array->members[p].device, sector, 0, size, buf))) + (! grub_disk_read (array->members[p].device, + array->members[i].start_sector + sector, + 0, size, buf))) { grub_raid_block_xor (buf, pbuf, size); goto quit; @@ -163,7 +166,8 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p, } grub_errno = GRUB_ERR_NONE; - if (grub_disk_read (array->members[q].device, sector, 0, size, buf)) + if (grub_disk_read (array->members[q].device, + array->members[i].start_sector + sector, 0, size, buf)) goto quit; grub_raid_block_xor (buf, qbuf, size); @@ -181,12 +185,16 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p, goto quit; } - if (grub_disk_read (array->members[p].device, sector, 0, size, buf)) + if (grub_disk_read (array->members[p].device, + array->members[i].start_sector + sector, + 0, size, buf)) goto quit; grub_raid_block_xor (pbuf, buf, size); - if (grub_disk_read (array->members[q].device, sector, 0, size, buf)) + if (grub_disk_read (array->members[q].device, + array->members[i].start_sector + sector, + 0, size, buf)) goto quit; grub_raid_block_xor (qbuf, buf, size); From c0cf26da6b7662fd309b509b4238aa3877003f15 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 7 Jan 2011 16:17:24 +0100 Subject: [PATCH 05/75] * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Add missing endian transformations. * grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Likewise. Based on report by: Doug Nazar. --- ChangeLog | 7 +++++++ grub-core/disk/mdraid1x_linux.c | 19 ++++++++++------- grub-core/disk/mdraid_linux.c | 37 +++++++++++++++++++-------------- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index c5cc7afa6..0362abd51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-07 Vladimir Serbinenko + + * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Add missing + endian transformations. + * grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Likewise. + Based on report by: Doug Nazar. + 2011-01-07 Doug Nazar * grub-core/disk/raid5_recover.c (grub_raid5_recover): Add missing diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c index b6a48b848..155210df3 100644 --- a/grub-core/disk/mdraid1x_linux.c +++ b/grub-core/disk/mdraid1x_linux.c @@ -143,24 +143,27 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, &sb)) return grub_errno; - if (sb.magic != SB_MAGIC) + if (grub_le_to_cpu32 (sb.magic) != SB_MAGIC) continue; { grub_uint64_t sb_size; struct grub_raid_super_1x *real_sb; + grub_uint32_t level; - if (sb.major_version != 1) + if (grub_le_to_cpu32 (sb.major_version) != 1) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "Unsupported RAID version: %d", - sb.major_version); + grub_le_to_cpu32 (sb.major_version)); + + level = grub_le_to_cpu32 (sb.level); /* Multipath. */ - if ((int) sb.level == -4) - sb.level = 1; + if ((int) level == -4) + level = 1; - if (sb.level != 0 && sb.level != 1 && sb.level != 4 && - sb.level != 5 && sb.level != 6 && sb.level != 10) + if (level != 0 && level != 1 && level != 4 && + level != 5 && level != 6 && level != 10) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "Unsupported RAID level: %d", sb.level); @@ -209,7 +212,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, grub_memcpy (array->uuid, real_sb->set_uuid, 16); - *start_sector = real_sb->data_offset; + *start_sector = grub_le_to_cpu64 (real_sb->data_offset); grub_free (real_sb); return 0; diff --git a/grub-core/disk/mdraid_linux.c b/grub-core/disk/mdraid_linux.c index dc0d80ffd..7aa48fd7a 100644 --- a/grub-core/disk/mdraid_linux.c +++ b/grub-core/disk/mdraid_linux.c @@ -167,6 +167,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, grub_uint64_t size; struct grub_raid_super_09 sb; grub_uint32_t *uuid; + grub_uint32_t level; /* The sector where the mdraid 0.90 superblock is stored, if available. */ size = grub_disk_get_size (disk); @@ -178,36 +179,40 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, return grub_errno; /* Look whether there is a mdraid 0.90 superblock. */ - if (sb.md_magic != SB_MAGIC) + if (grub_le_to_cpu32 (sb.md_magic) != SB_MAGIC) return grub_error (GRUB_ERR_OUT_OF_RANGE, "not 0.9x raid"); - if (sb.major_version != 0 || sb.minor_version != 90) + if (grub_le_to_cpu32 (sb.major_version) != 0 + || grub_le_to_cpu32 (sb.minor_version) != 90) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "unsupported RAID version: %d.%d", - sb.major_version, sb.minor_version); + grub_le_to_cpu32 (sb.major_version), + grub_le_to_cpu32 (sb.minor_version)); /* FIXME: Check the checksum. */ + level = grub_le_to_cpu32 (sb.level); /* Multipath. */ - if ((int) sb.level == -4) - sb.level = 1; + if ((int) level == -4) + level = 1; - if (sb.level != 0 && sb.level != 1 && sb.level != 4 && - sb.level != 5 && sb.level != 6 && sb.level != 10) + if (level != 0 && level != 1 && level != 4 && + level != 5 && level != 6 && level != 10) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "unsupported RAID level: %d", sb.level); - if (sb.this_disk.number == 0xffff || sb.this_disk.number == 0xfffe) + "unsupported RAID level: %d", level); + if (grub_le_to_cpu32 (sb.this_disk.number) == 0xffff + || grub_le_to_cpu32 (sb.this_disk.number) == 0xfffe) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "spares aren't implemented"); array->name = NULL; - array->number = sb.md_minor; - array->level = sb.level; - array->layout = sb.layout; - array->total_devs = sb.raid_disks; - array->disk_size = (sb.size) ? sb.size * 2 : sector; - array->chunk_size = sb.chunk_size >> 9; - array->index = sb.this_disk.number; + array->number = grub_le_to_cpu32 (sb.md_minor); + array->level = level; + array->layout = grub_le_to_cpu32 (sb.layout); + array->total_devs = grub_le_to_cpu32 (sb.raid_disks); + array->disk_size = (sb.size) ? grub_le_to_cpu32 (sb.size) * 2 : sector; + array->chunk_size = grub_le_to_cpu32 (sb.chunk_size) >> 9; + array->index = grub_le_to_cpu32 (sb.this_disk.number); array->uuid_len = 16; array->uuid = grub_malloc (16); if (!array->uuid) From e72d259fe113e41722904bb25e7a51ba6bc3239c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 7 Jan 2011 17:06:42 +0100 Subject: [PATCH 06/75] * grub-core/fs/xfs.c (grub_xfs_iterate_dir): Take into account that inopos might be unaligned. --- ChangeLog | 5 +++++ grub-core/fs/xfs.c | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0362abd51..ca63b0e85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-07 Vladimir Serbinenko + + * grub-core/fs/xfs.c (grub_xfs_iterate_dir): Take into account that + inopos might be unaligned. + 2011-01-07 Vladimir Serbinenko * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Add missing diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 3d773856e..9f8dc28de 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -451,18 +451,27 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, for (i = 0; i < diro->inode.data.dir.dirhead.count; i++) { grub_uint64_t ino; - void *inopos = (((char *) de) + grub_uint8_t *inopos = (((grub_uint8_t *) de) + sizeof (struct grub_xfs_dir_entry) + de->len - 1); char name[de->len + 1]; + /* inopos might be unaligned. */ if (smallino) - { - ino = grub_be_to_cpu32 (*(grub_uint32_t *) inopos); - ino = grub_cpu_to_be64 (ino); - } + ino = (((grub_uint32_t) inopos[0]) << 24) + | (((grub_uint32_t) inopos[1]) << 16) + | (((grub_uint32_t) inopos[2]) << 8) + | (((grub_uint32_t) inopos[3]) << 0); else - ino = *(grub_uint64_t *) inopos; + ino = (((grub_uint64_t) inopos[0]) << 56) + | (((grub_uint64_t) inopos[1]) << 48) + | (((grub_uint64_t) inopos[2]) << 40) + | (((grub_uint64_t) inopos[3]) << 32) + | (((grub_uint64_t) inopos[4]) << 24) + | (((grub_uint64_t) inopos[5]) << 16) + | (((grub_uint64_t) inopos[6]) << 8) + | (((grub_uint64_t) inopos[7]) << 0); + ino = grub_cpu_to_be64 (ino); grub_memcpy (name, de->name, de->len); name[de->len] = '\0'; From 25953e10553dad2e378541a68686fc094603ec54 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Fri, 7 Jan 2011 17:09:39 +0100 Subject: [PATCH 07/75] Improve loaders' kernel command line handling. * grub-core/lib/cmdline.c: New file. * include/grub/lib/cmdline.h: Likewise. * grub-core/loader/i386/linux.c (grub_cmd_linux): Use grub_create_loader_cmdline to create kernel command line. * grub-core/loader/i386/pc/linux.c (grub_cmd_linux): Likewise. * grub-core/loader/powerpc/ieee1275/linux.c (grub_cmd_linux): Likewise. * grub-core/loader/sparc64/ieee1275/linux.c (grub_cmd_linux): Likewise. * grub-core/Makefile.core.def (linux16): Add lib/cmdline.c on i386_pc. (linux): Add lib/cmdline.c on common. --- ChangeLog | 14 +++ grub-core/Makefile.core.def | 2 + grub-core/lib/cmdline.c | 105 ++++++++++++++++++++++ grub-core/loader/i386/linux.c | 26 ++---- grub-core/loader/i386/pc/linux.c | 25 ++---- grub-core/loader/powerpc/ieee1275/linux.c | 23 ++--- grub-core/loader/sparc64/ieee1275/linux.c | 22 ++--- include/grub/lib/cmdline.h | 31 +++++++ 8 files changed, 184 insertions(+), 64 deletions(-) create mode 100644 grub-core/lib/cmdline.c create mode 100644 include/grub/lib/cmdline.h diff --git a/ChangeLog b/ChangeLog index ca63b0e85..d1ddc8741 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-01-07 Szymon Janc + + Improve loaders' kernel command line handling. + + * grub-core/lib/cmdline.c: New file. + * include/grub/lib/cmdline.h: Likewise. + * grub-core/loader/i386/linux.c (grub_cmd_linux): Use + grub_create_loader_cmdline to create kernel command line. + * grub-core/loader/i386/pc/linux.c (grub_cmd_linux): Likewise. + * grub-core/loader/powerpc/ieee1275/linux.c (grub_cmd_linux): Likewise. + * grub-core/loader/sparc64/ieee1275/linux.c (grub_cmd_linux): Likewise. + * grub-core/Makefile.core.def (linux16): Add lib/cmdline.c on i386_pc. + (linux): Add lib/cmdline.c on common. + 2011-01-07 Vladimir Serbinenko * grub-core/fs/xfs.c (grub_xfs_iterate_dir): Take into account that diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 37c0ce970..094bbc835 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1149,6 +1149,7 @@ module = { module = { name = linux16; i386_pc = loader/i386/pc/linux.c; + i386_pc = lib/cmdline.c; enable = i386_pc; }; @@ -1183,6 +1184,7 @@ module = { mips = loader/mips/linux.c; powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c; sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c; + common = lib/cmdline.c; enable = noemu; }; diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c new file mode 100644 index 000000000..a702e6487 --- /dev/null +++ b/grub-core/lib/cmdline.c @@ -0,0 +1,105 @@ +/* cmdline.c - linux command line handling */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include + +static unsigned int check_arg (char *c, int *has_space) +{ + int space = 0; + unsigned int size = 0; + + while (*c) + { + if (*c == '\\' || *c == '\'' || *c == '"') + size++; + else if (*c == ' ') + space = 1; + + size++; + c++; + } + + if (space) + size += 2; + + if (has_space) + *has_space = space; + + return size; +} + +unsigned int grub_loader_cmdline_size (int argc, char *argv[]) +{ + int i; + unsigned int size = 0; + + for (i = 0; i < argc; i++) + { + size += check_arg (argv[i], 0); + size++; /* Separator space or NULL. */ + } + + return size; +} + +int grub_create_loader_cmdline (int argc, char *argv[], char *buf, + grub_size_t size) +{ + int i, space; + unsigned int arg_size; + char *c; + + for (i = 0; i < argc; i++) + { + c = argv[i]; + arg_size = check_arg(argv[i], &space); + arg_size++; /* Separator space or NULL. */ + + if (size < arg_size) + break; + + size -= arg_size; + + if (space) + *buf++ = '"'; + + while (*c) + { + if (*c == '\\' || *c == '\'' || *c == '"') + *buf++ = '\\'; + + *buf++ = *c; + c++; + } + + if (space) + *buf++ = '"'; + + *buf++ = ' '; + } + + /* Replace last space with null. */ + if (i) + buf--; + + *buf = 0; + + return i; +} diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index ca88c7403..80f583cef 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef GRUB_MACHINE_PCBIOS #include @@ -575,7 +576,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_size_t real_size, prot_size; grub_ssize_t len; int i; - char *dest; grub_dl_ref (my_mod); @@ -836,22 +836,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), params->loadflags |= GRUB_LINUX_FLAG_QUIET; } - - /* Specify the boot file. */ - dest = grub_stpcpy ((char *) real_mode_mem + GRUB_LINUX_CL_OFFSET, - "BOOT_IMAGE="); - dest = grub_stpcpy (dest, argv[0]); - - /* Copy kernel parameters. */ - for (i = 1; - i < argc - && dest + grub_strlen (argv[i]) + 1 < ((char *) real_mode_mem - + GRUB_LINUX_CL_END_OFFSET); - i++) - { - *dest++ = ' '; - dest = grub_stpcpy (dest, argv[i]); - } + /* Create kernel command line. */ + grub_memcpy ((char *)real_mode_mem + GRUB_LINUX_CL_OFFSET, LINUX_IMAGE, + sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, + (char *)real_mode_mem + GRUB_LINUX_CL_OFFSET + + sizeof (LINUX_IMAGE) - 1, + GRUB_LINUX_CL_END_OFFSET - GRUB_LINUX_CL_OFFSET + - (sizeof (LINUX_IMAGE) - 1)); len = prot_size; if (grub_file_read (file, prot_mode_mem, len) != len) diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index 90de70f66..96d00f927 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -34,6 +34,7 @@ #include #include #include +#include #define GRUB_LINUX_CL_OFFSET 0x9000 #define GRUB_LINUX_CL_END_OFFSET 0x90FF @@ -86,7 +87,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_size_t real_size; grub_ssize_t len; int i; - char *dest; char *grub_linux_prot_chunk; int grub_linux_is_bzimage; grub_addr_t grub_linux_prot_target; @@ -286,21 +286,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), ((GRUB_LINUX_MAX_SETUP_SECTS - setup_sects - 1) << GRUB_DISK_SECTOR_BITS)); - /* Specify the boot file. */ - dest = grub_stpcpy (grub_linux_real_chunk + GRUB_LINUX_CL_OFFSET, - "BOOT_IMAGE="); - dest = grub_stpcpy (dest, argv[0]); - - /* Copy kernel parameters. */ - for (i = 1; - i < argc - && dest + grub_strlen (argv[i]) + 1 < (grub_linux_real_chunk - + GRUB_LINUX_CL_END_OFFSET); - i++) - { - *dest++ = ' '; - dest = grub_stpcpy (dest, argv[i]); - } + /* Create kernel command line. */ + grub_memcpy ((char *)grub_linux_real_chunk + GRUB_LINUX_CL_OFFSET, + LINUX_IMAGE, sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, + (char *)grub_linux_real_chunk + + GRUB_LINUX_CL_OFFSET + sizeof (LINUX_IMAGE) - 1, + GRUB_LINUX_CL_END_OFFSET - GRUB_LINUX_CL_OFFSET + - (sizeof (LINUX_IMAGE) - 1)); if (grub_linux_is_bzimage) grub_linux_prot_target = GRUB_LINUX_BZIMAGE_ADDR; diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c index 231aec1d3..a99310cfd 100644 --- a/grub-core/loader/powerpc/ieee1275/linux.c +++ b/grub-core/loader/powerpc/ieee1275/linux.c @@ -27,6 +27,7 @@ #include #include #include +#include #define ELF32_LOADMASK (0xc0000000UL) #define ELF64_LOADMASK (0xc000000000000000ULL) @@ -238,9 +239,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_elf_t elf = 0; - int i; int size; - char *dest; grub_dl_ref (my_mod); @@ -275,23 +274,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto out; } - size = sizeof ("BOOT_IMAGE=") + grub_strlen (argv[0]); - for (i = 0; i < argc; i++) - size += grub_strlen (argv[i]) + 1; - - linux_args = grub_malloc (size); + size = grub_loader_cmdline_size(argc, argv); + linux_args = grub_malloc (size + sizeof (LINUX_IMAGE)); if (! linux_args) goto out; - /* Specify the boot file. */ - dest = grub_stpcpy (linux_args, "BOOT_IMAGE="); - dest = grub_stpcpy (dest, argv[0]); - - for (i = 1; i < argc; i++) - { - *dest++ = ' '; - dest = grub_stpcpy (dest, argv[i]); - } + /* Create kernel command line. */ + grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1, + size); out: diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index 8ea96f1c9..a262049a7 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -27,6 +27,7 @@ #include #include #include +#include static grub_dl_t my_mod; @@ -295,9 +296,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), { grub_file_t file = 0; grub_elf_t elf = 0; - int i; int size; - char *dest; grub_dl_ref (my_mod); @@ -333,23 +332,16 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto out; } - size = sizeof ("BOOT_IMAGE=") + grub_strlen (argv[0]); - for (i = 0; i < argc; i++) - size += grub_strlen (argv[i]) + 1; + size = grub_loader_cmdline_size(argc, argv); - linux_args = grub_malloc (size); + linux_args = grub_malloc (size + sizeof (LINUX_IMAGE)); if (! linux_args) goto out; - /* Specify the boot file. */ - dest = grub_stpcpy (linux_args, "BOOT_IMAGE="); - dest = grub_stpcpy (dest, argv[0]); - - for (i = 1; i < argc; i++) - { - *dest++ = ' '; - dest = grub_stpcpy (dest, argv[i]); - } + /* Create kernel command line. */ + grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1, + size); out: if (elf) diff --git a/include/grub/lib/cmdline.h b/include/grub/lib/cmdline.h new file mode 100644 index 000000000..1fe8d0179 --- /dev/null +++ b/include/grub/lib/cmdline.h @@ -0,0 +1,31 @@ +/* cmdline.h - linux command line handling */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_CMDLINE_HEADER +#define GRUB_CMDLINE_HEADER 1 + +#include + +#define LINUX_IMAGE "BOOT_IMAGE=" + +unsigned int grub_loader_cmdline_size (int argc, char *argv[]); +int grub_create_loader_cmdline (int argc, char *argv[], char *buf, + grub_size_t size); + +#endif /* ! GRUB_CMDLINE_HEADER */ From 64d1f0412bbbfafb0bef788ad6fe13b28329e65d Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Fri, 7 Jan 2011 22:42:02 +0100 Subject: [PATCH 08/75] * docs/grub.texi (Support automatic decompression): Update with xz decompression support. --- ChangeLog | 5 +++++ docs/grub.texi | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1ddc8741..d65e97e09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-07 Szymon Janc + + * docs/grub.texi (Support automatic decompression): Update with xz + decompression support. + 2011-01-07 Szymon Janc Improve loaders' kernel command line handling. diff --git a/docs/grub.texi b/docs/grub.texi index 54a2d8791..daf48da13 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -346,9 +346,11 @@ ext2/ext3/ext4}, @dfn{DOS FAT12/FAT16/FAT32}, @dfn{HFS}, @dfn{HFS+}, @dfn{BSD UFS/UFS2}, and @dfn{XFS}. @xref{Filesystem}, for more information. @item Support automatic decompression -Can decompress files which were compressed by @command{gzip}. This -function is both automatic and transparent to the user (i.e. all -functions operate upon the uncompressed contents of the specified +Can decompress files which were compressed by @command{gzip} or +@command{xz}@footnote{Only CRC32 data integrity check is supported (xz default +is CRC64 so one should use --check=crc32 option). LZMA BCJ filters are +supported.}. This function is both automatic and transparent to the user +(i.e. all functions operate upon the uncompressed contents of the specified files). This greatly reduces a file size and loading time, a particularly great benefit for floppies.@footnote{There are a few pathological cases where loading a very badly organized ELF kernel might From 43f1bc8369211247259581d458a0f3aaa9782bbb Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 00:27:38 +0100 Subject: [PATCH 09/75] * grub-core/loader/i386/bsdXX.c (grub_netbsd_load_elf_meta): Silence spurious warning. Reported and tested by: Alain Greppin. --- ChangeLog | 6 ++++++ grub-core/loader/i386/bsdXX.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d65e97e09..52f59019b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-08 Vladimir Serbinenko + + * grub-core/loader/i386/bsdXX.c (grub_netbsd_load_elf_meta): + Silence spurious warning. + Reported and tested by: Alain Greppin. + 2011-01-07 Szymon Janc * docs/grub.texi (Support automatic decompression): Update with xz diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 2dd180509..5b9e7689e 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -394,7 +394,7 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, grub_err_t err; Elf_Ehdr e; Elf_Shdr *s, *symsh, *strsh; - char *shdr; + char *shdr = NULL; unsigned symsize, strsize; void *sym_chunk; grub_uint8_t *curload; From 0fd48e357f73864f7a334be23153e973f2f76f2a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 00:34:23 +0100 Subject: [PATCH 10/75] Satisfy some bison versions need for inttypes.h. * grub-core/lib/posix_wrap/inttypes.h: New file. * grub-core/lib/posix_wrap/sys/types.h (int8_t): New type. (int16_t): Likewise. (int32_t): Likewise. (int64_t): Likewise. Reported and tested by: Alain Greppin. --- ChangeLog | 11 +++++++++++ grub-core/lib/posix_wrap/inttypes.h | 1 + grub-core/lib/posix_wrap/sys/types.h | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 grub-core/lib/posix_wrap/inttypes.h diff --git a/ChangeLog b/ChangeLog index 52f59019b..1a297da01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-01-08 Vladimir Serbinenko + + Satisfy some bison versions need for inttypes.h. + + * grub-core/lib/posix_wrap/inttypes.h: New file. + * grub-core/lib/posix_wrap/sys/types.h (int8_t): New type. + (int16_t): Likewise. + (int32_t): Likewise. + (int64_t): Likewise. + Reported and tested by: Alain Greppin. + 2011-01-08 Vladimir Serbinenko * grub-core/loader/i386/bsdXX.c (grub_netbsd_load_elf_meta): diff --git a/grub-core/lib/posix_wrap/inttypes.h b/grub-core/lib/posix_wrap/inttypes.h new file mode 100644 index 000000000..a12c43b15 --- /dev/null +++ b/grub-core/lib/posix_wrap/inttypes.h @@ -0,0 +1 @@ +#include diff --git a/grub-core/lib/posix_wrap/sys/types.h b/grub-core/lib/posix_wrap/sys/types.h index 4e8331fdd..69e49509e 100644 --- a/grub-core/lib/posix_wrap/sys/types.h +++ b/grub-core/lib/posix_wrap/sys/types.h @@ -32,6 +32,11 @@ typedef grub_uint16_t uint16_t; typedef grub_uint32_t uint32_t; typedef grub_uint64_t uint64_t; +typedef grub_int8_t int8_t; +typedef grub_int16_t int16_t; +typedef grub_int32_t int32_t; +typedef grub_int64_t int64_t; + #ifdef GRUB_CPU_WORDS_BIGENDIAN #define WORDS_BIGENDIAN #else From 9462775a2df7842cf4a4c21f19e5dd1d92ef5183 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 00:39:12 +0100 Subject: [PATCH 11/75] * grub-core/Makefile.am (rs_decoder.S): Force compilation with -Os. Reported and tested by: Alain Greppin. --- ChangeLog | 5 +++++ grub-core/Makefile.am | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1a297da01..984c3fc5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-08 Vladimir Serbinenko + + * grub-core/Makefile.am (rs_decoder.S): Force compilation with -Os. + Reported and tested by: Alain Greppin. + 2011-01-08 Vladimir Serbinenko Satisfy some bison versions need for inttypes.h. diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 073ce37f6..fcf3fc42d 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -50,7 +50,7 @@ grub_script.yy.h: script/yylex.l grub_script.yy.c: grub_script.yy.h rs_decoder.S: $(srcdir)/lib/reed_solomon.c - $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(top_builddir) -S -DSTANDALONE -o $@ $< -g0 -mregparm=3 + $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Os -I$(top_builddir) -S -DSTANDALONE -o $@ $< -g0 -mregparm=3 kern/i386/pc/startup.S: $(builddir)/rs_decoder.S From ec1dfd634e3c2f09d9e293239529c5ea784ac102 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 00:44:38 +0100 Subject: [PATCH 12/75] * configure.ac: Do CPU substitution even if it's specified explicitly. Reported and tested by: Alain Greppin. --- ChangeLog | 5 +++++ configure.ac | 15 ++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 984c3fc5a..5116604f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-08 Vladimir Serbinenko + + * configure.ac: Do CPU substitution even if it's specified explicitly. + Reported and tested by: Alain Greppin. + 2011-01-08 Vladimir Serbinenko * grub-core/Makefile.am (rs_decoder.S): Force compilation with -Os. diff --git a/configure.ac b/configure.ac index c013c9022..8bb585a78 100644 --- a/configure.ac +++ b/configure.ac @@ -103,15 +103,12 @@ else platform="$with_platform" fi -# Adjust CPU unless target was explicitly specified. -if test -z "$target_alias"; then - case "$target_cpu"-"$platform" in - x86_64-efi) ;; - x86_64-emu) ;; - x86_64-*) target_cpu=i386 ;; - powerpc64-ieee1275) target_cpu=powerpc ;; - esac -fi +case "$target_cpu"-"$platform" in + x86_64-efi) ;; + x86_64-emu) ;; + x86_64-*) target_cpu=i386 ;; + powerpc64-ieee1275) target_cpu=powerpc ;; +esac # Check if the platform is supported, make final adjustments. case "$target_cpu"-"$platform" in From f9f376488bc602b6c8f370c6697e0765747ac1c6 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 01:45:57 +0100 Subject: [PATCH 13/75] =?UTF-8?q?=09*=20grub-core/term/at=5Fkeyboard.c=20(?= =?UTF-8?q?grub=5Fkeyboard=5Fgetkey):=20Silence=20spurious=20=09warning.?= =?UTF-8?q?=20=09Reported=20and=20tested=20by:=20Gr=C3=A9goire=20Sutre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 6 ++++++ grub-core/term/at_keyboard.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5116604f5..4c2fd2a62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-08 Vladimir Serbinenko + + * grub-core/term/at_keyboard.c (grub_keyboard_getkey): Silence spurious + warning. + Reported and tested by: Grégoire Sutre. + 2011-01-08 Vladimir Serbinenko * configure.ac: Do CPU substitution even if it's specified explicitly. diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c index 5bc3f578c..55cb76483 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -494,7 +494,7 @@ static int grub_keyboard_getkey (void) { int key; - int is_break; + int is_break = 0; key = fetch_key (&is_break); if (key == -1) From fc836af9a520da52a84c74b99d06de8a3fd117b6 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 01:50:06 +0100 Subject: [PATCH 14/75] =?UTF-8?q?=09*=20grub-core/commands/terminal.c=20(g?= =?UTF-8?q?rub=5Fcmd=5Fterminal=5Finput):=20Silence=20=09aliasing=20warnin?= =?UTF-8?q?g.=20=09(grub=5Fcmd=5Fterminal=5Foutput):=20Likewise.=20=09Repo?= =?UTF-8?q?rted=20and=20tested=20by:=20Gr=C3=A9goire=20Sutre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 7 +++++++ grub-core/commands/terminal.c | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c2fd2a62..7545cbef9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-08 Vladimir Serbinenko + + * grub-core/commands/terminal.c (grub_cmd_terminal_input): Silence + aliasing warning. + (grub_cmd_terminal_output): Likewise. + Reported and tested by: Grégoire Sutre. + 2011-01-08 Vladimir Serbinenko * grub-core/term/at_keyboard.c (grub_keyboard_getkey): Silence spurious diff --git a/grub-core/commands/terminal.c b/grub-core/commands/terminal.c index c8b1b6315..c2d9550f6 100644 --- a/grub-core/commands/terminal.c +++ b/grub-core/commands/terminal.c @@ -210,11 +210,11 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)), (void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, init); (void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, fini); return handle_command (argc, args, - (struct abstract_terminal **) &grub_term_inputs, - (struct abstract_terminal **) &grub_term_inputs_disabled, - grub_term_input_autoload, - N_ ("Active input terminals:"), - N_ ("Available input terminals:")); + (struct abstract_terminal **) (void *) &grub_term_inputs, + (struct abstract_terminal **) (void *) &grub_term_inputs_disabled, + grub_term_input_autoload, + N_ ("Active input terminals:"), + N_ ("Available input terminals:")); } static grub_err_t @@ -225,11 +225,12 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)), (void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, name); (void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, init); (void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, fini); - return handle_command (argc, args, (struct abstract_terminal **) &grub_term_outputs, - (struct abstract_terminal **) &grub_term_outputs_disabled, - grub_term_output_autoload, - N_ ("Active output terminals:"), - N_ ("Available output terminals:")); + return handle_command (argc, args, + (struct abstract_terminal **) (void *) &grub_term_outputs, + (struct abstract_terminal **) (void *) &grub_term_outputs_disabled, + grub_term_output_autoload, + N_ ("Active output terminals:"), + N_ ("Available output terminals:")); } static grub_command_t cmd_terminal_input, cmd_terminal_output; From e7121b69329ce5bff182ab85ccaf2f888a07a7b9 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 01:56:09 +0100 Subject: [PATCH 15/75] * grub-core/fs/zfs/zfs.c (dmu_read): Use void * for some pointers to avoid aliasing. (fzap_lookup): Likewise. (dnode_get): Likewise. (make_mdn): Likewise. (zfs_mount): Likewise. (fzap_iterate): Use temporary pointer to avoid aliasing. (grub_zfs_read): Likewise. * grub-core/loader/i386/xnu.c (grub_xnu_boot): Likewise. * grub-core/loader/xnu.c (grub_cmd_xnu_kernel): Use void * for some pointers to avoid aliasing. (grub_cmd_xnu_kernel64): Likewise. (grub_xnu_load_driver): Likewise. --- ChangeLog | 16 ++++++++++++++ grub-core/fs/zfs/zfs.c | 43 +++++++++++++++++++++---------------- grub-core/loader/i386/xnu.c | 10 +++++---- grub-core/loader/xnu.c | 27 +++++++++++++---------- 4 files changed, 63 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7545cbef9..0f132cb01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2011-01-08 Vladimir Serbinenko + + * grub-core/fs/zfs/zfs.c (dmu_read): Use void * for some pointers to + avoid aliasing. + (fzap_lookup): Likewise. + (dnode_get): Likewise. + (make_mdn): Likewise. + (zfs_mount): Likewise. + (fzap_iterate): Use temporary pointer to avoid aliasing. + (grub_zfs_read): Likewise. + * grub-core/loader/i386/xnu.c (grub_xnu_boot): Likewise. + * grub-core/loader/xnu.c (grub_cmd_xnu_kernel): Use void * for some + pointers to avoid aliasing. + (grub_cmd_xnu_kernel64): Likewise. + (grub_xnu_load_driver): Likewise. + 2011-01-08 Vladimir Serbinenko * grub-core/commands/terminal.c (grub_cmd_terminal_input): Silence diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 8901af76f..5b575f369 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -603,7 +603,8 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, int idx, level; blkptr_t *bp_array = dn->dn.dn_blkptr; int epbs = dn->dn.dn_indblkshift - SPA_BLKPTRSHIFT; - blkptr_t *bp, *tmpbuf = 0; + blkptr_t *bp; + void *tmpbuf = 0; grub_zfs_endian_t endian; grub_err_t err = GRUB_ERR_NONE; @@ -646,7 +647,7 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, break; } grub_dprintf ("zfs", "endian = %d\n", endian); - err = zio_read (bp, endian, (void **) &tmpbuf, 0, data); + err = zio_read (bp, endian, &tmpbuf, 0, data); endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1; if (err) break; @@ -880,7 +881,7 @@ static grub_err_t fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap, char *name, grub_uint64_t * value, struct grub_zfs_data *data) { - zap_leaf_phys_t *l; + void *l; grub_uint64_t hash, idx, blkid; int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, zap_dnode->endian) << DNODE_SHIFT); @@ -903,7 +904,7 @@ fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap, /* Get the leaf block */ if ((1U << blksft) < sizeof (zap_leaf_phys_t)) return grub_error (GRUB_ERR_BAD_FS, "ZAP leaf is too small"); - err = dmu_read (zap_dnode, blkid, (void **) &l, &leafendian, data); + err = dmu_read (zap_dnode, blkid, &l, &leafendian, data); if (err) return err; @@ -920,6 +921,7 @@ fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap, struct grub_zfs_data *data) { zap_leaf_phys_t *l; + void *l_in; grub_uint64_t idx, blkid; grub_uint16_t chunk; int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, @@ -947,7 +949,8 @@ fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap, { blkid = ((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))]; - err = dmu_read (zap_dnode, blkid, (void **) &l, &endian, data); + err = dmu_read (zap_dnode, blkid, &l_in, &endian, data); + l = l_in; if (err) { grub_errno = GRUB_ERR_NONE; @@ -1108,7 +1111,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type, grub_uint64_t blkid, blksz; /* the block id this object dnode is in */ int epbs; /* shift of number of dnodes in a block */ int idx; /* index within a block */ - dnode_phys_t *dnbuf; + void *dnbuf; grub_err_t err; grub_zfs_endian_t endian; @@ -1131,7 +1134,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type, grub_dprintf ("zfs", "endian = %d, blkid=%llx\n", mdn->endian, (unsigned long long) blkid); - err = dmu_read (mdn, blkid, (void **) &dnbuf, &endian, data); + err = dmu_read (mdn, blkid, &dnbuf, &endian, data); if (err) return err; grub_dprintf ("zfs", "alive\n"); @@ -1153,7 +1156,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type, data->dnode_endian = endian; } - grub_memmove (&(buf->dn), &dnbuf[idx], DNODE_SIZE); + grub_memmove (&(buf->dn), (dnode_phys_t *) dnbuf + idx, DNODE_SIZE); buf->endian = endian; if (type && buf->dn.dn_type != type) return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type"); @@ -1465,7 +1468,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname, static grub_err_t make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data) { - objset_phys_t *osp; + void *osp; blkptr_t *bp; grub_size_t ospsize; grub_err_t err; @@ -1473,7 +1476,7 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data) grub_dprintf ("zfs", "endian = %d\n", mdn->endian); bp = &(((dsl_dataset_phys_t *) DN_BONUS (&mdn->dn))->ds_bp); - err = zio_read (bp, mdn->endian, (void **) &osp, &ospsize, data); + err = zio_read (bp, mdn->endian, &osp, &ospsize, data); if (err) return err; if (ospsize < OBJSET_PHYS_SIZE_V14) @@ -1483,7 +1486,8 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data) } mdn->endian = (grub_zfs_to_cpu64 (bp->blk_prop, mdn->endian)>>63) & 1; - grub_memmove ((char *) &(mdn->dn), (char *) &osp->os_meta_dnode, DNODE_SIZE); + grub_memmove ((char *) &(mdn->dn), + (char *) &((objset_phys_t *) osp)->os_meta_dnode, DNODE_SIZE); grub_free (osp); return GRUB_ERR_NONE; } @@ -1960,7 +1964,7 @@ zfs_mount (grub_device_t dev) int label = 0; uberblock_phys_t *ub_array, *ubbest = NULL; vdev_boot_header_t *bh; - objset_phys_t *osp = 0; + void *osp = 0; grub_size_t ospsize; grub_err_t err; int vdevnum; @@ -2038,7 +2042,7 @@ zfs_mount (grub_device_t dev) ? LITTLE_ENDIAN : BIG_ENDIAN); err = zio_read (&ubbest->ubp_uberblock.ub_rootbp, ub_endian, - (void **) &osp, &ospsize, data); + &osp, &ospsize, data); if (err) { grub_dprintf ("zfs", "couldn't zio_read\n"); @@ -2067,7 +2071,8 @@ zfs_mount (grub_device_t dev) continue; #endif /* Got the MOS. Save it at the memory addr MOS. */ - grub_memmove (&(data->mos.dn), &osp->os_meta_dnode, DNODE_SIZE); + grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode, + DNODE_SIZE); data->mos.endian = (grub_zfs_to_cpu64 (ubbest->ubp_uberblock.ub_rootbp.blk_prop, ub_endian) >> 63) & 1; grub_memmove (&(data->current_uberblock), &ubbest->ubp_uberblock, sizeof (uberblock_t)); @@ -2201,7 +2206,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename) */ if (data->dnode.dn.dn_bonustype == DMU_OT_SA) { - sa_hdr_phys_t *sahdrp; + void *sahdrp; int hdrsize; if (data->dnode.dn.dn_bonuslen != 0) @@ -2212,7 +2217,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename) { blkptr_t *bp = &data->dnode.dn.dn_spill; - err = zio_read (bp, data->dnode.endian, (void **) &sahdrp, NULL, data); + err = zio_read (bp, data->dnode.endian, &sahdrp, NULL, data); if (err) return err; } @@ -2221,7 +2226,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename) return grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt"); } - hdrsize = SA_HDR_SIZE (sahdrp); + hdrsize = SA_HDR_SIZE (((sa_hdr_phys_t *) sahdrp)); file->size = *(grub_uint64_t *) ((char *) sahdrp + hdrsize + SA_SIZE_OFFSET); } else @@ -2280,6 +2285,7 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len) read = 0; while (length) { + void *t; /* * Find requested blkid and the offset within that block. */ @@ -2287,8 +2293,9 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len) grub_free (data->file_buf); data->file_buf = 0; - err = dmu_read (&(data->dnode), blkid, (void **) &(data->file_buf), + err = dmu_read (&(data->dnode), blkid, &t, 0, data); + data->file_buf = t; if (err) return -1; diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index a9435eff3..a0df6f4aa 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -951,10 +951,11 @@ grub_err_t grub_xnu_boot (void) { struct grub_xnu_boot_params *bootparams; + void *bp_in; grub_addr_t bootparams_target; grub_err_t err; grub_efi_uintn_t memory_map_size = 0; - grub_efi_memory_descriptor_t *memory_map; + void *memory_map; grub_addr_t memory_map_target; grub_efi_uintn_t map_key = 0; grub_efi_uintn_t descriptor_size = 0; @@ -1006,9 +1007,10 @@ grub_xnu_boot (void) /* Relocate the boot parameters to heap. */ err = grub_xnu_heap_malloc (sizeof (*bootparams), - (void **) &bootparams, &bootparams_target); + &bp_in, &bootparams_target); if (err) return err; + bootparams = bp_in; /* Set video. */ err = grub_xnu_set_video (bootparams); @@ -1035,7 +1037,7 @@ grub_xnu_boot (void) memory map growth. */ memory_map_size += 20 * descriptor_size; err = grub_xnu_heap_malloc (memory_map_size, - (void **) &memory_map, &memory_map_target); + &memory_map, &memory_map_target); if (err) return err; @@ -1109,7 +1111,7 @@ grub_xnu_boot (void) grub_xnu_arg1 = bootparams_target; grub_autoefi_set_virtual_address_map (memory_map_size, descriptor_size, - descriptor_version,memory_map); + descriptor_version, memory_map); state.eip = grub_xnu_entry_point; state.eax = grub_xnu_arg1; diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index 95857951a..5a84dea1c 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -342,7 +342,8 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), grub_macho_t macho; grub_uint32_t startcode, endcode; int i; - char *ptr, *loadaddr; + char *ptr; + void *loadaddr; grub_addr_t loadaddr_target; if (argc < 1) @@ -375,7 +376,7 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), if (!grub_xnu_relocator) return grub_errno; grub_xnu_heap_target_start = startcode; - err = grub_xnu_heap_malloc (endcode - startcode, (void **) &loadaddr, + err = grub_xnu_heap_malloc (endcode - startcode, &loadaddr, &loadaddr_target); if (err) @@ -386,7 +387,8 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), } /* Load kernel. */ - err = grub_macho_load32 (macho, loadaddr - startcode, GRUB_MACHO_NOBSS); + err = grub_macho_load32 (macho, (char *) loadaddr - startcode, + GRUB_MACHO_NOBSS); if (err) { grub_macho_close (macho); @@ -450,7 +452,8 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), grub_macho_t macho; grub_uint64_t startcode, endcode; int i; - char *ptr, *loadaddr; + char *ptr; + void *loadaddr; grub_addr_t loadaddr_target; if (argc < 1) @@ -486,7 +489,7 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), if (!grub_xnu_relocator) return grub_errno; grub_xnu_heap_target_start = startcode; - err = grub_xnu_heap_malloc (endcode - startcode, (void **) &loadaddr, + err = grub_xnu_heap_malloc (endcode - startcode, &loadaddr, &loadaddr_target); if (err) @@ -497,7 +500,8 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), } /* Load kernel. */ - err = grub_macho_load64 (macho, loadaddr - startcode, GRUB_MACHO_NOBSS); + err = grub_macho_load64 (macho, (char *) loadaddr - startcode, + GRUB_MACHO_NOBSS); if (err) { grub_macho_close (macho); @@ -636,7 +640,8 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) grub_file_t infoplist; struct grub_xnu_extheader *exthead; int neededspace = sizeof (*exthead); - grub_uint8_t *buf, *buf0; + grub_uint8_t *buf; + void *buf0; grub_addr_t buf_target; grub_size_t infoplistsize = 0, machosize = 0; char *name, *nameend; @@ -692,7 +697,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE); if (err) return err; - err = grub_xnu_heap_malloc (neededspace, (void **) &buf0, &buf_target); + err = grub_xnu_heap_malloc (neededspace, &buf0, &buf_target); if (err) return err; buf = buf0; @@ -704,7 +709,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) /* Load the binary. */ if (macho) { - exthead->binaryaddr = buf_target + (buf - buf0); + exthead->binaryaddr = buf_target + (buf - (grub_uint8_t *) buf0); exthead->binarysize = machosize; if (grub_xnu_is_64bit) err = grub_macho_readfile64 (macho, buf); @@ -723,7 +728,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) /* Load the plist. */ if (infoplist) { - exthead->infoplistaddr = buf_target + (buf - buf0); + exthead->infoplistaddr = buf_target + (buf - (grub_uint8_t *) buf0); exthead->infoplistsize = infoplistsize + 1; if (grub_file_read (infoplist, buf, infoplistsize) != (grub_ssize_t) (infoplistsize)) @@ -739,7 +744,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) } grub_errno = GRUB_ERR_NONE; - exthead->nameaddr = (buf - buf0) + buf_target; + exthead->nameaddr = (buf - (grub_uint8_t *) buf0) + buf_target; exthead->namesize = namelen + 1; grub_memcpy (buf, name, namelen); buf[namelen] = 0; From 53798c4bd1ae9c635740f72207c9db5509505f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Sutre?= Date: Sat, 8 Jan 2011 17:01:38 +0100 Subject: [PATCH 16/75] Check for libdevmapper header --- ChangeLog | 4 ++++ configure.ac | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0f132cb01..8a832d41d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-08 Grégoire Sutre + + * configure.ac: Check for libdevmapper header. + 2011-01-08 Vladimir Serbinenko * grub-core/fs/zfs/zfs.c (dmu_read): Use void * for some pointers to diff --git a/configure.ac b/configure.ac index 8bb585a78..a9ca130b4 100644 --- a/configure.ac +++ b/configure.ac @@ -863,6 +863,12 @@ if test x"$enable_device_mapper" = xno ; then device_mapper_excuse="explicitly disabled" fi +if test x"$device_mapper_excuse" = x ; then + # Check for device-mapper header. + AC_CHECK_HEADER([libdevmapper.h], [], + [device_mapper_excuse="need libdevmapper header"]) +fi + if test x"$device_mapper_excuse" = x ; then # Check for device-mapper library. AC_CHECK_LIB([devmapper], [dm_task_create], [], From c88172fa92efe15950247491db154c01a58df074 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 20:22:32 +0100 Subject: [PATCH 17/75] * config.h.in (_LARGEFILE_SOURCE): Add missing define. (_FILE_OFFSET_BITS): Likewise. Reported by: Seth Goldberg. --- ChangeLog | 6 ++++++ config.h.in | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8a832d41d..30dd4798f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-08 Vladimir Serbinenko + + * config.h.in (_LARGEFILE_SOURCE): Add missing define. + (_FILE_OFFSET_BITS): Likewise. + Reported by: Seth Goldberg. + 2011-01-08 Grégoire Sutre * configure.ac: Check for libdevmapper header. diff --git a/config.h.in b/config.h.in index 6d7d95dec..3974ad7d5 100644 --- a/config.h.in +++ b/config.h.in @@ -1,3 +1,7 @@ +#undef _LARGEFILE_SOURCE +#undef _FILE_OFFSET_BITS +#define _LARGEFILE_SOURCE +#define _FILE_OFFSET_BITS 64 #if defined (GRUB_UTIL) || !defined (GRUB_MACHINE) #include #define NESTED_FUNC_ATTR From a21e5672fd8edd1f7ab17204396fb436dba0c2ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Sutre?= Date: Sun, 9 Jan 2011 23:23:25 +0100 Subject: [PATCH 18/75] Handle openbsd and netbsd types being in part_bsd module. --- ChangeLog | 5 +++++ util/grub-mkconfig_lib.in | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 30dd4798f..723df8522 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-09 Grégoire Sutre + + * util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Handle + openbsd and netbsd types being in part_bsd module. + 2011-01-08 Vladimir Serbinenko * config.h.in (_LARGEFILE_SOURCE): Add missing define. diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index ec4084698..2a48fb260 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -107,7 +107,12 @@ prepare_grub_to_access_device () partmap="`${grub_probe} --device ${device} --target=partmap`" for module in ${partmap} ; do - echo "insmod part_${module}" + case "${module}" in + netbsd | openbsd) + echo "insmod part_bsd";; + *) + echo "insmod part_${module}";; + esac done fs="`${grub_probe} --device ${device} --target=fs`" From 1f060f399a5eebbb50f0e3aa41e734de09380aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Sutre?= Date: Mon, 10 Jan 2011 01:08:40 +0100 Subject: [PATCH 19/75] Teach grub-mkconfig to load fs modules for NetBSD. --- ChangeLog | 5 ++++ util/grub.d/10_netbsd.in | 62 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 723df8522..e215db3bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-09 Grégoire Sutre + + * util/grub.d/10_netbsd.in (netbsd_load_fs_module): New function. + (netbsd_entry): Use netbsd_load_fs_module() to load filesystem module. + 2011-01-09 Grégoire Sutre * util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Handle diff --git a/util/grub.d/10_netbsd.in b/util/grub.d/10_netbsd.in index 13f9d923a..ffd31ad93 100644 --- a/util/grub.d/10_netbsd.in +++ b/util/grub.d/10_netbsd.in @@ -27,11 +27,65 @@ export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR=@localedir@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then - OS=NetBSD + OS="NetBSD" else OS="${GRUB_DISTRIBUTOR} NetBSD" fi +netbsd_load_fs_module () +{ + loader="$1" # "knetbsd" or "multiboot" + kernel="$2" # absolute path to the kernel file + + case $(zcat -f "${kernel}" | file -bL - | cut -d , -f 2 | tr -d ' ') in + Intel80386) + karch="i386" + ;; + x86-64) + karch="amd64" + ;; + *) + return + ;; + esac + + case $(${grub_probe} --target=fs -d ${GRUB_DEVICE}) in + ext2) + kmod="ext2fs" + ;; + fat) + kmod="msdosfs" + ;; + ntfs) + kmod="ntfs" + ;; + ufs*) + kmod="ffs" + ;; + *) + return + ;; + esac + + kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }') + kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod" + + if test -z "$karch" -o -z "$kversion" -o ! -f "${kmodule}"; then + return + fi + + kmodule_rel=$(make_system_path_relative_to_its_root "$kmodule") || return + prepare_grub_to_access_device $(${grub_probe} -t device "${kmodule}") | sed -e 's,^, ,' + case "${loader}" in + knetbsd) + printf "\tknetbsd_module_elf %s\n" "${kmodule_rel}" + ;; + multiboot) + printf "\tmodule %s\n" "${kmodule_rel}" + ;; + esac +} + netbsd_entry () { loader="$1" # "knetbsd" or "multiboot" @@ -59,6 +113,9 @@ netbsd_entry () "${kernel}" "${kernel}" "${kroot_device}" "${GRUB_CMDLINE_NETBSD} ${args}" ;; esac + + netbsd_load_fs_module "${loader}" "${kernel}" + printf "}\n" } @@ -72,8 +129,7 @@ for k in $(ls -t /netbsd*) ; do if ! grub_file_is_not_garbage "$k" ; then continue fi - if ! ((file -bL "$k" | grep -q "${pattern}") || - (zcat "$k" | file -bL - | grep -q "${pattern}")) 2>/dev/null ; then + if ! (zcat -f "$k" | file -bL - | grep -q "${pattern}") 2>/dev/null ; then continue fi From cf0eaf13a102d71b8f7d56af8b1d00a623903d0e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 17:28:29 +0100 Subject: [PATCH 20/75] * grub-core/disk/raid.c (insert_array): Display RAID name in duplicate members errors. --- ChangeLog | 5 +++++ grub-core/disk/raid.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e215db3bd..85495e8ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/disk/raid.c (insert_array): Display RAID name in duplicate + members errors. + 2011-01-09 Grégoire Sutre * util/grub.d/10_netbsd.in (netbsd_load_fs_module): New function. diff --git a/grub-core/disk/raid.c b/grub-core/disk/raid.c index edc2b195d..c789fea50 100644 --- a/grub-core/disk/raid.c +++ b/grub-core/disk/raid.c @@ -530,8 +530,8 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array, /* We found multiple devices with the same number. Again, this shouldn't happen. */ return grub_error (GRUB_ERR_BAD_DEVICE, - "found two disks with the number %d", - new_array->number); + "found two disks with the index %d for RAID %s", + new_array->index, array->name); if (new_array->disk_size < array->disk_size) array->disk_size = new_array->disk_size; From b1969b304927c0fcd7ad812d97e564ddf3216476 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 17:35:32 +0100 Subject: [PATCH 21/75] * grub-core/fs/btrfs.c (grub_btrfs_mount): Transform out of range into badfs. Reported by: TiCPU. --- ChangeLog | 6 ++++++ grub-core/fs/btrfs.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 85495e8ad..12927d0f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/fs/btrfs.c (grub_btrfs_mount): Transform out of range into + badfs. + Reported by: TiCPU. + 2011-01-10 Vladimir Serbinenko * grub-core/disk/raid.c (insert_array): Display RAID name in duplicate diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index a2ee485b4..179891da8 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -60,6 +60,9 @@ grub_btrfs_mount (grub_disk_t disk) return data; fail: + if (grub_errno == GRUB_ERR_OUT_OF_RANGE) + grub_error (GRUB_ERR_BAD_FS, "not a Btrfs filesystem"); + grub_free (data); return NULL; } From c49849cc63560d02e042eda337135dbcf72a92fa Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 17:51:06 +0100 Subject: [PATCH 22/75] * grub-core/kern/i386/pc/mmap.c (grub_get_conv_memsize): New function. (grub_machine_mmap_iterate): Take low memory into account --- ChangeLog | 5 +++++ grub-core/kern/i386/pc/mmap.c | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 12927d0f2..34703b81d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/kern/i386/pc/mmap.c (grub_get_conv_memsize): New function. + (grub_machine_mmap_iterate): Take low memory into account + 2011-01-10 Vladimir Serbinenko * grub-core/fs/btrfs.c (grub_btrfs_mount): Transform out of range into diff --git a/grub-core/kern/i386/pc/mmap.c b/grub-core/kern/i386/pc/mmap.c index a305d4511..480ffa949 100644 --- a/grub-core/kern/i386/pc/mmap.c +++ b/grub-core/kern/i386/pc/mmap.c @@ -36,6 +36,22 @@ struct grub_machine_mmap_entry } __attribute__((packed)); +/* + * + * grub_get_conv_memsize(i) : return the conventional memory size in KB. + * BIOS call "INT 12H" to get conventional memory size + * The return value in AX. + */ +static inline grub_uint16_t +grub_get_conv_memsize (void) +{ + struct grub_bios_int_registers regs; + + regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; + grub_bios_interrupt (0x12, ®s); + return regs.eax & 0xffff; +} + /* * grub_get_ext_memsize() : return the extended memory size in KB. * BIOS call "INT 15H, AH=88H" to get extended memory size @@ -155,6 +171,10 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook) { grub_uint32_t eisa_mmap = grub_get_eisa_mmap (); + if (hook (0x0, ((grub_uint32_t) grub_get_conv_memsize ()) << 10, + GRUB_MEMORY_AVAILABLE)) + return 0; + if (eisa_mmap) { if (hook (0x100000, (eisa_mmap & 0xFFFF) << 10, @@ -162,7 +182,8 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook) hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MEMORY_AVAILABLE); } else - hook (0x100000, grub_get_ext_memsize () << 10, GRUB_MEMORY_AVAILABLE); + hook (0x100000, ((grub_uint32_t) grub_get_ext_memsize ()) << 10, + GRUB_MEMORY_AVAILABLE); } return 0; From db87be2aeab310b4740c0a6c556f667d43dd342e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 17:54:21 +0100 Subject: [PATCH 23/75] * grub-core/kern/i386/pc/init.c (grub_get_conv_memsize): Removed. (grub_machine_init): Don't check amount of low memory as reportedly INT 12h can be broken and if low memory is too low we wouldn't have gotten into grub_machine_init anyway. --- ChangeLog | 7 +++++++ grub-core/kern/i386/pc/init.c | 23 +++++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34703b81d..a1d948151 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/kern/i386/pc/init.c (grub_get_conv_memsize): Removed. + (grub_machine_init): Don't check amount of low memory as reportedly + INT 12h can be broken and if low memory is too low we wouldn't have + gotten into grub_machine_init anyway. + 2011-01-10 Vladimir Serbinenko * grub-core/kern/i386/pc/mmap.c (grub_get_conv_memsize): New function. diff --git a/grub-core/kern/i386/pc/init.c b/grub-core/kern/i386/pc/init.c index 122c2c556..d8c337bde 100644 --- a/grub-core/kern/i386/pc/init.c +++ b/grub-core/kern/i386/pc/init.c @@ -140,36 +140,27 @@ compact_mem_regions (void) } } -/* - * - * grub_get_conv_memsize(i) : return the conventional memory size in KB. - * BIOS call "INT 12H" to get conventional memory size - * The return value in AX. - */ -static inline grub_uint16_t -grub_get_conv_memsize (void) -{ - struct grub_bios_int_registers regs; - - regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; - grub_bios_interrupt (0x12, ®s); - return regs.eax & 0xffff; -} - void grub_machine_init (void) { int i; +#if 0 int grub_lower_mem; +#endif /* Initialize the console as early as possible. */ grub_console_init (); + /* This sanity check is useless since top of GRUB_MEMORY_MACHINE_RESERVED_END + is used for stack and if it's unavailable we wouldn't have gotten so far. + */ +#if 0 grub_lower_mem = grub_get_conv_memsize () << 10; /* Sanity check. */ if (grub_lower_mem < GRUB_MEMORY_MACHINE_RESERVED_END) grub_fatal ("too small memory"); +#endif /* FIXME: This prevents loader/i386/linux.c from using low memory. When our heap implements support for requesting a chunk in low memory, this should From ce6bb3ee31b651a09cd513cf8af5fb3b142bb82c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 19:20:50 +0100 Subject: [PATCH 24/75] * util/grub-menulst2cfg.c (main): Trim the line. --- ChangeLog | 4 ++++ util/grub-menulst2cfg.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a1d948151..64f9a5be9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-10 Vladimir Serbinenko + + * util/grub-menulst2cfg.c (main): Trim the line. + 2011-01-10 Vladimir Serbinenko * grub-core/kern/i386/pc/init.c (grub_get_conv_memsize): Removed. diff --git a/util/grub-menulst2cfg.c b/util/grub-menulst2cfg.c index e29c6b17c..da1c289a8 100644 --- a/util/grub-menulst2cfg.c +++ b/util/grub-menulst2cfg.c @@ -78,9 +78,12 @@ main (int argc, char **argv) { char *oldname = NULL; char *newsuffix; + char *ptr; + + for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++); oldname = entryname; - parsed = grub_legacy_parse (buf, &entryname, &newsuffix); + parsed = grub_legacy_parse (ptr, &entryname, &newsuffix); if (newsuffix) { suffixlen += strlen (newsuffix); From 47a77af5e8f03eed1edb60f81ab7764d54ab515a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 19:25:00 +0100 Subject: [PATCH 25/75] * grub-core/commands/legacycfg.c (legacy_file): Trim the line. --- ChangeLog | 4 ++++ grub-core/commands/legacycfg.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 64f9a5be9..6461f79f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/commands/legacycfg.c (legacy_file): Trim the line. + 2011-01-10 Vladimir Serbinenko * util/grub-menulst2cfg.c (main): Trim the line. diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index de392ac81..71ac5c620 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -83,9 +83,13 @@ legacy_file (const char *filename) { char *oldname = NULL; char *newsuffix; + char *ptr; + + for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++); oldname = entryname; - parsed = grub_legacy_parse (buf, &entryname, &newsuffix); + parsed = grub_legacy_parse (ptr, &entryname, &newsuffix); + grub_free (buf); buf = NULL; if (newsuffix) { From 6fef99b4e4121ccd3bf9208c13faa6433a51453f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 19:52:12 +0100 Subject: [PATCH 26/75] * util/grub-mklayout.c (usage): Update help text. --- ChangeLog | 4 ++++ util/grub-mklayout.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6461f79f4..d856bbff2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-10 Vladimir Serbinenko + + * util/grub-mklayout.c (usage): Update help text. + 2011-01-10 Vladimir Serbinenko * grub-core/commands/legacycfg.c (legacy_file): Trim the line. diff --git a/util/grub-mklayout.c b/util/grub-mklayout.c index e90d955ff..36f6e04fc 100644 --- a/util/grub-mklayout.c +++ b/util/grub-mklayout.c @@ -259,8 +259,9 @@ usage (int status) fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ -Usage: %s [OPTIONS] LAYOUT\n\ - -o, --output set output base name file. Default is LAYOUT.gkb\n\ +Usage: %s [OPTIONS]\n\ + -i, --input set input filename. Default is STDIN\n\ + -o, --output set output filename. Default is STDOUT\n\ -h, --help display this message and exit.\n\ -V, --version print version information and exit.\n\ -v, --verbose print verbose messages.\n\ From dcb883b1623c730190357ad8803f88e592b6d364 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:27:58 +0100 Subject: [PATCH 27/75] Submenu default support. * grub-core/normal/menu.c (grub_menu_execute_entry): New parameter auto_boot. All users updated. Declared static. Handle chosen and default with submenus. (grub_menu_execute_with_fallback): Declared static. Don't notify failure if autobooted. Upper level does it. (menuentry_eq): New function. (get_entry_number): Use menuentry_eq. (show_menu): New parameter "autobooted". All users updated. (grub_show_menu): Likewise. * include/grub/normal.h (grub_show_menu): Likewise. * include/grub/menu.h (grub_menu_execute_entry): Removed. (grub_menu_execute_with_fallback): Likewise. --- ChangeLog | 18 +++++ grub-core/commands/legacycfg.c | 2 +- grub-core/normal/main.c | 2 +- grub-core/normal/menu.c | 130 +++++++++++++++++++++++++++++---- grub-core/normal/menu_entry.c | 2 +- include/grub/menu.h | 5 -- include/grub/normal.h | 2 +- 7 files changed, 137 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index d856bbff2..976c2cf5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2011-01-10 Vladimir Serbinenko + + Submenu default support. + + * grub-core/normal/menu.c (grub_menu_execute_entry): New parameter + auto_boot. All users updated. + Declared static. + Handle chosen and default with submenus. + (grub_menu_execute_with_fallback): Declared static. + Don't notify failure if autobooted. Upper level does it. + (menuentry_eq): New function. + (get_entry_number): Use menuentry_eq. + (show_menu): New parameter "autobooted". All users updated. + (grub_show_menu): Likewise. + * include/grub/normal.h (grub_show_menu): Likewise. + * include/grub/menu.h (grub_menu_execute_entry): Removed. + (grub_menu_execute_with_fallback): Likewise. + 2011-01-10 Vladimir Serbinenko * util/grub-mklayout.c (usage): Update help text. diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index 71ac5c620..23c1c1908 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -213,7 +213,7 @@ grub_cmd_legacy_source (struct grub_command *cmd, grub_menu_t menu; menu = grub_env_get_menu (); if (menu && menu->size) - grub_show_menu (menu, 1); + grub_show_menu (menu, 1, 0); if (!extractor) grub_env_context_close (); } diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index 3bfbbeb72..69bf5e6b5 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -287,7 +287,7 @@ grub_normal_execute (const char *config, int nested, int batch) { if (menu && menu->size) { - grub_show_menu (menu, nested); + grub_show_menu (menu, nested, 0); if (nested) grub_normal_free_menu (menu); } diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index 807ad51e0..6a123a6de 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -154,12 +154,15 @@ get_and_remove_first_entry_number (const char *name) } /* Run a menu entry. */ -void -grub_menu_execute_entry(grub_menu_entry_t entry) +static void +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; + char *optr, *buf, *oldchosen = NULL, *olddefault = NULL; + const char *ptr, *chosen, *def; + grub_size_t sz = 0; if (entry->restricted) err = grub_auth_check_authentication (entry->users); @@ -173,6 +176,9 @@ grub_menu_execute_entry(grub_menu_entry_t entry) errs_before = grub_err_printed_errors; + chosen = grub_env_get ("chosen"); + def = grub_env_get ("default"); + if (entry->submenu) { grub_env_context_open (); @@ -180,9 +186,64 @@ grub_menu_execute_entry(grub_menu_entry_t entry) if (! menu) return; grub_env_set_menu (menu); + if (auto_boot) + grub_env_set ("timeout", "0"); } - grub_env_set ("chosen", entry->title); + for (ptr = entry->title; *ptr; ptr++) + sz += (*ptr == '>') ? 2 : 1; + if (chosen) + { + oldchosen = grub_strdup (chosen); + if (!oldchosen) + grub_print_error (); + } + if (def) + { + olddefault = grub_strdup (def); + if (!olddefault) + grub_print_error (); + } + sz++; + if (chosen) + sz += grub_strlen (chosen); + sz++; + buf = grub_malloc (sz); + if (!buf) + grub_print_error (); + else + { + optr = buf; + if (chosen) + { + optr = grub_stpcpy (optr, chosen); + *optr++ = '>'; + } + for (ptr = entry->title; *ptr; ptr++) + { + if (*ptr == '>') + *optr++ = '>'; + *optr++ = *ptr; + } + *optr = 0; + grub_env_set ("chosen", buf); + grub_env_export ("chosen"); + grub_free (buf); + } + for (ptr = def; *ptr; ptr++) + { + if (ptr[0] == '>' && ptr[1] == '>') + { + ptr++; + continue; + } + if (ptr[0] == '>') + break; + } + if (ptr[0] && ptr[1]) + grub_env_set ("default", ptr + 1); + else + grub_env_unset ("default"); grub_script_execute_sourcecode (entry->sourcecode, entry->argc, entry->args); if (errs_before != grub_err_printed_errors) @@ -196,20 +257,30 @@ grub_menu_execute_entry(grub_menu_entry_t entry) { if (menu && menu->size) { - grub_show_menu (menu, 1); + grub_show_menu (menu, 1, auto_boot); grub_normal_free_menu (menu); } grub_env_context_close (); } + if (oldchosen) + grub_env_set ("chosen", oldchosen); + else + grub_env_unset ("chosen"); + if (olddefault) + grub_env_set ("default", olddefault); + else + grub_env_unset ("default"); + grub_env_unset ("timeout"); } /* Execute ENTRY from the menu MENU, falling back to entries specified in the environment variable "fallback" if it fails. CALLBACK is a pointer to a struct of function pointers which are used to allow the caller provide feedback to the user. */ -void +static void grub_menu_execute_with_fallback (grub_menu_t menu, grub_menu_entry_t entry, + int autobooted, grub_menu_execute_callback_t callback, void *callback_data) { @@ -217,7 +288,7 @@ grub_menu_execute_with_fallback (grub_menu_t menu, callback->notify_booting (entry, callback_data); - grub_menu_execute_entry (entry); + grub_menu_execute_entry (entry, 1); /* Deal with fallback entries. */ while ((fallback_entry = get_and_remove_first_entry_number ("fallback")) @@ -228,14 +299,15 @@ grub_menu_execute_with_fallback (grub_menu_t menu, entry = grub_menu_get_entry (menu, fallback_entry); callback->notify_fallback (entry, callback_data); - grub_menu_execute_entry (entry); + grub_menu_execute_entry (entry, 1); /* If the function call to execute the entry returns at all, then this is taken to indicate a boot failure. For menu entries that do something other than actually boot an operating system, this could assume incorrectly that something failed. */ } - callback->notify_failure (callback_data); + if (!autobooted) + callback->notify_failure (callback_data); } static struct grub_menu_viewer *viewers; @@ -309,11 +381,35 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer) viewers = viewer; } +static int +menuentry_eq (const char *title, const char *spec) +{ + const char *ptr1, *ptr2; + ptr1 = title; + ptr2 = spec; + while (1) + { + if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0) + return 1; + if (*ptr2 == '>' && ptr2[1] != '>') + return 0; + if (*ptr2 == '>') + ptr2++; + if (*ptr1 != *ptr2) + return 0; + if (*ptr1 == 0) + return 1; + ptr1++; + ptr2++; + } +} + + /* Get the entry number from the variable NAME. */ static int get_entry_number (grub_menu_t menu, const char *name) { - char *val; + const char *val; int entry; val = grub_env_get (name); @@ -334,7 +430,7 @@ get_entry_number (grub_menu_t menu, const char *name) for (i = 0; e; i++) { - if (grub_strcmp (e->title, val) == 0) + if (menuentry_eq (e->title, val)) { entry = i; break; @@ -590,7 +686,7 @@ static struct grub_menu_execute_callback execution_callback = }; static grub_err_t -show_menu (grub_menu_t menu, int nested) +show_menu (grub_menu_t menu, int nested, int autobooted) { while (1) { @@ -609,22 +705,26 @@ show_menu (grub_menu_t menu, int nested) grub_cls (); if (auto_boot) - grub_menu_execute_with_fallback (menu, e, &execution_callback, 0); + grub_menu_execute_with_fallback (menu, e, autobooted, + &execution_callback, 0); else - grub_menu_execute_entry (e); + grub_menu_execute_entry (e, 0); + if (autobooted) + break; } return GRUB_ERR_NONE; } grub_err_t -grub_show_menu (grub_menu_t menu, int nested) +grub_show_menu (grub_menu_t menu, int nested, int autoboot) { grub_err_t err1, err2; while (1) { - err1 = show_menu (menu, nested); + err1 = show_menu (menu, nested, autoboot); + autoboot = 0; grub_print_error (); if (grub_normal_exit_level) diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index 4db4a45c1..e744d8d69 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -1227,7 +1227,7 @@ run (struct screen *screen) { if (menu && menu->size) { - grub_show_menu (menu, 1); + grub_show_menu (menu, 1, 0); grub_normal_free_menu (menu); } grub_env_context_close (); diff --git a/include/grub/menu.h b/include/grub/menu.h index 5ff356beb..1f23a2363 100644 --- a/include/grub/menu.h +++ b/include/grub/menu.h @@ -94,11 +94,6 @@ typedef struct grub_menu_execute_callback grub_menu_entry_t grub_menu_get_entry (grub_menu_t menu, int no); int grub_menu_get_timeout (void); void grub_menu_set_timeout (int timeout); -void grub_menu_execute_entry (grub_menu_entry_t entry); -void grub_menu_execute_with_fallback (grub_menu_t menu, - grub_menu_entry_t entry, - grub_menu_execute_callback_t callback, - void *callback_data); void grub_menu_entry_run (grub_menu_entry_t entry); int grub_menu_get_default_entry_index (grub_menu_t menu); diff --git a/include/grub/normal.h b/include/grub/normal.h index 187567797..3b99e073a 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -89,7 +89,7 @@ void grub_print_message_indented (const char *msg, int margin_left, void grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested); grub_err_t -grub_show_menu (grub_menu_t menu, int nested); +grub_show_menu (grub_menu_t menu, int nested, int autobooted); /* Defined in `handler.c'. */ void read_handler_list (void); From a508e7764271aa8abcb4c93a799eec64326806e4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:31:27 +0100 Subject: [PATCH 28/75] * util/grub-kbdcomp.in: Add missing transform and bindir variables. Reported by: nebuchadnezzar. --- ChangeLog | 5 +++++ util/grub-kbdcomp.in | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 976c2cf5b..eff9002cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-10 Vladimir Serbinenko + + * util/grub-kbdcomp.in: Add missing transform and bindir variables. + Reported by: nebuchadnezzar. + 2011-01-10 Vladimir Serbinenko Submenu default support. diff --git a/util/grub-kbdcomp.in b/util/grub-kbdcomp.in index 87b24bcdf..b7e706c24 100644 --- a/util/grub-kbdcomp.in +++ b/util/grub-kbdcomp.in @@ -1,5 +1,9 @@ #!/bin/sh +transform="@program_transform_name@" + +bindir="@bindir@" + grub_mklayout=${bindir}/`echo grub-mklayout | sed ${transform}` ckbcomp "$@" | $grub_mklayout -o "$1".gkb From d570097a04f3249274d1d588d51b1fffa8aa6513 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:41:58 +0100 Subject: [PATCH 29/75] * util/grub-kbdcomp.in: Add missing prefix and exec_prefix variables. Reported by: nebuchadnezzar. --- ChangeLog | 5 +++++ util/grub-kbdcomp.in | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index eff9002cf..5ef4b1c95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-10 Vladimir Serbinenko + + * util/grub-kbdcomp.in: Add missing prefix and exec_prefix variables. + Reported by: nebuchadnezzar. + 2011-01-10 Vladimir Serbinenko * util/grub-kbdcomp.in: Add missing transform and bindir variables. diff --git a/util/grub-kbdcomp.in b/util/grub-kbdcomp.in index b7e706c24..05e516d23 100644 --- a/util/grub-kbdcomp.in +++ b/util/grub-kbdcomp.in @@ -2,6 +2,8 @@ transform="@program_transform_name@" +prefix="@prefix@" +exec_prefix="@exec_prefix@" bindir="@bindir@" grub_mklayout=${bindir}/`echo grub-mklayout | sed ${transform}` From ae67942e7819481499fbc9710781b5eacaf445b3 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:51:10 +0100 Subject: [PATCH 30/75] Don't use post-4G memory on EFI even if 64-bit since some non-compliant implementations bug on them. * grub-core/kern/efi/mm.c (grub_efi_allocate_pages): Skip post-4G memory. (filter_memory_map): Likewise. --- ChangeLog | 9 +++++++++ grub-core/kern/efi/mm.c | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ef4b1c95..0b9b9b6aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-01-10 Vladimir Serbinenko + + Don't use post-4G memory on EFI even if 64-bit since some non-compliant + implementations bug on them. + + * grub-core/kern/efi/mm.c (grub_efi_allocate_pages): Skip post-4G + memory. + (filter_memory_map): Likewise. + 2011-01-10 Vladimir Serbinenko * util/grub-kbdcomp.in: Add missing prefix and exec_prefix variables. diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index a715da076..8b9e6ec25 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -52,13 +52,13 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address, grub_efi_status_t status; grub_efi_boot_services_t *b; -#if GRUB_TARGET_SIZEOF_VOID_P < 8 +#if 1 /* Limit the memory access to less than 4GB for 32-bit platforms. */ if (address > 0xffffffff) return 0; #endif -#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL) +#if 1 if (address == 0) { type = GRUB_EFI_ALLOCATE_MAX_ADDRESS; @@ -251,7 +251,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) { if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY -#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL) +#if 1 && desc->physical_start <= 0xffffffff #endif && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000 @@ -267,7 +267,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, desc->physical_start = 0x100000; } -#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL) +#if 1 if (BYTES_TO_PAGES (filtered_desc->physical_start) + filtered_desc->num_pages > BYTES_TO_PAGES (0x100000000LL)) From b3ff6ff0565a4f774763eb71f70979b126029dce Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:56:11 +0100 Subject: [PATCH 31/75] * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Use comma as separator and pass bootpath/devid even if only one of them is available. Reported by: Seth Goldberg. --- ChangeLog | 6 ++++++ grub-core/fs/zfs/zfsinfo.c | 23 ++++++++--------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b9b9b6aa..4433ffa5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Use comma as + separator and pass bootpath/devid even if only one of them is available. + Reported by: Seth Goldberg. + 2011-01-10 Vladimir Serbinenko Don't use post-4G memory on EFI even if 64-bit since some non-compliant diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c index 33065892a..5a7b5ec44 100644 --- a/grub-core/fs/zfs/zfsinfo.c +++ b/grub-core/fs/zfs/zfsinfo.c @@ -364,21 +364,14 @@ grub_cmd_zfs_bootfs (grub_command_t cmd __attribute__ ((unused)), int argc, grub_free (nv); grub_free (nvlist); - if (bootpath && devid) - { - bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu bootpath=%s diskdevid=%s", - poolname, (unsigned long long) mdnobj, - bootpath, devid); - if (!bootfs) - return grub_errno; - } - else - { - bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu", - poolname, (unsigned long long) mdnobj); - if (!bootfs) - return grub_errno; - } + bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu%s%s%s%s", + poolname, (unsigned long long) mdnobj, + bootpath ? ",bootpath=" : "", + bootpath ? : "", + devid ? ",diskdevid=" : "", + devid ? : ""); + if (!bootfs) + return grub_errno; if (argc >= 2) grub_env_set (args[1], bootfs); else From c2fa6cbb42dd3e2a17e7074a2eec421c31f4b4fa Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:57:49 +0100 Subject: [PATCH 32/75] * util/grub-menulst2cfg.c: Add missing include of misc.h. --- ChangeLog | 4 ++++ util/grub-menulst2cfg.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4433ffa5e..63a0ee46c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-10 Vladimir Serbinenko + + * util/grub-menulst2cfg.c: Add missing include of misc.h. + 2011-01-10 Vladimir Serbinenko * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Use comma as diff --git a/util/grub-menulst2cfg.c b/util/grub-menulst2cfg.c index da1c289a8..513af47c1 100644 --- a/util/grub-menulst2cfg.c +++ b/util/grub-menulst2cfg.c @@ -23,6 +23,7 @@ #include #include #include +#include int main (int argc, char **argv) From 3395fe5230ef31f838692b88dc0c7ebc62599151 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 11 Jan 2011 00:02:01 +0100 Subject: [PATCH 33/75] Pass more appropriate video id to Linux. * grub-core/loader/i386/linux.c (grub_linux_setup_video): Use grub_video_get_driver_id and variable gfxpayloadforcelfb to fill have_vga. (grub_linux_boot): Rely on grub_linux_setup_video to fill have_vga and shift params->lfb_size. * include/grub/i386/linux.h: Make an enume out of have_vga values. --- BUGS | 2 ++ ChangeLog | 11 ++++++++ grub-core/loader/i386/linux.c | 51 +++++++++++++++++++++++++---------- include/grub/i386/linux.h | 10 ++++--- 4 files changed, 57 insertions(+), 17 deletions(-) create mode 100644 BUGS diff --git a/BUGS b/BUGS new file mode 100644 index 000000000..0faebcdcc --- /dev/null +++ b/BUGS @@ -0,0 +1,2 @@ +Currently search and assembling multidevice abstractions scans all the devices which can be slow. +Cache isn't used correctly for video which results in slowness. diff --git a/ChangeLog b/ChangeLog index 63a0ee46c..1a6a71bc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-01-10 Vladimir Serbinenko + + Pass more appropriate video id to Linux. + + * grub-core/loader/i386/linux.c (grub_linux_setup_video): Use + grub_video_get_driver_id and variable gfxpayloadforcelfb to + fill have_vga. + (grub_linux_boot): Rely on grub_linux_setup_video to fill have_vga and + shift params->lfb_size. + * include/grub/i386/linux.h: Make an enume out of have_vga values. + 2011-01-10 Vladimir Serbinenko * util/grub-menulst2cfg.c: Add missing include of misc.h. diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 80f583cef..80960570b 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -313,6 +313,13 @@ grub_linux_setup_video (struct linux_kernel_params *params) struct grub_video_mode_info mode_info; void *framebuffer; grub_err_t err; + grub_video_driver_id_t driver_id; + char *gfxlfbvar = grub_env_get ("gfxpayloadforcelfb"); + + driver_id = grub_video_get_driver_id (); + + if (driver_id == GRUB_VIDEO_DRIVER_NONE) + return 1; err = grub_video_get_info_and_fini (&mode_info, &framebuffer); @@ -339,12 +346,40 @@ grub_linux_setup_video (struct linux_kernel_params *params) params->reserved_mask_size = mode_info.reserved_mask_size; params->reserved_field_pos = mode_info.reserved_field_pos; + if (gfxlfbvar && (gfxlfbvar[0] == '1' || gfxlfbvar[0] == 'y')) + params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE; + else + { + switch (driver_id) + { + case GRUB_VIDEO_DRIVER_VBE: + params->lfb_size >>= 16; + params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA; + break; + + case GRUB_VIDEO_DRIVER_EFI_UGA: + case GRUB_VIDEO_DRIVER_EFI_GOP: + params->have_vga = GRUB_VIDEO_LINUX_TYPE_EFIFB; + break; + + /* FIXME: check if better id is available. */ + case GRUB_VIDEO_DRIVER_SM712: + case GRUB_VIDEO_DRIVER_VGA: + case GRUB_VIDEO_DRIVER_CIRRUS: + case GRUB_VIDEO_DRIVER_BOCHS: + /* Make gcc happy. */ + case GRUB_VIDEO_DRIVER_SDL: + case GRUB_VIDEO_DRIVER_NONE: + params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE; + break; + } + } #ifdef GRUB_MACHINE_PCBIOS /* VESA packed modes may come with zeroed mask sizes, which need to be set here according to DAC Palette width. If we don't, this results in Linux displaying a black screen. */ - if (mode_info.bpp <= 8) + if (driver_id == GRUB_VIDEO_DRIVER_VBE && mode_info.bpp <= 8) { struct grub_vbe_info_block controller_info; int status; @@ -457,15 +492,7 @@ grub_linux_boot (void) grub_errno = GRUB_ERR_NONE; } - if (! grub_linux_setup_video (params)) - { - /* Use generic framebuffer unless VESA is known to be supported. */ - if (params->have_vga != GRUB_VIDEO_LINUX_TYPE_VESA) - params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE; - else - params->lfb_size >>= 16; - } - else + if (grub_linux_setup_video (params)) { #if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) params->have_vga = GRUB_VIDEO_LINUX_TYPE_TEXT; @@ -771,10 +798,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), break; } - /* We can't detect VESA, but user is implicitly telling us that it - is built-in because `vga=' parameter was used. */ - params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA; - linux_mode = &grub_vesa_mode_table[vid_mode - GRUB_VESA_MODE_TABLE_START]; diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index 9ba83eee2..fed58a630 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -79,9 +79,13 @@ struct grub_e820_mmap grub_uint32_t type; } __attribute__((packed)); -#define GRUB_VIDEO_LINUX_TYPE_TEXT 0x01 -#define GRUB_VIDEO_LINUX_TYPE_VESA 0x23 /* VESA VGA in graphic mode. */ -#define GRUB_VIDEO_LINUX_TYPE_SIMPLE 0x70 /* Linear framebuffer without any additional functions. */ +enum + { + GRUB_VIDEO_LINUX_TYPE_TEXT = 0x01, + GRUB_VIDEO_LINUX_TYPE_VESA = 0x23, /* VESA VGA in graphic mode. */ + GRUB_VIDEO_LINUX_TYPE_EFIFB = 0x70, /* EFI Framebuffer. */ + GRUB_VIDEO_LINUX_TYPE_SIMPLE = 0x70 /* Linear framebuffer without any additional functions. */ + }; /* For the Linux/i386 boot protocol version 2.03. */ struct linux_kernel_header From f093110b52d6d2b3b97fd1c07388f441863e0f5f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 11 Jan 2011 00:06:01 +0100 Subject: [PATCH 34/75] * BUGS: New file. --- BUGS | 9 +++++++-- ChangeLog | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/BUGS b/BUGS index 0faebcdcc..46faa6452 100644 --- a/BUGS +++ b/BUGS @@ -1,2 +1,7 @@ -Currently search and assembling multidevice abstractions scans all the devices which can be slow. -Cache isn't used correctly for video which results in slowness. +GRUB team is aware of following problems: + - Currently search and assembling multidevice abstractions scans + all the devices which can be slow. + - Cache isn't used correctly for video which results in slowness. + +While these are bugs their solution has a potential of breaking more and more +seriously. So it was decided for 1.99 that they aren't fixed. diff --git a/ChangeLog b/ChangeLog index 1a6a71bc5..894f886b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-11 Vladimir Serbinenko + + * BUGS: New file. + 2011-01-10 Vladimir Serbinenko Pass more appropriate video id to Linux. From 45146057263bc0d47cefe2f46ee6157f92fd3af4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 11 Jan 2011 00:44:56 +0100 Subject: [PATCH 35/75] =?UTF-8?q?=09*=20grub-core/loader/i386/multiboot=5F?= =?UTF-8?q?mbi.c=20(grub=5Fmultiboot=5Fmake=5Fmbi):=20=09Take=20into=20acc?= =?UTF-8?q?ount=20space=20used=20by=20ELF=20sections=20and=20multiboot=20p?= =?UTF-8?q?alette.=20=09Reported=20by:=20Gr=C3=A9goire=20Sutre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 6 ++++++ grub-core/loader/i386/multiboot_mbi.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index 894f886b4..73571a549 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-11 Vladimir Serbinenko + + * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): + Take into account space used by ELF sections and multiboot palette. + Reported by: Grégoire Sutre. + 2011-01-11 Vladimir Serbinenko * BUGS: New file. diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index eade78e93..b98bda223 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -539,6 +539,9 @@ grub_multiboot_make_mbi (grub_uint32_t *target) mbi->u.elf_sec.shndx = elf_sec_shstrndx; mbi->flags |= MULTIBOOT_INFO_ELF_SHDR; + + ptrorig += elf_sec_entsize * elf_sec_num; + ptrdest += elf_sec_entsize * elf_sec_num; } err = retrieve_video_parameters (mbi, ptrorig, ptrdest); @@ -547,6 +550,16 @@ grub_multiboot_make_mbi (grub_uint32_t *target) grub_print_error (); grub_errno = GRUB_ERR_NONE; } + + if ((mbi->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO) + && mbi->framebuffer_type == MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED) + { + ptrorig += mbi->framebuffer_palette_num_colors + * sizeof (struct multiboot_color); + ptrdest += mbi->framebuffer_palette_num_colors + * sizeof (struct multiboot_color); + } + #if GRUB_MACHINE_HAS_VBE ptrorig += sizeof (struct grub_vbe_info_block); ptrdest += sizeof (struct grub_vbe_info_block); From 4531a206a1c112d405ef9ea00f2e06037ef0c01a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 11 Jan 2011 11:51:05 +0100 Subject: [PATCH 36/75] * grub-core/fs/i386/pc/pxe.c (set_mac_env): Export variable. (set_env_limn_ro): Likewise. (GRUB_MOD_INIT): Likewise. * grub-core/hook/datehook.c (GRUB_MOD_INIT): Likewise. Change to ARRAY_SIZE while on it. (GRUB_MOD_FINI): Change to ARRAY_SIZE. * grub-core/normal/context.c (grub_env_export): Move from here ... * grub-core/kern/env.c (grub_env_export): ... here. * grub-core/normal/context.c (grub_cmd_export): Skip exporting root and prefix. * grub-core/kern/main.c (grub_main): Export root and prefix. * include/grub/env.h (grub_env_export): Export. Reported by: Seth Goldberg. --- ChangeLog | 16 ++++++++++++++++ grub-core/fs/i386/pc/pxe.c | 9 +++++++++ grub-core/hook/datehook.c | 15 +++++++++------ grub-core/kern/env.c | 20 ++++++++++++++++++++ grub-core/kern/main.c | 2 ++ grub-core/normal/context.c | 23 ----------------------- include/grub/env.h | 2 +- 7 files changed, 57 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 73571a549..a4f7122fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2011-01-11 Vladimir Serbinenko + + * grub-core/fs/i386/pc/pxe.c (set_mac_env): Export variable. + (set_env_limn_ro): Likewise. + (GRUB_MOD_INIT): Likewise. + * grub-core/hook/datehook.c (GRUB_MOD_INIT): Likewise. Change to + ARRAY_SIZE while on it. + (GRUB_MOD_FINI): Change to ARRAY_SIZE. + * grub-core/normal/context.c (grub_env_export): Move from here ... + * grub-core/kern/env.c (grub_env_export): ... here. + * grub-core/normal/context.c (grub_cmd_export): Skip exporting root and + prefix. + * grub-core/kern/main.c (grub_main): Export root and prefix. + * include/grub/env.h (grub_env_export): Export. + Reported by: Seth Goldberg. + 2011-01-11 Vladimir Serbinenko * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): diff --git a/grub-core/fs/i386/pc/pxe.c b/grub-core/fs/i386/pc/pxe.c index cbb3c7d87..e2b53d637 100644 --- a/grub-core/fs/i386/pc/pxe.c +++ b/grub-core/fs/i386/pc/pxe.c @@ -420,6 +420,7 @@ set_mac_env (grub_uint8_t *mac_addr, grub_size_t mac_len) grub_env_set ("net_pxe_mac", buf); /* XXX: Is it possible to change MAC in PXE? */ grub_register_variable_hook ("net_pxe_mac", 0, grub_env_write_readonly); + grub_env_export ("net_pxe_mac"); } static void @@ -431,6 +432,7 @@ set_env_limn_ro (const char *varname, char *value, grub_size_t len) grub_env_set (varname, value); value[len] = c; grub_register_variable_hook (varname, 0, grub_env_write_readonly); + grub_env_export (varname); } static void @@ -624,12 +626,19 @@ GRUB_MOD_INIT(pxe) grub_env_write_pxe_default_server); grub_register_variable_hook ("pxe_default_gateway", 0, grub_env_write_pxe_default_gateway); + /* XXX: Is it possible to change IP in PXE? */ grub_register_variable_hook ("net_pxe_ip", 0, grub_env_write_readonly); grub_register_variable_hook ("pxe_blksize", 0, grub_env_write_pxe_blocksize); + + grub_env_export ("pxe_default_server"); + grub_env_export ("pxe_default_gateway"); + grub_env_export ("net_pxe_ip"); + grub_env_export ("pxe_blksize"); + grub_disk_dev_register (&grub_pxe_dev); grub_fs_register (&grub_pxefs_fs); } diff --git a/grub-core/hook/datehook.c b/grub-core/hook/datehook.c index 9b5b54bf3..d855311d3 100644 --- a/grub-core/hook/datehook.c +++ b/grub-core/hook/datehook.c @@ -86,18 +86,21 @@ grub_read_hook_datetime (struct grub_env_var *var, GRUB_MOD_INIT(datehook) { - int i; + unsigned i; - for (i = 0; i < 7; i++) - grub_register_variable_hook (grub_datetime_names[i], - grub_read_hook_datetime, 0); + for (i = 0; i < ARRAY_SIZE (grub_datetime_names); i++) + { + grub_register_variable_hook (grub_datetime_names[i], + grub_read_hook_datetime, 0); + grub_env_export (grub_datetime_names[i]); + } } GRUB_MOD_FINI(datehook) { - int i; + unsigned i; - for (i = 0; i < 7; i++) + for (i = 0; i < ARRAY_SIZE (grub_datetime_names); i++) { grub_register_variable_hook (grub_datetime_names[i], 0, 0); grub_env_unset (grub_datetime_names[i]); diff --git a/grub-core/kern/env.c b/grub-core/kern/env.c index 84b3a001d..8f843a872 100644 --- a/grub-core/kern/env.c +++ b/grub-core/kern/env.c @@ -240,3 +240,23 @@ grub_register_variable_hook (const char *name, return GRUB_ERR_NONE; } + +grub_err_t +grub_env_export (const char *name) +{ + struct grub_env_var *var; + + var = grub_env_find (name); + if (! var) + { + grub_err_t err; + + err = grub_env_set (name, ""); + if (err) + return err; + var = grub_env_find (name); + } + var->global = 1; + + return GRUB_ERR_NONE; +} diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c index 8b6c8a180..da7123234 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -189,6 +189,8 @@ grub_main (void) for convenience. */ grub_machine_set_prefix (); grub_set_root_dev (); + grub_env_export ("root"); + grub_env_export ("prefix"); grub_register_core_commands (); diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c index 75beeefda..b73161d0b 100644 --- a/grub-core/normal/context.c +++ b/grub-core/normal/context.c @@ -175,26 +175,6 @@ grub_env_extractor_close (int source) return err; } -grub_err_t -grub_env_export (const char *name) -{ - struct grub_env_var *var; - - var = grub_env_find (name); - if (! var) - { - grub_err_t err; - - err = grub_env_set (name, ""); - if (err) - return err; - var = grub_env_find (name); - } - var->global = 1; - - return GRUB_ERR_NONE; -} - static grub_command_t export_cmd; static grub_err_t @@ -216,9 +196,6 @@ grub_cmd_export (struct grub_command *cmd __attribute__ ((unused)), void grub_context_init (void) { - grub_env_export ("root"); - grub_env_export ("prefix"); - export_cmd = grub_register_command ("export", grub_cmd_export, N_("ENVVAR [ENVVAR] ..."), N_("Export variables.")); diff --git a/include/grub/env.h b/include/grub/env.h index 6d1f0de6e..c0107f16a 100644 --- a/include/grub/env.h +++ b/include/grub/env.h @@ -53,7 +53,7 @@ grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name, grub_err_t grub_env_context_open (void); grub_err_t grub_env_context_close (void); -grub_err_t grub_env_export (const char *name); +grub_err_t EXPORT_FUNC(grub_env_export) (const char *name); void grub_env_unset_menu (void); grub_menu_t grub_env_get_menu (void); From 86205c94c3f85579f56b005896c4ad3cf0c69d00 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 11 Jan 2011 09:08:57 -0600 Subject: [PATCH 37/75] * util/grub-mklayout.c (console_grub_equivalences_shift): Terminate with NULL. (console_grub_equivalences_unshift): Likewise. Reported by: Daniel Dehennin. --- ChangeLog | 7 +++++++ util/grub-mklayout.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index a4f7122fb..56a8db213 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-11 Colin Watson + + * util/grub-mklayout.c (console_grub_equivalences_shift): Terminate + with NULL. + (console_grub_equivalences_unshift): Likewise. + Reported by: Daniel Dehennin. + 2011-01-11 Vladimir Serbinenko * grub-core/fs/i386/pc/pxe.c (set_mac_env): Export variable. diff --git a/util/grub-mklayout.c b/util/grub-mklayout.c index 36f6e04fc..04501cb40 100644 --- a/util/grub-mklayout.c +++ b/util/grub-mklayout.c @@ -60,6 +60,8 @@ static struct console_grub_equivalence console_grub_equivalences_shift[] = { {"KP_8", '8'}, {"KP_9", '9'}, {"KP_Period", '.'}, + + {NULL, '\0'} }; static struct console_grub_equivalence console_grub_equivalences_unshift[] = { @@ -74,6 +76,8 @@ static struct console_grub_equivalence console_grub_equivalences_unshift[] = { {"KP_8", GRUB_TERM_KEY_UP}, {"KP_9", GRUB_TERM_KEY_PPAGE}, {"KP_Period", GRUB_TERM_KEY_DC}, + + {NULL, '\0'} }; static struct console_grub_equivalence console_grub_equivalences_common[] = { From 9da068a5dc3b507276552980fc9c6459aef0a02d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 11 Jan 2011 23:01:07 +0100 Subject: [PATCH 38/75] * 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 39/75] * 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 40/75] 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 41/75] * 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 42/75] * 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 43/75] * 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 44/75] * 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 45/75] * 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 46/75] 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 47/75] * 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 48/75] * 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 49/75] * 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 50/75] * 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 51/75] * 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 52/75] * .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 53/75] * 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 54/75] * 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 55/75] * 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 56/75] * 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 57/75] * 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 58/75] * 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 59/75] * 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 60/75] * 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 61/75] * 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 62/75] 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 63/75] * 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 64/75] * 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 65/75] * 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 66/75] * 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 67/75] * 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 68/75] * 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 69/75] * 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 70/75] * 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 71/75] 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); From 57d75699d6eff414d65bd0cc704c2b86be518c94 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 7 Mar 2011 22:23:06 +0100 Subject: [PATCH 72/75] 2011-03-07 Szymon Janc * grub-core/fs/zfs/zfs.c (zap_leaf_lookup): Set-but-not-used variable removed. --- ChangeLog | 5 +++++ grub-core/fs/zfs/zfs.c | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 72d718b08..d8a8d1fc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-07 Szymon Janc + + * grub-core/fs/zfs/zfs.c (zap_leaf_lookup): + Set-but-not-used variable removed. + 2011-02-12 Vladimir Serbinenko Workaround yet another IEEE1275 bug. diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 5b575f369..3a94d8874 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -837,14 +837,12 @@ zap_leaf_lookup (zap_leaf_phys_t * l, grub_zfs_endian_t endian, name)) { struct zap_leaf_array *la; - grub_uint8_t *ip; if (le->le_int_size != 8 || le->le_value_length != 1) return grub_error (GRUB_ERR_BAD_FS, "invalid leaf chunk entry"); /* get the uint64_t property value */ la = &ZAP_LEAF_CHUNK (l, blksft, le->le_value_chunk).l_array; - ip = la->la_array; *value = grub_be_to_cpu64 (la->la_array64); From 83a3c48d3749b64eda1708f2d76efd18f2d6e487 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 9 Mar 2011 17:35:16 +0000 Subject: [PATCH 73/75] * docs/grub.texi (Simple configuration): Tidy up formatting. --- ChangeLog | 4 ++++ docs/grub.texi | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8a8d1fc2..103706af0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-09 Colin Watson + + * docs/grub.texi (Simple configuration): Tidy up formatting. + 2011-03-07 Szymon Janc * grub-core/fs/zfs/zfs.c (zap_leaf_lookup): diff --git a/docs/grub.texi b/docs/grub.texi index 590e6afb7..83bd80023 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1036,8 +1036,8 @@ it as a new default entry for use by future runs of GRUB. This is only useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because @samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with @command{grub-set-default} or @command{grub-reboot}. Unset by default. -The remarks of @pxref{Changes from GRUB Legacy} on the availability -of @samp{save_env} apply. +@samp{save_env} may not be available in all situations +(@pxref{Changes from GRUB Legacy}). @item GRUB_TIMEOUT Boot the default entry this many seconds after the menu is displayed, unless From be1a7ce0cfdd3ada7298abae16168a16bc551e96 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 9 Mar 2011 17:38:31 +0000 Subject: [PATCH 74/75] * grub-core/loader/i386/linux.c (find_efi_mmap_size): Page-align cached mmap_size, so that this works correctly when called multiple times. Reported by: Daniel Kahn Gillmor. Should fix Debian bug #616638. --- ChangeLog | 7 +++++++ grub-core/loader/i386/linux.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 103706af0..0406cf91f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-03-09 Colin Watson + + * grub-core/loader/i386/linux.c (find_efi_mmap_size): Page-align + cached mmap_size, so that this works correctly when called multiple + times. + Reported by: Daniel Kahn Gillmor. Should fix Debian bug #616638. + 2011-03-09 Colin Watson * docs/grub.texi (Simple configuration): Tidy up formatting. diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 80960570b..0178e2fd4 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -136,7 +136,8 @@ find_efi_mmap_size (void) later, and EFI itself may allocate more. */ mmap_size += (1 << 12); - return page_align (mmap_size); + mmap_size = page_align (mmap_size); + return mmap_size; } #endif From 9b43bf396a61b60a0ee4b8a1591634b1120b8906 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 11 Mar 2011 11:51:10 +0000 Subject: [PATCH 75/75] * grub-core/boot/i386/pc/lnxboot.S (real_code_2): Ensure that the initial chunk read from the kernel always includes GRUB's multiboot header, which is now outside the first sector. --- ChangeLog | 6 ++++++ grub-core/boot/i386/pc/lnxboot.S | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0406cf91f..08b937dcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-11 Colin Watson + + * grub-core/boot/i386/pc/lnxboot.S (real_code_2): Ensure that the + initial chunk read from the kernel always includes GRUB's multiboot + header, which is now outside the first sector. + 2011-03-09 Colin Watson * grub-core/loader/i386/linux.c (find_efi_mmap_size): Page-align diff --git a/grub-core/boot/i386/pc/lnxboot.S b/grub-core/boot/i386/pc/lnxboot.S index 9a599c261..2c7596026 100644 --- a/grub-core/boot/i386/pc/lnxboot.S +++ b/grub-core/boot/i386/pc/lnxboot.S @@ -178,8 +178,13 @@ real_code_2: pushw %es popw %ds +#if GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4 < 0x200 movl $0x200, %ecx addl %ecx, %esi +#else + movl $(GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4), %ecx + addl $0x200, %esi +#endif movl $DATA_ADDR, %edi call LOCAL(move_memory) @@ -196,7 +201,11 @@ real_code_2: 1: movl %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE), %ecx +#if GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4 < 0x200 addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx +#else + addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - (GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4)), %ecx +#endif 2: call LOCAL(move_memory)