From c11fded5f22b06e243006081c1c4765d6f1a8bbf Mon Sep 17 00:00:00 2001 From: phcoder Date: Sun, 23 Aug 2009 11:46:25 +0000 Subject: [PATCH 01/85] 2009-08-23 Vladimir Serbinenko * loader/i386/bsd.c (freebsd_opts): Rewritten to use extcmd. (openbsd_opts): Likewise. (netbsd_opts): Likewise. (freebsd_flags): Added 0 terminator. (openbsd_flags): Likewise. (netbsd_flags): Likewise. (grub_bsd_parse_flags): Rewritten to use extcmd. All users updated. (grub_cmd_freebsd): Transformed into extended command. (grub_cmd_openbsd): Likewise. (grub_cmd_netbsd): Likewise. (cmd_freebsd): Changed type to grub_extcmd_t. (cmd_openbsd): Likewise. (cmd_netbsd): Likewise. (GRUB_MOD_INIT (bsd)): Register grub_cmd_freebsd, grub_cmd_netbsd and grub_cmd_openbsd as extended commands. (GRUB_MOD_FINI (bsd)): Use grub_unregister_extcmd for cmd_freebsd, cmd_netbsd and cmd_openbsd --- ChangeLog | 20 ++++++++ loader/i386/bsd.c | 127 +++++++++++++++++++++++++++------------------- 2 files changed, 96 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index b72d07e88..6cf11a6c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2009-08-23 Vladimir Serbinenko + + * loader/i386/bsd.c (freebsd_opts): Rewritten to use extcmd. + (openbsd_opts): Likewise. + (netbsd_opts): Likewise. + (freebsd_flags): Added 0 terminator. + (openbsd_flags): Likewise. + (netbsd_flags): Likewise. + (grub_bsd_parse_flags): Rewritten to use extcmd. All users updated. + (grub_cmd_freebsd): Transformed into extended command. + (grub_cmd_openbsd): Likewise. + (grub_cmd_netbsd): Likewise. + (cmd_freebsd): Changed type to grub_extcmd_t. + (cmd_openbsd): Likewise. + (cmd_netbsd): Likewise. + (GRUB_MOD_INIT (bsd)): Register grub_cmd_freebsd, grub_cmd_netbsd and + grub_cmd_openbsd as extended commands. + (GRUB_MOD_FINI (bsd)): Use grub_unregister_extcmd for cmd_freebsd, + cmd_netbsd and cmd_openbsd + 2009-08-22 Vladimir Serbinenko * commands/xnu_uuid.c (transform): Use grub_memcpy instead of memcpy. diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 5badb7932..d5f677a2a 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -33,6 +33,8 @@ #include #include #include +#include + #ifdef GRUB_MACHINE_PCBIOS #include #include @@ -55,30 +57,71 @@ static char *mod_buf; static grub_uint32_t mod_buf_len, mod_buf_max, kern_end_mdofs; static int is_elf_kernel, is_64bit; -static const char freebsd_opts[] = "DhaCcdgmnpqrsv"; +static const struct grub_arg_option freebsd_opts[] = + { + {"dual", 'D', 0, "Display output on all consoles.", 0, 0}, + {"serial", 'h', 0, "Use serial console.", 0, 0}, + {"askname", 'a', 0, "Ask for file name to reboot from.", 0, 0}, + {"cdrom", 'C', 0, "Use cdrom as root.", 0, 0}, + {"config", 'c', 0, "Invoke user configuration routing.", 0, 0}, + {"kdb", 'd', 0, "Enter in KDB on boot.", 0, 0}, + {"gdb", 'g', 0, "Use GDB remote debugger instead of DDB.", 0, 0}, + {"mute", 'm', 0, "Disable all boot output.", 0, 0}, + {"nointr", 'n', 0, "", 0, 0}, + {"pause", 'p', 0, "Wait for keypress after every line of output.", 0, 0}, + {"quiet", 'q', 0, "", 0, 0}, + {"dfltroot", 'r', 0, "Use compiled-in rootdev.", 0, 0}, + {"single", 's', 0, "Boot into single mode.", 0, 0}, + {"verbose", 'v', 0, "Boot with verbose messages.", 0, 0}, + {0, 0, 0, 0, 0, 0} + }; + static const grub_uint32_t freebsd_flags[] = { FREEBSD_RB_DUAL, FREEBSD_RB_SERIAL, FREEBSD_RB_ASKNAME, FREEBSD_RB_CDROM, FREEBSD_RB_CONFIG, FREEBSD_RB_KDB, FREEBSD_RB_GDB, FREEBSD_RB_MUTE, FREEBSD_RB_NOINTR, FREEBSD_RB_PAUSE, FREEBSD_RB_QUIET, FREEBSD_RB_DFLTROOT, - FREEBSD_RB_SINGLE, FREEBSD_RB_VERBOSE + FREEBSD_RB_SINGLE, FREEBSD_RB_VERBOSE, 0 }; -static const char openbsd_opts[] = "abcsd"; +static const struct grub_arg_option openbsd_opts[] = + { + {"askname", 'a', 0, "Ask for file name to reboot from.", 0, 0}, + {"halt", 'b', 0, "Don't reboot, just halt.", 0, 0}, + {"config", 'c', 0, "Change configured devices.", 0, 0}, + {"single", 's', 0, "Boot into single mode.", 0, 0}, + {"kdb", 'd', 0, "Enter in KDB on boot.", 0, 0}, + {0, 0, 0, 0, 0, 0} + }; + static const grub_uint32_t openbsd_flags[] = { OPENBSD_RB_ASKNAME, OPENBSD_RB_HALT, OPENBSD_RB_CONFIG, - OPENBSD_RB_SINGLE, OPENBSD_RB_KDB + OPENBSD_RB_SINGLE, OPENBSD_RB_KDB, 0 }; -static const char netbsd_opts[] = "abcdmqsvxz"; +static const struct grub_arg_option netbsd_opts[] = + { + {"askname", 'a', 0, "Ask for file name to reboot from.", 0, 0}, + {"halt", 'b', 0, "Don't reboot, just halt.", 0, 0}, + {"config", 'c', 0, "Change configured devices.", 0, 0}, + {"kdb", 'd', 0, "Enter in KDB on boot.", 0, 0}, + {"miniroot", 'm', 0, "", 0, 0}, + {"quiet", 'q', 0, "Don't display boot diagnostic messages.", 0, 0}, + {"single", 's', 0, "Boot into single mode.", 0, 0}, + {"verbose", 'v', 0, "Boot with verbose messages.", 0, 0}, + {"debug", 'x', 0, "Boot with debug messages.", 0, 0}, + {"silent", 'z', 0, "Supress normal output (warnings remain).", 0, 0}, + {0, 0, 0, 0, 0, 0} + }; + static const grub_uint32_t netbsd_flags[] = { NETBSD_RB_ASKNAME, NETBSD_RB_HALT, NETBSD_RB_USERCONFIG, NETBSD_RB_KDB, NETBSD_RB_MINIROOT, NETBSD_AB_QUIET, NETBSD_RB_SINGLE, NETBSD_AB_VERBOSE, NETBSD_AB_DEBUG, - NETBSD_AB_SILENT + NETBSD_AB_SILENT, 0 }; static void @@ -785,41 +828,24 @@ fail: } static grub_uint32_t -grub_bsd_parse_flags (char *str, const char *opts, +grub_bsd_parse_flags (const struct grub_arg_list *state, const grub_uint32_t * flags) { grub_uint32_t result = 0; + unsigned i; - while (*str) - { - const char *po; - const grub_uint32_t *pf; - - po = opts; - pf = flags; - while (*po) - { - if (*str == *po) - { - result |= *pf; - break; - } - po++; - pf++; - } - str++; - } + for (i = 0; flags[i]; i++) + if (state[i].set) + result |= flags[i]; return result; } static grub_err_t -grub_cmd_freebsd (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) +grub_cmd_freebsd (grub_extcmd_t cmd, int argc, char *argv[]) { kernel_type = KERNEL_TYPE_FREEBSD; - bootflags = ((argc <= 1) ? 0 : - grub_bsd_parse_flags (argv[1], freebsd_opts, freebsd_flags)); + bootflags = grub_bsd_parse_flags (cmd->state, freebsd_flags); if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE) { @@ -879,12 +905,10 @@ grub_cmd_freebsd (grub_command_t cmd __attribute__ ((unused)), } static grub_err_t -grub_cmd_openbsd (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) +grub_cmd_openbsd (grub_extcmd_t cmd, int argc, char *argv[]) { kernel_type = KERNEL_TYPE_OPENBSD; - bootflags = ((argc <= 1) ? 0 : - grub_bsd_parse_flags (argv[1], openbsd_opts, openbsd_flags)); + bootflags = grub_bsd_parse_flags (cmd->state, openbsd_flags); if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE) grub_loader_set (grub_openbsd_boot, grub_bsd_unload, 1); @@ -893,12 +917,10 @@ grub_cmd_openbsd (grub_command_t cmd __attribute__ ((unused)), } static grub_err_t -grub_cmd_netbsd (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) +grub_cmd_netbsd (grub_extcmd_t cmd, int argc, char *argv[]) { kernel_type = KERNEL_TYPE_NETBSD; - bootflags = ((argc <= 1) ? 0 : - grub_bsd_parse_flags (argv[1], netbsd_opts, netbsd_flags)); + bootflags = grub_bsd_parse_flags (cmd->state, netbsd_flags); if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE) grub_loader_set (grub_netbsd_boot, grub_bsd_unload, 1); @@ -1112,21 +1134,24 @@ grub_cmd_freebsd_module_elf (grub_command_t cmd __attribute__ ((unused)), } -static grub_command_t cmd_freebsd, cmd_openbsd, cmd_netbsd; +static grub_extcmd_t cmd_freebsd, cmd_openbsd, cmd_netbsd; static grub_command_t cmd_freebsd_loadenv, cmd_freebsd_module; static grub_command_t cmd_freebsd_module_elf; GRUB_MOD_INIT (bsd) { - cmd_freebsd = - grub_register_command ("freebsd", grub_cmd_freebsd, - 0, "load kernel of FreeBSD"); - cmd_openbsd = - grub_register_command ("openbsd", grub_cmd_openbsd, - 0, "load kernel of OpenBSD"); - cmd_netbsd = - grub_register_command ("netbsd", grub_cmd_netbsd, - 0, "load kernel of NetBSD"); + cmd_freebsd = grub_register_extcmd ("freebsd", grub_cmd_freebsd, + GRUB_COMMAND_FLAG_BOTH, + "freebsd FILE", "Load kernel of FreeBSD.", + freebsd_opts); + cmd_openbsd = grub_register_extcmd ("openbsd", grub_cmd_openbsd, + GRUB_COMMAND_FLAG_BOTH, + "openbsd FILE", "Load kernel of OpenBSD.", + openbsd_opts); + cmd_netbsd = grub_register_extcmd ("netbsd", grub_cmd_netbsd, + GRUB_COMMAND_FLAG_BOTH, + "netbsd FILE", "Load kernel of NetBSD.", + netbsd_opts); cmd_freebsd_loadenv = grub_register_command ("freebsd_loadenv", grub_cmd_freebsd_loadenv, 0, "load FreeBSD env"); @@ -1142,9 +1167,9 @@ GRUB_MOD_INIT (bsd) GRUB_MOD_FINI (bsd) { - grub_unregister_command (cmd_freebsd); - grub_unregister_command (cmd_openbsd); - grub_unregister_command (cmd_netbsd); + grub_unregister_extcmd (cmd_freebsd); + grub_unregister_extcmd (cmd_openbsd); + grub_unregister_extcmd (cmd_netbsd); grub_unregister_command (cmd_freebsd_loadenv); grub_unregister_command (cmd_freebsd_module); From 71acf5e54bfceef23af245ff8c64979c5efdb4ba Mon Sep 17 00:00:00 2001 From: robertmh Date: Sun, 23 Aug 2009 12:00:57 +0000 Subject: [PATCH 02/85] 2009-08-23 Robert Millan * partmap/pc.c: Rename to ... * partmap/msdos.c: ... this. Update all users. (grub_pc_partition_map): Rename to ... (grub_msdos_partition_map): ... this. Update all users. * parttool/pcpart.c: Rename to ... * parttool/msdospart.c: ... this. Update all users. * include/grub/pc_partition.h: Rename to ... * include/grub/msdos_partition.h: ... this. Update all users. (grub_pc_partition_bsd_entry): Rename to ... (grub_msdos_partition_bsd_entry): ... this. Update all users. (grub_pc_partition_disk_label): Rename to ... (grub_msdos_partition_disk_label): ... this. Update all users. (grub_pc_partition_entry): Rename to ... (grub_msdos_partition_entry): ... this. Update all users. (grub_pc_partition_mbr): Rename to ... (grub_msdos_partition_mbr): ... this. Update all users. (grub_pc_partition): Rename to ... (grub_msdos_partition): ... this. Update all users. (grub_pc_partition_is_empty): Rename to ... (grub_msdos_partition_is_empty): ... this. Update all users. (grub_pc_partition_is_extended): Rename to ... (grub_msdos_partition_is_extended): ... this. Update all users. (grub_pc_partition_is_bsd): Rename to ... (grub_msdos_partition_is_bsd): ... this. Update all users. * conf/common.rmk (amiga_mod_SOURCES, amiga_mod_CFLAGS) (amiga_mod_LDFLAGS, apple_mod_SOURCES, apple_mod_CFLAGS) (apple_mod_LDFLAGS, msdos_mod_SOURCES, msdos_mod_CFLAGS) (msdos_mod_LDFLAGS, sun_mod_SOURCES, sun_mod_CFLAGS) (sun_mod_LDFLAGS, acorn_mod_SOURCES, acorn_mod_CFLAGS) (acorn_mod_LDFLAGS, gpt_mod_SOURCES, gpt_mod_CFLAGS) (gpt_mod_LDFLAGS): Rename to ... (part_amiga_mod_SOURCES, part_amiga_mod_CFLAGS, part_amiga_mod_LDFLAGS) (part_apple_mod_SOURCES, part_apple_mod_CFLAGS, part_apple_mod_LDFLAGS) (part_msdos_mod_SOURCES, part_msdos_mod_CFLAGS, part_msdos_mod_LDFLAGS) (part_sun_mod_SOURCES, part_sun_mod_CFLAGS, part_sun_mod_LDFLAGS) (part_acorn_mod_SOURCES, part_acorn_mod_CFLAGS, part_acorn_mod_LDFLAGS) (part_gpt_mod_SOURCES, part_gpt_mod_CFLAGS) (part_gpt_mod_LDFLAGS): ... this. (pkglib_MODULES): Prefix partition modules with `part_'. Rename `pcpart.mod' to `msdospart.mod'. (pcpart_mod_SOURCES, pcpart_mod_CFLAGS, pcpart_mod_LDFLAGS): Rename to ... (msdospart_mod_SOURCES, msdospart_mod_CFLAGS) (msdospart_mod_LDFLAGS): ... this. --- ChangeLog | 50 +++++++++++++++ commands/gptsync.c | 4 +- conf/common.rmk | 63 +++++++++---------- conf/i386-coreboot.rmk | 8 +-- conf/i386-efi.rmk | 8 +-- conf/i386-ieee1275.rmk | 4 +- conf/i386-pc.rmk | 8 +-- conf/powerpc-ieee1275.rmk | 6 +- conf/sparc64-ieee1275.rmk | 8 +-- conf/x86_64-efi.rmk | 8 +-- .../{pc_partition.h => msdos_partition.h} | 20 +++--- include/grub/partition.h | 4 +- partmap/gpt.c | 4 +- partmap/{pc.c => msdos.c} | 44 ++++++------- parttool/{pcpart.c => msdospart.c} | 14 ++--- util/grub-probe.c | 2 +- util/hostdisk.c | 6 +- util/i386/pc/grub-setup.c | 16 ++--- util/sparc64/ieee1275/grub-setup.c | 2 +- 19 files changed, 164 insertions(+), 115 deletions(-) rename include/grub/{pc_partition.h => msdos_partition.h} (93%) rename partmap/{pc.c => msdos.c} (86%) rename parttool/{pcpart.c => msdospart.c} (91%) diff --git a/ChangeLog b/ChangeLog index 6cf11a6c8..ba1fdfef9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,53 @@ +2009-08-23 Robert Millan + + * partmap/pc.c: Rename to ... + * partmap/msdos.c: ... this. Update all users. + (grub_pc_partition_map): Rename to ... + (grub_msdos_partition_map): ... this. Update all users. + + * parttool/pcpart.c: Rename to ... + * parttool/msdospart.c: ... this. Update all users. + + * include/grub/pc_partition.h: Rename to ... + * include/grub/msdos_partition.h: ... this. Update all users. + (grub_pc_partition_bsd_entry): Rename to ... + (grub_msdos_partition_bsd_entry): ... this. Update all users. + (grub_pc_partition_disk_label): Rename to ... + (grub_msdos_partition_disk_label): ... this. Update all users. + (grub_pc_partition_entry): Rename to ... + (grub_msdos_partition_entry): ... this. Update all users. + (grub_pc_partition_mbr): Rename to ... + (grub_msdos_partition_mbr): ... this. Update all users. + (grub_pc_partition): Rename to ... + (grub_msdos_partition): ... this. Update all users. + (grub_pc_partition_is_empty): Rename to ... + (grub_msdos_partition_is_empty): ... this. Update all users. + (grub_pc_partition_is_extended): Rename to ... + (grub_msdos_partition_is_extended): ... this. Update all users. + (grub_pc_partition_is_bsd): Rename to ... + (grub_msdos_partition_is_bsd): ... this. Update all users. + + * conf/common.rmk (amiga_mod_SOURCES, amiga_mod_CFLAGS) + (amiga_mod_LDFLAGS, apple_mod_SOURCES, apple_mod_CFLAGS) + (apple_mod_LDFLAGS, msdos_mod_SOURCES, msdos_mod_CFLAGS) + (msdos_mod_LDFLAGS, sun_mod_SOURCES, sun_mod_CFLAGS) + (sun_mod_LDFLAGS, acorn_mod_SOURCES, acorn_mod_CFLAGS) + (acorn_mod_LDFLAGS, gpt_mod_SOURCES, gpt_mod_CFLAGS) + (gpt_mod_LDFLAGS): Rename to ... + (part_amiga_mod_SOURCES, part_amiga_mod_CFLAGS, part_amiga_mod_LDFLAGS) + (part_apple_mod_SOURCES, part_apple_mod_CFLAGS, part_apple_mod_LDFLAGS) + (part_msdos_mod_SOURCES, part_msdos_mod_CFLAGS, part_msdos_mod_LDFLAGS) + (part_sun_mod_SOURCES, part_sun_mod_CFLAGS, part_sun_mod_LDFLAGS) + (part_acorn_mod_SOURCES, part_acorn_mod_CFLAGS, part_acorn_mod_LDFLAGS) + (part_gpt_mod_SOURCES, part_gpt_mod_CFLAGS) + (part_gpt_mod_LDFLAGS): ... this. + (pkglib_MODULES): Prefix partition modules with `part_'. Rename + `pcpart.mod' to `msdospart.mod'. + (pcpart_mod_SOURCES, pcpart_mod_CFLAGS, pcpart_mod_LDFLAGS): Rename + to ... + (msdospart_mod_SOURCES, msdospart_mod_CFLAGS) + (msdospart_mod_LDFLAGS): ... this. + 2009-08-23 Vladimir Serbinenko * loader/i386/bsd.c (freebsd_opts): Rewritten to use extcmd. diff --git a/commands/gptsync.c b/commands/gptsync.c index 600309f70..a603746a2 100644 --- a/commands/gptsync.c +++ b/commands/gptsync.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -60,7 +60,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) { grub_device_t dev; - struct grub_pc_partition_mbr mbr; + struct grub_msdos_partition_mbr mbr; struct grub_partition *partition; grub_disk_addr_t first_sector; int numactive = 0; diff --git a/conf/common.rmk b/conf/common.rmk index b0d3785d1..c33e8000a 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -19,7 +19,7 @@ grub_probe_SOURCES = util/grub-probe.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ - partmap/pc.c partmap/apple.c partmap/sun.c partmap/gpt.c\ + partmap/msdos.c partmap/apple.c partmap/sun.c partmap/gpt.c\ kern/fs.c kern/env.c fs/fshelp.c \ disk/raid.c disk/mdraid_linux.c disk/lvm.c grub_probe_init.c @@ -40,7 +40,7 @@ grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ - kern/partition.c partmap/pc.c partmap/apple.c partmap/sun.c \ + kern/partition.c partmap/msdos.c partmap/apple.c partmap/sun.c \ partmap/gpt.c \ kern/fs.c kern/env.c fs/fshelp.c disk/raid.c \ disk/raid5_recover.c disk/raid6_recover.c \ @@ -285,37 +285,36 @@ befs_mod_CFLAGS = $(COMMON_CFLAGS) befs_mod_LDFLAGS = $(COMMON_LDFLAGS) # Partition maps. -pkglib_MODULES += amiga.mod apple.mod pc.mod sun.mod acorn.mod gpt.mod -# For amiga.mod -amiga_mod_SOURCES = partmap/amiga.c -amiga_mod_CFLAGS = $(COMMON_CFLAGS) -amiga_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += part_amiga.mod +part_amiga_mod_SOURCES = partmap/amiga.c +part_amiga_mod_CFLAGS = $(COMMON_CFLAGS) +part_amiga_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For apple.mod -apple_mod_SOURCES = partmap/apple.c -apple_mod_CFLAGS = $(COMMON_CFLAGS) -apple_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += part_apple.mod +part_apple_mod_SOURCES = partmap/apple.c +part_apple_mod_CFLAGS = $(COMMON_CFLAGS) +part_apple_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For pc.mod -pc_mod_SOURCES = partmap/pc.c -pc_mod_CFLAGS = $(COMMON_CFLAGS) -pc_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += part_msdos.mod +part_msdos_mod_SOURCES = partmap/msdos.c +part_msdos_mod_CFLAGS = $(COMMON_CFLAGS) +part_msdos_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For sun.mod -sun_mod_SOURCES = partmap/sun.c -sun_mod_CFLAGS = $(COMMON_CFLAGS) -sun_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += part_sun.mod +part_sun_mod_SOURCES = partmap/sun.c +part_sun_mod_CFLAGS = $(COMMON_CFLAGS) +part_sun_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For acorn.mod -acorn_mod_SOURCES = partmap/acorn.c -acorn_mod_CFLAGS = $(COMMON_CFLAGS) -acorn_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += part_acorn.mod +part_acorn_mod_SOURCES = partmap/acorn.c +part_acorn_mod_CFLAGS = $(COMMON_CFLAGS) +part_acorn_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For gpt.mod -gpt_mod_SOURCES = partmap/gpt.c -gpt_mod_CFLAGS = $(COMMON_CFLAGS) -gpt_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += part_gpt.mod +part_gpt_mod_SOURCES = partmap/gpt.c +part_gpt_mod_CFLAGS = $(COMMON_CFLAGS) +part_gpt_mod_LDFLAGS = $(COMMON_LDFLAGS) # Special disk structures and generic drivers @@ -363,7 +362,7 @@ pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \ fs_file.mod fs_uuid.mod configfile.mod echo.mod \ terminfo.mod test.mod blocklist.mod hexdump.mod \ read.mod sleep.mod loadenv.mod crc.mod parttool.mod \ - pcpart.mod memrw.mod normal.mod sh.mod lua.mod \ + msdospart.mod memrw.mod normal.mod sh.mod lua.mod \ gptsync.mod true.mod probe.mod # For gptsync.mod. @@ -391,10 +390,10 @@ parttool_mod_SOURCES = commands/parttool.c parttool_mod_CFLAGS = $(COMMON_CFLAGS) parttool_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For pcpart.mod. -pcpart_mod_SOURCES = parttool/pcpart.c -pcpart_mod_CFLAGS = $(COMMON_CFLAGS) -pcpart_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For msdospart.mod. +msdospart_mod_SOURCES = parttool/msdospart.c +msdospart_mod_CFLAGS = $(COMMON_CFLAGS) +msdospart_mod_LDFLAGS = $(COMMON_LDFLAGS) # For handler.mod. handler_mod_SOURCES = commands/handler.c diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index ce2576b95..de3004140 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -32,7 +32,7 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \ symlist.c kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ - partition.h pc_partition.h reader.h symbol.h term.h time.h types.h \ + partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \ machine/boot.h machine/console.h machine/init.h \ machine/memory.h machine/loader.h list.h handler.h command.h kernel_img_CFLAGS = $(COMMON_CFLAGS) @@ -75,7 +75,7 @@ kernel_img_SOURCES = kern/i386/qemu/startup.S \ symlist.c kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ - partition.h pc_partition.h reader.h symbol.h term.h time.h types.h \ + partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \ machine/boot.h machine/console.h machine/init.h \ machine/memory.h machine/loader.h list.h handler.h command.h kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR) @@ -134,14 +134,14 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ normal/color.c \ script/sh/main.c script/sh/execute.c script/sh/function.c \ script/sh/lexer.c script/sh/script.c grub_script.tab.c \ - partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ + partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \ partmap/acorn.c partmap/gpt.c \ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/hostdisk.c util/getroot.c \ \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - commands/parttool.c parttool/pcpart.c \ + commands/parttool.c parttool/msdospart.c \ grub_emu_init.c grub_emu_LDFLAGS = $(LIBCURSES) diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index 6e3cbcf6d..372d8fc58 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -23,7 +23,7 @@ util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile #grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \ # util/misc.c util/getroot.c kern/device.c kern/disk.c \ # kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \ -# fs/sfs.c kern/parser.c kern/partition.c partmap/pc.c \ +# fs/sfs.c kern/parser.c kern/partition.c partmap/msdos.c \ # fs/ufs.c fs/ufs2.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \ # kern/fs.c kern/env.c fs/fshelp.c @@ -61,14 +61,14 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ normal/color.c \ script/sh/main.c script/sh/execute.c script/sh/function.c \ script/sh/lexer.c script/sh/script.c grub_script.tab.c \ - partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ + partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \ partmap/acorn.c partmap/gpt.c \ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/hostdisk.c util/getroot.c \ \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - commands/parttool.c parttool/pcpart.c \ + commands/parttool.c parttool/msdospart.c \ grub_emu_init.c grub_emu_LDFLAGS = $(LIBCURSES) @@ -100,7 +100,7 @@ kernel_mod_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.c \ kern/generic/millisleep.c kernel_mod_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ - partition.h pc_partition.h reader.h symbol.h term.h time.h types.h \ + partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \ efi/efi.h efi/time.h efi/disk.h i386/pit.h list.h handler.h command.h kernel_mod_CFLAGS = $(COMMON_CFLAGS) kernel_mod_ASFLAGS = $(COMMON_ASFLAGS) diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk index 65d1c6bde..98aaf5849 100644 --- a/conf/i386-ieee1275.rmk +++ b/conf/i386-ieee1275.rmk @@ -31,7 +31,7 @@ kernel_img_SOURCES = kern/i386/ieee1275/startup.S \ symlist.c kernel_img_HEADERS = cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ - partition.h pc_partition.h reader.h symbol.h term.h time.h types.h \ + partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \ ieee1275/ieee1275.h machine/kernel.h machine/loader.h machine/memory.h \ list.h handler.h command.h kernel_img_CFLAGS = $(COMMON_CFLAGS) @@ -88,7 +88,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ normal/color.c \ script/sh/main.c script/sh/execute.c script/sh/function.c \ script/sh/lexer.c script/sh/script.c grub_script.tab.c \ - partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ + partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \ partmap/acorn.c partmap/gpt.c \ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/hostdisk.c util/getroot.c \ diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 0ef5e4730..13aaa2618 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -61,7 +61,7 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \ symlist.c kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ - partition.h pc_partition.h reader.h symbol.h term.h time.h types.h \ + partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \ machine/biosdisk.h machine/boot.h machine/console.h machine/init.h \ machine/memory.h machine/loader.h machine/vga.h machine/vbe.h \ machine/kernel.h machine/pxe.h i386/pit.h list.h handler.h command.h @@ -104,7 +104,7 @@ grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ - partmap/pc.c partmap/gpt.c \ + partmap/msdos.c partmap/gpt.c \ \ disk/raid.c disk/mdraid_linux.c disk/lvm.c \ util/raid.c util/lvm.c \ @@ -140,7 +140,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ normal/menu_text.c \ script/sh/main.c script/sh/execute.c script/sh/function.c \ script/sh/lexer.c script/sh/script.c grub_script.tab.c \ - partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ + partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \ partmap/acorn.c partmap/gpt.c \ \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ @@ -153,7 +153,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - commands/parttool.c parttool/pcpart.c \ + commands/parttool.c parttool/msdospart.c \ grub_emu_init.c grub_emu_LDFLAGS = $(LIBCURSES) diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index c30f61a48..c1c04e484 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -16,7 +16,7 @@ DEFSYMFILES += kernel_syms.lst kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h misc.h mm.h net.h parser.h reader.h \ symbol.h term.h time.h types.h powerpc/libgcc.h loader.h partition.h \ - pc_partition.h ieee1275/ieee1275.h machine/kernel.h handler.h list.h \ + msdos_partition.h ieee1275/ieee1275.h machine/kernel.h handler.h list.h \ command.h symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh @@ -69,14 +69,14 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ normal/color.c \ script/sh/main.c script/sh/execute.c script/sh/function.c \ script/sh/lexer.c script/sh/script.c \ - partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ + partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \ partmap/acorn.c \ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/hostdisk.c util/getroot.c \ \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - commands/parttool.c parttool/pcpart.c \ + commands/parttool.c parttool/msdospart.c \ grub_script.tab.c grub_emu_init.c grub_emu_LDFLAGS = $(LIBCURSES) diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index b26496d20..c3ecba28f 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -28,7 +28,7 @@ DEFSYMFILES += kernel_syms.lst kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ - partition.h pc_partition.h reader.h symbol.h term.h time.h types.h \ + partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \ list.h handler.h command.h \ sparc64/libgcc.h ieee1275/ieee1275.h machine/kernel.h \ sparc64/ieee1275/ieee1275.h @@ -80,7 +80,7 @@ grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ \ - partmap/amiga.c partmap/apple.c partmap/pc.c \ + partmap/amiga.c partmap/apple.c partmap/msdos.c \ partmap/sun.c partmap/acorn.c \ \ disk/raid.c disk/mdraid_linux.c disk/lvm.c \ @@ -126,14 +126,14 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ normal/color.c \ script/sh/main.c script/sh/execute.c script/sh/function.c \ script/sh/lexer.c script/sh/script.c \ - partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ + partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \ partmap/acorn.c \ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/hostdisk.c util/getroot.c \ \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - commands/parttool.c parttool/pcpart.c \ + commands/parttool.c parttool/msdospart.c \ grub_script.tab.c grub_emu_init.c grub_emu_LDFLAGS = $(LIBCURSES) diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index 71a90ce18..c914fbf19 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -22,7 +22,7 @@ grub_mkimage_SOURCES = util/i386/efi/grub-mkimage.c util/misc.c \ #grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \ # util/misc.c util/getroot.c kern/device.c kern/disk.c \ # kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \ -# fs/sfs.c kern/parser.c kern/partition.c partmap/pc.c \ +# fs/sfs.c kern/parser.c kern/partition.c partmap/msdos.c \ # fs/ufs.c fs/ufs2.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \ # kern/fs.c kern/env.c fs/fshelp.c @@ -58,14 +58,14 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ normal/color.c \ script/sh/main.c script/sh/execute.c script/sh/function.c \ script/sh/lexer.c script/sh/script.c grub_script.tab.c \ - partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ + partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \ partmap/acorn.c partmap/gpt.c \ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/hostdisk.c util/getroot.c \ \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - commands/parttool.c parttool/pcpart.c \ + commands/parttool.c parttool/msdospart.c \ grub_emu_init.c grub_emu_LDFLAGS = $(LIBCURSES) @@ -97,7 +97,7 @@ kernel_mod_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \ term/efi/console.c disk/efi/efidisk.c kernel_mod_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ - partition.h pc_partition.h reader.h symbol.h term.h time.h types.h \ + partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \ efi/efi.h efi/time.h efi/disk.h machine/loader.h i386/pit.h list.h \ handler.h command.h kernel_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/include/grub/pc_partition.h b/include/grub/msdos_partition.h similarity index 93% rename from include/grub/pc_partition.h rename to include/grub/msdos_partition.h index 67c312e64..273d8c95e 100644 --- a/include/grub/pc_partition.h +++ b/include/grub/msdos_partition.h @@ -99,7 +99,7 @@ #define GRUB_PC_PARTITION_OPENBSD_TYPE_RAID 19 /* The BSD partition entry. */ -struct grub_pc_partition_bsd_entry +struct grub_msdos_partition_bsd_entry { grub_uint32_t size; grub_uint32_t offset; @@ -110,7 +110,7 @@ struct grub_pc_partition_bsd_entry } __attribute__ ((packed)); /* The BSD disk label. Only define members useful for GRUB. */ -struct grub_pc_partition_disk_label +struct grub_msdos_partition_disk_label { grub_uint32_t magic; grub_uint8_t padding[128]; @@ -119,11 +119,11 @@ struct grub_pc_partition_disk_label grub_uint16_t num_partitions; grub_uint32_t boot_size; grub_uint32_t superblock_size; - struct grub_pc_partition_bsd_entry entries[GRUB_PC_PARTITION_BSD_MAX_ENTRIES]; + struct grub_msdos_partition_bsd_entry entries[GRUB_PC_PARTITION_BSD_MAX_ENTRIES]; } __attribute__ ((packed)); /* The partition entry. */ -struct grub_pc_partition_entry +struct grub_msdos_partition_entry { /* If active, 0x80, otherwise, 0x00. */ grub_uint8_t flag; @@ -155,20 +155,20 @@ struct grub_pc_partition_entry } __attribute__ ((packed)); /* The structure of MBR. */ -struct grub_pc_partition_mbr +struct grub_msdos_partition_mbr { /* The code area (actually, including BPB). */ grub_uint8_t code[446]; /* Four partition entries. */ - struct grub_pc_partition_entry entries[4]; + struct grub_msdos_partition_entry entries[4]; /* The signature 0xaa55. */ grub_uint16_t signature; } __attribute__ ((packed)); -struct grub_pc_partition +struct grub_msdos_partition { /* The DOS partition number. */ int dos_part; @@ -187,13 +187,13 @@ struct grub_pc_partition }; static inline int -grub_pc_partition_is_empty (int type) +grub_msdos_partition_is_empty (int type) { return (type == GRUB_PC_PARTITION_TYPE_NONE); } static inline int -grub_pc_partition_is_extended (int type) +grub_msdos_partition_is_extended (int type) { return (type == GRUB_PC_PARTITION_TYPE_EXTENDED || type == GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED @@ -201,7 +201,7 @@ grub_pc_partition_is_extended (int type) } static inline int -grub_pc_partition_is_bsd (int type) +grub_msdos_partition_is_bsd (int type) { return (type == GRUB_PC_PARTITION_TYPE_FREEBSD || type == GRUB_PC_PARTITION_TYPE_OPENBSD diff --git a/include/grub/partition.h b/include/grub/partition.h index 37c5f2403..d35658cdd 100644 --- a/include/grub/partition.h +++ b/include/grub/partition.h @@ -84,8 +84,8 @@ void EXPORT_FUNC(grub_partition_map_register) (grub_partition_map_t partmap); void EXPORT_FUNC(grub_partition_map_unregister) (grub_partition_map_t partmap); #ifdef GRUB_UTIL -void grub_pc_partition_map_init (void); -void grub_pc_partition_map_fini (void); +void grub_msdos_partition_map_init (void); +void grub_msdos_partition_map_fini (void); void grub_amiga_partition_map_init (void); void grub_amiga_partition_map_fini (void); void grub_apple_partition_map_init (void); diff --git a/partmap/gpt.c b/partmap/gpt.c index d646d41b8..e860f35da 100644 --- a/partmap/gpt.c +++ b/partmap/gpt.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include static grub_uint8_t grub_gpt_magic[8] = @@ -45,7 +45,7 @@ gpt_partition_map_iterate (grub_disk_t disk, struct grub_gpt_header gpt; struct grub_gpt_partentry entry; struct grub_disk raw; - struct grub_pc_partition_mbr mbr; + struct grub_msdos_partition_mbr mbr; grub_uint64_t entries; unsigned int i; int last_offset = 0; diff --git a/partmap/pc.c b/partmap/msdos.c similarity index 86% rename from partmap/pc.c rename to partmap/msdos.c index 6a2efd21e..9fc620df0 100644 --- a/partmap/pc.c +++ b/partmap/msdos.c @@ -18,13 +18,13 @@ */ #include -#include +#include #include #include #include #include -static struct grub_partition_map grub_pc_partition_map; +static struct grub_partition_map grub_msdos_partition_map; /* Parse the partition representation in STR and return a partition. */ @@ -32,7 +32,7 @@ static grub_partition_t grub_partition_parse (const char *str) { grub_partition_t p; - struct grub_pc_partition *pcdata; + struct grub_msdos_partition *pcdata; char *s = (char *) str; @@ -40,12 +40,12 @@ grub_partition_parse (const char *str) if (! p) return 0; - pcdata = (struct grub_pc_partition *) grub_malloc (sizeof (*pcdata)); + pcdata = (struct grub_msdos_partition *) grub_malloc (sizeof (*pcdata)); if (! pcdata) goto fail; p->data = pcdata; - p->partmap = &grub_pc_partition_map; + p->partmap = &grub_msdos_partition_map; /* Initialize some of the fields with invalid values. */ pcdata->bsd_part = pcdata->dos_type = pcdata->bsd_type = p->index = -1; @@ -93,9 +93,9 @@ pc_partition_map_iterate (grub_disk_t disk, const grub_partition_t partition)) { struct grub_partition p; - struct grub_pc_partition pcdata; - struct grub_pc_partition_mbr mbr; - struct grub_pc_partition_disk_label label; + struct grub_msdos_partition pcdata; + struct grub_msdos_partition_mbr mbr; + struct grub_msdos_partition_disk_label label; struct grub_disk raw; /* Enforce raw disk access. */ @@ -106,12 +106,12 @@ pc_partition_map_iterate (grub_disk_t disk, pcdata.ext_offset = 0; pcdata.dos_part = -1; p.data = &pcdata; - p.partmap = &grub_pc_partition_map; + p.partmap = &grub_msdos_partition_map; while (1) { int i; - struct grub_pc_partition_entry *e; + struct grub_msdos_partition_entry *e; /* Read the MBR. */ if (grub_disk_read (&raw, p.offset, 0, sizeof (mbr), &mbr)) @@ -147,8 +147,8 @@ pc_partition_map_iterate (grub_disk_t disk, return grub_error (GRUB_ERR_BAD_PART_TABLE, "dummy mbr"); /* If this partition is a normal one, call the hook. */ - if (! grub_pc_partition_is_empty (e->type) - && ! grub_pc_partition_is_extended (e->type)) + if (! grub_msdos_partition_is_empty (e->type) + && ! grub_msdos_partition_is_extended (e->type)) { pcdata.dos_part++; @@ -156,7 +156,7 @@ pc_partition_map_iterate (grub_disk_t disk, return 1; /* Check if this is a BSD partition. */ - if (grub_pc_partition_is_bsd (e->type)) + if (grub_msdos_partition_is_bsd (e->type)) { /* Check if the BSD label is within the DOS partition. */ if (p.len <= GRUB_PC_PARTITION_BSD_LABEL_SECTOR) @@ -186,7 +186,7 @@ pc_partition_map_iterate (grub_disk_t disk, pcdata.bsd_part < grub_cpu_to_le16 (label.num_partitions); pcdata.bsd_part++) { - struct grub_pc_partition_bsd_entry *be + struct grub_msdos_partition_bsd_entry *be = label.entries + pcdata.bsd_part; p.start = grub_le_to_cpu32 (be->offset); @@ -210,7 +210,7 @@ pc_partition_map_iterate (grub_disk_t disk, { e = mbr.entries + i; - if (grub_pc_partition_is_extended (e->type)) + if (grub_msdos_partition_is_extended (e->type)) { p.offset = pcdata.ext_offset + grub_le_to_cpu32 (e->start); if (! pcdata.ext_offset) @@ -234,14 +234,14 @@ static grub_partition_t pc_partition_map_probe (grub_disk_t disk, const char *str) { grub_partition_t p; - struct grub_pc_partition *pcdata; + struct grub_msdos_partition *pcdata; auto int find_func (grub_disk_t d, const grub_partition_t partition); int find_func (grub_disk_t d __attribute__ ((unused)), const grub_partition_t partition) { - struct grub_pc_partition *partdata = partition->data; + struct grub_msdos_partition *partdata = partition->data; if ((pcdata->dos_part == partdata->dos_part || pcdata->dos_part == -1) && pcdata->bsd_part == partdata->bsd_part) @@ -283,7 +283,7 @@ static char * pc_partition_map_get_name (const grub_partition_t p) { char *name; - struct grub_pc_partition *pcdata = p->data; + struct grub_msdos_partition *pcdata = p->data; name = grub_malloc (13); if (! name) @@ -301,9 +301,9 @@ pc_partition_map_get_name (const grub_partition_t p) /* Partition map type. */ -static struct grub_partition_map grub_pc_partition_map = +static struct grub_partition_map grub_msdos_partition_map = { - .name = "pc_partition_map", + .name = "msdos_partition_map", .iterate = pc_partition_map_iterate, .probe = pc_partition_map_probe, .get_name = pc_partition_map_get_name @@ -311,10 +311,10 @@ static struct grub_partition_map grub_pc_partition_map = GRUB_MOD_INIT(pc_partition_map) { - grub_partition_map_register (&grub_pc_partition_map); + grub_partition_map_register (&grub_msdos_partition_map); } GRUB_MOD_FINI(pc_partition_map) { - grub_partition_map_unregister (&grub_pc_partition_map); + grub_partition_map_unregister (&grub_msdos_partition_map); } diff --git a/parttool/pcpart.c b/parttool/msdospart.c similarity index 91% rename from parttool/pcpart.c rename to parttool/msdospart.c index 6876d0d58..1bb9cd3e1 100644 --- a/parttool/pcpart.c +++ b/parttool/msdospart.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,7 +42,7 @@ static grub_err_t grub_pcpart_boot (const grub_device_t dev, { int i, index; grub_partition_t part; - struct grub_pc_partition_mbr mbr; + struct grub_msdos_partition_mbr mbr; if (dev->disk->partition->offset) return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a primary partition"); @@ -92,7 +92,7 @@ static grub_err_t grub_pcpart_type (const grub_device_t dev, int index; grub_uint8_t type; grub_partition_t part; - struct grub_pc_partition_mbr mbr; + struct grub_msdos_partition_mbr mbr; index = dev->disk->partition->index; part = dev->disk->partition; @@ -119,8 +119,8 @@ static grub_err_t grub_pcpart_type (const grub_device_t dev, type &= ~GRUB_PC_PARTITION_TYPE_HIDDEN_FLAG; } - if (grub_pc_partition_is_empty (type) - || grub_pc_partition_is_extended (type)) + if (grub_msdos_partition_is_empty (type) + || grub_msdos_partition_is_extended (type)) { dev->disk->partition = part; return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid type"); @@ -140,10 +140,10 @@ static grub_err_t grub_pcpart_type (const grub_device_t dev, GRUB_MOD_INIT (pcpart) { - activate_table_handle = grub_parttool_register ("pc_partition_map", + activate_table_handle = grub_parttool_register ("msdos_partition_map", grub_pcpart_boot, grub_pcpart_bootargs); - type_table_handle = grub_parttool_register ("pc_partition_map", + type_table_handle = grub_parttool_register ("msdos_partition_map", grub_pcpart_type, grub_pcpart_typeargs); diff --git a/util/grub-probe.c b/util/grub-probe.c index 0088028f5..7c63f64ef 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/util/hostdisk.c b/util/hostdisk.c index fdf35148f..8a3e2ef1f 100644 --- a/util/hostdisk.c +++ b/util/hostdisk.c @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -947,9 +947,9 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) int find_partition (grub_disk_t disk __attribute__ ((unused)), const grub_partition_t partition) { - struct grub_pc_partition *pcdata = NULL; + struct grub_msdos_partition *pcdata = NULL; - if (strcmp (partition->partmap->name, "pc_partition_map") == 0) + if (strcmp (partition->partmap->name, "msdos_partition_map") == 0) pcdata = partition->data; if (pcdata) diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c index 92c69ef15..0dc2e2c31 100644 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -121,14 +121,14 @@ setup (const char *dir, int NESTED_FUNC_ATTR find_usable_region_msdos (grub_disk_t disk __attribute__ ((unused)), const grub_partition_t p) { - struct grub_pc_partition *pcdata = p->data; + struct grub_msdos_partition *pcdata = p->data; /* There's always an embed region, and it starts right after the MBR. */ embed_region.start = 1; /* For its end offset, include as many dummy partitions as we can. */ - if (! grub_pc_partition_is_empty (pcdata->dos_type) - && ! grub_pc_partition_is_bsd (pcdata->dos_type) + if (! grub_msdos_partition_is_empty (pcdata->dos_type) + && ! grub_msdos_partition_is_bsd (pcdata->dos_type) && embed_region.end > p->start) embed_region.end = p->start; @@ -279,9 +279,9 @@ setup (const char *dir, if (root_dev->disk->partition) { if (strcmp (root_dev->disk->partition->partmap->name, - "pc_partition_map") == 0) + "msdos_partition_map") == 0) { - struct grub_pc_partition *pcdata = + struct grub_msdos_partition *pcdata = root_dev->disk->partition->data; dos_part = pcdata->dos_part; bsd_part = pcdata->bsd_part; @@ -338,12 +338,12 @@ setup (const char *dir, goto unable_to_embed; } - grub_partition_iterate (dest_dev->disk, (strcmp (dest_partmap, "pc_partition_map") ? + grub_partition_iterate (dest_dev->disk, (strcmp (dest_partmap, "msdos_partition_map") ? find_usable_region_gpt : find_usable_region_msdos)); if (embed_region.end == embed_region.start) { - if (! strcmp (dest_partmap, "pc_partition_map")) + if (! strcmp (dest_partmap, "msdos_partition_map")) grub_util_warn ("This msdos-style partition label has no post-MBR gap; embedding won't be possible!"); else grub_util_warn ("This GPT partition label has no BIOS Boot Partition; embedding won't be possible!"); diff --git a/util/sparc64/ieee1275/grub-setup.c b/util/sparc64/ieee1275/grub-setup.c index 9509eb30b..7008147bf 100644 --- a/util/sparc64/ieee1275/grub-setup.c +++ b/util/sparc64/ieee1275/grub-setup.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include From c8c80635ae021b400a92eaa09f13b74ad2df48c4 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sun, 23 Aug 2009 12:59:22 +0000 Subject: [PATCH 03/85] 2009-08-23 Colin Watson * util/grub.d/30_os-prober.in: Disable os-prober if `GRUB_DISABLE_OS_PROBER' was set to true. --- ChangeLog | 5 +++++ util/grub.d/30_os-prober.in | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index ba1fdfef9..50c1cd4a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-23 Colin Watson + + * util/grub.d/30_os-prober.in: Disable os-prober if + `GRUB_DISABLE_OS_PROBER' was set to true. + 2009-08-23 Robert Millan * partmap/pc.c: Rename to ... diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index b36c2a366..ffc46c9d4 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -22,6 +22,10 @@ libdir=@libdir@ . ${libdir}/grub/grub-mkconfig_lib +if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then + exit 0 +fi + if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then # missing os-prober and/or linux-boot-prober exit 0 From 5174302b557d97cf0e50f92889b09d2fcdc9c70a Mon Sep 17 00:00:00 2001 From: fzielcke Date: Sun, 23 Aug 2009 15:09:05 +0000 Subject: [PATCH 04/85] 2009-08-23 Colin Watson * util/grub-mkconfig.in: Export GRUB_DISABLE_OS_PROBER. --- ChangeLog | 4 ++++ util/grub-mkconfig.in | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 50c1cd4a8..a2cc07f9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-08-23 Colin Watson + + * util/grub-mkconfig.in: Export GRUB_DISABLE_OS_PROBER. + 2009-08-23 Colin Watson * util/grub.d/30_os-prober.in: Disable os-prober if diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 93f96525e..8e3c3372b 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -205,7 +205,8 @@ export GRUB_DEFAULT \ GRUB_SERIAL_COMMAND \ GRUB_DISABLE_LINUX_UUID \ GRUB_DISABLE_LINUX_RECOVERY \ - GRUB_GFXMODE + GRUB_GFXMODE \ + GRUB_DISABLE_OS_PROBER if test "x${grub_cfg}" != "x"; then rm -f ${grub_cfg}.new From e9a925da69cc89b86f051690a3b8ab2981f7557c Mon Sep 17 00:00:00 2001 From: phcoder Date: Sun, 23 Aug 2009 15:27:07 +0000 Subject: [PATCH 05/85] 2009-08-23 Vladimir Serbinenko * commands/search.c (search_fs): Try searching without autoload first. * util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Load filesystem module explicitly for faster booting. --- ChangeLog | 6 ++++++ commands/search.c | 18 +++++++++++++++++- util/grub-mkconfig_lib.in | 5 +++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a2cc07f9a..a00842cec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-23 Vladimir Serbinenko + + * commands/search.c (search_fs): Try searching without autoload first. + * util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Load + filesystem module explicitly for faster booting. + 2009-08-23 Colin Watson * util/grub-mkconfig.in: Export GRUB_DISABLE_OS_PROBER. diff --git a/commands/search.c b/commands/search.c index d10b51abf..0cfd0ebbc 100644 --- a/commands/search.c +++ b/commands/search.c @@ -51,6 +51,7 @@ search_fs (const char *key, const char *var, int no_floppy, enum options type) { int count = 0; char *buf = NULL; + grub_fs_autoload_hook_t saved_autoload; auto int iterate_device (const char *name); int iterate_device (const char *name) @@ -131,7 +132,22 @@ search_fs (const char *key, const char *var, int no_floppy, enum options type) return (found && var); } - grub_device_iterate (iterate_device); + /* First try without autoloading if we're setting variable. */ + if (var) + { + saved_autoload = grub_fs_autoload_hook; + grub_fs_autoload_hook = 0; + grub_device_iterate (iterate_device); + + /* Restore autoload hook. */ + grub_fs_autoload_hook = saved_autoload; + + /* Retry with autoload if nothing found. */ + if (grub_errno == GRUB_ERR_NONE && count == 0) + grub_device_iterate (iterate_device); + } + else + grub_device_iterate (iterate_device); grub_free (buf); diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 3585a68ef..2385b0878 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -140,6 +140,11 @@ prepare_grub_to_access_device () echo "insmod ${module}" done + fs="`${grub_probe} --device ${device} --target=fs`" + for module in ${fs} ; do + echo "insmod ${module}" + done + # If there's a filesystem UUID that GRUB is capable of identifying, use it; # otherwise set root as per value in device.map. echo "set root=`${grub_probe} --device ${device} --target=drive`" From de74f136b72547b10a50e6e0b73ff384e38261c1 Mon Sep 17 00:00:00 2001 From: phcoder Date: Sun, 23 Aug 2009 15:35:22 +0000 Subject: [PATCH 06/85] 2009-08-23 Vladimir Serbinenko * fs/hfsplus.c (grub_hfsplus_mount): Don't ignore grub_hfsplus_read_file errors. (grub_hfsplus_btree_iterate_node): Don't ignore grub_hfsplus_read_file errors. Call grub_error when needed. --- ChangeLog | 7 +++++++ fs/hfsplus.c | 32 ++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index a00842cec..bc631b910 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-08-23 Vladimir Serbinenko + + * fs/hfsplus.c (grub_hfsplus_mount): Don't ignore grub_hfsplus_read_file + errors. + (grub_hfsplus_btree_iterate_node): Don't ignore grub_hfsplus_read_file + errors. Call grub_error when needed. + 2009-08-23 Vladimir Serbinenko * commands/search.c (search_fs): Try searching without autoload first. diff --git a/fs/hfsplus.c b/fs/hfsplus.c index 31bb54014..5e0ab093f 100644 --- a/fs/hfsplus.c +++ b/fs/hfsplus.c @@ -469,9 +469,9 @@ grub_hfsplus_mount (grub_disk_t disk) grub_be_to_cpu64 (data->volheader.extents_file.size); /* Read the essential information about the trees. */ - if (! grub_hfsplus_read_file (&data->catalog_tree.file, 0, - sizeof (struct grub_hfsplus_btnode), - sizeof (header), (char *) &header)) + if (grub_hfsplus_read_file (&data->catalog_tree.file, 0, + sizeof (struct grub_hfsplus_btnode), + sizeof (header), (char *) &header) <= 0) goto fail; data->catalog_tree.root = grub_be_to_cpu32 (header.root); @@ -479,15 +479,15 @@ grub_hfsplus_mount (grub_disk_t disk) data->case_sensitive = ((magic == GRUB_HFSPLUSX_MAGIC) && (header.key_compare == GRUB_HFSPLUSX_BINARYCOMPARE)); - if (! grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, - sizeof (struct grub_hfsplus_btnode), - sizeof (header), (char *) &header)) + if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, + sizeof (struct grub_hfsplus_btnode), + sizeof (header), (char *) &header) <= 0) goto fail; data->extoverflow_tree.root = grub_be_to_cpu32 (header.root); - if (! grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0, - sizeof (node), (char *) &node)) + if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0, + sizeof (node), (char *) &node) <= 0) goto fail; data->extoverflow_tree.root = grub_be_to_cpu32 (header.root); @@ -608,10 +608,10 @@ grub_hfsplus_btree_iterate_node (struct grub_hfsplus_btree *btree, if (! first_node->next) break; - if (! grub_hfsplus_read_file (&btree->file, 0, - (grub_be_to_cpu32 (first_node->next) - * btree->nodesize), - btree->nodesize, cnode)) + if (grub_hfsplus_read_file (&btree->file, 0, + (grub_be_to_cpu32 (first_node->next) + * btree->nodesize), + btree->nodesize, cnode) <= 0) return 1; /* Don't skip any record in the next iteration. */ @@ -647,12 +647,12 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree, int match = 0; /* Read a node. */ - if (! grub_hfsplus_read_file (&btree->file, 0, - (long)currnode * (long)btree->nodesize, - btree->nodesize, (char *) node)) + if (grub_hfsplus_read_file (&btree->file, 0, + (long)currnode * (long)btree->nodesize, + btree->nodesize, (char *) node) <= 0) { grub_free (node); - return grub_errno; + return grub_error (GRUB_ERR_BAD_FS, "Couldn't read i-node."); } nodedesc = (struct grub_hfsplus_btnode *) node; From cb4735645d772caf4765773d9470031093ba491a Mon Sep 17 00:00:00 2001 From: phcoder Date: Sun, 23 Aug 2009 21:04:44 +0000 Subject: [PATCH 07/85] 2009-08-23 Vladimir Serbinenko Fix grub-install. * util/i386/pc/grub-install.in: Add 'part_' to partmap_module. --- ChangeLog | 6 ++++++ util/i386/pc/grub-install.in | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bc631b910..5701f9beb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-23 Vladimir Serbinenko + + Fix grub-install. + + * util/i386/pc/grub-install.in: Add 'part_' to partmap_module. + 2009-08-23 Vladimir Serbinenko * fs/hfsplus.c (grub_hfsplus_mount): Don't ignore grub_hfsplus_read_file diff --git a/util/i386/pc/grub-install.in b/util/i386/pc/grub-install.in index 8ceb811dd..b6ee95772 100644 --- a/util/i386/pc/grub-install.in +++ b/util/i386/pc/grub-install.in @@ -261,7 +261,7 @@ fi # Then the partition map module. In order to support partition-less media, # this command is allowed to fail (--target=fs already grants us that the # filesystem will be accessible). -partmap_module=`$grub_probe --target=partmap --device ${grub_device} 2> /dev/null` +partmap_module=part_`$grub_probe --target=partmap --device ${grub_device} 2> /dev/null` # Device abstraction module, if any (lvm, raid). devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}` From af0f0beafaae4a67dc7e12f3d5330de779a468b7 Mon Sep 17 00:00:00 2001 From: phcoder Date: Sun, 23 Aug 2009 23:24:33 +0000 Subject: [PATCH 08/85] 2009-08-23 Vladimir Serbinenko Fix grub-install. * util/i386/efi/grub-install.in: Add 'part_' to partmap_module. * util/sparc64/ieee1275/grub-install.in: Likewise. --- ChangeLog | 2 ++ util/i386/efi/grub-install.in | 2 +- util/sparc64/ieee1275/grub-install.in | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5701f9beb..0af2eb8b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ Fix grub-install. * util/i386/pc/grub-install.in: Add 'part_' to partmap_module. + * util/i386/efi/grub-install.in: Likewise. + * util/sparc64/ieee1275/grub-install.in: Likewise. 2009-08-23 Vladimir Serbinenko diff --git a/util/i386/efi/grub-install.in b/util/i386/efi/grub-install.in index a5f97e346..db459885d 100644 --- a/util/i386/efi/grub-install.in +++ b/util/i386/efi/grub-install.in @@ -188,7 +188,7 @@ fi # Then the partition map module. In order to support partition-less media, # this command is allowed to fail (--target=fs already grants us that the # filesystem will be accessible). -partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null` +partmap_module=part_`$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null` # Device abstraction module, if any (lvm, raid). devabstraction_module=`$grub_probe --target=abstraction --device-map=${device_map} ${grubdir}` diff --git a/util/sparc64/ieee1275/grub-install.in b/util/sparc64/ieee1275/grub-install.in index 5cfb858d7..c7c50da71 100644 --- a/util/sparc64/ieee1275/grub-install.in +++ b/util/sparc64/ieee1275/grub-install.in @@ -220,7 +220,7 @@ fi # Then the partition map module. In order to support partition-less media, # this command is allowed to fail (--target=fs already grants us that the # filesystem will be accessible). -partmap_module=`$grub_probe --target=partmap --device ${grub_device} 2> /dev/null` +partmap_module=part_`$grub_probe --target=partmap --device ${grub_device} 2> /dev/null` # Device abstraction module, if any (lvm, raid). devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}` From 0b8e386c0962d40232c09a0ab49d685bb91ca1db Mon Sep 17 00:00:00 2001 From: phcoder Date: Sun, 23 Aug 2009 23:40:29 +0000 Subject: [PATCH 09/85] Revert 2 previous commits. 2009-08-23 Vladimir Serbinenko Fix grub-install. * util/grub-probe.c (probe_partmap): Prefix partmap with 'part_'. --- ChangeLog | 4 +--- util/grub-probe.c | 2 +- util/i386/efi/grub-install.in | 2 +- util/i386/pc/grub-install.in | 2 +- util/sparc64/ieee1275/grub-install.in | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0af2eb8b3..80d3f89a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,9 +2,7 @@ Fix grub-install. - * util/i386/pc/grub-install.in: Add 'part_' to partmap_module. - * util/i386/efi/grub-install.in: Likewise. - * util/sparc64/ieee1275/grub-install.in: Likewise. + * util/grub-probe.c (probe_partmap): Prefix partmap with 'part_'. 2009-08-23 Vladimir Serbinenko diff --git a/util/grub-probe.c b/util/grub-probe.c index 7c63f64ef..c8dbc0175 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -97,7 +97,7 @@ probe_partmap (grub_disk_t disk) grub_util_error ("Invalid partition map %s", name); *underscore = '\0'; - printf ("%s\n", name); + printf ("part_%s\n", name); free (name); } diff --git a/util/i386/efi/grub-install.in b/util/i386/efi/grub-install.in index db459885d..a5f97e346 100644 --- a/util/i386/efi/grub-install.in +++ b/util/i386/efi/grub-install.in @@ -188,7 +188,7 @@ fi # Then the partition map module. In order to support partition-less media, # this command is allowed to fail (--target=fs already grants us that the # filesystem will be accessible). -partmap_module=part_`$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null` +partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null` # Device abstraction module, if any (lvm, raid). devabstraction_module=`$grub_probe --target=abstraction --device-map=${device_map} ${grubdir}` diff --git a/util/i386/pc/grub-install.in b/util/i386/pc/grub-install.in index b6ee95772..8ceb811dd 100644 --- a/util/i386/pc/grub-install.in +++ b/util/i386/pc/grub-install.in @@ -261,7 +261,7 @@ fi # Then the partition map module. In order to support partition-less media, # this command is allowed to fail (--target=fs already grants us that the # filesystem will be accessible). -partmap_module=part_`$grub_probe --target=partmap --device ${grub_device} 2> /dev/null` +partmap_module=`$grub_probe --target=partmap --device ${grub_device} 2> /dev/null` # Device abstraction module, if any (lvm, raid). devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}` diff --git a/util/sparc64/ieee1275/grub-install.in b/util/sparc64/ieee1275/grub-install.in index c7c50da71..5cfb858d7 100644 --- a/util/sparc64/ieee1275/grub-install.in +++ b/util/sparc64/ieee1275/grub-install.in @@ -220,7 +220,7 @@ fi # Then the partition map module. In order to support partition-less media, # this command is allowed to fail (--target=fs already grants us that the # filesystem will be accessible). -partmap_module=part_`$grub_probe --target=partmap --device ${grub_device} 2> /dev/null` +partmap_module=`$grub_probe --target=partmap --device ${grub_device} 2> /dev/null` # Device abstraction module, if any (lvm, raid). devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}` From f5ae9f745f0255d69675c054e5f77d3a0f799d58 Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 24 Aug 2009 12:55:19 +0000 Subject: [PATCH 10/85] 2009-08-24 Vladimir Serbinenko Support --no-smp and --no-acpi for NetBSD. * include/grub/i386/bsd.h (NETBSD_AB_NOSMP): New definition. (NETBSD_AB_NOACPI): Likewise. * loader/i386/bsd.c (netbsd_opts): New entries no-smp and no-acpi. (netbsd_flags): Add NETBSD_AB_NOSMP, NETBSD_AB_NOACPI. --- ChangeLog | 9 +++++++++ include/grub/i386/bsd.h | 2 ++ loader/i386/bsd.c | 10 ++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80d3f89a7..9ec86ede8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-08-24 Vladimir Serbinenko + + Support --no-smp and --no-acpi for NetBSD. + + * include/grub/i386/bsd.h (NETBSD_AB_NOSMP): New definition. + (NETBSD_AB_NOACPI): Likewise. + * loader/i386/bsd.c (netbsd_opts): New entries no-smp and no-acpi. + (netbsd_flags): Add NETBSD_AB_NOSMP, NETBSD_AB_NOACPI. + 2009-08-23 Vladimir Serbinenko Fix grub-install. diff --git a/include/grub/i386/bsd.h b/include/grub/i386/bsd.h index 117ed5c68..f39fc9d5c 100644 --- a/include/grub/i386/bsd.h +++ b/include/grub/i386/bsd.h @@ -189,6 +189,8 @@ struct grub_openbsd_bootargs #define NETBSD_AB_VERBOSE (1 << 17) /* boot verbosely */ #define NETBSD_AB_SILENT (1 << 18) /* boot silently */ #define NETBSD_AB_DEBUG (1 << 19) /* boot with debug messages */ +#define NETBSD_AB_NOSMP (1 << 28) /* Boot without SMP support. */ +#define NETBSD_AB_NOACPI (1 << 29) /* Boot without ACPI support. */ struct grub_netbsd_bootinfo { diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index d5f677a2a..10b92e3c6 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -103,6 +103,8 @@ static const grub_uint32_t openbsd_flags[] = static const struct grub_arg_option netbsd_opts[] = { + {"no-smp", '1', 0, "Disable SMP.", 0, 0}, + {"no-acpi", '2', 0, "Disable ACPI.", 0, 0}, {"askname", 'a', 0, "Ask for file name to reboot from.", 0, 0}, {"halt", 'b', 0, "Don't reboot, just halt.", 0, 0}, {"config", 'c', 0, "Change configured devices.", 0, 0}, @@ -118,10 +120,10 @@ static const struct grub_arg_option netbsd_opts[] = static const grub_uint32_t netbsd_flags[] = { - NETBSD_RB_ASKNAME, NETBSD_RB_HALT, NETBSD_RB_USERCONFIG, - NETBSD_RB_KDB, NETBSD_RB_MINIROOT, NETBSD_AB_QUIET, - NETBSD_RB_SINGLE, NETBSD_AB_VERBOSE, NETBSD_AB_DEBUG, - NETBSD_AB_SILENT, 0 + NETBSD_AB_NOSMP, NETBSD_AB_NOACPI, NETBSD_RB_ASKNAME, + NETBSD_RB_HALT, NETBSD_RB_USERCONFIG, NETBSD_RB_KDB, + NETBSD_RB_MINIROOT, NETBSD_AB_QUIET, NETBSD_RB_SINGLE, + NETBSD_AB_VERBOSE, NETBSD_AB_DEBUG, NETBSD_AB_SILENT, 0 }; static void From adb29902f39d18660c0cb4115c79f2a55dc1ba04 Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 24 Aug 2009 12:59:48 +0000 Subject: [PATCH 11/85] 2009-08-24 Vladimir Serbinenko Support for 64-bit NetBSD. * loader/i386/bsd.c (grub_bsd_load_elf): Apply correct mask to entry point when booting non-FreeBSD. --- ChangeLog | 7 +++++++ loader/i386/bsd.c | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ec86ede8..59b50f04a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-08-24 Vladimir Serbinenko + + Support for 64-bit NetBSD. + + * loader/i386/bsd.c (grub_bsd_load_elf): Apply correct mask to entry + point when booting non-FreeBSD. + 2009-08-24 Vladimir Serbinenko Support --no-smp and --no-acpi for NetBSD. diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 10b92e3c6..26f98b3a9 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -778,8 +778,18 @@ grub_bsd_load_elf (grub_elf_t elf) else if (grub_elf_is_elf64 (elf)) { is_64bit = 1; - entry = elf->ehdr.ehdr64.e_entry & 0xffffffff; - entry_hi = (elf->ehdr.ehdr64.e_entry >> 32) & 0xffffffff; + + /* FreeBSD has 64-bit entry point. */ + if (kernel_type == KERNEL_TYPE_FREEBSD) + { + entry = elf->ehdr.ehdr64.e_entry & 0xffffffff; + entry_hi = (elf->ehdr.ehdr64.e_entry >> 32) & 0xffffffff; + } + else + { + entry = elf->ehdr.ehdr64.e_entry & 0x0fffffff; + entry_hi = 0; + } return grub_elf64_load (elf, grub_bsd_elf64_hook, 0, 0); } else From 16c84d744cd724d2f6e0efb4af245e74d914d2f5 Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 24 Aug 2009 13:10:12 +0000 Subject: [PATCH 12/85] 2009-08-24 Vladimir Serbinenko Let user specify NetBSD root device. * loader/i386/bsd.c (netbsd_root): New variable. (netbsd_opts): New option 'root'. (NETBSD_ROOT_ARG): New macro. (grub_netbsd_boot): Use 'netbsd_root'. (grub_bsd_unload): Free 'netbsd_root'. (grub_cmd_netbsd): Fill 'netbsd_root'. --- ChangeLog | 11 +++++++++++ loader/i386/bsd.c | 44 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 59b50f04a..f26013862 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-08-24 Vladimir Serbinenko + + Let user specify NetBSD root device. + + * loader/i386/bsd.c (netbsd_root): New variable. + (netbsd_opts): New option 'root'. + (NETBSD_ROOT_ARG): New macro. + (grub_netbsd_boot): Use 'netbsd_root'. + (grub_bsd_unload): Free 'netbsd_root'. + (grub_cmd_netbsd): Fill 'netbsd_root'. + 2009-08-24 Vladimir Serbinenko Support for 64-bit NetBSD. diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 26f98b3a9..09e5f5876 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -56,6 +56,7 @@ static grub_uint32_t bootflags; static char *mod_buf; static grub_uint32_t mod_buf_len, mod_buf_max, kern_end_mdofs; static int is_elf_kernel, is_64bit; +static char *netbsd_root = NULL; static const struct grub_arg_option freebsd_opts[] = { @@ -115,6 +116,7 @@ static const struct grub_arg_option netbsd_opts[] = {"verbose", 'v', 0, "Boot with verbose messages.", 0, 0}, {"debug", 'x', 0, "Boot with debug messages.", 0, 0}, {"silent", 'z', 0, "Supress normal output (warnings remain).", 0, 0}, + {"root", 'r', 0, "Set root device.", "DEVICE", ARG_TYPE_STRING}, {0, 0, 0, 0, 0, 0} }; @@ -126,6 +128,8 @@ static const grub_uint32_t netbsd_flags[] = NETBSD_AB_VERBOSE, NETBSD_AB_DEBUG, NETBSD_AB_SILENT, 0 }; +#define NETBSD_ROOT_ARG (ARRAY_SIZE (netbsd_flags) - 1) + static void grub_bsd_get_device (grub_uint32_t * biosdev, grub_uint32_t * unit, @@ -607,22 +611,35 @@ grub_openbsd_boot (void) static grub_err_t grub_netbsd_boot (void) { - struct grub_netbsd_btinfo_rootdevice *rootdev; struct grub_netbsd_bootinfo *bootinfo; grub_uint32_t biosdev, unit, slice, part; grub_bsd_get_device (&biosdev, &unit, &slice, &part); - rootdev = (struct grub_netbsd_btinfo_rootdevice *) GRUB_BSD_TEMP_BUFFER; + if (kern_end + sizeof (struct grub_netbsd_btinfo_rootdevice) + + sizeof (struct grub_netbsd_bootinfo) > grub_os_area_addr + + grub_os_area_size) + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "No memory fo boot info."); - rootdev->common.len = sizeof (struct grub_netbsd_btinfo_rootdevice); - rootdev->common.type = NETBSD_BTINFO_ROOTDEVICE; - grub_sprintf (rootdev->devname, "%cd%d%c", (biosdev & 0x80) ? 'w' : 'f', - unit, 'a' + part); + if (netbsd_root) + { + struct grub_netbsd_btinfo_rootdevice *rootdev; - bootinfo = (struct grub_netbsd_bootinfo *) (rootdev + 1); - bootinfo->bi_count = 1; - bootinfo->bi_data[0] = rootdev; + rootdev = (struct grub_netbsd_btinfo_rootdevice *) kern_end; + + rootdev->common.len = sizeof (struct grub_netbsd_btinfo_rootdevice); + rootdev->common.type = NETBSD_BTINFO_ROOTDEVICE; + grub_strncpy (rootdev->devname, netbsd_root, sizeof (rootdev->devname)); + + bootinfo = (struct grub_netbsd_bootinfo *) (rootdev + 1); + bootinfo->bi_count = 1; + bootinfo->bi_data[0] = rootdev; + } + else + { + bootinfo = (struct grub_netbsd_bootinfo *) kern_end; + bootinfo->bi_count = 0; + } grub_unix_real_boot (entry, bootflags, 0, bootinfo, 0, grub_mmap_get_upper () >> 10, @@ -645,6 +662,9 @@ grub_bsd_unload (void) kernel_type = KERNEL_TYPE_NONE; grub_dl_unref (my_mod); + grub_free (netbsd_root); + netbsd_root = NULL; + return GRUB_ERR_NONE; } @@ -935,7 +955,11 @@ grub_cmd_netbsd (grub_extcmd_t cmd, int argc, char *argv[]) bootflags = grub_bsd_parse_flags (cmd->state, netbsd_flags); if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE) - grub_loader_set (grub_netbsd_boot, grub_bsd_unload, 1); + { + grub_loader_set (grub_netbsd_boot, grub_bsd_unload, 1); + if (cmd->state[NETBSD_ROOT_ARG].set) + netbsd_root = grub_strdup (cmd->state[NETBSD_ROOT_ARG].arg); + } return grub_errno; } From dd103c4e042c00e5b59ccdae701f8a4a90f09b3f Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 24 Aug 2009 13:20:24 +0000 Subject: [PATCH 13/85] 2009-08-24 Vladimir Serbinenko Fix OpenBSD and NetBSD support. * include/grub/i386/bsd.h (GRUB_BSD_TEMP_BUFFER): Change to resolve memory address conflict. (OPENBSD_MMAP_ACPI): New definition. (OPENBSD_MMAP_NVS): Likewise. * loader/i386/bsd.c (grub_openbsd_boot): Support OPENBSD_MMAP_ACPI and OPENBSD_MMAP_NVS. Add memory map terminator Explicit cast when calling grub_unix_real_boot. (grub_nebsd_boot): Explicit cast when calling grub_unix_real_boot. --- ChangeLog | 14 ++++++++++++++ include/grub/i386/bsd.h | 4 +++- loader/i386/bsd.c | 22 ++++++++++++++++++---- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f26013862..d81560913 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2009-08-24 Vladimir Serbinenko + + Fix OpenBSD and NetBSD support. + + * include/grub/i386/bsd.h (GRUB_BSD_TEMP_BUFFER): Change to resolve + memory address conflict. + (OPENBSD_MMAP_ACPI): New definition. + (OPENBSD_MMAP_NVS): Likewise. + * loader/i386/bsd.c (grub_openbsd_boot): Support OPENBSD_MMAP_ACPI + and OPENBSD_MMAP_NVS. + Add memory map terminator + Explicit cast when calling grub_unix_real_boot. + (grub_nebsd_boot): Explicit cast when calling grub_unix_real_boot. + 2009-08-24 Vladimir Serbinenko Let user specify NetBSD root device. diff --git a/include/grub/i386/bsd.h b/include/grub/i386/bsd.h index f39fc9d5c..2939035d2 100644 --- a/include/grub/i386/bsd.h +++ b/include/grub/i386/bsd.h @@ -29,7 +29,7 @@ enum bsd_kernel_types KERNEL_TYPE_NETBSD, }; -#define GRUB_BSD_TEMP_BUFFER 0x68000 +#define GRUB_BSD_TEMP_BUFFER 0x80000 #define FREEBSD_RB_ASKNAME (1 << 0) /* ask for file name to reboot from */ #define FREEBSD_RB_SINGLE (1 << 1) /* reboot to single user only */ @@ -157,6 +157,8 @@ struct grub_openbsd_bios_mmap grub_uint64_t len; #define OPENBSD_MMAP_AVAILABLE 1 #define OPENBSD_MMAP_RESERVED 2 +#define OPENBSD_MMAP_ACPI 3 +#define OPENBSD_MMAP_NVS 4 grub_uint32_t type; }; diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 09e5f5876..1b6f1902b 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -574,6 +574,14 @@ grub_openbsd_boot (void) pm->type = OPENBSD_MMAP_AVAILABLE; break; + case GRUB_MACHINE_MEMORY_ACPI: + pm->type = OPENBSD_MMAP_ACPI; + break; + + case GRUB_MACHINE_MEMORY_NVS: + pm->type = OPENBSD_MMAP_NVS; + break; + default: pm->type = OPENBSD_MMAP_RESERVED; break; @@ -589,6 +597,12 @@ grub_openbsd_boot (void) pm = (struct grub_openbsd_bios_mmap *) (pa + 1); grub_mmap_iterate (hook); + /* Memory map terminator. */ + pm->addr = 0; + pm->len = 0; + pm->type = 0; + pm++; + pa->ba_size = (char *) pm - (char *) pa; pa->ba_next = (struct grub_openbsd_bootargs *) pm; pa = pa->ba_next; @@ -600,8 +614,8 @@ grub_openbsd_boot (void) (part << OPENBSD_B_PARTSHIFT)); grub_unix_real_boot (entry, bootflags, bootdev, OPENBSD_BOOTARG_APIVER, - 0, grub_mmap_get_upper () >> 10, - grub_mmap_get_lower () >> 10, + 0, (grub_uint32_t) (grub_mmap_get_upper () >> 10), + (grub_uint32_t) (grub_mmap_get_lower () >> 10), (char *) pa - buf, buf); /* Not reached. */ @@ -642,8 +656,8 @@ grub_netbsd_boot (void) } grub_unix_real_boot (entry, bootflags, 0, bootinfo, - 0, grub_mmap_get_upper () >> 10, - grub_mmap_get_lower () >> 10); + 0, (grub_uint32_t) (grub_mmap_get_upper () >> 10), + (grub_uint32_t) (grub_mmap_get_lower () >> 10)); /* Not reached. */ return GRUB_ERR_NONE; From 2d21e3e8e0b20a7b19bc66e8f51c1c153d1dc7df Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 24 Aug 2009 13:34:03 +0000 Subject: [PATCH 14/85] 2009-08-24 Vladimir Serbinenko Rename *_partition_map to part_* * partmap/acorn.c (grub_acorn_partition_map): Set name to 'part_acorn'. * partmap/amiga.c (grub_amiga_partition_map): Set name to 'part_amiga'. * partmap/apple.c (grub_apple_partition_map): Set name to 'part_apple'. * partmap/gpt.c (grub_gpt_partition_map): Set name to 'part_gpt'. All users updated. * partmap/msdos.c (grub_msdos_partition_map): Set name to 'part_msdos'. All users updated. * partmap/sun.c (grub_sun_partition_map): Set name to 'part_sun'. * util/grub-probe.c (probe_partmap): Don't transform partition name to get module name. --- ChangeLog | 21 +++++++++++++++------ partmap/acorn.c | 2 +- partmap/amiga.c | 2 +- partmap/apple.c | 2 +- partmap/gpt.c | 2 +- partmap/msdos.c | 2 +- partmap/sun.c | 2 +- parttool/msdospart.c | 4 ++-- util/grub-probe.c | 15 +-------------- util/hostdisk.c | 2 +- util/i386/pc/grub-setup.c | 4 ++-- 11 files changed, 27 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index d81560913..1efb882bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-08-24 Vladimir Serbinenko + + Rename *_partition_map to part_* + + * partmap/acorn.c (grub_acorn_partition_map): Set name to 'part_acorn'. + * partmap/amiga.c (grub_amiga_partition_map): Set name to 'part_amiga'. + * partmap/apple.c (grub_apple_partition_map): Set name to 'part_apple'. + * partmap/gpt.c (grub_gpt_partition_map): Set name to 'part_gpt'. + All users updated. + * partmap/msdos.c (grub_msdos_partition_map): Set name to 'part_msdos'. + All users updated. + * partmap/sun.c (grub_sun_partition_map): Set name to 'part_sun'. + * util/grub-probe.c (probe_partmap): Don't transform partition name + to get module name. + 2009-08-24 Vladimir Serbinenko Fix OpenBSD and NetBSD support. @@ -39,12 +54,6 @@ * loader/i386/bsd.c (netbsd_opts): New entries no-smp and no-acpi. (netbsd_flags): Add NETBSD_AB_NOSMP, NETBSD_AB_NOACPI. -2009-08-23 Vladimir Serbinenko - - Fix grub-install. - - * util/grub-probe.c (probe_partmap): Prefix partmap with 'part_'. - 2009-08-23 Vladimir Serbinenko * fs/hfsplus.c (grub_hfsplus_mount): Don't ignore grub_hfsplus_read_file diff --git a/partmap/acorn.c b/partmap/acorn.c index 42fd61f4a..e005975c0 100644 --- a/partmap/acorn.c +++ b/partmap/acorn.c @@ -189,7 +189,7 @@ acorn_partition_map_get_name (const grub_partition_t p) /* Partition map type. */ static struct grub_partition_map grub_acorn_partition_map = { - .name = "Linux/ADFS partition map", + .name = "part_acorn", .iterate = acorn_partition_map_iterate, .probe = acorn_partition_map_probe, .get_name = acorn_partition_map_get_name diff --git a/partmap/amiga.c b/partmap/amiga.c index ffb807f5a..dce9f4f1f 100644 --- a/partmap/amiga.c +++ b/partmap/amiga.c @@ -198,7 +198,7 @@ amiga_partition_map_get_name (const grub_partition_t p) /* Partition map type. */ static struct grub_partition_map grub_amiga_partition_map = { - .name = "amiga_partition_map", + .name = "part_amiga", .iterate = amiga_partition_map_iterate, .probe = amiga_partition_map_probe, .get_name = amiga_partition_map_get_name diff --git a/partmap/apple.c b/partmap/apple.c index 04ccff146..4dea55a32 100644 --- a/partmap/apple.c +++ b/partmap/apple.c @@ -241,7 +241,7 @@ apple_partition_map_get_name (const grub_partition_t p) /* Partition map type. */ static struct grub_partition_map grub_apple_partition_map = { - .name = "apple_partition_map", + .name = "part_apple", .iterate = apple_partition_map_iterate, .probe = apple_partition_map_probe, .get_name = apple_partition_map_get_name diff --git a/partmap/gpt.c b/partmap/gpt.c index e860f35da..4a4957437 100644 --- a/partmap/gpt.c +++ b/partmap/gpt.c @@ -176,7 +176,7 @@ gpt_partition_map_get_name (const grub_partition_t p) /* Partition map type. */ static struct grub_partition_map grub_gpt_partition_map = { - .name = "gpt_partition_map", + .name = "part_gpt", .iterate = gpt_partition_map_iterate, .probe = gpt_partition_map_probe, .get_name = gpt_partition_map_get_name diff --git a/partmap/msdos.c b/partmap/msdos.c index 9fc620df0..d0fc18efe 100644 --- a/partmap/msdos.c +++ b/partmap/msdos.c @@ -303,7 +303,7 @@ pc_partition_map_get_name (const grub_partition_t p) /* Partition map type. */ static struct grub_partition_map grub_msdos_partition_map = { - .name = "msdos_partition_map", + .name = "part_msdos", .iterate = pc_partition_map_iterate, .probe = pc_partition_map_probe, .get_name = pc_partition_map_get_name diff --git a/partmap/sun.c b/partmap/sun.c index ce6d58899..e816ec17a 100644 --- a/partmap/sun.c +++ b/partmap/sun.c @@ -196,7 +196,7 @@ sun_partition_map_get_name (const grub_partition_t p) /* Partition map type. */ static struct grub_partition_map grub_sun_partition_map = { - .name = "sun_partition_map", + .name = "part_sun", .iterate = sun_partition_map_iterate, .probe = sun_partition_map_probe, .get_name = sun_partition_map_get_name diff --git a/parttool/msdospart.c b/parttool/msdospart.c index 1bb9cd3e1..dbb25bc52 100644 --- a/parttool/msdospart.c +++ b/parttool/msdospart.c @@ -140,10 +140,10 @@ static grub_err_t grub_pcpart_type (const grub_device_t dev, GRUB_MOD_INIT (pcpart) { - activate_table_handle = grub_parttool_register ("msdos_partition_map", + activate_table_handle = grub_parttool_register ("part_msdos", grub_pcpart_boot, grub_pcpart_bootargs); - type_table_handle = grub_parttool_register ("msdos_partition_map", + type_table_handle = grub_parttool_register ("part_msdos", grub_pcpart_type, grub_pcpart_typeargs); diff --git a/util/grub-probe.c b/util/grub-probe.c index c8dbc0175..1710ec51b 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -79,26 +79,13 @@ grub_refresh (void) static void probe_partmap (grub_disk_t disk) { - char *name; - char *underscore; - if (disk->partition == NULL) { grub_util_info ("No partition map found for %s", disk->name); return; } - name = strdup (disk->partition->partmap->name); - if (! name) - grub_util_error ("Not enough memory"); - - underscore = strchr (name, '_'); - if (! underscore) - grub_util_error ("Invalid partition map %s", name); - - *underscore = '\0'; - printf ("part_%s\n", name); - free (name); + printf ("%s\n", disk->partition->partmap->name); } static int diff --git a/util/hostdisk.c b/util/hostdisk.c index 8a3e2ef1f..a06ecca2a 100644 --- a/util/hostdisk.c +++ b/util/hostdisk.c @@ -949,7 +949,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) { struct grub_msdos_partition *pcdata = NULL; - if (strcmp (partition->partmap->name, "msdos_partition_map") == 0) + if (strcmp (partition->partmap->name, "part_msdos") == 0) pcdata = partition->data; if (pcdata) diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c index 0dc2e2c31..7f38c4293 100644 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@ -279,7 +279,7 @@ setup (const char *dir, if (root_dev->disk->partition) { if (strcmp (root_dev->disk->partition->partmap->name, - "msdos_partition_map") == 0) + "part_msdos") == 0) { struct grub_msdos_partition *pcdata = root_dev->disk->partition->data; @@ -287,7 +287,7 @@ setup (const char *dir, bsd_part = pcdata->bsd_part; } else if (strcmp (root_dev->disk->partition->partmap->name, - "gpt_partition_map") == 0) + "part_gpt") == 0) { dos_part = root_dev->disk->partition->index; bsd_part = -1; From c385bfc37f47025ba50e9e5549462ca12f2d9df8 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Mon, 24 Aug 2009 17:03:24 +0000 Subject: [PATCH 15/85] 2009-08-24 Colin Watson * term/usb_keyboard.c (grub_usb_keyboard_getreport): Make `report' grub_uint8_t *. (grub_usb_keyboard_checkkey): Make `data' elements grub_uint8_t. Use a 50-millisecond timeout rather than just repeating grub_usb_keyboard_getreport 50 times. (grub_usb_keyboard_getkey): Make `data' elements grub_uint8_t. --- ChangeLog | 9 +++++++++ term/usb_keyboard.c | 16 ++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1efb882bc..38e8d4650 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-08-24 Colin Watson + + * term/usb_keyboard.c (grub_usb_keyboard_getreport): Make + `report' grub_uint8_t *. + (grub_usb_keyboard_checkkey): Make `data' elements grub_uint8_t. + Use a 50-millisecond timeout rather than just repeating + grub_usb_keyboard_getreport 50 times. + (grub_usb_keyboard_getkey): Make `data' elements grub_uint8_t. + 2009-08-24 Vladimir Serbinenko Rename *_partition_map to part_* diff --git a/term/usb_keyboard.c b/term/usb_keyboard.c index c827955ab..bb62b35ed 100644 --- a/term/usb_keyboard.c +++ b/term/usb_keyboard.c @@ -97,7 +97,7 @@ grub_usb_hid (void) } static grub_err_t -grub_usb_keyboard_getreport (grub_usb_device_t dev, unsigned char *report) +grub_usb_keyboard_getreport (grub_usb_device_t dev, grub_uint8_t *report) { return grub_usb_control_msg (dev, (1 << 7) | (1 << 5) | 1, 0x01, 0, 0, 8, (char *) report); @@ -108,20 +108,24 @@ grub_usb_keyboard_getreport (grub_usb_device_t dev, unsigned char *report) static int grub_usb_keyboard_checkkey (void) { - unsigned char data[8]; + grub_uint8_t data[8]; int key; - int i; grub_err_t err; + grub_uint64_t currtime; + int timeout = 50; data[2] = 0; - for (i = 0; i < 50; i++) + currtime = grub_get_time_ms (); + do { /* Get_Report. */ err = grub_usb_keyboard_getreport (usbdev, data); - if (! err && data[2]) + /* Implement a timeout. */ + if (grub_get_time_ms () > currtime + timeout) break; } + while (err || !data[2]); if (err || !data[2]) return -1; @@ -174,7 +178,7 @@ grub_usb_keyboard_getkey (void) { int key; grub_err_t err; - unsigned char data[8]; + grub_uint8_t data[8]; grub_uint64_t currtime; int timeout; static grub_usb_keyboard_repeat_t repeat = GRUB_HIDBOOT_REPEAT_NONE; From 48e40bff44271bda0c3d7592112ad15b40c63153 Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 24 Aug 2009 19:08:11 +0000 Subject: [PATCH 16/85] 2009-08-24 Vladimir Serbinenko * script/sh/function.c (grub_script_function_find): Cut error message not to flood terminal. * script/sh/lexer.c (grub_script_yylex): Remove command line length limit. * script/sh/script.c (grub_script_arg_add): Duplicate string. --- ChangeLog | 8 +++++ script/sh/function.c | 2 +- script/sh/lexer.c | 78 +++++++++++++++++++++++++++++++------------- script/sh/script.c | 5 ++- 4 files changed, 69 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 38e8d4650..a8c30d971 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-08-24 Vladimir Serbinenko + + * script/sh/function.c (grub_script_function_find): Cut error message + not to flood terminal. + * script/sh/lexer.c (grub_script_yylex): Remove command line length + limit. + * script/sh/script.c (grub_script_arg_add): Duplicate string. + 2009-08-24 Colin Watson * term/usb_keyboard.c (grub_usb_keyboard_getreport): Make diff --git a/script/sh/function.c b/script/sh/function.c index 1e49c709f..a3950a8a0 100644 --- a/script/sh/function.c +++ b/script/sh/function.c @@ -99,7 +99,7 @@ grub_script_function_find (char *functionname) break; if (! func) - grub_error (GRUB_ERR_UNKNOWN_COMMAND, "unknown command `%s'", functionname); + grub_error (GRUB_ERR_UNKNOWN_COMMAND, "unknown command `%.20s'", functionname); return func; } diff --git a/script/sh/lexer.c b/script/sh/lexer.c index 44d7da2ad..a30e3c005 100644 --- a/script/sh/lexer.c +++ b/script/sh/lexer.c @@ -134,8 +134,6 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate) { grub_parser_state_t newstate; char use; - char *buffer; - char *bp; struct grub_lexer_param *state = parsestate->lexerstate; int firstrun = 1; @@ -212,6 +210,14 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate) /* Check if it is a text. */ if (check_textstate (newstate)) { + char *buffer = NULL; + int bufpos = 0; + /* Buffer is initially large enough to hold most commands + but extends automatically when needed. */ + int bufsize = 128; + + buffer = grub_malloc (bufsize); + /* In case the string is not quoted, this can be a one char length symbol. */ if (newstate == GRUB_PARSER_STATE_TEXT) @@ -254,16 +260,12 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate) } } if (doexit) - break; + { + grub_free (buffer); + break; + } } - /* XXX: Use a better size. */ - buffer = grub_script_malloc (parsestate, 2048); - if (! buffer) - return 0; - - bp = buffer; - /* Read one token, possible quoted. */ while (*state->script) { @@ -295,32 +297,47 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate) } if (breakout) break; - if (use) - *(bp++) = use; } - else if (use) - *(bp++) = use; + + if (use) + { + if (bufsize <= bufpos + 1) + { + bufsize <<= 1; + buffer = grub_realloc (buffer, bufsize); + } + buffer[bufpos++] = use; + } state->state = newstate; nextchar (state); } /* A string of text was read in. */ - *bp = '\0'; + if (bufsize <= bufpos + 1) + { + bufsize <<= 1; + buffer = grub_realloc (buffer, bufsize); + } + + buffer[bufpos++] = 0; + grub_dprintf ("scripting", "token=`%s'\n", buffer); yylval->arg = grub_script_arg_add (parsestate, yylval->arg, GRUB_SCRIPT_ARG_TYPE_STR, buffer); + grub_free (buffer); } else if (newstate == GRUB_PARSER_STATE_VAR || newstate == GRUB_PARSER_STATE_QVAR) { - /* XXX: Use a better size. */ - buffer = grub_script_malloc (parsestate, 2096); - if (! buffer) - return 0; + char *buffer = NULL; + int bufpos = 0; + /* Buffer is initially large enough to hold most commands + but extends automatically when needed. */ + int bufsize = 128; - bp = buffer; + buffer = grub_malloc (bufsize); /* This is a variable, read the variable name. */ while (*state->script) @@ -340,16 +357,33 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate) } if (use) - *(bp++) = use; + { + if (bufsize <= bufpos + 1) + { + bufsize <<= 1; + buffer = grub_realloc (buffer, bufsize); + } + buffer[bufpos++] = use; + } + nextchar (state); state->state = newstate; } - *bp = '\0'; + if (bufsize <= bufpos + 1) + { + bufsize <<= 1; + buffer = grub_realloc (buffer, bufsize); + } + + buffer[bufpos++] = 0; + state->state = newstate; yylval->arg = grub_script_arg_add (parsestate, yylval->arg, GRUB_SCRIPT_ARG_TYPE_VAR, buffer); grub_dprintf ("scripting", "vartoken=`%s'\n", buffer); + + grub_free (buffer); } else { diff --git a/script/sh/script.c b/script/sh/script.c index cefafe605..c04a44966 100644 --- a/script/sh/script.c +++ b/script/sh/script.c @@ -110,10 +110,13 @@ grub_script_arg_add (struct grub_parser_param *state, struct grub_script_arg *ar { struct grub_script_arg *argpart; struct grub_script_arg *ll; + int len; argpart = (struct grub_script_arg *) grub_script_malloc (state, sizeof (*arg)); argpart->type = type; - argpart->str = str; + len = grub_strlen (str) + 1; + argpart->str = grub_script_malloc (state, len); + grub_memcpy (argpart->str, str, len); argpart->next = 0; if (! arg) From 70f1161d1319da9db44b2fa41bea3615a1ca5584 Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 24 Aug 2009 19:40:40 +0000 Subject: [PATCH 17/85] 2009-08-24 Vladimir Serbinenko Save space by inlining misc.c functions. * kern/misc.c (grub_iswordseparator): Made static. * kern/misc.c (grub_strcat): Moved from here ... * include/grub/misc.h (grub_strcat): ... here. Inlined. * kern/misc.c (grub_strncat): Moved from here ... * include/grub/misc.h (grub_strncat): ... here. Inlined. * kern/misc.c (grub_strcasecmp): Moved from here ... * include/grub/misc.h (grub_strcasecmp): ... here. Inlined. * kern/misc.c (grub_strncasecmp): Moved from here ... * include/grub/misc.h (grub_strncasecmp): ... here. Inlined. * kern/misc.c (grub_isalpha): Moved from here ... * include/grub/misc.h (grub_isalpha): ... here. Inlined. * kern/misc.c (grub_isdigit): Moved from here ... * include/grub/misc.h (grub_isdigit): ... here. Inlined. * kern/misc.c (grub_isgraph): Moved from here ... * include/grub/misc.h (grub_isgraph): ... here. Inlined. * kern/misc.c (grub_tolower): Moved from here ... * include/grub/misc.h (grub_tolower): ... here. Inlined. --- ChangeLog | 22 +++++++++ include/grub/misc.h | 108 ++++++++++++++++++++++++++++++++++++++++---- kern/misc.c | 108 +++----------------------------------------- 3 files changed, 127 insertions(+), 111 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8c30d971..f9c915016 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2009-08-24 Vladimir Serbinenko + + Save space by inlining misc.c functions. + + * kern/misc.c (grub_iswordseparator): Made static. + * kern/misc.c (grub_strcat): Moved from here ... + * include/grub/misc.h (grub_strcat): ... here. Inlined. + * kern/misc.c (grub_strncat): Moved from here ... + * include/grub/misc.h (grub_strncat): ... here. Inlined. + * kern/misc.c (grub_strcasecmp): Moved from here ... + * include/grub/misc.h (grub_strcasecmp): ... here. Inlined. + * kern/misc.c (grub_strncasecmp): Moved from here ... + * include/grub/misc.h (grub_strncasecmp): ... here. Inlined. + * kern/misc.c (grub_isalpha): Moved from here ... + * include/grub/misc.h (grub_isalpha): ... here. Inlined. + * kern/misc.c (grub_isdigit): Moved from here ... + * include/grub/misc.h (grub_isdigit): ... here. Inlined. + * kern/misc.c (grub_isgraph): Moved from here ... + * include/grub/misc.h (grub_isgraph): ... here. Inlined. + * kern/misc.c (grub_tolower): Moved from here ... + * include/grub/misc.h (grub_tolower): ... here. Inlined. + 2009-08-24 Vladimir Serbinenko * script/sh/function.c (grub_script_function_find): Cut error message diff --git a/include/grub/misc.h b/include/grub/misc.h index 769ec5cd8..a63a0b442 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -37,8 +37,42 @@ void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n); char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src); char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c); char *EXPORT_FUNC(grub_stpcpy) (char *dest, const char *src); -char *EXPORT_FUNC(grub_strcat) (char *dest, const char *src); -char *EXPORT_FUNC(grub_strncat) (char *dest, const char *src, int c); + +static inline char * +grub_strcat (char *dest, const char *src) +{ + char *p = dest; + + while (*p) + p++; + + while ((*p = *src) != '\0') + { + p++; + src++; + } + + return dest; +} + +static inline char * +grub_strncat (char *dest, const char *src, int c) +{ + char *p = dest; + + while (*p) + p++; + + while ((*p = *src) != '\0' && c--) + { + p++; + src++; + } + + *p = '\0'; + + return dest; +} /* Prototypes for aliases. */ #if !defined (GRUB_UTIL) || !defined (APPLE_CC) @@ -49,19 +83,41 @@ void *EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n); int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n); int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2); int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n); -int EXPORT_FUNC(grub_strcasecmp) (const char *s1, const char *s2); -int EXPORT_FUNC(grub_strncasecmp) (const char *s1, const char *s2, grub_size_t n); + char *EXPORT_FUNC(grub_strchr) (const char *s, int c); char *EXPORT_FUNC(grub_strrchr) (const char *s, int c); int EXPORT_FUNC(grub_strword) (const char *s, const char *w); char *EXPORT_FUNC(grub_strstr) (const char *haystack, const char *needle); -int EXPORT_FUNC(grub_iswordseparator) (int c); int EXPORT_FUNC(grub_isspace) (int c); int EXPORT_FUNC(grub_isprint) (int c); -int EXPORT_FUNC(grub_isalpha) (int c); -int EXPORT_FUNC(grub_isgraph) (int c); -int EXPORT_FUNC(grub_isdigit) (int c); -int EXPORT_FUNC(grub_tolower) (int c); + +static inline int +grub_isalpha (int c) +{ + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); +} + +static inline int +grub_isgraph (int c) +{ + return (c >= '!' && c <= '~'); +} + +static inline int +grub_isdigit (int c) +{ + return (c >= '0' && c <= '9'); +} + +static inline int +grub_tolower (int c) +{ + if (c >= 'A' && c <= 'Z') + return c - 'A' + 'a'; + + return c; +} + static inline int grub_toupper (int c) { @@ -71,6 +127,40 @@ grub_toupper (int c) return c; } +static inline int +grub_strcasecmp (const char *s1, const char *s2) +{ + while (*s1 && *s2) + { + if (grub_tolower (*s1) != grub_tolower (*s2)) + break; + + s1++; + s2++; + } + + return (int) grub_tolower (*s1) - (int) grub_tolower (*s2); +} + +static inline int +grub_strncasecmp (const char *s1, const char *s2, grub_size_t n) +{ + if (n == 0) + return 0; + + while (*s1 && *s2 && --n) + { + if (grub_tolower (*s1) != grub_tolower (*s2)) + break; + + s1++; + s2++; + } + + return (int) grub_tolower (*s1) - (int) grub_tolower (*s2); +} + + unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base); unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, char **end, int base); char *EXPORT_FUNC(grub_strdup) (const char *s); diff --git a/kern/misc.c b/kern/misc.c index d797f1781..1c38fe661 100644 --- a/kern/misc.c +++ b/kern/misc.c @@ -24,6 +24,12 @@ #include #include +static int +grub_iswordseparator (int c) +{ + return (grub_isspace (c) || c == ',' || c == ';' || c == '|' || c == '&'); +} + void * grub_memmove (void *dest, const void *src, grub_size_t n) { @@ -97,42 +103,6 @@ grub_stpcpy (char *dest, const char *src) return d - 1; } -char * -grub_strcat (char *dest, const char *src) -{ - char *p = dest; - - while (*p) - p++; - - while ((*p = *src) != '\0') - { - p++; - src++; - } - - return dest; -} - -char * -grub_strncat (char *dest, const char *src, int c) -{ - char *p = dest; - - while (*p) - p++; - - while ((*p = *src) != '\0' && c--) - { - p++; - src++; - } - - *p = '\0'; - - return dest; -} - int grub_printf (const char *fmt, ...) { @@ -250,39 +220,6 @@ grub_strncmp (const char *s1, const char *s2, grub_size_t n) return (int) *s1 - (int) *s2; } -int -grub_strcasecmp (const char *s1, const char *s2) -{ - while (*s1 && *s2) - { - if (grub_tolower (*s1) != grub_tolower (*s2)) - break; - - s1++; - s2++; - } - - return (int) grub_tolower (*s1) - (int) grub_tolower (*s2); -} - -int -grub_strncasecmp (const char *s1, const char *s2, grub_size_t n) -{ - if (n == 0) - return 0; - - while (*s1 && *s2 && --n) - { - if (grub_tolower (*s1) != grub_tolower (*s2)) - break; - - s1++; - s2++; - } - - return (int) grub_tolower (*s1) - (int) grub_tolower (*s2); -} - char * grub_strchr (const char *s, int c) { @@ -394,12 +331,6 @@ grub_strword (const char *haystack, const char *needle) return 0; } -int -grub_iswordseparator (int c) -{ - return (grub_isspace (c) || c == ',' || c == ';' || c == '|' || c == '&'); -} - int grub_isspace (int c) { @@ -412,33 +343,6 @@ grub_isprint (int c) return (c >= ' ' && c <= '~'); } -int -grub_isalpha (int c) -{ - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); -} - -int -grub_isdigit (int c) -{ - return (c >= '0' && c <= '9'); -} - -int -grub_isgraph (int c) -{ - return (c >= '!' && c <= '~'); -} - -int -grub_tolower (int c) -{ - if (c >= 'A' && c <= 'Z') - return c - 'A' + 'a'; - - return c; -} - unsigned long grub_strtoul (const char *str, char **end, int base) From e7e1f93ff62b0ecaaddad9d63649a4ab76591810 Mon Sep 17 00:00:00 2001 From: phcoder Date: Mon, 24 Aug 2009 23:55:06 +0000 Subject: [PATCH 18/85] 2009-08-25 Vladimir Serbinenko Authentication support. * commands/password.c: New file. * conf/common.rmk (pkglib_MODULES): Add password.mod. (password_mod_SOURCES): New variable. (password_mod_CFLAGS): Likewise. (password_mod_LDFLAGS): Likewise. (normal_mod_SOURCES): Add normal/auth.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add commands/password.c and normal/auth.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/i386-pc.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * include/grub/auth.h: New file. * include/grub/err.h (grub_err_t): New enum value GRUB_ERR_ACCESS_DENIED. * include/grub/menu.h (grub_menu_entry): New fields 'restricted' and 'users'. * include/grub/normal.h (grub_cmdline_get): New argument 'history'. * normal/cmdline.c (grub_cmdline_get): New argument 'history'. All users updated. * normal/auth.c: New file. * normal/main.c (grub_normal_add_menu_entry): Handle --users option. (grub_cmdline_run): Don't allow to go to command line without authentication. * normal/menu.c (grub_menu_execute_entry): Handle restricted entries. * normal/menu_entry.c (grub_menu_entry_run): Don't allow editing menuentry without superuser rights. * normal/menu_viewer.c (grub_menu_viewer_show_menu): Don't exit if user isn't a superuser. --- ChangeLog | 36 ++++++ commands/password.c | 86 +++++++++++++ conf/common.rmk | 9 +- conf/i386-coreboot.rmk | 3 +- conf/i386-efi.rmk | 3 +- conf/i386-ieee1275.rmk | 3 +- conf/i386-pc.rmk | 3 +- conf/powerpc-ieee1275.rmk | 3 +- conf/sparc64-ieee1275.rmk | 3 +- conf/x86_64-efi.rmk | 4 +- include/grub/auth.h | 45 +++++++ include/grub/err.h | 3 +- include/grub/menu.h | 6 + include/grub/normal.h | 2 +- normal/auth.c | 250 ++++++++++++++++++++++++++++++++++++++ normal/cmdline.c | 15 ++- normal/main.c | 33 ++++- normal/menu.c | 13 ++ normal/menu_entry.c | 11 ++ normal/menu_viewer.c | 20 ++- 20 files changed, 531 insertions(+), 20 deletions(-) create mode 100644 commands/password.c create mode 100644 include/grub/auth.h create mode 100644 normal/auth.c diff --git a/ChangeLog b/ChangeLog index f9c915016..34694a4ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,39 @@ +2009-08-25 Vladimir Serbinenko + + Authentication support. + + * commands/password.c: New file. + * conf/common.rmk (pkglib_MODULES): Add password.mod. + (password_mod_SOURCES): New variable. + (password_mod_CFLAGS): Likewise. + (password_mod_LDFLAGS): Likewise. + (normal_mod_SOURCES): Add normal/auth.c. + * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add commands/password.c and + normal/auth.c. + * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. + * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. + * conf/i386-pc.rmk (grub_emu_SOURCES): Likewise. + * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. + * conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise. + * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. + * include/grub/auth.h: New file. + * include/grub/err.h (grub_err_t): New enum value + GRUB_ERR_ACCESS_DENIED. + * include/grub/menu.h (grub_menu_entry): New fields 'restricted' and + 'users'. + * include/grub/normal.h (grub_cmdline_get): New argument 'history'. + * normal/cmdline.c (grub_cmdline_get): New argument 'history'. All + users updated. + * normal/auth.c: New file. + * normal/main.c (grub_normal_add_menu_entry): Handle --users option. + (grub_cmdline_run): Don't allow to go to command line without + authentication. + * normal/menu.c (grub_menu_execute_entry): Handle restricted entries. + * normal/menu_entry.c (grub_menu_entry_run): Don't allow editing + menuentry without superuser rights. + * normal/menu_viewer.c (grub_menu_viewer_show_menu): Don't exit if + user isn't a superuser. + 2009-08-24 Vladimir Serbinenko Save space by inlining misc.c functions. diff --git a/commands/password.c b/commands/password.c new file mode 100644 index 000000000..0e048797e --- /dev/null +++ b/commands/password.c @@ -0,0 +1,86 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 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 +#include +#include +#include +#include +#include + +static grub_dl_t my_mod; + +static grub_err_t +check_password (const char *user, + void *password) +{ + char entered[1024]; + + grub_memset (entered, 0, sizeof (entered)); + + if (!GRUB_GET_PASSWORD (entered, sizeof (entered) - 1)) + return GRUB_ACCESS_DENIED; + + if (grub_auth_strcmp (entered, password) != 0) + return GRUB_ACCESS_DENIED; + + grub_auth_authenticate (user); + + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_cmd_password (grub_command_t cmd __attribute__ ((unused)), + int argc, char **args) +{ + grub_err_t err; + char *pass; + + if (argc != 2) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Two arguments expected."); + + pass = grub_strdup (args[1]); + if (!pass) + return grub_errno; + + err = grub_auth_register_authentication (args[0], check_password, pass); + if (err) + { + grub_free (pass); + return err; + } + grub_dl_ref (my_mod); + return GRUB_ERR_NONE; +} + +static grub_command_t cmd; + +GRUB_MOD_INIT(password) +{ + my_mod = mod; + cmd = grub_register_command ("password", grub_cmd_password, + "password USER PASSWORD", + "Set user password (plaintext). " + "Unrecommended and insecure."); +} + +GRUB_MOD_FINI(password) +{ + grub_unregister_command (cmd); +} diff --git a/conf/common.rmk b/conf/common.rmk index c33e8000a..6d767460b 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -363,7 +363,12 @@ pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \ terminfo.mod test.mod blocklist.mod hexdump.mod \ read.mod sleep.mod loadenv.mod crc.mod parttool.mod \ msdospart.mod memrw.mod normal.mod sh.mod lua.mod \ - gptsync.mod true.mod probe.mod + gptsync.mod true.mod probe.mod password.mod + +# For password.mod. +password_mod_SOURCES = commands/password.c +password_mod_CFLAGS = $(COMMON_CFLAGS) +password_mod_LDFLAGS = $(COMMON_LDFLAGS) # For gptsync.mod. gptsync_mod_SOURCES = commands/gptsync.c @@ -507,7 +512,7 @@ probe_mod_LDFLAGS = $(COMMON_LDFLAGS) # For normal.mod. normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c \ - normal/autofs.c normal/handler.c \ + normal/auth.c normal/autofs.c normal/handler.c \ normal/color.c normal/completion.c normal/datetime.c normal/menu.c \ normal/menu_entry.c normal/menu_text.c normal/menu_viewer.c \ normal/misc.c diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index de3004140..7e9f853d7 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -110,6 +110,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/handler.c commands/ls.c commands/test.c \ commands/search.c commands/blocklist.c commands/hexdump.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ + commands/password.c \ lib/hexdump.c commands/i386/cpuid.c \ disk/host.c disk/loopback.c \ \ @@ -127,7 +128,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ kern/partition.c kern/reader.c kern/term.c \ kern/rescue_reader.c kern/rescue_parser.c \ lib/arg.c normal/cmdline.c normal/misc.c \ - normal/handler.c normal/autofs.c \ + normal/handler.c normal/auth.c normal/autofs.c \ normal/completion.c normal/datetime.c normal/main.c \ normal/menu_text.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index 372d8fc58..f1e5e8fe3 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -39,6 +39,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/search.c commands/hexdump.c lib/hexdump.c \ commands/halt.c commands/reboot.c \ commands/i386/cpuid.c \ + commands/password.c \ disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ @@ -54,7 +55,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ kern/partition.c kern/reader.c kern/term.c \ kern/rescue_reader.c kern/rescue_parser.c \ lib/arg.c normal/cmdline.c normal/command.c normal/datetime.c \ - normal/autofs.c \ + normal/auth.c normal/autofs.c \ normal/completion.c normal/context.c normal/main.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/menu_text.c \ diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk index 98aaf5849..67234ebb6 100644 --- a/conf/i386-ieee1275.rmk +++ b/conf/i386-ieee1275.rmk @@ -66,6 +66,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ lib/hexdump.c commands/halt.c commands/reboot.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ commands/i386/cpuid.c \ + commands/password.c \ disk/host.c disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ @@ -82,7 +83,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ kern/partition.c kern/reader.c kern/term.c \ kern/rescue_reader.c kern/rescue_parser.c \ lib/arg.c normal/cmdline.c normal/datetime.c normal/misc.c \ - normal/handler.c normal/autofs.c \ + normal/handler.c normal/auth.c normal/autofs.c \ normal/completion.c normal/main.c normal/menu_text.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/color.c \ diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 13aaa2618..6b177963e 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -123,6 +123,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ lib/hexdump.c commands/i386/pc/halt.c commands/reboot.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ commands/i386/cpuid.c \ + commands/password.c \ disk/host.c disk/loopback.c disk/scsi.c \ fs/fshelp.c \ \ @@ -134,7 +135,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ kern/partition.c kern/reader.c kern/term.c \ kern/rescue_reader.c kern/rescue_parser.c \ lib/arg.c normal/cmdline.c normal/datetime.c normal/misc.c \ - normal/handler.c normal/autofs.c \ + normal/handler.c normal/auth.c normal/autofs.c \ normal/completion.c normal/main.c normal/color.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ normal/menu_text.c \ diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index c1c04e484..c9b7e7592 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -46,6 +46,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/ls.c commands/blocklist.c commands/hexdump.c \ lib/hexdump.c commands/halt.c commands/reboot.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ + commands/password.c \ disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ @@ -62,7 +63,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ kern/command.c kern/corecmd.c commands/extcmd.c \ lib/arg.c normal/cmdline.c normal/datetime.c \ normal/completion.c normal/misc.c \ - normal/handler.c normal/autofs.c normal/main.c \ + normal/handler.c normal/auth.c normal/autofs.c normal/main.c \ normal/menu.c \ normal/menu_text.c \ normal/menu_entry.c normal/menu_viewer.c \ diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index c3ecba28f..621621399 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -103,6 +103,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/ls.c commands/blocklist.c commands/hexdump.c \ lib/hexdump.c commands/halt.c commands/reboot.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ + commands/password.c \ disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ @@ -119,7 +120,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ kern/command.c kern/corecmd.c commands/extcmd.c \ lib/arg.c normal/cmdline.c normal/datetime.c \ normal/completion.c normal/misc.c \ - normal/handler.c normal/autofs.c normal/main.c \ + normal/handler.c normal/auth.c normal/autofs.c normal/main.c \ normal/menu.c \ normal/menu_text.c \ normal/menu_entry.c normal/menu_viewer.c \ diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index c914fbf19..b4c08b093 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -37,6 +37,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/search.c commands/hexdump.c lib/hexdump.c \ commands/halt.c commands/reboot.c \ commands/i386/cpuid.c \ + commands/password.c \ disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ @@ -50,7 +51,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ kern/command.c kern/corecmd.c commands/extcmd.c kern/file.c \ kern/fs.c commands/boot.c kern/main.c kern/misc.c kern/parser.c \ kern/partition.c kern/readerescue.c kern/term.c \ - lib/arg.c normal/cmdline.c normal/misc.c normal/autofs.c \ + lib/arg.c normal/cmdline.c normal/misc.c normal/auth.c \ + normal/autofs.c \ normal/completion.c normal/datetime.c normal/context.c \ normal/main.c \ normal/menu.c normal/menu_entry.c normal/menu_viewer.c \ diff --git a/include/grub/auth.h b/include/grub/auth.h new file mode 100644 index 000000000..da930eeda --- /dev/null +++ b/include/grub/auth.h @@ -0,0 +1,45 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 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_AURH_HEADER +#define GRUB_AUTH_HEADER 1 + +#include + +/* Macros for indistinguishibility. */ +#define GRUB_ACCESS_DENIED grub_error (GRUB_ERR_ACCESS_DENIED, "Access denied.") +#define GRUB_GET_PASSWORD(string, len) grub_cmdline_get ("Enter password: ", \ + string, len, \ + '*', 0, 0) + +/* Like strcmp but untimeable. Accepts NULL as second argument. */ +int grub_auth_strcmp (const char *user_input, const char *template); +/* Like strcmp but untimeable and ignores commas in needle. */ +int grub_auth_strword (const char *haystack, const char *needle); + +typedef grub_err_t (*grub_auth_callback_t) (const char*, void *); + +grub_err_t grub_auth_register_authentication (const char *user, + grub_auth_callback_t callback, + void *arg); +grub_err_t grub_auth_unregister_authentication (const char *user); + +grub_err_t grub_auth_authenticate (const char *user); +grub_err_t grub_auth_deauthenticate (const char *user); +grub_err_t grub_auth_check_authentication (const char *userlist); + +#endif /* ! GRUB_AUTH_HEADER */ diff --git a/include/grub/err.h b/include/grub/err.h index 3435fb769..7a5ce1ae0 100644 --- a/include/grub/err.h +++ b/include/grub/err.h @@ -53,7 +53,8 @@ typedef enum GRUB_ERR_BAD_GZIP_DATA, GRUB_ERR_MENU, GRUB_ERR_TIMEOUT, - GRUB_ERR_IO + GRUB_ERR_IO, + GRUB_ERR_ACCESS_DENIED } grub_err_t; diff --git a/include/grub/menu.h b/include/grub/menu.h index 3bd25e875..c7114a93b 100644 --- a/include/grub/menu.h +++ b/include/grub/menu.h @@ -32,6 +32,12 @@ struct grub_menu_entry /* The title name. */ const char *title; + /* If set means not everybody is allowed to boot this entry. */ + int restricted; + + /* Allowed users. */ + const char *users; + /* The classes associated with the menu entry: used to choose an icon or other style attributes. This is a dummy head node for the linked list, so for an entry E, diff --git a/include/grub/normal.h b/include/grub/normal.h index 7d8122a2b..feebc85b1 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -56,7 +56,7 @@ void grub_cmdline_run (int nested); /* Defined in `cmdline.c'. */ int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, - int echo_char, int readline); + int echo_char, int readline, int history); grub_err_t grub_set_history (int newsize); /* Defined in `completion.c'. */ diff --git a/normal/auth.c b/normal/auth.c new file mode 100644 index 000000000..1dc61e898 --- /dev/null +++ b/normal/auth.c @@ -0,0 +1,250 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 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 +#include +#include +#include +#include + +struct grub_auth_user +{ + struct grub_auth_user *next; + char *name; + grub_auth_callback_t callback; + void *arg; + int authenticated; +}; + +struct grub_auth_user *users = NULL; + +int +grub_auth_strcmp (const char *user_input, const char *template) +{ + int ok = 1; + const char *ptr1, *ptr2; + for (ptr1 = user_input, ptr2 = template; *ptr1; ptr1++) + if (*ptr1 == (ptr2 ? *ptr2 : ptr1[1]) && ok && ptr2 != NULL) + ptr2++; + else + ok = 0; + + return !ok; +} + +int +grub_auth_strword (const char *haystack, const char *needle) +{ + const char *n_pos = needle; + int found = 0; + + while (grub_iswordseparator (*haystack)) + haystack++; + + while (*haystack) + { + int ok = 1; + /* Crawl both the needle and the haystack word we're on. */ + while(*haystack && !grub_iswordseparator (*haystack)) + { + if (*haystack == *n_pos && ok) + n_pos++; + else + ok = 0; + + haystack++; + } + + if (ok) + found = 1; + } + + return found; +} + +grub_err_t +grub_auth_register_authentication (const char *user, + grub_auth_callback_t callback, + void *arg) +{ + struct grub_auth_user *cur; + + cur = grub_named_list_find (GRUB_AS_NAMED_LIST (users), user); + if (!cur) + cur = grub_zalloc (sizeof (*cur)); + if (!cur) + return grub_errno; + cur->callback = callback; + cur->arg = arg; + if (! cur->name) + { + cur->name = grub_strdup (user); + if (!cur->name) + { + grub_free (cur); + return grub_errno; + } + grub_list_push (GRUB_AS_LIST_P (&users), GRUB_AS_LIST (cur)); + } + return GRUB_ERR_NONE; +} + +grub_err_t +grub_auth_unregister_authentication (const char *user) +{ + struct grub_auth_user *cur; + cur = grub_named_list_find (GRUB_AS_NAMED_LIST (users), user); + if (!cur) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "user '%s' not found", user); + if (!cur->authenticated) + { + grub_free (cur->name); + grub_list_remove (GRUB_AS_LIST_P (&users), GRUB_AS_LIST (cur)); + grub_free (cur); + } + else + { + cur->callback = NULL; + cur->arg = NULL; + } + return GRUB_ERR_NONE; +} + +grub_err_t +grub_auth_authenticate (const char *user) +{ + struct grub_auth_user *cur; + + cur = grub_named_list_find (GRUB_AS_NAMED_LIST (users), user); + if (!cur) + cur = grub_zalloc (sizeof (*cur)); + if (!cur) + return grub_errno; + + cur->authenticated = 1; + + if (! cur->name) + { + cur->name = grub_strdup (user); + if (!cur->name) + { + grub_free (cur); + return grub_errno; + } + grub_list_push (GRUB_AS_LIST_P (&users), GRUB_AS_LIST (cur)); + } + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_auth_deauthenticate (const char *user) +{ + struct grub_auth_user *cur; + cur = grub_named_list_find (GRUB_AS_NAMED_LIST (users), user); + if (!cur) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "user '%s' not found", user); + if (!cur->callback) + { + grub_free (cur->name); + grub_list_remove (GRUB_AS_LIST_P (&users), GRUB_AS_LIST (cur)); + grub_free (cur); + } + else + cur->authenticated = 0; + return GRUB_ERR_NONE; +} + +static int +is_authenticated (const char *userlist) +{ + const char *superusers; + + auto int hook (grub_list_t item); + int hook (grub_list_t item) + { + const char *name; + if (!((struct grub_auth_user *) item)->authenticated) + return 0; + name = ((struct grub_auth_user *) item)->name; + + return (userlist && grub_auth_strword (userlist, name)) + || grub_auth_strword (superusers, name); + } + + superusers = grub_env_get ("superusers"); + + if (!superusers) + return 1; + + return grub_list_iterate (GRUB_AS_LIST (users), hook); +} + +grub_err_t +grub_auth_check_authentication (const char *userlist) +{ + char login[1024]; + struct grub_auth_user *cur = NULL; + grub_err_t err; + + auto int hook (grub_list_t item); + int hook (grub_list_t item) + { + if (grub_auth_strcmp (login, ((struct grub_auth_user *) item)->name) == 0) + cur = (struct grub_auth_user *) item; + return 0; + } + + auto int hook_any (grub_list_t item); + int hook_any (grub_list_t item) + { + if (((struct grub_auth_user *) item)->callback) + cur = (struct grub_auth_user *) item; + return 0; + } + + grub_memset (login, 0, sizeof (login)); + + if (is_authenticated (userlist)) + return GRUB_ERR_NONE; + + if (!grub_cmdline_get ("Enter username: ", login, sizeof (login) - 1, + 0, 0, 0)) + return GRUB_ACCESS_DENIED; + + grub_list_iterate (GRUB_AS_LIST (users), hook); + + if (!cur || ! cur->callback) + { + grub_list_iterate (GRUB_AS_LIST (users), hook_any); + + /* No users present at all. */ + if (!cur) + return GRUB_ACCESS_DENIED; + + /* Display any of available authentication schemes. */ + err = cur->callback (login, 0); + + return GRUB_ACCESS_DENIED; + } + err = cur->callback (login, cur->arg); + if (is_authenticated (userlist)) + return GRUB_ERR_NONE; + return GRUB_ACCESS_DENIED; +} diff --git a/normal/cmdline.c b/normal/cmdline.c index 9a07d7d59..56f892121 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -181,7 +181,7 @@ print_completion (const char *item, grub_completion_type_t type, int count) /* FIXME: The dumb interface is not supported yet. */ int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, - int echo_char, int readline) + int echo_char, int readline, int history) { unsigned xpos, ypos, ystart; grub_size_t lpos, llen; @@ -280,7 +280,7 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, cl_insert (cmdline); - if (hist_used == 0) + if (history && hist_used == 0) grub_history_add (buf); while ((key = GRUB_TERM_ASCII_CHAR (grub_getkey ())) != '\n' && key != '\r') @@ -468,11 +468,14 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, while (buf[lpos] == ' ') lpos++; - histpos = 0; - if (grub_strlen (buf) > 0) + if (history) { - grub_history_replace (histpos, buf); - grub_history_add (""); + histpos = 0; + if (grub_strlen (buf) > 0) + { + grub_history_replace (histpos, buf); + grub_history_add (""); + } } grub_memcpy (cmdline, buf + lpos, llen - lpos + 1); diff --git a/normal/main.c b/normal/main.c index 66d841867..748eef805 100644 --- a/normal/main.c +++ b/normal/main.c @@ -28,6 +28,7 @@ #include #include #include +#include #define GRUB_DEFAULT_HISTORY_SIZE 50 @@ -164,6 +165,7 @@ grub_normal_add_menu_entry (int argc, const char **args, int i; struct grub_menu_entry_class *classes_head; /* Dummy head node for list. */ struct grub_menu_entry_class *classes_tail; + char *users = NULL; /* Allocate dummy head node for class list. */ classes_head = grub_zalloc (sizeof (struct grub_menu_entry_class)); @@ -218,6 +220,18 @@ grub_normal_add_menu_entry (int argc, const char **args, classes_tail = new_class; continue; } + else if (grub_strcmp(arg, "users") == 0) + { + i++; + users = grub_strdup (args[i]); + if (! users) + { + failed = 1; + break; + } + + continue; + } else { /* Handle invalid argument. */ @@ -275,6 +289,9 @@ grub_normal_add_menu_entry (int argc, const char **args, (*last)->title = menutitle; (*last)->classes = classes_head; + if (users) + (*last)->restricted = 1; + (*last)->users = users; (*last)->sourcecode = menusourcecode; menu->size++; @@ -465,7 +482,19 @@ quit: void grub_cmdline_run (int nested) { - grub_reader_t reader = grub_reader_get_current (); + grub_reader_t reader; + grub_err_t err = GRUB_ERR_NONE; + + err = grub_auth_check_authentication (NULL); + + if (err) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + return; + } + + reader = grub_reader_get_current (); reader_nested = nested; if (reader->init) @@ -501,7 +530,7 @@ grub_normal_read_line (char **line, int cont) while (1) { cmdline[0] = 0; - if (grub_cmdline_get (prompt, cmdline, sizeof (cmdline), 0, 1)) + if (grub_cmdline_get (prompt, cmdline, sizeof (cmdline), 0, 1, 1)) break; if ((reader_nested) || (cont)) diff --git a/normal/menu.c b/normal/menu.c index 59ad83fa7..8ee7d1c22 100644 --- a/normal/menu.c +++ b/normal/menu.c @@ -26,6 +26,7 @@ #include #include #include +#include /* Get a menu entry by its index in the entry list. */ grub_menu_entry_t @@ -124,6 +125,18 @@ get_and_remove_first_entry_number (const char *name) void grub_menu_execute_entry(grub_menu_entry_t entry) { + grub_err_t err = GRUB_ERR_NONE; + + if (entry->restricted) + err = grub_auth_check_authentication (entry->users); + + if (err) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + return; + } + grub_parser_execute ((char *) entry->sourcecode); if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ()) diff --git a/normal/menu_entry.c b/normal/menu_entry.c index f7662ff75..75a63779f 100644 --- a/normal/menu_entry.c +++ b/normal/menu_entry.c @@ -23,6 +23,7 @@ #include #include #include +#include enum update_mode { @@ -1026,6 +1027,16 @@ grub_menu_entry_run (grub_menu_entry_t entry) { struct screen *screen; int prev_c; + grub_err_t err = GRUB_ERR_NONE; + + err = grub_auth_check_authentication (NULL); + + if (err) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + return; + } screen = make_screen (entry); if (! screen) diff --git a/normal/menu_viewer.c b/normal/menu_viewer.c index 37d317b0b..1bd271a21 100644 --- a/normal/menu_viewer.c +++ b/normal/menu_viewer.c @@ -21,6 +21,7 @@ #include #include #include +#include /* The list of menu viewers. */ static grub_menu_viewer_t menu_viewer_list; @@ -55,9 +56,26 @@ grub_err_t grub_menu_viewer_show_menu (grub_menu_t menu, int nested) { grub_menu_viewer_t cur = get_current_menu_viewer (); + grub_err_t err1, err2; if (!cur) return grub_error (GRUB_ERR_BAD_ARGUMENT, "No menu viewer available."); - return cur->show_menu (menu, nested); + while (1) + { + err1 = cur->show_menu (menu, nested); + grub_print_error (); + + err2 = grub_auth_check_authentication (NULL); + if (err2) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + continue; + } + + break; + } + + return err1; } From ff747d50c1fcf81e0226d2da1923b1b8113f2b93 Mon Sep 17 00:00:00 2001 From: phcoder Date: Tue, 25 Aug 2009 08:11:50 +0000 Subject: [PATCH 19/85] 2009-08-25 Vladimir Serbinenko Fix breakage in normal/auth.c. * normal/auth.c (grub_iswordseparator): New function. --- ChangeLog | 6 ++++++ normal/auth.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 34694a4ea..4f8c068dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-25 Vladimir Serbinenko + + Fix breakage in normal/auth.c. + + * normal/auth.c (grub_iswordseparator): New function. + 2009-08-25 Vladimir Serbinenko Authentication support. diff --git a/normal/auth.c b/normal/auth.c index 1dc61e898..9029ba1ce 100644 --- a/normal/auth.c +++ b/normal/auth.c @@ -48,6 +48,12 @@ grub_auth_strcmp (const char *user_input, const char *template) return !ok; } +static int +grub_iswordseparator (int c) +{ + return (grub_isspace (c) || c == ',' || c == ';' || c == '|' || c == '&'); +} + int grub_auth_strword (const char *haystack, const char *needle) { From aea664ea288daf09569c9eed2ac7932fd7b1f1af Mon Sep 17 00:00:00 2001 From: phcoder Date: Tue, 25 Aug 2009 08:28:13 +0000 Subject: [PATCH 20/85] 2009-08-25 Vladimir Serbinenko Fix breakage in grub-setup. * util/i386/pc/grub-setup.c (setup): Use "part_msdos" instead of "msdos_partition_map". --- ChangeLog | 7 +++++++ util/i386/pc/grub-setup.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4f8c068dd..d30cfd137 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-08-25 Vladimir Serbinenko + + Fix breakage in grub-setup. + + * util/i386/pc/grub-setup.c (setup): Use "part_msdos" instead of + "msdos_partition_map". + 2009-08-25 Vladimir Serbinenko Fix breakage in normal/auth.c. diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c index 7f38c4293..ccfbd1d25 100644 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@ -338,12 +338,12 @@ setup (const char *dir, goto unable_to_embed; } - grub_partition_iterate (dest_dev->disk, (strcmp (dest_partmap, "msdos_partition_map") ? + grub_partition_iterate (dest_dev->disk, (strcmp (dest_partmap, "part_msdos") ? find_usable_region_gpt : find_usable_region_msdos)); if (embed_region.end == embed_region.start) { - if (! strcmp (dest_partmap, "msdos_partition_map")) + if (! strcmp (dest_partmap, "part_msdos")) grub_util_warn ("This msdos-style partition label has no post-MBR gap; embedding won't be possible!"); else grub_util_warn ("This GPT partition label has no BIOS Boot Partition; embedding won't be possible!"); From 3b76e68ba7f132656cd5841acf9c7171c1791b1c Mon Sep 17 00:00:00 2001 From: fzielcke Date: Tue, 25 Aug 2009 19:42:56 +0000 Subject: [PATCH 21/85] 2009-08-25 Felix Zielcke * util/grub.d/00_header.in: Move check for the video backend of gfxterm from here ... * util/grub-mkconfig.in: ... to here. Enable gfxterm if there's a suitable video backend. --- ChangeLog | 7 +++++++ util/grub-mkconfig.in | 22 ++++++++++++++++++++-- util/grub.d/00_header.in | 14 +------------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index d30cfd137..2236b61aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-08-25 Felix Zielcke + + * util/grub.d/00_header.in: Move check for the video backend of + gfxterm from here ... + * util/grub-mkconfig.in: ... to here. Enable gfxterm if there's + a suitable video backend. + 2009-08-25 Vladimir Serbinenko Fix breakage in grub-setup. diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 8e3c3372b..d9640e910 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -141,7 +141,24 @@ if [ "x${GRUB_TERMINAL}" != "x" ] ; then fi case x${GRUB_TERMINAL_OUTPUT} in - x | xconsole | xserial | xofconsole | xgfxterm) ;; + x | xgfxterm) + # If this platform supports gfxterm, try to use it. + if test -e ${grub_prefix}/gfxterm.mod ; then + GRUB_VIDEO_BACKEND= + for i in vbe ; do + if test -e ${grub_prefix}/$i.mod ; then + GRUB_VIDEO_BACKEND=$i + break + fi + done + if [ -n "${GRUB_VIDEO_BACKEND}" ] ; then + GRUB_TERMINAL_OUTPUT=gfxterm + elif [ "${GRUB_TERMINAL_OUTPUT}" = "gfxterm" ] ; then + echo "No suitable backend could be found for gfxterm." >&2 ; exit 1 + fi + fi + ;; + xconsole | xserial | xofconsole) ;; *) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;; esac @@ -190,7 +207,8 @@ export GRUB_DEVICE \ GRUB_DEVICE_BOOT_UUID \ GRUB_FS \ GRUB_FONT_PATH \ - GRUB_PRELOAD_MODULES + GRUB_PRELOAD_MODULES \ + GRUB_VIDEO_BACKEND # These are optional, user-defined variables. export GRUB_DEFAULT \ diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 98c7c004b..9f421dc1c 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -73,23 +73,11 @@ case x${GRUB_TERMINAL_OUTPUT} in # Make the font accessible prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_FONT_PATH}` - # Pick a video backend - video_backend= - for i in vbe ; do - if test -e ${grub_prefix}/$i.mod ; then - video_backend=$i - break - fi - done - if ! [ "${video_backend}" ] ; then - echo "No suitable backend could be found for gfxterm." >&2 ; exit 1 - fi - cat << EOF if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then set gfxmode=${GRUB_GFXMODE} insmod gfxterm - insmod ${video_backend} + insmod ${GRUB_VIDEO_BACKEND} if terminal_output gfxterm ; then true ; else # For backward compatibility with versions of terminal.mod that don't # understand terminal_output From beefc59841349272faab093d1a1d3d99130bcd64 Mon Sep 17 00:00:00 2001 From: phcoder Date: Tue, 25 Aug 2009 19:57:18 +0000 Subject: [PATCH 22/85] 2009-08-25 Vladimir Serbinenko Cleanup NetBSD root support. * loader/i386/bsd.c (grub_netbsd_boot): Remove call to grub_bsd_get_device. Fix typo. --- ChangeLog | 8 ++++++++ loader/i386/bsd.c | 5 +---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2236b61aa..1de68adf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-08-25 Vladimir Serbinenko + + Cleanup NetBSD root support. + + * loader/i386/bsd.c (grub_netbsd_boot): Remove call to + grub_bsd_get_device. + Fix typo. + 2009-08-25 Felix Zielcke * util/grub.d/00_header.in: Move check for the video backend of diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 1b6f1902b..0b9a2b471 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -626,14 +626,11 @@ static grub_err_t grub_netbsd_boot (void) { struct grub_netbsd_bootinfo *bootinfo; - grub_uint32_t biosdev, unit, slice, part; - - grub_bsd_get_device (&biosdev, &unit, &slice, &part); if (kern_end + sizeof (struct grub_netbsd_btinfo_rootdevice) + sizeof (struct grub_netbsd_bootinfo) > grub_os_area_addr + grub_os_area_size) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "No memory fo boot info."); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "No memory for boot info."); if (netbsd_root) { From 1ae2078cd86989d79754d19557b54f9cd9a98350 Mon Sep 17 00:00:00 2001 From: phcoder Date: Tue, 25 Aug 2009 23:18:48 +0000 Subject: [PATCH 23/85] 2009-08-25 Vladimir Serbinenko Enable bsd.mod on coreboot. * conf/i386-coreboot.rmk (pkglib_MODULES): Add bsd.mod. (bsd_mod_SOURCES): New variable. (bsd_mod_CFLAGS): Likewise. (bsd_mod_LDFLAGS): Likewise. (bsd_mod_ASFLAGS): Likewise. * loader/i386/bsd.c [!GRUB_MACHINE_PCBIOS]: Fix includes. (grub_bsd_get_device) [!GRUB_MACHINE_PCBIOS]: Set *biosdev to 0xff. --- ChangeLog | 12 ++++++++++++ conf/i386-coreboot.rmk | 7 +++++++ loader/i386/bsd.c | 6 +++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1de68adf1..e5d7ba088 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2009-08-25 Vladimir Serbinenko + + Enable bsd.mod on coreboot. + + * conf/i386-coreboot.rmk (pkglib_MODULES): Add bsd.mod. + (bsd_mod_SOURCES): New variable. + (bsd_mod_CFLAGS): Likewise. + (bsd_mod_LDFLAGS): Likewise. + (bsd_mod_ASFLAGS): Likewise. + * loader/i386/bsd.c [!GRUB_MACHINE_PCBIOS]: Fix includes. + (grub_bsd_get_device) [!GRUB_MACHINE_PCBIOS]: Set *biosdev to 0xff. + 2009-08-25 Vladimir Serbinenko Cleanup NetBSD root support. diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index 7e9f853d7..196abe68b 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -204,6 +204,13 @@ aout_mod_SOURCES = loader/aout.c aout_mod_CFLAGS = $(COMMON_CFLAGS) aout_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For bsd.mod +pkglib_MODULES += bsd.mod +bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c loader/i386/bsd_helper.S loader/i386/bsd_trampoline.S +bsd_mod_CFLAGS = $(COMMON_CFLAGS) +bsd_mod_LDFLAGS = $(COMMON_LDFLAGS) +bsd_mod_ASFLAGS = $(COMMON_ASFLAGS) + # For play.mod. play_mod_SOURCES = commands/i386/pc/play.c play_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 0b9a2b471..0cb3c75f1 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -37,10 +37,10 @@ #ifdef GRUB_MACHINE_PCBIOS #include +#endif #include #include #include -#endif #define ALIGN_DWORD(a) ALIGN_UP (a, 4) #define ALIGN_QWORD(a) ALIGN_UP (a, 8) @@ -138,7 +138,11 @@ grub_bsd_get_device (grub_uint32_t * biosdev, char *p; grub_device_t dev; +#ifdef GRUB_MACHINE_PCBIOS *biosdev = grub_get_root_biosnumber () & 0xff; +#else + *biosdev = 0xff; +#endif *unit = (*biosdev & 0x7f); *slice = 0xff; *part = 0xff; From 552bf6c568e367ed34b60277519c6f4e2cd18bf7 Mon Sep 17 00:00:00 2001 From: phcoder Date: Wed, 26 Aug 2009 00:32:57 +0000 Subject: [PATCH 24/85] 2009-08-25 Vladimir Serbinenko NetBSD memory map support. * include/grub/i386/bsd.h (NETBSD_BTINFO_MEMMAP): New definition. (grub_netbsd_btinfo_mmap_header): New structure. (grub_netbsd_btinfo_mmap_entry): Likewise. * loader/i386/bsd.c (grub_netbsd_boot): Pass memory map. --- ChangeLog | 9 ++++++ include/grub/i386/bsd.h | 18 +++++++++++ loader/i386/bsd.c | 71 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 91 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5d7ba088..54b3e4849 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-08-25 Vladimir Serbinenko + + NetBSD memory map support. + + * include/grub/i386/bsd.h (NETBSD_BTINFO_MEMMAP): New definition. + (grub_netbsd_btinfo_mmap_header): New structure. + (grub_netbsd_btinfo_mmap_entry): Likewise. + * loader/i386/bsd.c (grub_netbsd_boot): Pass memory map. + 2009-08-25 Vladimir Serbinenko Enable bsd.mod on coreboot. diff --git a/include/grub/i386/bsd.h b/include/grub/i386/bsd.h index 2939035d2..8ffaf7d18 100644 --- a/include/grub/i386/bsd.h +++ b/include/grub/i386/bsd.h @@ -203,6 +203,7 @@ struct grub_netbsd_bootinfo #define NETBSD_BTINFO_BOOTPATH 0 #define NETBSD_BTINFO_ROOTDEVICE 1 #define NETBSD_BTINFO_BOOTDISK 3 +#define NETBSD_BTINFO_MEMMAP 9 struct grub_netbsd_btinfo_common { @@ -210,6 +211,23 @@ struct grub_netbsd_btinfo_common int type; }; +struct grub_netbsd_btinfo_mmap_header +{ + struct grub_netbsd_btinfo_common common; + grub_uint32_t count; +}; + +struct grub_netbsd_btinfo_mmap_entry +{ + grub_uint64_t addr; + grub_uint64_t len; +#define NETBSD_MMAP_AVAILABLE 1 +#define NETBSD_MMAP_RESERVED 2 +#define NETBSD_MMAP_ACPI 3 +#define NETBSD_MMAP_NVS 4 + grub_uint32_t type; +}; + struct grub_netbsd_btinfo_bootpath { struct grub_netbsd_btinfo_common common; diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 0cb3c75f1..1accfb660 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -630,30 +630,87 @@ static grub_err_t grub_netbsd_boot (void) { struct grub_netbsd_bootinfo *bootinfo; + int count = 0; + struct grub_netbsd_btinfo_mmap_header *mmap; + struct grub_netbsd_btinfo_mmap_entry *pm; + void *curarg; + + auto int NESTED_FUNC_ATTR count_hook (grub_uint64_t, grub_uint64_t, grub_uint32_t); + int NESTED_FUNC_ATTR count_hook (grub_uint64_t addr __attribute__ ((unused)), + grub_uint64_t size __attribute__ ((unused)), + grub_uint32_t type __attribute__ ((unused))) + { + count++; + return 0; + } + + auto int NESTED_FUNC_ATTR fill_hook (grub_uint64_t, grub_uint64_t, grub_uint32_t); + int NESTED_FUNC_ATTR fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type) + { + pm->addr = addr; + pm->len = size; + + switch (type) + { + case GRUB_MACHINE_MEMORY_AVAILABLE: + pm->type = NETBSD_MMAP_AVAILABLE; + break; + + case GRUB_MACHINE_MEMORY_ACPI: + pm->type = NETBSD_MMAP_ACPI; + break; + + case GRUB_MACHINE_MEMORY_NVS: + pm->type = NETBSD_MMAP_NVS; + break; + + default: + pm->type = NETBSD_MMAP_RESERVED; + break; + } + pm++; + + return 0; + } + + grub_mmap_iterate (count_hook); if (kern_end + sizeof (struct grub_netbsd_btinfo_rootdevice) - + sizeof (struct grub_netbsd_bootinfo) > grub_os_area_addr - + grub_os_area_size) + + sizeof (struct grub_netbsd_bootinfo) + + sizeof (struct grub_netbsd_btinfo_mmap_header) + + count * sizeof (struct grub_netbsd_btinfo_mmap_entry) + > grub_os_area_addr + grub_os_area_size) return grub_error (GRUB_ERR_OUT_OF_MEMORY, "No memory for boot info."); + curarg = mmap = (struct grub_netbsd_btinfo_mmap_header *) kern_end; + pm = (struct grub_netbsd_btinfo_mmap_entry *) (mmap + 1); + + grub_mmap_iterate (fill_hook); + mmap->common.type = NETBSD_BTINFO_MEMMAP; + mmap->common.len = (char *) pm - (char *) mmap; + mmap->count = count; + curarg = pm; + if (netbsd_root) { struct grub_netbsd_btinfo_rootdevice *rootdev; - rootdev = (struct grub_netbsd_btinfo_rootdevice *) kern_end; + rootdev = (struct grub_netbsd_btinfo_rootdevice *) curarg; rootdev->common.len = sizeof (struct grub_netbsd_btinfo_rootdevice); rootdev->common.type = NETBSD_BTINFO_ROOTDEVICE; grub_strncpy (rootdev->devname, netbsd_root, sizeof (rootdev->devname)); bootinfo = (struct grub_netbsd_bootinfo *) (rootdev + 1); - bootinfo->bi_count = 1; - bootinfo->bi_data[0] = rootdev; + bootinfo->bi_count = 2; + bootinfo->bi_data[0] = mmap; + bootinfo->bi_data[1] = rootdev; } else { - bootinfo = (struct grub_netbsd_bootinfo *) kern_end; - bootinfo->bi_count = 0; + bootinfo = (struct grub_netbsd_bootinfo *) curarg; + bootinfo->bi_count = 1; + bootinfo->bi_data[0] = mmap; } grub_unix_real_boot (entry, bootflags, 0, bootinfo, From 32a716555daef67288b6b848338684742069f150 Mon Sep 17 00:00:00 2001 From: bean Date: Wed, 26 Aug 2009 14:17:34 +0000 Subject: [PATCH 25/85] 2009-08-26 Bean * fs/xfs.c (GRUB_XFS_INO_INOINAG): Replace 1L with 1LL to support 64-bit number. (GRUB_XFS_FSB_TO_BLOCK): Likewise. (grub_xfs_inode_block): Change return type to grub_uint64_t. (grub_xfs_read_inode): Change type of block to grub_uint64_t. --- ChangeLog | 8 ++++++++ fs/xfs.c | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 54b3e4849..953cf126e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-08-26 Bean + + * fs/xfs.c (GRUB_XFS_INO_INOINAG): Replace 1L with 1LL to support + 64-bit number. + (GRUB_XFS_FSB_TO_BLOCK): Likewise. + (grub_xfs_inode_block): Change return type to grub_uint64_t. + (grub_xfs_read_inode): Change type of block to grub_uint64_t. + 2009-08-25 Vladimir Serbinenko NetBSD memory map support. diff --git a/fs/xfs.c b/fs/xfs.c index a143b55a0..1b18bef3b 100644 --- a/fs/xfs.c +++ b/fs/xfs.c @@ -160,13 +160,13 @@ static grub_dl_t my_mod; #define GRUB_XFS_INO_AGBITS(data) \ ((data)->sblock.log2_agblk + (data)->sblock.log2_inop) #define GRUB_XFS_INO_INOINAG(data, ino) \ - (grub_be_to_cpu64 (ino) & ((1 << GRUB_XFS_INO_AGBITS (data)) - 1)) + (grub_be_to_cpu64 (ino) & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1)) #define GRUB_XFS_INO_AG(data,ino) \ (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data)) #define GRUB_XFS_FSB_TO_BLOCK(data, fsb) \ (((fsb) >> (data)->sblock.log2_agblk) * (data)->agsize \ - + ((fsb) & ((1 << (data)->sblock.log2_agblk) - 1))) + + ((fsb) & ((1LL << (data)->sblock.log2_agblk) - 1))) #define GRUB_XFS_EXTENT_OFFSET(exts,ex) \ ((grub_be_to_cpu32 (exts[ex][0]) & ~(1 << 31)) << 23 \ @@ -185,7 +185,7 @@ static grub_dl_t my_mod; #define GRUB_XFS_NEXT_DIRENT(pos,len) \ (pos) + GRUB_XFS_ROUND_TO_DIRENT (8 + 1 + len + 2) -static inline int +static inline grub_uint64_t grub_xfs_inode_block (struct grub_xfs_data *data, grub_uint64_t ino) { @@ -213,7 +213,7 @@ static grub_err_t grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, struct grub_xfs_inode *inode) { - int block = grub_xfs_inode_block (data, ino); + grub_uint64_t block = grub_xfs_inode_block (data, ino); int offset = grub_xfs_inode_offset (data, ino); /* Read the inode. */ From 6e2a90859add777ca77b061e8ac57ceb79091277 Mon Sep 17 00:00:00 2001 From: phcoder Date: Fri, 28 Aug 2009 13:01:26 +0000 Subject: [PATCH 26/85] 2009-08-28 Vladimir Serbinenko Split befs.mod and afs.mod into *_be.mod and *.mod * conf/common.rmk (grub_probe_SOURCES): Add afs_be.c and befs_be.c. (grub_fstest_SOURCES): Likewise. (pkglib_MODULES): Add afs_be.mod and befs_be.mod. (afs_be_mod_SOURCES): New variable. (afs_be_mod_CFLAGS): Likewise. (afs_be_mod_LDFLAGS): Likewise. (befs_be_mod_SOURCES): Likewise. (befs_be_mod_CFLAGS): Likewise. (befs_be_mod_LDFLAGS): Likewise. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add afs_be.c and befs_be.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/i386-pc.rmk (grub_setup_SOURCES): Likewise. (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * fs/afs_be.c: New file. * fs/befs_be.c: New file. * fs/afs.c (GRUB_AFS_FSNAME_SUFFIX): New definition. (GRUB_AFS_FSNAME): Use GRUB_AFS_FSNAME_SUFFIX. (U16): Replaced with ... (grub_afs_to_cpu16): ...this. All users updated. (U32): Replaced with ... (grub_afs_to_cpu32): ...this. All users updated. (U64): Replaced with ... (grub_afs_to_cpu64): ...this. All users updated. (GRUB_AFS_BO_LITTLE_ENDIAN): Remove. (GRUB_AFS_BO_BIG_ENDIAN): Likewise. (grub_afs_validate_sblock): Check only one endiannness. (GRUB_MOD_INIT (befs)) [MODE_BIGENDIAN && MODE_BFS]: Rename to .. (GRUB_MOD_INIT (befs_be)) [MODE_BIGENDIAN && MODE_BFS]: ... this. (GRUB_MOD_INIT (afs)) [MODE_BIGENDIAN && !MODE_BFS]: Rename to .. (GRUB_MOD_INIT (afs_be)) [MODE_BIGENDIAN && !MODE_BFS]: ... this. (GRUB_MOD_FINI (befs)) [MODE_BIGENDIAN && MODE_BFS]: Rename to .. (GRUB_MOD_FINI (befs_be)) [MODE_BIGENDIAN && MODE_BFS]: ... this. (GRUB_MOD_FINI (afs)) [MODE_BIGENDIAN && !MODE_BFS]: Rename to .. (GRUB_MOD_FINI (afs_be)) [MODE_BIGENDIAN && !MODE_BFS]: ... this. --- ChangeLog | 43 ++++++++++ conf/common.rmk | 18 ++++- conf/i386-coreboot.rmk | 3 +- conf/i386-efi.rmk | 3 +- conf/i386-ieee1275.rmk | 3 +- conf/i386-pc.rmk | 6 +- conf/powerpc-ieee1275.rmk | 3 +- conf/sparc64-ieee1275.rmk | 6 +- conf/x86_64-efi.rmk | 2 +- fs/afs.c | 165 +++++++++++++++++--------------------- fs/afs_be.c | 2 + fs/befs_be.c | 4 + 12 files changed, 156 insertions(+), 102 deletions(-) create mode 100644 fs/afs_be.c create mode 100644 fs/befs_be.c diff --git a/ChangeLog b/ChangeLog index 953cf126e..ab542e2e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,46 @@ +2009-08-28 Vladimir Serbinenko + + Split befs.mod and afs.mod into *_be.mod and *.mod + + * conf/common.rmk (grub_probe_SOURCES): Add afs_be.c and befs_be.c. + (grub_fstest_SOURCES): Likewise. + (pkglib_MODULES): Add afs_be.mod and befs_be.mod. + (afs_be_mod_SOURCES): New variable. + (afs_be_mod_CFLAGS): Likewise. + (afs_be_mod_LDFLAGS): Likewise. + (befs_be_mod_SOURCES): Likewise. + (befs_be_mod_CFLAGS): Likewise. + (befs_be_mod_LDFLAGS): Likewise. + * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add afs_be.c and befs_be.c. + * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. + * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. + * conf/i386-pc.rmk (grub_setup_SOURCES): Likewise. + (grub_emu_SOURCES): Likewise. + * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. + * conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise. + * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. + * fs/afs_be.c: New file. + * fs/befs_be.c: New file. + * fs/afs.c (GRUB_AFS_FSNAME_SUFFIX): New definition. + (GRUB_AFS_FSNAME): Use GRUB_AFS_FSNAME_SUFFIX. + (U16): Replaced with ... + (grub_afs_to_cpu16): ...this. All users updated. + (U32): Replaced with ... + (grub_afs_to_cpu32): ...this. All users updated. + (U64): Replaced with ... + (grub_afs_to_cpu64): ...this. All users updated. + (GRUB_AFS_BO_LITTLE_ENDIAN): Remove. + (GRUB_AFS_BO_BIG_ENDIAN): Likewise. + (grub_afs_validate_sblock): Check only one endiannness. + (GRUB_MOD_INIT (befs)) [MODE_BIGENDIAN && MODE_BFS]: Rename to .. + (GRUB_MOD_INIT (befs_be)) [MODE_BIGENDIAN && MODE_BFS]: ... this. + (GRUB_MOD_INIT (afs)) [MODE_BIGENDIAN && !MODE_BFS]: Rename to .. + (GRUB_MOD_INIT (afs_be)) [MODE_BIGENDIAN && !MODE_BFS]: ... this. + (GRUB_MOD_FINI (befs)) [MODE_BIGENDIAN && MODE_BFS]: Rename to .. + (GRUB_MOD_FINI (befs_be)) [MODE_BIGENDIAN && MODE_BFS]: ... this. + (GRUB_MOD_FINI (afs)) [MODE_BIGENDIAN && !MODE_BFS]: Rename to .. + (GRUB_MOD_FINI (afs_be)) [MODE_BIGENDIAN && !MODE_BFS]: ... this. + 2009-08-26 Bean * fs/xfs.c (GRUB_XFS_INO_INOINAG): Replace 1L with 1LL to support diff --git a/conf/common.rmk b/conf/common.rmk index 6d767460b..7727f19e8 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -17,7 +17,8 @@ grub_probe_SOURCES = util/grub-probe.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \ + fs/befs.c fs/befs_be.c fs/tar.c \ \ partmap/msdos.c partmap/apple.c partmap/sun.c partmap/gpt.c\ kern/fs.c kern/env.c fs/fshelp.c \ @@ -38,7 +39,8 @@ grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c fs/befs.c \ + fs/befs_be.c fs/tar.c \ \ kern/partition.c partmap/msdos.c partmap/apple.c partmap/sun.c \ partmap/gpt.c \ @@ -177,7 +179,7 @@ CLEANFILES += grub-dumpbios pkglib_MODULES += fshelp.mod fat.mod ufs1.mod ufs2.mod ext2.mod ntfs.mod \ ntfscomp.mod minix.mod hfs.mod jfs.mod iso9660.mod xfs.mod \ affs.mod sfs.mod hfsplus.mod reiserfs.mod cpio.mod tar.mod \ - udf.mod afs.mod befs.mod + udf.mod afs.mod afs_be.mod befs.mod befs_be.mod # For fshelp.mod. fshelp_mod_SOURCES = fs/fshelp.c @@ -279,11 +281,21 @@ afs_mod_SOURCES = fs/afs.c afs_mod_CFLAGS = $(COMMON_CFLAGS) afs_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For afs_be.mod. +afs_be_mod_SOURCES = fs/afs_be.c +afs_be_mod_CFLAGS = $(COMMON_CFLAGS) +afs_be_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For befs.mod. befs_mod_SOURCES = fs/befs.c befs_mod_CFLAGS = $(COMMON_CFLAGS) befs_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For befs_be.mod. +befs_be_mod_SOURCES = fs/befs_be.c +befs_be_mod_CFLAGS = $(COMMON_CFLAGS) +befs_be_mod_LDFLAGS = $(COMMON_LDFLAGS) + # Partition maps. pkglib_MODULES += part_amiga.mod diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index 196abe68b..990ba805d 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -117,7 +117,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \ + fs/befs.c fs/befs_be.c fs/tar.c \ \ fs/fshelp.c \ io/gzio.c \ diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index f1e5e8fe3..b470a7687 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -45,7 +45,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \ + fs/befs.c fs/befs_be.c fs/tar.c \ \ io/gzio.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk index 67234ebb6..989f1bc61 100644 --- a/conf/i386-ieee1275.rmk +++ b/conf/i386-ieee1275.rmk @@ -72,7 +72,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c fs/befs.c \ + fs/befs_be.c fs/tar.c \ \ fs/fshelp.c \ io/gzio.c \ diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 6b177963e..d415aed32 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -102,7 +102,8 @@ grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \ fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \ + fs/befs.c fs/befs_be.c fs/tar.c \ \ partmap/msdos.c partmap/gpt.c \ \ @@ -147,7 +148,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \ + fs/befs.c fs/befs_be.c fs/tar.c \ \ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/hostdisk.c util/getroot.c \ diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index c9b7e7592..0c6650dfd 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -52,7 +52,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \ + fs/befs.c fs/befs_be.c fs/tar.c \ \ io/gzio.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index 621621399..7851fd64a 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -78,7 +78,8 @@ grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \ fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \ + fs/befs.c fs/befs_be.c fs/tar.c \ \ partmap/amiga.c partmap/apple.c partmap/msdos.c \ partmap/sun.c partmap/acorn.c \ @@ -109,7 +110,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \ + fs/befs.c fs/befs_be.c fs/tar.c \ \ io/gzio.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index b4c08b093..0defdcd93 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -43,7 +43,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ - fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \ + fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \ \ io/gzio.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ diff --git a/fs/afs.c b/fs/afs.c index 971c8bd2e..cd61f4db9 100644 --- a/fs/afs.c +++ b/fs/afs.c @@ -26,10 +26,16 @@ #include #include -#ifdef MODE_BFS -#define GRUB_AFS_FSNAME "befs" +#ifdef MODE_BIGENDIAN +#define GRUB_AFS_FSNAME_SUFFIX "_be" #else -#define GRUB_AFS_FSNAME "afs" +#define GRUB_AFS_FSNAME_SUFFIX "" +#endif + +#ifdef MODE_BFS +#define GRUB_AFS_FSNAME "befs" GRUB_AFS_FSNAME_SUFFIX +#else +#define GRUB_AFS_FSNAME "afs" GRUB_AFS_FSNAME_SUFFIX #endif #define GRUB_AFS_DIRECT_BLOCK_COUNT 12 @@ -65,14 +71,15 @@ #define GRUB_AFS_NULL_VAL ((grub_afs_bvalue_t)-1) -#define U16(sb, u) (((sb)->byte_order == GRUB_AFS_BO_LITTLE_ENDIAN) ? \ - grub_le_to_cpu16 (u) : grub_be_to_cpu16 (u)) - -#define U32(sb, u) (((sb)->byte_order == GRUB_AFS_BO_LITTLE_ENDIAN) ? \ - grub_le_to_cpu32 (u) : grub_be_to_cpu32 (u)) - -#define U64(sb, u) (((sb)->byte_order == GRUB_AFS_BO_LITTLE_ENDIAN) ? \ - grub_le_to_cpu64 (u) : grub_be_to_cpu64 (u)) +#ifdef MODE_BIGENDIAN +#define grub_afs_to_cpu16(x) grub_be_to_cpu16 (x) +#define grub_afs_to_cpu32(x) grub_be_to_cpu32 (x) +#define grub_afs_to_cpu64(x) grub_be_to_cpu64 (x) +#else +#define grub_afs_to_cpu16(x) grub_le_to_cpu16 (x) +#define grub_afs_to_cpu32(x) grub_le_to_cpu32 (x) +#define grub_afs_to_cpu64(x) grub_le_to_cpu64 (x) +#endif #ifdef MODE_BFS #define B_KEY_INDEX_ALIGN 8 @@ -90,12 +97,6 @@ ((char *) B_KEY_INDEX_OFFSET (node) + \ node->key_count * 2)) -enum -{ - GRUB_AFS_BO_LITTLE_ENDIAN, - GRUB_AFS_BO_BIG_ENDIAN -}; - typedef grub_uint64_t grub_afs_off_t; typedef grub_uint64_t grub_afs_bigtime; typedef grub_uint64_t grub_afs_bvalue_t; @@ -154,6 +155,9 @@ struct grub_afs_btree } __attribute__ ((packed)); #endif +/* Beware that following structure describes AtheFS and if you write code + which uses currently unused fields check it with both AtheFS and BeFS. + */ struct grub_afs_sblock { char name[32]; @@ -227,8 +231,8 @@ static grub_afs_off_t grub_afs_run_to_num (struct grub_afs_sblock *sb, struct grub_afs_blockrun *run) { - return ((grub_afs_off_t) U32 (sb, run->group) * sb->block_per_group + - U16 (sb, run->start)); + return ((grub_afs_off_t) grub_afs_to_cpu32 (run->group) + * sb->block_per_group + grub_afs_to_cpu16 (run->start)); } static grub_err_t @@ -248,25 +252,25 @@ grub_afs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) struct grub_afs_sblock *sb = &node->data->sblock; struct grub_afs_datastream *ds = &node->inode.stream; - if (fileblock < U64 (sb, ds->max_direct_range)) + if (fileblock < grub_afs_to_cpu64 (ds->max_direct_range)) { int i; for (i = 0; i < GRUB_AFS_DIRECT_BLOCK_COUNT; i++) { - if (fileblock < U16 (sb, ds->direct[i].len)) + if (fileblock < grub_afs_to_cpu16 (ds->direct[i].len)) return grub_afs_run_to_num (sb, &ds->direct[i]) + fileblock; - fileblock -= U16 (sb, ds->direct[i].len); + fileblock -= grub_afs_to_cpu16 (ds->direct[i].len); } } - else if (fileblock < U64 (sb, ds->max_indirect_range)) + else if (fileblock < grub_afs_to_cpu64 (ds->max_indirect_range)) { int ptrs_per_blk = sb->block_size / sizeof (struct grub_afs_blockrun); struct grub_afs_blockrun indir[ptrs_per_blk]; grub_afs_off_t blk = grub_afs_run_to_num (sb, &ds->indirect); int i; - fileblock -= U64 (sb, ds->max_direct_range); + fileblock -= grub_afs_to_cpu64 (ds->max_direct_range); for (i = 0; i < ds->indirect.len; i++, blk++) { int j; @@ -279,10 +283,10 @@ grub_afs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) for (j = 0; j < ptrs_per_blk; j++) { - if (fileblock < U16 (sb, indir[j].len)) + if (fileblock < grub_afs_to_cpu16 (indir[j].len)) return grub_afs_run_to_num (sb, &indir[j]) + fileblock; - fileblock -= U16 (sb, indir[j].len); + fileblock -= grub_afs_to_cpu16 (indir[j].len); } } } @@ -292,7 +296,7 @@ grub_afs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) struct grub_afs_blockrun indir[ptrs_per_blk]; /* ([idblk][idptr]) ([dblk][dptr]) [blk] */ - int cur_pos = fileblock - U64 (sb, ds->max_indirect_range); + int cur_pos = fileblock - grub_afs_to_cpu64 (ds->max_indirect_range); int dptr_size = GRUB_AFS_BLOCKS_PER_DI_RUN; int dblk_size = dptr_size * ptrs_per_blk; @@ -334,8 +338,7 @@ grub_afs_read_file (grub_fshelp_node_t node, { return grub_fshelp_read_file (node->data->disk, node, read_hook, pos, len, buf, grub_afs_read_block, - U64 (&node->data->sblock, - node->inode.stream.size), + grub_afs_to_cpu64 (node->inode.stream.size), node->data->sblock.block_shift - GRUB_DISK_SECTOR_BITS); } @@ -344,8 +347,7 @@ static char * grub_afs_read_symlink (grub_fshelp_node_t node) { char *ret; - struct grub_afs_sblock *sb = &node->data->sblock; - grub_afs_off_t size = U64 (sb, node->inode.stream.size); + grub_afs_off_t size = grub_afs_to_cpu64 (node->inode.stream.size); if (size == 0) { @@ -374,27 +376,27 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir, struct grub_afs_btree head; char node_data [GRUB_AFS_BNODE_SIZE]; struct grub_afs_bnode *node = (struct grub_afs_bnode *) node_data; - struct grub_afs_sblock *sb = &dir->data->sblock; int i; if ((dir->inode.stream.size == 0) - || ((U32 (sb, dir->inode.mode) & GRUB_AFS_S_IFMT) != GRUB_AFS_S_IFDIR)) + || ((grub_afs_to_cpu32 (dir->inode.mode) & GRUB_AFS_S_IFMT) + != GRUB_AFS_S_IFDIR)) return 0; grub_afs_read_file (dir, 0, 0, sizeof (head), (char *) &head); if (grub_errno) return 0; - grub_afs_read_file (dir, 0, U64 (sb, head.root), + grub_afs_read_file (dir, 0, grub_afs_to_cpu64 (head.root), GRUB_AFS_BNODE_SIZE, (char *) node); if (grub_errno) return 0; - for (i = 0; i < (int) U32 (sb, head.tree_depth) - 1; i++) + for (i = 0; i < (int) grub_afs_to_cpu32 (head.tree_depth) - 1; i++) { grub_afs_bvalue_t blk; - blk = U64(sb, B_KEY_VALUE_OFFSET (node) [0]); + blk = grub_afs_to_cpu64(B_KEY_VALUE_OFFSET (node) [0]); grub_afs_read_file (dir, 0, blk, GRUB_AFS_BNODE_SIZE, (char *) node); if (grub_errno) return 0; @@ -411,8 +413,9 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir, index = B_KEY_INDEX_OFFSET (node); - key_start = U16 (sb, (cur_key > 0) ? index[cur_key - 1] : 0); - key_size = U16 (sb, index[cur_key]) - key_start; + key_start = (cur_key > 0) + ? grub_afs_to_cpu16 (index[cur_key - 1]) : 0; + key_size = grub_afs_to_cpu16 (index[cur_key]) - key_start; if (key_size > 0) { char filename [key_size + 1]; @@ -425,14 +428,15 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir, fdiro->data = dir->data; if (grub_afs_read_inode (dir->data, - U64 (sb, B_KEY_VALUE_OFFSET (node) [cur_key]), + grub_afs_to_cpu64 + (B_KEY_VALUE_OFFSET (node) [cur_key]), &fdiro->inode)) return 0; grub_memcpy (filename, &node->key_data[key_start], key_size); filename [key_size] = 0; - mode = (U32 (sb, fdiro->inode.mode) & GRUB_AFS_S_IFMT); + mode = (grub_afs_to_cpu32 (fdiro->inode.mode) & GRUB_AFS_S_IFMT); if (mode == GRUB_AFS_S_IFDIR) type = GRUB_FSHELP_DIR; else if (mode == GRUB_AFS_S_IFREG) @@ -447,12 +451,12 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir, } cur_key++; - if (cur_key >= U32 (sb, node->key_count)) + if (cur_key >= grub_afs_to_cpu32 (node->key_count)) { if (node->right == GRUB_AFS_NULL_VAL) break; - grub_afs_read_file (dir, 0, U64 (sb, node->right), + grub_afs_read_file (dir, 0, grub_afs_to_cpu64 (node->right), GRUB_AFS_BNODE_SIZE, (char *) node); if (grub_errno) return 0; @@ -468,47 +472,20 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir, static int grub_afs_validate_sblock (struct grub_afs_sblock *sb) { - if (grub_le_to_cpu32 (sb->magic1) == GRUB_AFS_SBLOCK_MAGIC1) + if (grub_afs_to_cpu32 (sb->magic1) == GRUB_AFS_SBLOCK_MAGIC1) { -#ifndef MODE_BFS - if (grub_le_to_cpu32 (sb->byte_order) != GRUB_AFS_BO_LITTLE_ENDIAN) - return 0; -#endif - - sb->byte_order = GRUB_AFS_BO_LITTLE_ENDIAN; - sb->magic2 = grub_le_to_cpu32 (sb->magic2); - sb->magic3 = grub_le_to_cpu32 (sb->magic3); - sb->block_shift = grub_le_to_cpu32 (sb->block_shift); - sb->block_size = grub_le_to_cpu32 (sb->block_size); - sb->used_blocks = grub_le_to_cpu64 (sb->used_blocks); - sb->num_blocks = grub_le_to_cpu64 (sb->num_blocks); - sb->inode_size = grub_le_to_cpu32 (sb->inode_size); - sb->alloc_group_count = grub_le_to_cpu32 (sb->alloc_group_count); - sb->alloc_group_shift = grub_le_to_cpu32 (sb->alloc_group_shift); - sb->block_per_group = grub_le_to_cpu32 (sb->block_per_group); - sb->alloc_group_count = grub_le_to_cpu32 (sb->alloc_group_count); - sb->log_size = grub_le_to_cpu32 (sb->log_size); - } - else if (grub_be_to_cpu32 (sb->magic1) == GRUB_AFS_SBLOCK_MAGIC1) - { -#ifndef MODE_BFS - if (grub_be_to_cpu32 (sb->byte_order) != GRUB_AFS_BO_BIG_ENDIAN) - return 0; -#endif - - sb->byte_order = GRUB_AFS_BO_BIG_ENDIAN; - sb->magic2 = grub_be_to_cpu32 (sb->magic2); - sb->magic3 = grub_be_to_cpu32 (sb->magic3); - sb->block_shift = grub_be_to_cpu32 (sb->block_shift); - sb->block_size = grub_be_to_cpu32 (sb->block_size); - sb->used_blocks = grub_be_to_cpu64 (sb->used_blocks); - sb->num_blocks = grub_be_to_cpu64 (sb->num_blocks); - sb->inode_size = grub_be_to_cpu32 (sb->inode_size); - sb->alloc_group_count = grub_be_to_cpu32 (sb->alloc_group_count); - sb->alloc_group_shift = grub_be_to_cpu32 (sb->alloc_group_shift); - sb->block_per_group = grub_be_to_cpu32 (sb->block_per_group); - sb->alloc_group_count = grub_be_to_cpu32 (sb->alloc_group_count); - sb->log_size = grub_be_to_cpu32 (sb->log_size); + sb->magic2 = grub_afs_to_cpu32 (sb->magic2); + sb->magic3 = grub_afs_to_cpu32 (sb->magic3); + sb->block_shift = grub_afs_to_cpu32 (sb->block_shift); + sb->block_size = grub_afs_to_cpu32 (sb->block_size); + sb->used_blocks = grub_afs_to_cpu64 (sb->used_blocks); + sb->num_blocks = grub_afs_to_cpu64 (sb->num_blocks); + sb->inode_size = grub_afs_to_cpu32 (sb->inode_size); + sb->alloc_group_count = grub_afs_to_cpu32 (sb->alloc_group_count); + sb->alloc_group_shift = grub_afs_to_cpu32 (sb->alloc_group_shift); + sb->block_per_group = grub_afs_to_cpu32 (sb->block_per_group); + sb->alloc_group_count = grub_afs_to_cpu32 (sb->alloc_group_count); + sb->log_size = grub_afs_to_cpu32 (sb->log_size); } else return 0; @@ -529,8 +506,8 @@ grub_afs_validate_sblock (struct grub_afs_sblock *sb) || ((grub_uint32_t) (1 << sb->alloc_group_shift) != sb->block_per_group * sb->block_size) || (sb->alloc_group_count * sb->block_per_group < sb->num_blocks) - || (U16 (sb, sb->log_block.len) != sb->log_size) - || (U32 (sb, sb->valid_log_blocks) > sb->log_size) + || (grub_afs_to_cpu16 (sb->log_block.len) != sb->log_size) + || (grub_afs_to_cpu32 (sb->valid_log_blocks) > sb->log_size) #endif ) return 0; @@ -594,7 +571,7 @@ grub_afs_open (struct grub_file *file, const char *name) grub_memcpy (data->inode, &fdiro->inode, sizeof (struct grub_afs_inode)); grub_free (fdiro); - file->size = U64 (&data->sblock, data->inode->stream.size); + file->size = grub_afs_to_cpu64 (data->inode->stream.size); file->data = data; file->offset = 0; @@ -648,10 +625,10 @@ grub_afs_dir (grub_device_t device, const char *path, info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR); info.mtimeset = 1; #ifdef MODE_BFS - info.mtime = U64 (&data->sblock, node->inode.modified_time) >> 16; + info.mtime = grub_afs_to_cpu64 (node->inode.modified_time) >> 16; #else - info.mtime = grub_divmod64 (U64 (&data->sblock, - node->inode.modified_time), 1000000, 0); + info.mtime = grub_divmod64 (grub_afs_to_cpu64 (node->inode.modified_time), + 1000000, 0); #endif grub_free (node); return hook (filename, &info); @@ -713,8 +690,12 @@ static struct grub_fs grub_afs_fs = { .next = 0 }; -#ifdef MODE_BFS +#if defined (MODE_BIGENDIAN) && defined (MODE_BFS) +GRUB_MOD_INIT (befs_be) +#elif defined (MODE_BFS) GRUB_MOD_INIT (befs) +#elif defined (MODE_BIGENDIAN) +GRUB_MOD_INIT (afs_be) #else GRUB_MOD_INIT (afs) #endif @@ -723,8 +704,12 @@ GRUB_MOD_INIT (afs) my_mod = mod; } -#ifdef MODE_BFS +#if defined (MODE_BIGENDIAN) && defined (MODE_BFS) +GRUB_MOD_FINI (befs_be) +#elif defined (MODE_BFS) GRUB_MOD_FINI (befs) +#elif defined (MODE_BIGENDIAN) +GRUB_MOD_FINI (afs_be) #else GRUB_MOD_FINI (afs) #endif diff --git a/fs/afs_be.c b/fs/afs_be.c new file mode 100644 index 000000000..1f1f48fbb --- /dev/null +++ b/fs/afs_be.c @@ -0,0 +1,2 @@ +#define MODE_BIGENDIAN 1 +#include "afs.c" diff --git a/fs/befs_be.c b/fs/befs_be.c new file mode 100644 index 000000000..f6e8179f4 --- /dev/null +++ b/fs/befs_be.c @@ -0,0 +1,4 @@ +/* befs.c - The native BeOS/Haiku file-system. */ +#define MODE_BFS 1 +#define MODE_BIGENDIAN 1 +#include "afs.c" From 4cbe67e509788b3aaa19a57afa2184c8d9f1061c Mon Sep 17 00:00:00 2001 From: cjwatson Date: Fri, 28 Aug 2009 13:20:34 +0000 Subject: [PATCH 27/85] 2009-08-28 Colin Watson 2009-08-28 Robert Millan Add `getkeystatus' terminal method. Add a new `keystatus' command to query it. * include/grub/term.h (GRUB_TERM_STATUS_SHIFT, GRUB_TERM_STATUS_CTRL, GRUB_TERM_STATUS_ALT): Definitions for modifier key bitmasks. (struct grub_term_input): Add `getkeystatus' member. (grub_getkeystatus): Add prototype. * kern/term.c (grub_getkeystatus): New function. * include/grub/i386/pc/memory.h (GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR): New macro. (struct grub_machine_bios_data_area): Define necessary parts of BIOS Data Area layout. * term/i386/pc/console.c (grub_console_getkeystatus): New function. (grub_console_term_input): Set `getkeystatus' member. * term/usb_keyboard.c (grub_usb_hid): Macroify HID protocol constants. (grub_usb_keyboard_getreport): Likewise. (grub_usb_keyboard_checkkey): Likewise. (grub_usb_keyboard_getkeystatus): New function. (grub_usb_keyboard_term): Set `getkeystatus' member. * commands/keystatus.c: New file. * conf/common.rmk (pkglib_MODULES): Add keystatus.mod. (keystatus_mod_SOURCES): New variable. (keystatus_mod_CFLAGS): Likewise. (keystatus_mod_LDFLAGS): Likewise. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add commands/keystatus.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/i386-pc.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * DISTLIST: Add commands/keystatus.c. --- ChangeLog | 41 ++++++++++++++++++ commands/keystatus.c | 81 ++++++++++++++++++++++++++++++++++ conf/common.rmk | 8 +++- conf/i386-coreboot.rmk | 2 +- conf/i386-efi.rmk | 2 +- conf/i386-ieee1275.rmk | 2 +- conf/i386-pc.rmk | 2 +- conf/powerpc-ieee1275.rmk | 2 +- conf/sparc64-ieee1275.rmk | 2 +- conf/x86_64-efi.rmk | 2 +- include/grub/i386/pc/memory.h | 11 +++++ include/grub/term.h | 12 ++++- kern/term.c | 9 ++++ term/i386/pc/console.c | 27 +++++++++++- term/usb_keyboard.c | 82 ++++++++++++++++++++++++++++++++--- 15 files changed, 270 insertions(+), 15 deletions(-) create mode 100644 commands/keystatus.c diff --git a/ChangeLog b/ChangeLog index ab542e2e8..691273fc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,44 @@ +2009-08-28 Colin Watson +2009-08-28 Robert Millan + + Add `getkeystatus' terminal method. Add a new `keystatus' command + to query it. + + * include/grub/term.h (GRUB_TERM_STATUS_SHIFT, + GRUB_TERM_STATUS_CTRL, GRUB_TERM_STATUS_ALT): Definitions for + modifier key bitmasks. + (struct grub_term_input): Add `getkeystatus' member. + (grub_getkeystatus): Add prototype. + * kern/term.c (grub_getkeystatus): New function. + + * include/grub/i386/pc/memory.h + (GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR): New macro. + (struct grub_machine_bios_data_area): Define necessary parts of BIOS + Data Area layout. + * term/i386/pc/console.c (grub_console_getkeystatus): New function. + (grub_console_term_input): Set `getkeystatus' member. + * term/usb_keyboard.c (grub_usb_hid): Macroify HID protocol + constants. + (grub_usb_keyboard_getreport): Likewise. + (grub_usb_keyboard_checkkey): Likewise. + (grub_usb_keyboard_getkeystatus): New function. + (grub_usb_keyboard_term): Set `getkeystatus' member. + + * commands/keystatus.c: New file. + * conf/common.rmk (pkglib_MODULES): Add keystatus.mod. + (keystatus_mod_SOURCES): New variable. + (keystatus_mod_CFLAGS): Likewise. + (keystatus_mod_LDFLAGS): Likewise. + * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add + commands/keystatus.c. + * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. + * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. + * conf/i386-pc.rmk (grub_emu_SOURCES): Likewise. + * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. + * conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise. + * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. + * DISTLIST: Add commands/keystatus.c. + 2009-08-28 Vladimir Serbinenko Split befs.mod and afs.mod into *_be.mod and *.mod diff --git a/commands/keystatus.c b/commands/keystatus.c new file mode 100644 index 000000000..cecbba504 --- /dev/null +++ b/commands/keystatus.c @@ -0,0 +1,81 @@ +/* keystatus.c - Command to check key modifier status. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 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 +#include +#include + +static const struct grub_arg_option options[] = + { + {"shift", 's', 0, "check Shift key", 0, 0}, + {"ctrl", 'c', 0, "check Control key", 0, 0}, + {"alt", 'a', 0, "check Alt key", 0, 0}, + {0, 0, 0, 0, 0, 0} + }; + +#define grub_cur_term_input grub_term_get_current_input () + +static grub_err_t +grub_cmd_keystatus (grub_extcmd_t cmd, + int argc __attribute__ ((unused)), + char **args __attribute__ ((unused))) +{ + struct grub_arg_list *state = cmd->state; + int expect_mods = 0; + int mods; + + if (state[0].set) + expect_mods |= GRUB_TERM_STATUS_SHIFT; + if (state[1].set) + expect_mods |= GRUB_TERM_STATUS_CTRL; + if (state[2].set) + expect_mods |= GRUB_TERM_STATUS_ALT; + + /* Without arguments, just check whether getkeystatus is supported at + all. */ + if (!grub_cur_term_input->getkeystatus) + return grub_error (GRUB_ERR_TEST_FAILURE, "false"); + grub_dprintf ("keystatus", "expect_mods: %d\n", expect_mods); + if (!expect_mods) + return 0; + + mods = grub_getkeystatus (); + grub_dprintf ("keystatus", "mods: %d\n", mods); + if (mods >= 0 && (mods & expect_mods) != 0) + return 0; + else + return grub_error (GRUB_ERR_TEST_FAILURE, "false"); +} + +static grub_extcmd_t cmd; + +GRUB_MOD_INIT(keystatus) +{ + cmd = grub_register_extcmd ("keystatus", grub_cmd_keystatus, + GRUB_COMMAND_FLAG_BOTH, + "keystatus [--shift|--ctrl|--alt]", + "Check key modifier status", + options); +} + +GRUB_MOD_FINI(keystatus) +{ + grub_unregister_extcmd (cmd); +} diff --git a/conf/common.rmk b/conf/common.rmk index 7727f19e8..73cf02caa 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -375,7 +375,8 @@ pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \ terminfo.mod test.mod blocklist.mod hexdump.mod \ read.mod sleep.mod loadenv.mod crc.mod parttool.mod \ msdospart.mod memrw.mod normal.mod sh.mod lua.mod \ - gptsync.mod true.mod probe.mod password.mod + gptsync.mod true.mod probe.mod password.mod \ + keystatus.mod # For password.mod. password_mod_SOURCES = commands/password.c @@ -522,6 +523,11 @@ probe_mod_SOURCES = commands/probe.c probe_mod_CFLAGS = $(COMMON_CFLAGS) probe_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For keystatus.mod. +keystatus_mod_SOURCES = commands/keystatus.c +keystatus_mod_CFLAGS = $(COMMON_CFLAGS) +keystatus_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For normal.mod. normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c \ normal/auth.c normal/autofs.c normal/handler.c \ diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index 990ba805d..4e2d1f1ec 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -110,7 +110,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/handler.c commands/ls.c commands/test.c \ commands/search.c commands/blocklist.c commands/hexdump.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ - commands/password.c \ + commands/password.c commands/keystatus.c \ lib/hexdump.c commands/i386/cpuid.c \ disk/host.c disk/loopback.c \ \ diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index b470a7687..18a9a636b 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -37,7 +37,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/configfile.c commands/help.c \ commands/handler.c commands/ls.c commands/test.c \ commands/search.c commands/hexdump.c lib/hexdump.c \ - commands/halt.c commands/reboot.c \ + commands/halt.c commands/reboot.c commands/keystatus.c \ commands/i386/cpuid.c \ commands/password.c \ disk/loopback.c \ diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk index 989f1bc61..b426bdd80 100644 --- a/conf/i386-ieee1275.rmk +++ b/conf/i386-ieee1275.rmk @@ -66,7 +66,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ lib/hexdump.c commands/halt.c commands/reboot.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ commands/i386/cpuid.c \ - commands/password.c \ + commands/password.c commands/keystatus.c \ disk/host.c disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index d415aed32..8d7d9fca9 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -124,7 +124,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ lib/hexdump.c commands/i386/pc/halt.c commands/reboot.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ commands/i386/cpuid.c \ - commands/password.c \ + commands/password.c commands/keystatus.c \ disk/host.c disk/loopback.c disk/scsi.c \ fs/fshelp.c \ \ diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index 0c6650dfd..b294de917 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -46,7 +46,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/ls.c commands/blocklist.c commands/hexdump.c \ lib/hexdump.c commands/halt.c commands/reboot.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ - commands/password.c \ + commands/password.c commands/keystatus.c \ disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index 7851fd64a..c44c6ca78 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -104,7 +104,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/ls.c commands/blocklist.c commands/hexdump.c \ lib/hexdump.c commands/halt.c commands/reboot.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ - commands/password.c \ + commands/password.c commands/keystatus.c \ disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index 0defdcd93..1a4cf89ed 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -37,7 +37,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/search.c commands/hexdump.c lib/hexdump.c \ commands/halt.c commands/reboot.c \ commands/i386/cpuid.c \ - commands/password.c \ + commands/password.c commands/keystatus.c \ disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ diff --git a/include/grub/i386/pc/memory.h b/include/grub/i386/pc/memory.h index d7910ab15..815390482 100644 --- a/include/grub/i386/pc/memory.h +++ b/include/grub/i386/pc/memory.h @@ -78,8 +78,19 @@ /* The data segment of the pseudo real mode. */ #define GRUB_MEMORY_MACHINE_PSEUDO_REAL_DSEG 0x20 +#define GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR 0x400 + #ifndef ASM_FILE +/* See http://heim.ifi.uio.no/~stanisls/helppc/bios_data_area.html for a + description of the BIOS Data Area layout. */ +struct grub_machine_bios_data_area +{ + grub_uint8_t unused1[0x17]; + grub_uint8_t keyboard_flag_lower; /* 0x17 */ + grub_uint8_t unused2[0xf0 - 0x18]; +}; + struct grub_machine_mmap_entry { grub_uint32_t size; diff --git a/include/grub/term.h b/include/grub/term.h index 9ce3be7d1..316d75390 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2005,2007,2008,2009 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 @@ -72,6 +72,12 @@ grub_term_color_state; #define GRUB_TERM_NEED_INIT (1 << 16) +/* Bitmasks for modifier keys returned by grub_getkeystatus. */ +#define GRUB_TERM_STATUS_SHIFT (1 << 0) +#define GRUB_TERM_STATUS_CTRL (1 << 1) +#define GRUB_TERM_STATUS_ALT (1 << 2) + + /* Unicode characters for fancy graphics. */ #define GRUB_TERM_DISP_LEFT 0x2190 #define GRUB_TERM_DISP_UP 0x2191 @@ -157,6 +163,9 @@ struct grub_term_input /* Get a character. */ int (*getkey) (void); + + /* Get keyboard modifier status. */ + int (*getkeystatus) (void); }; typedef struct grub_term_input *grub_term_input_t; @@ -275,6 +284,7 @@ void EXPORT_FUNC(grub_putcode) (grub_uint32_t code); grub_ssize_t EXPORT_FUNC(grub_getcharwidth) (grub_uint32_t code); int EXPORT_FUNC(grub_getkey) (void); int EXPORT_FUNC(grub_checkkey) (void); +int EXPORT_FUNC(grub_getkeystatus) (void); grub_uint16_t EXPORT_FUNC(grub_getwh) (void); grub_uint16_t EXPORT_FUNC(grub_getxy) (void); void EXPORT_FUNC(grub_gotoxy) (grub_uint8_t x, grub_uint8_t y); diff --git a/kern/term.c b/kern/term.c index 3583a301d..03e2ae573 100644 --- a/kern/term.c +++ b/kern/term.c @@ -140,6 +140,15 @@ grub_checkkey (void) return (grub_cur_term_input->checkkey) (); } +int +grub_getkeystatus (void) +{ + if (grub_cur_term_input->getkeystatus) + return (grub_cur_term_input->getkeystatus) (); + else + return 0; +} + grub_uint16_t grub_getxy (void) { diff --git a/term/i386/pc/console.c b/term/i386/pc/console.c index c880595e4..ec1383942 100644 --- a/term/i386/pc/console.c +++ b/term/i386/pc/console.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2005,2007,2008,2009 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 @@ -16,15 +16,40 @@ * along with GRUB. If not, see . */ +#include #include #include #include +static const struct grub_machine_bios_data_area *bios_data_area = GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR; + +#define KEYBOARD_LEFT_SHIFT (1 << 0) +#define KEYBOARD_RIGHT_SHIFT (1 << 1) +#define KEYBOARD_CTRL (1 << 2) +#define KEYBOARD_ALT (1 << 3) + +static int +grub_console_getkeystatus (void) +{ + grub_uint8_t status = bios_data_area->keyboard_flag_lower; + int mods = 0; + + if (status & (KEYBOARD_LEFT_SHIFT | KEYBOARD_RIGHT_SHIFT)) + mods |= GRUB_TERM_STATUS_SHIFT; + if (status & KEYBOARD_CTRL) + mods |= GRUB_TERM_STATUS_CTRL; + if (status & KEYBOARD_ALT) + mods |= GRUB_TERM_STATUS_ALT; + + return mods; +} + static struct grub_term_input grub_console_term_input = { .name = "console", .checkkey = grub_console_checkkey, .getkey = grub_console_getkey, + .getkeystatus = grub_console_getkeystatus, }; static struct grub_term_output grub_console_term_output = diff --git a/term/usb_keyboard.c b/term/usb_keyboard.c index bb62b35ed..7f5e058f7 100644 --- a/term/usb_keyboard.c +++ b/term/usb_keyboard.c @@ -58,6 +58,19 @@ static char keyboard_map_shift[128] = static grub_usb_device_t usbdev; +/* Valid values for bmRequestType. See HID definition version 1.11 section + 7.2. */ +#define USB_HID_HOST_TO_DEVICE 0x21 +#define USB_HID_DEVICE_TO_HOST 0x61 + +/* Valid values for bRequest. See HID definition version 1.11 section 7.2. */ +#define USB_HID_GET_REPORT 0x01 +#define USB_HID_GET_IDLE 0x02 +#define USB_HID_GET_PROTOCOL 0x03 +#define USB_HID_SET_REPORT 0x09 +#define USB_HID_SET_IDLE 0x0A +#define USB_HID_SET_PROTOCOL 0x0B + static void grub_usb_hid (void) { @@ -90,17 +103,19 @@ grub_usb_hid (void) grub_usb_iterate (usb_iterate); /* Place the device in boot mode. */ - grub_usb_control_msg (usbdev, 0x21, 0x0B, 0, 0, 0, 0); + grub_usb_control_msg (usbdev, USB_HID_HOST_TO_DEVICE, USB_HID_SET_PROTOCOL, + 0, 0, 0, 0); /* Reports every time an event occurs and not more often than that. */ - grub_usb_control_msg (usbdev, 0x21, 0x0A, 0<<8, 0, 0, 0); + grub_usb_control_msg (usbdev, USB_HID_HOST_TO_DEVICE, USB_HID_SET_IDLE, + 0<<8, 0, 0, 0); } static grub_err_t grub_usb_keyboard_getreport (grub_usb_device_t dev, grub_uint8_t *report) { - return grub_usb_control_msg (dev, (1 << 7) | (1 << 5) | 1, 0x01, 0, 0, - 8, (char *) report); + return grub_usb_control_msg (dev, USB_HID_DEVICE_TO_HOST, USB_HID_GET_REPORT, + 0, 0, 8, (char *) report); } @@ -151,7 +166,8 @@ grub_usb_keyboard_checkkey (void) /* Wait until the key is released. */ while (!err && data[2]) { - err = grub_usb_control_msg (usbdev, (1 << 7) | (1 << 5) | 1, 0x01, 0, 0, + err = grub_usb_control_msg (usbdev, USB_HID_DEVICE_TO_HOST, + USB_HID_GET_REPORT, 0, 0, sizeof (data), (char *) data); grub_dprintf ("usb_keyboard", "report2: 0x%02x 0x%02x 0x%02x 0x%02x" @@ -238,11 +254,67 @@ grub_usb_keyboard_getkey (void) return key; } +static int +grub_usb_keyboard_getkeystatus (void) +{ + grub_uint8_t data[8]; + int mods = 0; + grub_err_t err; + grub_uint64_t currtime; + int timeout = 50; + + /* Set idle time to the minimum offered by the spec (4 milliseconds) so + that we can find out the current state. */ + grub_usb_control_msg (usbdev, USB_HID_HOST_TO_DEVICE, USB_HID_SET_IDLE, + 0<<8, 0, 0, 0); + + currtime = grub_get_time_ms (); + do + { + /* Get_Report. */ + err = grub_usb_keyboard_getreport (usbdev, data); + + /* Implement a timeout. */ + if (grub_get_time_ms () > currtime + timeout) + break; + } + while (err || !data[0]); + + /* Go back to reporting every time an event occurs and not more often than + that. */ + grub_usb_control_msg (usbdev, USB_HID_HOST_TO_DEVICE, USB_HID_SET_IDLE, + 0<<8, 0, 0, 0); + + /* We allowed a while for modifiers to show up in the report, but it is + not an error if they never did. */ + if (err) + return -1; + + grub_dprintf ("usb_keyboard", + "report: 0x%02x 0x%02x 0x%02x 0x%02x" + " 0x%02x 0x%02x 0x%02x 0x%02x\n", + data[0], data[1], data[2], data[3], + data[4], data[5], data[6], data[7]); + + /* Check Shift, Control, and Alt status. */ + if (data[0] & 0x02 || data[0] & 0x20) + mods |= GRUB_TERM_STATUS_SHIFT; + if (data[0] & 0x01 || data[0] & 0x10) + mods |= GRUB_TERM_STATUS_CTRL; + if (data[0] & 0x04 || data[0] & 0x40) + mods |= GRUB_TERM_STATUS_ALT; + + grub_errno = GRUB_ERR_NONE; + + return mods; +} + static struct grub_term_input grub_usb_keyboard_term = { .name = "usb_keyboard", .checkkey = grub_usb_keyboard_checkkey, .getkey = grub_usb_keyboard_getkey, + .getkeystatus = grub_usb_keyboard_getkeystatus, .next = 0 }; From a57da43f0dda6c27fe208e65dd59bec5ed3907a4 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Fri, 28 Aug 2009 13:25:10 +0000 Subject: [PATCH 28/85] 2009-08-28 Colin Watson * normal/cmdline.c (grub_cmdline_get): Supply a format string as the first argument to grub_printf. --- ChangeLog | 5 +++++ normal/cmdline.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 691273fc6..b32de1b10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-28 Colin Watson + + * normal/cmdline.c (grub_cmdline_get): Supply a format string as + the first argument to grub_printf. + 2009-08-28 Colin Watson 2009-08-28 Robert Millan diff --git a/normal/cmdline.c b/normal/cmdline.c index 56f892121..7a5b6ec84 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -273,7 +273,7 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, if ((grub_getxy () >> 8) != 0) grub_putchar ('\n'); - grub_printf (prompt); + grub_printf ("%s", prompt); xpos = plen; ystart = ypos = (grub_getxy () & 0xFF); From e7c69859a263c62b5a28c353b415f9bb1526b8e2 Mon Sep 17 00:00:00 2001 From: phcoder Date: Fri, 28 Aug 2009 13:54:20 +0000 Subject: [PATCH 29/85] 2009-08-28 Vladimir Serbinenko 1-bit optimised blitters. * include/grub/fbblit.h (grub_video_fbblit_replace_32bit_1bit): New prototype. (grub_video_fbblit_replace_24bit_1bit): Likewise. (grub_video_fbblit_replace_16bit_1bit): Likewise. (grub_video_fbblit_replace_8bit_1bit): Likewise. (grub_video_fbblit_blend_XXXA8888_1bit): Likewise. (grub_video_fbblit_blend_XXX888_1bit): Likewise. (grub_video_fbblit_blend_XXX565_1bit): Likewise. * video/fb/fbblit.c (grub_video_fbblit_replace_32bit_1bit): New function. (grub_video_fbblit_replace_24bit_1bit): Likewise. (grub_video_fbblit_replace_16bit_1bit): Likewise. (grub_video_fbblit_replace_8bit_1bit): Likewise. (grub_video_fbblit_blend_XXXA8888_1bit): Likewise. (grub_video_fbblit_blend_XXX888_1bit): Likewise. (grub_video_fbblit_blend_XXX565_1bit): Likewise. * video/fb/video_fb.c (common_blitter): Use 1-bit optimised blitters when possible. * video/video.c (grub_video_get_blit_format): Return GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED if bpp = 1. --- ChangeLog | 25 ++ include/grub/fbblit.h | 48 ++++ video/fb/fbblit.c | 587 ++++++++++++++++++++++++++++++++++++++++++ video/fb/video_fb.c | 66 +++++ video/video.c | 2 + 5 files changed, 728 insertions(+) diff --git a/ChangeLog b/ChangeLog index b32de1b10..b43aa72ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2009-08-28 Vladimir Serbinenko + + 1-bit optimised blitters. + + * include/grub/fbblit.h (grub_video_fbblit_replace_32bit_1bit): New + prototype. + (grub_video_fbblit_replace_24bit_1bit): Likewise. + (grub_video_fbblit_replace_16bit_1bit): Likewise. + (grub_video_fbblit_replace_8bit_1bit): Likewise. + (grub_video_fbblit_blend_XXXA8888_1bit): Likewise. + (grub_video_fbblit_blend_XXX888_1bit): Likewise. + (grub_video_fbblit_blend_XXX565_1bit): Likewise. + * video/fb/fbblit.c (grub_video_fbblit_replace_32bit_1bit): New + function. + (grub_video_fbblit_replace_24bit_1bit): Likewise. + (grub_video_fbblit_replace_16bit_1bit): Likewise. + (grub_video_fbblit_replace_8bit_1bit): Likewise. + (grub_video_fbblit_blend_XXXA8888_1bit): Likewise. + (grub_video_fbblit_blend_XXX888_1bit): Likewise. + (grub_video_fbblit_blend_XXX565_1bit): Likewise. + * video/fb/video_fb.c (common_blitter): Use 1-bit optimised blitters + when possible. + * video/video.c (grub_video_get_blit_format): Return + GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED if bpp = 1. + 2009-08-28 Colin Watson * normal/cmdline.c (grub_cmdline_get): Supply a format string as diff --git a/include/grub/fbblit.h b/include/grub/fbblit.h index 664f508c5..af97dfb97 100644 --- a/include/grub/fbblit.h +++ b/include/grub/fbblit.h @@ -131,4 +131,52 @@ grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst, int width, int height, int offset_x, int offset_y); +void +grub_video_fbblit_replace_32bit_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_24bit_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_16bit_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_replace_8bit_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_blend_XXXA8888_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_blend_XXX888_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); + +void +grub_video_fbblit_blend_XXX565_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y); #endif /* ! GRUB_FBBLIT_HEADER */ diff --git a/video/fb/fbblit.c b/video/fb/fbblit.c index 5b613bc79..a0f44d268 100644 --- a/video/fb/fbblit.c +++ b/video/fb/fbblit.c @@ -90,6 +90,302 @@ grub_video_fbblit_replace_directN (struct grub_video_fbblit_info *dst, } } +/* Optimized replacing blitter for 1-bit to 32bit. */ +void +grub_video_fbblit_replace_32bit_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) +{ + int i; + int j; + grub_uint8_t *srcptr; + grub_uint8_t *dstptr; + grub_uint8_t srcmask; + unsigned int dstrowskip; + unsigned int srcrowskipbyte, srcrowskipbit; + grub_uint32_t fgcolor, bgcolor; + int bit_index; + + /* Calculate the number of bytes to advance from the end of one line + to the beginning of the next line. */ + dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; + srcrowskipbyte = (src->mode_info->width - width) >> 3; + srcrowskipbit = (src->mode_info->width - width) & 7; + + bit_index = offset_y * src->mode_info->width + offset_x; + srcptr = (grub_uint8_t *) src->data + (bit_index >> 3); + srcmask = 1 << (~bit_index & 7); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); + + fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red, + src->mode_info->fg_green, + src->mode_info->fg_blue, + src->mode_info->fg_alpha); + + bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red, + src->mode_info->bg_green, + src->mode_info->bg_blue, + src->mode_info->bg_alpha); + + for (j = 0; j < height; j++) + { + for (i = 0; i < width; i++) + { + if (*srcptr & srcmask) + *(grub_uint32_t *) dstptr = fgcolor; + else + *(grub_uint32_t *) dstptr = bgcolor; + srcmask >>= 1; + if (!srcmask) + { + srcptr++; + srcmask = 0x80; + } + + dstptr += 4; + } + + srcptr += srcrowskipbyte; + if (srcmask >> srcrowskipbit) + srcmask >>= srcrowskipbit; + else + { + srcptr++; + srcmask <<= 8 - srcrowskipbit; + } + dstptr += dstrowskip; + } +} + + +/* Optimized replacing blitter for 1-bit to 24-bit. */ +void +grub_video_fbblit_replace_24bit_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) +{ + int i; + int j; + grub_uint8_t *srcptr; + grub_uint8_t *dstptr; + grub_uint8_t srcmask; + unsigned int dstrowskip; + unsigned int srcrowskipbyte, srcrowskipbit; + grub_uint32_t fgcolor, bgcolor; + int bit_index; + + /* Calculate the number of bytes to advance from the end of one line + to the beginning of the next line. */ + dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; + srcrowskipbyte = (src->mode_info->width - width) >> 3; + srcrowskipbit = (src->mode_info->width - width) & 7; + + bit_index = offset_y * src->mode_info->width + offset_x; + srcptr = (grub_uint8_t *) src->data + (bit_index >> 3); + srcmask = 1 << (~bit_index & 7); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); + + fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red, + src->mode_info->fg_green, + src->mode_info->fg_blue, + src->mode_info->fg_alpha); + + bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red, + src->mode_info->bg_green, + src->mode_info->bg_blue, + src->mode_info->bg_alpha); + + for (j = 0; j < height; j++) + { + for (i = 0; i < width - 1; i++) + { + if (*srcptr & srcmask) + *(grub_uint32_t *) dstptr = fgcolor; + else + *(grub_uint32_t *) dstptr = bgcolor; + srcmask >>= 1; + if (!srcmask) + { + srcptr++; + srcmask = 0x80; + } + + dstptr += 3; + } + + if (*srcptr & srcmask) + { + *dstptr++ = fgcolor & 0xff; + *dstptr++ = (fgcolor & 0xff00) >> 8; + *dstptr++ = (fgcolor & 0xff0000) >> 16; + } + else + { + *dstptr++ = bgcolor & 0xff; + *dstptr++ = (bgcolor & 0xff00) >> 8; + *dstptr++ = (bgcolor & 0xff0000) >> 16; + } + srcmask >>= 1; + if (!srcmask) + { + srcptr++; + srcmask = 0x80; + } + + srcptr += srcrowskipbyte; + if (srcmask >> srcrowskipbit) + srcmask >>= srcrowskipbit; + else + { + srcptr++; + srcmask <<= 8 - srcrowskipbit; + } + dstptr += dstrowskip; + } +} + +/* Optimized replacing blitter for 1-bit to 16-bit. */ +void +grub_video_fbblit_replace_16bit_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) +{ + int i; + int j; + grub_uint8_t *srcptr; + grub_uint8_t *dstptr; + grub_uint8_t srcmask; + unsigned int dstrowskip; + unsigned int srcrowskipbyte, srcrowskipbit; + grub_uint16_t fgcolor, bgcolor; + int bit_index; + + /* Calculate the number of bytes to advance from the end of one line + to the beginning of the next line. */ + dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; + srcrowskipbyte = (src->mode_info->width - width) >> 3; + srcrowskipbit = (src->mode_info->width - width) & 7; + + bit_index = offset_y * src->mode_info->width + offset_x; + srcptr = (grub_uint8_t *) src->data + (bit_index >> 3); + srcmask = 1 << (~bit_index & 7); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); + + fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red, + src->mode_info->fg_green, + src->mode_info->fg_blue, + src->mode_info->fg_alpha); + + bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red, + src->mode_info->bg_green, + src->mode_info->bg_blue, + src->mode_info->bg_alpha); + + for (j = 0; j < height; j++) + { + for (i = 0; i < width; i++) + { + if (*srcptr & srcmask) + *(grub_uint16_t *) dstptr = fgcolor; + else + *(grub_uint16_t *) dstptr = bgcolor; + srcmask >>= 1; + if (!srcmask) + { + srcptr++; + srcmask = 0x80; + } + + dstptr += 2; + } + + srcptr += srcrowskipbyte; + if (srcmask >> srcrowskipbit) + srcmask >>= srcrowskipbit; + else + { + srcptr++; + srcmask <<= 8 - srcrowskipbit; + } + dstptr += dstrowskip; + } +} + +/* Optimized replacing blitter for 1-bit to 8-bit. */ +void +grub_video_fbblit_replace_8bit_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) +{ + int i; + int j; + grub_uint8_t *srcptr; + grub_uint8_t *dstptr; + grub_uint8_t srcmask; + unsigned int dstrowskip; + unsigned int srcrowskipbyte, srcrowskipbit; + grub_uint8_t fgcolor, bgcolor; + int bit_index; + + /* Calculate the number of bytes to advance from the end of one line + to the beginning of the next line. */ + dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; + srcrowskipbyte = (src->mode_info->width - width) >> 3; + srcrowskipbit = (src->mode_info->width - width) & 7; + + bit_index = offset_y * src->mode_info->width + offset_x; + srcptr = (grub_uint8_t *) src->data + (bit_index >> 3); + srcmask = 1 << (~bit_index & 7); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); + + fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red, + src->mode_info->fg_green, + src->mode_info->fg_blue, + src->mode_info->fg_alpha); + + bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red, + src->mode_info->bg_green, + src->mode_info->bg_blue, + src->mode_info->bg_alpha); + + for (j = 0; j < height; j++) + { + for (i = 0; i < width; i++) + { + if (*srcptr & srcmask) + *(grub_uint8_t *) dstptr = fgcolor; + else + *(grub_uint8_t *) dstptr = bgcolor; + srcmask >>= 1; + if (!srcmask) + { + srcptr++; + srcmask = 0x80; + } + + dstptr++; + } + + srcptr += srcrowskipbyte; + if (srcmask >> srcrowskipbit) + srcmask >>= srcrowskipbit; + else + { + srcptr++; + srcmask <<= 8 - srcrowskipbit; + } + dstptr += dstrowskip; + } +} + /* Optimized replacing blitter for RGBX8888 to BGRX8888. */ void grub_video_fbblit_replace_BGRX8888_RGBX8888 (struct grub_video_fbblit_info *dst, @@ -826,3 +1122,294 @@ grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst, } } } + +/* Optimized blending blitter for 1-bit to XXXA8888. */ +void +grub_video_fbblit_blend_XXXA8888_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) +{ + int i; + int j; + grub_uint8_t *srcptr; + grub_uint8_t *dstptr; + grub_uint8_t srcmask; + unsigned int dstrowskip; + unsigned int srcrowskipbyte, srcrowskipbit; + grub_uint32_t fgcolor, bgcolor; + int bit_index; + + /* Calculate the number of bytes to advance from the end of one line + to the beginning of the next line. */ + dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; + srcrowskipbyte = (src->mode_info->width - width) >> 3; + srcrowskipbit = (src->mode_info->width - width) & 7; + + bit_index = offset_y * src->mode_info->width + offset_x; + srcptr = (grub_uint8_t *) src->data + (bit_index >> 3); + srcmask = 1 << (~bit_index & 7); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); + + fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red, + src->mode_info->fg_green, + src->mode_info->fg_blue, + src->mode_info->fg_alpha); + + bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red, + src->mode_info->bg_green, + src->mode_info->bg_blue, + src->mode_info->bg_alpha); + + for (j = 0; j < height; j++) + { + for (i = 0; i < width; i++) + { + grub_uint32_t color; + grub_uint8_t a; + + if (*srcptr & srcmask) + color = fgcolor; + else + color = bgcolor; + a = (color >> 24) & 0xff; + + if (a == 255) + *(grub_uint32_t *) dstptr = color; + else if (a != 0) + { + grub_uint8_t s1 = (color >> 0) & 0xFF; + grub_uint8_t s2 = (color >> 8) & 0xFF; + grub_uint8_t s3 = (color >> 16) & 0xFF; + + grub_uint8_t d1 = (*(grub_uint32_t *) dstptr >> 0) & 0xFF; + grub_uint8_t d2 = (*(grub_uint32_t *) dstptr >> 8) & 0xFF; + grub_uint8_t d3 = (*(grub_uint32_t *) dstptr >> 16) & 0xFF; + + d1 = (d1 * (255 - a) + s1 * a) / 255; + d2 = (d2 * (255 - a) + s2 * a) / 255; + d3 = (d3 * (255 - a) + s3 * a) / 255; + + *(grub_uint32_t *) dstptr = (a << 24) | (d3 << 16) | (d2 << 8) + | d1; + } + + srcmask >>= 1; + if (!srcmask) + { + srcptr++; + srcmask = 0x80; + } + + dstptr += 4; + } + + srcptr += srcrowskipbyte; + if (srcmask >> srcrowskipbit) + srcmask >>= srcrowskipbit; + else + { + srcptr++; + srcmask <<= 8 - srcrowskipbit; + } + dstptr += dstrowskip; + } +} + +/* Optimized blending blitter for 1-bit to XXX888. */ +void +grub_video_fbblit_blend_XXX888_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) +{ + int i; + int j; + grub_uint8_t *srcptr; + grub_uint8_t *dstptr; + grub_uint8_t srcmask; + unsigned int dstrowskip; + unsigned int srcrowskipbyte, srcrowskipbit; + grub_uint32_t fgcolor, bgcolor; + int bit_index; + + /* Calculate the number of bytes to advance from the end of one line + to the beginning of the next line. */ + dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; + srcrowskipbyte = (src->mode_info->width - width) >> 3; + srcrowskipbit = (src->mode_info->width - width) & 7; + + bit_index = offset_y * src->mode_info->width + offset_x; + srcptr = (grub_uint8_t *) src->data + (bit_index >> 3); + srcmask = 1 << (~bit_index & 7); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); + + fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red, + src->mode_info->fg_green, + src->mode_info->fg_blue, + src->mode_info->fg_alpha); + + bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red, + src->mode_info->bg_green, + src->mode_info->bg_blue, + src->mode_info->bg_alpha); + + for (j = 0; j < height; j++) + { + for (i = 0; i < width; i++) + { + grub_uint32_t color; + grub_uint8_t a; + if (*srcptr & srcmask) + { + color = fgcolor; + a = src->mode_info->fg_alpha; + } + else + { + color = bgcolor; + a = src->mode_info->bg_alpha; + } + + if (a == 255) + { + ((grub_uint8_t *) dstptr)[0] = color & 0xff; + ((grub_uint8_t *) dstptr)[1] = (color & 0xff00) >> 8; + ((grub_uint8_t *) dstptr)[2] = (color & 0xff0000) >> 16; + } + else if (a != 0) + { + grub_uint8_t s1 = (color >> 0) & 0xFF; + grub_uint8_t s2 = (color >> 8) & 0xFF; + grub_uint8_t s3 = (color >> 16) & 0xFF; + + grub_uint8_t d1 = (*(grub_uint32_t *) dstptr >> 0) & 0xFF; + grub_uint8_t d2 = (*(grub_uint32_t *) dstptr >> 8) & 0xFF; + grub_uint8_t d3 = (*(grub_uint32_t *) dstptr >> 16) & 0xFF; + + ((grub_uint8_t *) dstptr)[0] = (d1 * (255 - a) + s1 * a) / 255; + ((grub_uint8_t *) dstptr)[1] = (d2 * (255 - a) + s2 * a) / 255; + ((grub_uint8_t *) dstptr)[2] = (d3 * (255 - a) + s3 * a) / 255; + } + + srcmask >>= 1; + if (!srcmask) + { + srcptr++; + srcmask = 0x80; + } + + dstptr += 3; + } + + srcptr += srcrowskipbyte; + if (srcmask >> srcrowskipbit) + srcmask >>= srcrowskipbit; + else + { + srcptr++; + srcmask <<= 8 - srcrowskipbit; + } + dstptr += dstrowskip; + } +} + +/* Optimized blending blitter for 1-bit to XXX888. */ +void +grub_video_fbblit_blend_XXX565_1bit (struct grub_video_fbblit_info *dst, + struct grub_video_fbblit_info *src, + int x, int y, + int width, int height, + int offset_x, int offset_y) +{ + int i; + int j; + grub_uint8_t *srcptr; + grub_uint8_t *dstptr; + grub_uint8_t srcmask; + unsigned int dstrowskip; + unsigned int srcrowskipbyte, srcrowskipbit; + grub_uint16_t fgcolor, bgcolor; + int bit_index; + + /* Calculate the number of bytes to advance from the end of one line + to the beginning of the next line. */ + dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width; + srcrowskipbyte = (src->mode_info->width - width) >> 3; + srcrowskipbit = (src->mode_info->width - width) & 7; + + bit_index = offset_y * src->mode_info->width + offset_x; + srcptr = (grub_uint8_t *) src->data + (bit_index >> 3); + srcmask = 1 << (~bit_index & 7); + dstptr = (grub_uint8_t *) grub_video_fb_get_video_ptr (dst, x, y); + + fgcolor = grub_video_fb_map_rgba (src->mode_info->fg_red, + src->mode_info->fg_green, + src->mode_info->fg_blue, + src->mode_info->fg_alpha); + + bgcolor = grub_video_fb_map_rgba (src->mode_info->bg_red, + src->mode_info->bg_green, + src->mode_info->bg_blue, + src->mode_info->bg_alpha); + + for (j = 0; j < height; j++) + { + for (i = 0; i < width; i++) + { + grub_uint32_t color; + grub_uint8_t a; + if (*srcptr & srcmask) + { + color = fgcolor; + a = src->mode_info->fg_alpha; + } + else + { + color = bgcolor; + a = src->mode_info->bg_alpha; + } + + if (a == 255) + *(grub_uint16_t *) dstptr = color; + else if (a != 0) + { + grub_uint8_t s1 = (color >> 0) & 0x1F; + grub_uint8_t s2 = (color >> 5) & 0x3F; + grub_uint8_t s3 = (color >> 11) & 0x1F; + + grub_uint8_t d1 = (*(grub_uint16_t *) dstptr >> 0) & 0x1F; + grub_uint8_t d2 = (*(grub_uint16_t *) dstptr >> 5) & 0x3F; + grub_uint8_t d3 = (*(grub_uint16_t *) dstptr >> 11) & 0x1F; + + d1 = (d1 * (255 - a) + s1 * a) / 255; + d2 = (d2 * (255 - a) + s2 * a) / 255; + d3 = (d3 * (255 - a) + s3 * a) / 255; + + *(grub_uint16_t *) dstptr = (d1 & 0x1f) | ((d2 & 0x3f) << 5) + | ((d3 & 0x1f) << 11); + } + + srcmask >>= 1; + if (!srcmask) + { + srcptr++; + srcmask = 0x80; + } + + dstptr += 2; + } + + srcptr += srcrowskipbyte; + if (srcmask >> srcrowskipbit) + srcmask >>= srcrowskipbit; + else + { + srcptr++; + srcmask <<= 8 - srcrowskipbit; + } + dstptr += dstrowskip; + } +} diff --git a/video/fb/video_fb.c b/video/fb/video_fb.c index a35dd7a4e..5f2917da6 100644 --- a/video/fb/video_fb.c +++ b/video/fb/video_fb.c @@ -587,6 +587,37 @@ common_blitter (struct grub_video_fbblit_info *target, return; } } + else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED) + { + if (target->mode_info->bpp == 32) + { + grub_video_fbblit_replace_32bit_1bit (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->bpp == 24) + { + grub_video_fbblit_replace_24bit_1bit (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->bpp == 16) + { + grub_video_fbblit_replace_16bit_1bit (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->bpp == 8) + { + grub_video_fbblit_replace_8bit_1bit (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + } /* No optimized replace operator found, use default (slow) blitter. */ grub_video_fbblit_replace (target, source, x, y, width, height, @@ -674,6 +705,41 @@ common_blitter (struct grub_video_fbblit_info *target, return; } } + else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED) + { + if (target->mode_info->blit_format + == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888 + || target->mode_info->blit_format + == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888) + { + grub_video_fbblit_blend_XXXA8888_1bit (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format + == GRUB_VIDEO_BLIT_FORMAT_BGR_888 + || target->mode_info->blit_format + == GRUB_VIDEO_BLIT_FORMAT_RGB_888) + { + grub_video_fbblit_blend_XXX888_1bit (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + else if (target->mode_info->blit_format + == GRUB_VIDEO_BLIT_FORMAT_BGR_565 + || target->mode_info->blit_format + == GRUB_VIDEO_BLIT_FORMAT_RGB_565) + { + grub_video_fbblit_blend_XXX565_1bit (target, source, + x, y, width, height, + offset_x, offset_y); + return; + } + + } + /* No optimized blend operation found, use default (slow) blitter. */ grub_video_fbblit_blend (target, source, x, y, width, height, diff --git a/video/video.c b/video/video.c index 36ebfd1b8..c1d66bdd0 100644 --- a/video/video.c +++ b/video/video.c @@ -181,6 +181,8 @@ grub_video_get_blit_format (struct grub_video_mode_info *mode_info) return GRUB_VIDEO_BLIT_FORMAT_RGB_565; } } + else if (mode_info->bpp == 1) + return GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED; /* Backup route. Unknown format. */ From b4f34077c8a94d66cc1d22d613eba27c49781725 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Fri, 28 Aug 2009 14:10:02 +0000 Subject: [PATCH 30/85] 2009-08-28 Colin Watson * term/i386/pc/console.c (bios_data_area): Cast GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR explicitly. --- ChangeLog | 5 +++++ term/i386/pc/console.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b43aa72ba..1858a9cbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-28 Colin Watson + + * term/i386/pc/console.c (bios_data_area): Cast + GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR explicitly. + 2009-08-28 Vladimir Serbinenko 1-bit optimised blitters. diff --git a/term/i386/pc/console.c b/term/i386/pc/console.c index ec1383942..66475d456 100644 --- a/term/i386/pc/console.c +++ b/term/i386/pc/console.c @@ -21,7 +21,8 @@ #include #include -static const struct grub_machine_bios_data_area *bios_data_area = GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR; +static const struct grub_machine_bios_data_area *bios_data_area = + (struct grub_machine_bios_data_area *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR; #define KEYBOARD_LEFT_SHIFT (1 << 0) #define KEYBOARD_RIGHT_SHIFT (1 << 1) From 6f07b921bc5e60fde59fb10cb68896c6124b3335 Mon Sep 17 00:00:00 2001 From: phcoder Date: Fri, 28 Aug 2009 16:29:34 +0000 Subject: [PATCH 31/85] 2009-08-28 Vladimir Serbinenko * kern/file.c (grub_file_read): Check offset. * fs/hfs.c (grub_hfs_read_file): Remove unnecessary offset check. * fs/jfs.c (grub_jfs_read_file): Likewise. * fs/ntfs.c (grub_ntfs_read): Likewise. * fs/reiserfs.c (grub_reiserfs_read): Likewise. * fs/minix.c (grub_minix_read_file): Correct offset check. * fs/ufs.c (grub_ufs_read_file): Likewise. --- ChangeLog | 10 ++++++++++ fs/hfs.c | 4 ---- fs/jfs.c | 4 ---- fs/minix.c | 4 ++-- fs/ntfs.c | 9 --------- fs/reiserfs.c | 3 --- fs/ufs.c | 4 ++-- kern/file.c | 7 +++++++ 8 files changed, 21 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1858a9cbb..b657885fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-08-28 Vladimir Serbinenko + + * kern/file.c (grub_file_read): Check offset. + * fs/hfs.c (grub_hfs_read_file): Remove unnecessary offset check. + * fs/jfs.c (grub_jfs_read_file): Likewise. + * fs/ntfs.c (grub_ntfs_read): Likewise. + * fs/reiserfs.c (grub_reiserfs_read): Likewise. + * fs/minix.c (grub_minix_read_file): Correct offset check. + * fs/ufs.c (grub_ufs_read_file): Likewise. + 2009-08-28 Colin Watson * term/i386/pc/console.c (bios_data_area): Cast diff --git a/fs/hfs.c b/fs/hfs.c index 2f0702cbb..5062b5f71 100644 --- a/fs/hfs.c +++ b/fs/hfs.c @@ -243,10 +243,6 @@ grub_hfs_read_file (struct grub_hfs_data *data, int i; int blockcnt; - /* Adjust len so it we can't read past the end of the file. */ - if (len > grub_le_to_cpu32 (data->size)) - len = grub_le_to_cpu32 (data->size); - blockcnt = ((len + pos) + data->blksz - 1) / data->blksz; diff --git a/fs/jfs.c b/fs/jfs.c index 51ca91ad0..b73f9bdd4 100644 --- a/fs/jfs.c +++ b/fs/jfs.c @@ -544,10 +544,6 @@ grub_jfs_read_file (struct grub_jfs_data *data, int i; int blockcnt; - /* Adjust len so it we can't read past the end of the file. */ - if (len > data->currinode.size) - len = data->currinode.size; - blockcnt = ((len + pos + grub_le_to_cpu32 (data->sblock.blksz) - 1) / grub_le_to_cpu32 (data->sblock.blksz)); diff --git a/fs/minix.c b/fs/minix.c index 44218fb89..08eb60729 100644 --- a/fs/minix.c +++ b/fs/minix.c @@ -193,8 +193,8 @@ grub_minix_read_file (struct grub_minix_data *data, int blockcnt; /* Adjust len so it we can't read past the end of the file. */ - if (len > GRUB_MINIX_INODE_SIZE (data)) - len = GRUB_MINIX_INODE_SIZE (data); + if (len + pos > GRUB_MINIX_INODE_SIZE (data)) + len = GRUB_MINIX_INODE_SIZE (data) - pos; blockcnt = (len + pos + GRUB_MINIX_BSIZE - 1) / GRUB_MINIX_BSIZE; diff --git a/fs/ntfs.c b/fs/ntfs.c index d03a94016..3ff487c6e 100644 --- a/fs/ntfs.c +++ b/fs/ntfs.c @@ -970,15 +970,6 @@ grub_ntfs_read (grub_file_t file, char *buf, grub_size_t len) if (file->read_hook) mft->attr.save_pos = 1; - if (file->offset > file->size) - { - grub_error (GRUB_ERR_BAD_FS, "Bad offset"); - return -1; - } - - if (file->offset + len > file->size) - len = file->size - file->offset; - read_attr (&mft->attr, buf, file->offset, len, 1, file->read_hook); return (grub_errno) ? 0 : len; } diff --git a/fs/reiserfs.c b/fs/reiserfs.c index 04d33150f..fb4f1bc59 100644 --- a/fs/reiserfs.c +++ b/fs/reiserfs.c @@ -1077,9 +1077,6 @@ grub_reiserfs_read (grub_file_t file, char *buf, grub_size_t len) grub_disk_addr_t block; grub_off_t offset; - if (file->offset >= file->size) - return 0; - key.directory_id = node->header.key.directory_id; key.object_id = node->header.key.object_id; key.u.v2.offset_type = 0; diff --git a/fs/ufs.c b/fs/ufs.c index 797a45d13..c94ad9922 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -290,8 +290,8 @@ grub_ufs_read_file (struct grub_ufs_data *data, int blockcnt; /* Adjust len so it we can't read past the end of the file. */ - if (len > INODE_SIZE (data)) - len = INODE_SIZE (data); + if (len + pos > INODE_SIZE (data)) + len = INODE_SIZE (data) - pos; blockcnt = (len + pos + UFS_BLKSZ (sblock) - 1) / UFS_BLKSZ (sblock); diff --git a/kern/file.c b/kern/file.c index 9b56b88e4..22f2f6093 100644 --- a/kern/file.c +++ b/kern/file.c @@ -112,6 +112,13 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len) { grub_ssize_t res; + if (file->offset > file->size) + { + grub_error (GRUB_ERR_OUT_OF_RANGE, + "Attempt to read pat the end of file."); + return -1; + } + if (len == 0 || len > file->size - file->offset) len = file->size - file->offset; From d8888b5cb4f098d2c0758396ca52e99c0984b203 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sat, 29 Aug 2009 00:24:32 +0000 Subject: [PATCH 32/85] 2009-08-29 Robert Millan * term/i386/pc/serial.c: Include `'. [GRUB_MACHINE_PCBIOS] (serial_hw_io_addr): Macroify initialization value (0x0400 -> GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR). [! GRUB_MACHINE_PCBIOS] (GRUB_SERIAL_PORT_NUM): Calculate using `ARRAY_SIZE' macro. --- ChangeLog | 10 ++++++++++ term/i386/pc/serial.c | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b657885fe..66b8371dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-08-29 Robert Millan + + * term/i386/pc/serial.c: Include `'. + + [GRUB_MACHINE_PCBIOS] (serial_hw_io_addr): Macroify initialization + value (0x0400 -> GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR). + + [! GRUB_MACHINE_PCBIOS] (GRUB_SERIAL_PORT_NUM): Calculate using + `ARRAY_SIZE' macro. + 2009-08-28 Vladimir Serbinenko * kern/file.c (grub_file_read): Check offset. diff --git a/term/i386/pc/serial.c b/term/i386/pc/serial.c index 195f73670..1d74dbbc8 100644 --- a/term/i386/pc/serial.c +++ b/term/i386/pc/serial.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009 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 @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -64,12 +65,11 @@ struct serial_port static struct serial_port serial_settings; #ifdef GRUB_MACHINE_PCBIOS -/* The BIOS data area. */ -static const unsigned short *serial_hw_io_addr = (const unsigned short *) 0x0400; +static const unsigned short *serial_hw_io_addr = (const unsigned short *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR; #define GRUB_SERIAL_PORT_NUM 4 #else static const unsigned short serial_hw_io_addr[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; -#define GRUB_SERIAL_PORT_NUM (sizeof(serial_hw_io_addr)/sizeof(serial_hw_io_addr[0])) +#define GRUB_SERIAL_PORT_NUM (ARRAY_SIZE(serial_hw_io_addr)) #endif /* Return the port number for the UNITth serial device. */ From c90edae43aba3a15010b8502f403cc6bc9106504 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sat, 29 Aug 2009 00:34:33 +0000 Subject: [PATCH 33/85] 2009-08-29 Robert Millan * util/grub.d/10_freebsd.in: Detect `ufs1' and `ufs2' and map them to `ufs' in the vfs.root.mountfrom kernel parameter. --- ChangeLog | 5 +++++ util/grub.d/10_freebsd.in | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66b8371dd..0f4ca8fbd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-29 Robert Millan + + * util/grub.d/10_freebsd.in: Detect `ufs1' and `ufs2' and map them + to `ufs' in the vfs.root.mountfrom kernel parameter. + 2009-08-29 Robert Millan * term/i386/pc/serial.c: Include `'. diff --git a/util/grub.d/10_freebsd.in b/util/grub.d/10_freebsd.in index 64d2cc4c0..1e3a0de1f 100644 --- a/util/grub.d/10_freebsd.in +++ b/util/grub.d/10_freebsd.in @@ -50,8 +50,10 @@ if [ "x$kfreebsd" != "x" ] ; then devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname` fi - # For "ufs" it's the same. Do we care about the others? - kfreebsd_fs=${GRUB_FS} + case ${GRUB_FS} in + ufs1 | ufs2) kfreebsd_fs=ufs ;; + *) kfreebsd_fs=${GRUB_FS} ;; + esac cat << EOF menuentry "${OS}" { From 64bf71d0b177d92aa706b8300dee8425baa6d0e9 Mon Sep 17 00:00:00 2001 From: phcoder Date: Sat, 29 Aug 2009 12:57:38 +0000 Subject: [PATCH 34/85] 2009-08-28 Vladimir Serbinenko * include/grub/i386/xnu.h: Add license header. include grub/err.h explicitly. --- ChangeLog | 5 +++++ include/grub/i386/xnu.h | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0f4ca8fbd..217a433fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-28 Vladimir Serbinenko + + * include/grub/i386/xnu.h: Add license header. + include grub/err.h explicitly. + 2009-08-29 Robert Millan * util/grub.d/10_freebsd.in: Detect `ufs1' and `ufs2' and map them diff --git a/include/grub/i386/xnu.h b/include/grub/i386/xnu.h index ebc38eb61..68674e605 100644 --- a/include/grub/i386/xnu.h +++ b/include/grub/i386/xnu.h @@ -1,6 +1,26 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 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_CPU_XNU_H #define GRUB_CPU_XNU_H 1 +#include + #define GRUB_XNU_PAGESIZE 4096 typedef grub_uint32_t grub_xnu_ptr_t; From 5c90cdd262f71239c93652885897ef2261f19c59 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sun, 30 Aug 2009 15:08:50 +0000 Subject: [PATCH 35/85] date fix --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 217a433fa..f953a3e56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2009-08-28 Vladimir Serbinenko +2009-08-29 Vladimir Serbinenko * include/grub/i386/xnu.h: Add license header. include grub/err.h explicitly. From cc55302e001c463244e6740c6101f9630143ce1f Mon Sep 17 00:00:00 2001 From: robertmh Date: Sun, 30 Aug 2009 15:12:48 +0000 Subject: [PATCH 36/85] 2009-08-30 Robert Millan * configure.ac: Bump version to 1.97~beta1. * docs/version.texi: Likewise. --- ChangeLog | 5 +++++ configure.ac | 2 +- docs/version.texi | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f953a3e56..66c5711ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-30 Robert Millan + + * configure.ac: Bump version to 1.97~beta1. + * docs/version.texi: Likewise. + 2009-08-29 Vladimir Serbinenko * include/grub/i386/xnu.h: Add license header. diff --git a/configure.ac b/configure.ac index 549b35c9b..cddd9fe2d 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target dnl type. -AC_INIT([GRUB],[1.96],[bug-grub@gnu.org]) +AC_INIT([GRUB],[1.97~beta1],[bug-grub@gnu.org]) AC_PREREQ(2.59) AC_CONFIG_SRCDIR([include/grub/dl.h]) AC_CONFIG_HEADER([config.h]) diff --git a/docs/version.texi b/docs/version.texi index 5a03fa3c9..4528c7b2e 100644 --- a/docs/version.texi +++ b/docs/version.texi @@ -1,4 +1,4 @@ @set UPDATED 7 Ago 2009 @set UPDATED-MONTH Ago 2009 -@set EDITION 1.97~snapshot -@set VERSION 1.97~snapshot +@set EDITION 1.97~beta1 +@set VERSION 1.97~beta1 From fe00f472fc546b54bec742f0eb5b6b1195061335 Mon Sep 17 00:00:00 2001 From: phcoder Date: Sun, 30 Aug 2009 19:28:01 +0000 Subject: [PATCH 37/85] 2009-08-30 Vladimir Serbinenko * loader/i386/bsdXX.c (SUFFIX (grub_freebsd_load_elfmodule)): Fix loading of headers in some cases. --- ChangeLog | 5 +++++ loader/i386/bsdXX.c | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66c5711ee..d4f1d894e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-08-30 Vladimir Serbinenko + + * loader/i386/bsdXX.c (SUFFIX (grub_freebsd_load_elfmodule)): Fix + loading of headers in some cases. + 2009-08-30 Robert Millan * configure.ac: Bump version to 1.97~beta1. diff --git a/loader/i386/bsdXX.c b/loader/i386/bsdXX.c index 3f15579dd..aedc204b2 100644 --- a/loader/i386/bsdXX.c +++ b/loader/i386/bsdXX.c @@ -197,15 +197,15 @@ SUFFIX (grub_freebsd_load_elfmodule) (grub_file_t file, int argc, char *argv[], if (curload < module + sizeof (e)) curload = module + sizeof (e); - load (file, UINT_TO_PTR (module + e.e_shoff), e.e_shoff, + load (file, UINT_TO_PTR (curload), e.e_shoff, e.e_shnum * e.e_shentsize); - if (curload < module + e.e_shoff + e.e_shnum * e.e_shentsize) - curload = module + e.e_shoff + e.e_shnum * e.e_shentsize; + e.e_shoff = curload - module; + curload += e.e_shnum * e.e_shentsize; - load (file, UINT_TO_PTR (module + e.e_phoff), e.e_phoff, + load (file, UINT_TO_PTR (curload), e.e_phoff, e.e_phnum * e.e_phentsize); - if (curload < module + e.e_phoff + e.e_phnum * e.e_phentsize) - curload = module + e.e_phoff + e.e_phnum * e.e_phentsize; + e.e_phoff = curload - module; + curload += e.e_phnum * e.e_phentsize; *kern_end = curload; From b5e7312c4335b3bb6a0b784171541dcba83664d3 Mon Sep 17 00:00:00 2001 From: phcoder Date: Sun, 30 Aug 2009 20:19:09 +0000 Subject: [PATCH 38/85] 2009-08-30 Vladimir Serbinenko * kern/file.c (grub_file_read): Spelling fix --- ChangeLog | 4 ++++ kern/file.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d4f1d894e..84dd6e4a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-08-30 Vladimir Serbinenko + + * kern/file.c (grub_file_read): Spelling fix + 2009-08-30 Vladimir Serbinenko * loader/i386/bsdXX.c (SUFFIX (grub_freebsd_load_elfmodule)): Fix diff --git a/kern/file.c b/kern/file.c index 22f2f6093..f713acbca 100644 --- a/kern/file.c +++ b/kern/file.c @@ -115,7 +115,7 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len) if (file->offset > file->size) { grub_error (GRUB_ERR_OUT_OF_RANGE, - "Attempt to read pat the end of file."); + "Attempt to read past the end of file."); return -1; } From 31aba781b65308f95a6f82f7c32156b748e8be2b Mon Sep 17 00:00:00 2001 From: fzielcke Date: Tue, 1 Sep 2009 15:46:06 +0000 Subject: [PATCH 39/85] 2009-01-01 Felix Zielcke * genmk.rb: Add quotes around $(TARGET_OBJ2ELF) to cope with non GNU test. --- ChangeLog | 5 +++++ genmk.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 84dd6e4a7..73e5436a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-01-01 Felix Zielcke + + * genmk.rb: Add quotes around $(TARGET_OBJ2ELF) to cope with + non GNU test. + 2009-08-30 Vladimir Serbinenko * kern/file.c (grub_file_read): Spelling fix diff --git a/genmk.rb b/genmk.rb index 9574ce98d..4aedb25c4 100644 --- a/genmk.rb +++ b/genmk.rb @@ -126,7 +126,7 @@ ifneq ($(TARGET_APPLE_CC),1) #{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF) -rm -f $@ $(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj} #{mod_obj} - if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi + if test ! -z \"$(TARGET_OBJ2ELF)\"; then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@ else #{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF) From c403a1250dce0ea374917122c95e56a1621b2890 Mon Sep 17 00:00:00 2001 From: fzielcke Date: Tue, 1 Sep 2009 16:13:29 +0000 Subject: [PATCH 40/85] fix wrong date and use \t instead of 8 spaces in previous ChangeLog entry --- ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 73e5436a3..15d059f92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ -2009-01-01 Felix Zielcke +2009-09-01 Felix Zielcke * genmk.rb: Add quotes around $(TARGET_OBJ2ELF) to cope with - non GNU test. + non GNU test. 2009-08-30 Vladimir Serbinenko From ecb3166a82e01adf2407c0916cc42d38dad6d014 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Tue, 1 Sep 2009 16:14:11 +0000 Subject: [PATCH 41/85] 2009-09-01 Colin Watson * script/lua/grub_lua.h (fputs): Supply a format string as the first argument to grub_printf. --- ChangeLog | 5 +++++ script/lua/grub_lua.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 15d059f92..1893f9ee8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-01 Colin Watson + + * script/lua/grub_lua.h (fputs): Supply a format string as the first + argument to grub_printf. + 2009-09-01 Felix Zielcke * genmk.rb: Add quotes around $(TARGET_OBJ2ELF) to cope with diff --git a/script/lua/grub_lua.h b/script/lua/grub_lua.h index d5181f147..78e6546c7 100644 --- a/script/lua/grub_lua.h +++ b/script/lua/grub_lua.h @@ -58,7 +58,7 @@ #define setjmp grub_setjmp #define longjmp grub_longjmp -#define fputs(s,f) grub_printf(s) +#define fputs(s,f) grub_printf("%s", s) #define isdigit grub_isdigit #define isalpha grub_isalpha From 3e81e9369ba19b91b5427acd506df9f778be2dba Mon Sep 17 00:00:00 2001 From: cjwatson Date: Tue, 1 Sep 2009 16:15:38 +0000 Subject: [PATCH 42/85] DISTLIST is not in svn; fix my ChangeLog entry --- ChangeLog | 1 - 1 file changed, 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1893f9ee8..3fd3d2ec9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -126,7 +126,6 @@ * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. - * DISTLIST: Add commands/keystatus.c. 2009-08-28 Vladimir Serbinenko From aa0f752dfee9b85870e6b589b39b47c9eda767c2 Mon Sep 17 00:00:00 2001 From: phcoder Date: Tue, 1 Sep 2009 19:07:42 +0000 Subject: [PATCH 43/85] 2009-09-01 Vladimir Serbinenko * commands/loadenv.c (check_blocklists): Fix off-by-one error. (write_blocklists): Likewise. --- ChangeLog | 5 +++++ commands/loadenv.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3fd3d2ec9..d8c75dfab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-01 Vladimir Serbinenko + + * commands/loadenv.c (check_blocklists): Fix off-by-one error. + (write_blocklists): Likewise. + 2009-09-01 Colin Watson * script/lua/grub_lua.h (fputs): Supply a format string as the first diff --git a/commands/loadenv.c b/commands/loadenv.c index 22665f9fe..c60eb835c 100644 --- a/commands/loadenv.c +++ b/commands/loadenv.c @@ -242,7 +242,7 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists, part_start = 0; buf = grub_envblk_buffer (envblk); - for (p = blocklists, index = 0; p; p = p->next, index += p->length) + for (p = blocklists, index = 0; p; index += p->length, p = p->next) { char blockbuf[GRUB_DISK_SECTOR_SIZE]; @@ -278,7 +278,7 @@ write_blocklists (grub_envblk_t envblk, struct blocklist *blocklists, part_start = 0; index = 0; - for (p = blocklists; p; p = p->next, index += p->length) + for (p = blocklists; p; index += p->length, p = p->next) { if (grub_disk_write (disk, p->sector - part_start, p->offset, p->length, buf + index)) From c0bc232b724bd6b339906a42d9ebbb57cd31b755 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Wed, 2 Sep 2009 01:42:06 +0000 Subject: [PATCH 44/85] 2009-09-02 Colin Watson * util/grub-probe.c (probe): Test st.st_mode using S_ISREG macro rather than comparing against S_IFREG, which will almost never work. --- ChangeLog | 5 +++++ util/grub-probe.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d8c75dfab..209a9e29c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-02 Colin Watson + + * util/grub-probe.c (probe): Test st.st_mode using S_ISREG macro + rather than comparing against S_IFREG, which will almost never work. + 2009-09-01 Vladimir Serbinenko * commands/loadenv.c (check_blocklists): Fix off-by-one error. diff --git a/util/grub-probe.c b/util/grub-probe.c index 1710ec51b..3c54408c3 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -239,7 +239,7 @@ probe (const char *path, char *device_name) stat (path, &st); - if (st.st_mode == S_IFREG) + if (S_ISREG (st.st_mode)) { /* Regular file. Verify that we can read it properly. */ From f3e8cdfd497bf0ec7c3e22ae137a61dd1b9364e4 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Wed, 2 Sep 2009 09:14:20 +0000 Subject: [PATCH 45/85] 2009-09-02 Colin Watson * commands/keystatus.c (GRUB_MOD_INIT (keystatus)): Adjust summary to avoid implying that only one of --shift, --ctrl, or --alt may be used. --- ChangeLog | 6 ++++++ commands/keystatus.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 209a9e29c..372028de9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-09-02 Colin Watson + + * commands/keystatus.c (GRUB_MOD_INIT (keystatus)): Adjust summary + to avoid implying that only one of --shift, --ctrl, or --alt may be + used. + 2009-09-02 Colin Watson * util/grub-probe.c (probe): Test st.st_mode using S_ISREG macro diff --git a/commands/keystatus.c b/commands/keystatus.c index cecbba504..28ceb2d0b 100644 --- a/commands/keystatus.c +++ b/commands/keystatus.c @@ -70,7 +70,7 @@ GRUB_MOD_INIT(keystatus) { cmd = grub_register_extcmd ("keystatus", grub_cmd_keystatus, GRUB_COMMAND_FLAG_BOTH, - "keystatus [--shift|--ctrl|--alt]", + "keystatus [--shift] [--ctrl] [--alt]", "Check key modifier status", options); } From f091064493573f99310d508ba5d4955f80f519b3 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Wed, 2 Sep 2009 09:29:58 +0000 Subject: [PATCH 46/85] =?UTF-8?q?2009-09-02=20=C2=A0Colin=20Watson=20?= =?UTF-8?q?=C2=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs/grub.texi (Naming convention): Describe one-based partition numbering. (Device syntax): Likewise. (File name syntax): Likewise. (Block list syntax): Likewise. (Making a GRUB bootable CD-ROM): Talk about grub.cfg rather than menu.lst. (File name syntax): Likewise. (Command-line and menu entry commands): Document acpi, blocklist, crc, export, insmod, keystatus, ls, set, and unset commands. --- ChangeLog | 13 +++++ docs/grub.texi | 155 ++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 146 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 372028de9..543896b9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-09-02  Colin Watson   + + * docs/grub.texi (Naming convention): Describe one-based partition + numbering. + (Device syntax): Likewise. + (File name syntax): Likewise. + (Block list syntax): Likewise. + (Making a GRUB bootable CD-ROM): Talk about grub.cfg rather than + menu.lst. + (File name syntax): Likewise. + (Command-line and menu entry commands): Document acpi, blocklist, + crc, export, insmod, keystatus, ls, set, and unset commands. + 2009-09-02 Colin Watson * commands/keystatus.c (GRUB_MOD_INIT (keystatus)): Adjust summary diff --git a/docs/grub.texi b/docs/grub.texi index e3f412565..06059df4d 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -20,7 +20,7 @@ This manual is for GNU GRUB (version @value{VERSION}, @value{UPDATED}). -Copyright @copyright{} 1999,2000,2001,2002,2004,2006,2008 Free Software Foundation, Inc. +Copyright @copyright{} 1999,2000,2001,2002,2004,2006,2008,2009 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document @@ -356,25 +356,25 @@ disk. The number @samp{0} is the drive number, which is counted from disk. @example -(hd0,1) +(hd0,2) @end example Here, @samp{hd} means it is a hard disk drive. The first integer @samp{0} indicates the drive number, that is, the first hard disk, while the second integer, @samp{1}, indicates the partition number (or the -@sc{pc} slice number in the BSD terminology). Once again, please note -that the partition numbers are counted from @emph{zero}, not from -one. This expression means the second partition of the first hard disk -drive. In this case, GRUB uses one partition of the disk, instead of the -whole disk. +@sc{pc} slice number in the BSD terminology). The partition numbers are +counted from @emph{one}, not from zero (as was the case in previous +versions of GRUB). This expression means the second partition of the +first hard disk drive. In this case, GRUB uses one partition of the +disk, instead of the whole disk. @example -(hd0,4) +(hd0,5) @end example This specifies the first @dfn{extended partition} of the first hard disk drive. Note that the partition numbers for extended partitions are -counted from @samp{4}, regardless of the actual number of primary +counted from @samp{5}, regardless of the actual number of primary partitions on your hard disk. @example @@ -383,13 +383,13 @@ partitions on your hard disk. This means the BSD @samp{a} partition of the second hard disk. If you need to specify which @sc{pc} slice number should be used, use something -like this: @samp{(hd1,0,a)}. If the @sc{pc} slice number is omitted, +like this: @samp{(hd1,1,a)}. If the @sc{pc} slice number is omitted, GRUB searches for the first @sc{pc} slice which has a BSD @samp{a} partition. Of course, to actually access the disks or partitions with GRUB, you need to use the device specification in a command, like @samp{root -(fd0)} or @samp{unhide (hd0,2)}. To help you find out which number +(fd0)} or @samp{unhide (hd0,3)}. To help you find out which number specifies a partition you want, the GRUB command-line (@pxref{Command-line interface}) options have argument completion. This means that, for example, you only need to type @@ -413,7 +413,7 @@ Now the question is, how to specify a file? Again, consider an example: @example -(hd0,0)/vmlinuz +(hd0,1)/vmlinuz @end example This specifies the file named @samp{vmlinuz}, found on the first @@ -550,7 +550,7 @@ 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{menu.lst}. You don't need to use @file{stage1} or @file{stage2}, +@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. Here is an example of procedures to make a bootable CD-ROM @@ -573,7 +573,7 @@ Copy the file @file{stage2_eltorito}: $ @kbd{cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub} @end example -If desired, make the config file @file{menu.lst} under @file{iso/boot/grub} +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/}. @@ -786,7 +786,7 @@ which is a BIOS drive number, so the following are equivalent: @end example @var{part-num} represents the partition number of @var{device}, starting -from zero for primary partitions and from four for extended partitions, +from one for primary partitions and from five for extended partitions, and @var{bsd-subpart-letter} represents the BSD disklabel subpartition, such as @samp{a} or @samp{e}. @@ -800,7 +800,7 @@ finds the subpartition @var{bsd-subpart-letter}. Here is an example: @end example The syntax @samp{(hd0)} represents using the entire disk (or the -MBR when installing GRUB), while the syntax @samp{(hd0,0)} +MBR when installing GRUB), while the syntax @samp{(hd0,1)} represents using the first partition of the disk (or the boot sector of the partition when installing GRUB). @@ -820,12 +820,12 @@ There are two ways to specify files, by @dfn{absolute file name} and by An absolute file name resembles a Unix absolute file name, using @samp{/} for the directory separator (not @samp{\} as in DOS). One -example is @samp{(hd0,0)/boot/grub/menu.lst}. This means the file -@file{/boot/grub/menu.lst} in the first partition of the first hard +example is @samp{(hd0,1)/boot/grub/grub.cfg}. This means the file +@file{/boot/grub/grub.cfg} in the first partition of the first hard disk. If you omit the device name in an absolute file name, GRUB uses GRUB's @dfn{root device} implicitly. So if you set the root device to, -say, @samp{(hd1,0)} by the command @command{root} (@pxref{root}), then -@code{/boot/kernel} is the same as @code{(hd1,0)/boot/kernel}. +say, @samp{(hd1,1)} by the command @command{root} (@pxref{root}), then +@code{/boot/kernel} is the same as @code{(hd1,1)/boot/kernel}. @node Block list syntax @@ -846,8 +846,8 @@ the offset is zero. Like the file name syntax (@pxref{File name syntax}), if a blocklist does not contain a device name, then GRUB uses GRUB's @dfn{root -device}. So @code{(hd0,1)+1} is the same as @code{+1} when the root -device is @samp{(hd0,1)}. +device}. So @code{(hd0,2)+1} is the same as @code{+1} when the root +device is @samp{(hd0,2)}. @node Interface @@ -1110,17 +1110,56 @@ you forget a command, you can run the command @command{help} (@pxref{help}). @menu +* acpi:: Load ACPI tables +* blocklist:: Print a block list * boot:: Start up your operating system * cat:: Show the contents of a file * chainloader:: Chain-load another boot loader * cmp:: Compare two files * configfile:: Load a configuration file +* crc:: Calculate CRC32 checksums +* export:: Export an environment variable * halt:: Shut down your computer * help:: Show help messages +* insmod:: Insert a module +* keystatus:: Check key modifier status +* ls:: List devices or files * reboot:: Reboot your computer +* set:: Set an environment variable +* unset:: Unset an environment variable @end menu +@node acpi +@subsection acpi + +@deffn Command acpi [@option{-1}|@option{-2}] @ + [@option{--exclude=table1,@dots{}}|@option{--load-only=table1,@dots{}}] @ + [@option{--oemid=id}] [@option{--oemtable=table}] @ + [@option{--oemtablerev=rev}] [@option{--oemtablecreator=creator}] @ + [@option{--oemtablecreatorrev=rev}] [@option{--no-ebda}] @ + filename @dots{} +Modern BIOS systems normally implement the Advanced Configuration and Power +Interface (ACPI), and define various tables that describe the interface +between an ACPI-compliant operating system and the firmware. In some cases, +the tables provided by default only work well with certain operating +systems, and it may be necessary to replace some of them. + +Normally, this command will replace the Root System Description Pointer +(RSDP) in the Extended BIOS Data Area to point to the new tables. If the +@option{--no-ebda} option is used, the new tables will be known only to +GRUB, but may be used by GRUB's EFI emulation. +@end deffn + + +@node blocklist +@subsection blocklist + +@deffn Command blocklist file +Print a block list (@pxref{Block list syntax}) for @var{file}. +@end deffn + + @node boot @subsection boot @@ -1187,6 +1226,23 @@ Load @var{file} as a configuration file. @end deffn +@node crc +@subsection crc + +@deffn Command crc file +Display the CRC32 checksum of @var{file}. +@end deffn + + +@node export +@subsection export + +@deffn Command export envvar +Export the environment variable @var{envvar}. Exported variables are visible +to subsidiary configuration files loaded using @command{configfile}. +@end deffn + + @node halt @subsection halt @@ -1212,6 +1268,44 @@ about each of the commands which match those @var{patterns}. @end deffn +@node insmod +@subsection insmod + +@deffn Command insmod module +Insert the dynamic GRUB module called @var{module}. +@end deffn + + +@node keystatus +@subsection keystatus + +@deffn Command keystatus [@option{--shift}] [@option{--ctrl}] [@option{--alt}] +Return true if the Shift, Control, or Alt modifier keys are held down, as +requested by options. This is useful in scripting, to allow some user +control over behaviour without having to wait for a keypress. + +Checking key modifier status is only supported on some platforms. If invoked +without any options, the @command{keystatus} command returns true if and +only if checking key modifier status is supported. +@end deffn + + +@node ls +@subsection ls + +@deffn Command ls [arg] +List devices or files. + +With no arguments, print all devices known to GRUB. + +If the argument is a device name enclosed in parentheses (@pxref{Device +syntax}), then list all files at the root directory of that device. + +If the argument is a directory given as an absolute file name (@pxref{File +name syntax}), then list the contents of that directory. +@end deffn + + @node reboot @subsection reboot @@ -1220,6 +1314,23 @@ Reboot the computer. @end deffn +@node set +@subsection set + +@deffn Command set [envvar=value] +Set the environment variable @var{envvar} to @var{value}. If invoked with no +arguments, print all environment variables with their values. +@end deffn + + +@node unset +@subsection unset + +@deffn Command unset envvar +Unset the environment variable @var{envvar}. +@end deffn + + @node Invoking grub-install @chapter Invoking grub-install From cbf978c0f0857c95e0abbe86d525b13a10a54e5d Mon Sep 17 00:00:00 2001 From: phcoder Date: Wed, 2 Sep 2009 16:16:29 +0000 Subject: [PATCH 47/85] 2009-09-02 Vladimir Serbinenko * efiemu/loadcore.c (SUFFIX (grub_efiemu_loadcore_load)): Fix style according to GCS. --- ChangeLog | 7 ++++++- efiemu/loadcore.c | 15 ++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 543896b9e..feb735cb3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2009-09-02  Colin Watson   +2009-09-02 Vladimir Serbinenko + + * efiemu/loadcore.c (SUFFIX (grub_efiemu_loadcore_load)): Fix style + according to GCS. + +2009-09-02 Colin Watson * docs/grub.texi (Naming convention): Describe one-based partition numbering. diff --git a/efiemu/loadcore.c b/efiemu/loadcore.c index ee4c80649..4bf26ee44 100644 --- a/efiemu/loadcore.c +++ b/efiemu/loadcore.c @@ -352,13 +352,18 @@ SUFFIX (grub_efiemu_loadcore_load) (void *core, grub_efiemu_segment_t segments) { grub_err_t err; - if ((err = grub_efiemu_load_segments (segments, core))) + err = grub_efiemu_load_segments (segments, core); + if (err) return err; - if ((err = grub_efiemu_resolve_symbols (segments, core))) + + err = grub_efiemu_resolve_symbols (segments, core); + if (err) return err; - if ((err = SUFFIX (grub_arch_efiemu_relocate_symbols) (segments, - grub_efiemu_elfsyms, - core))) + + err = SUFFIX (grub_arch_efiemu_relocate_symbols) (segments, + grub_efiemu_elfsyms, + core); + if (err) return err; return GRUB_ERR_NONE; From 087c07c4fa73a50c87451e2ad9df89c66b4d6c63 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Thu, 3 Sep 2009 07:53:40 +0000 Subject: [PATCH 48/85] 2009-09-03 Colin Watson * kern/i386/pc/startup.S: Fix typo. --- ChangeLog | 4 ++++ kern/i386/pc/startup.S | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index feb735cb3..b0b2cbcf4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-09-03 Colin Watson + + * kern/i386/pc/startup.S: Fix typo. + 2009-09-02 Vladimir Serbinenko * efiemu/loadcore.c (SUFFIX (grub_efiemu_loadcore_load)): Fix style diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S index 1a896eda1..529662b93 100644 --- a/kern/i386/pc/startup.S +++ b/kern/i386/pc/startup.S @@ -37,7 +37,7 @@ * Note: GRUB is compiled with the options -mrtd and -mregparm=3. * So the first three arguments are passed in %eax, %edx, and %ecx, * respectively, and if a function has a fixed number of arguments - * and the number if greater than three, the function must return + * and the number is greater than three, the function must return * with "ret $N" where N is ((the number of arguments) - 3) * 4. */ From 160034b2bf0b542c510aa3d84ff45340c4723388 Mon Sep 17 00:00:00 2001 From: fzielcke Date: Thu, 3 Sep 2009 14:12:27 +0000 Subject: [PATCH 49/85] 2009-09-03 Felix Zielcke * INSTALL: Note that GNU Bison 2.3 or later is required. --- ChangeLog | 4 ++++ INSTALL | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b0b2cbcf4..84c051eee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-09-03 Felix Zielcke + + * INSTALL: Note that GNU Bison 2.3 or later is required. + 2009-09-03 Colin Watson * kern/i386/pc/startup.S: Fix typo. diff --git a/INSTALL b/INSTALL index 6048b1d6e..65993657f 100644 --- a/INSTALL +++ b/INSTALL @@ -13,7 +13,7 @@ configuring the GRUB. * GCC 2.95 or later * GNU Make -* GNU Bison +* GNU Bison 2.3 or later * GNU binutils 2.9.1.0.23 or later * Other standard GNU/Unix tools * Ruby 1.6 or later From 93a81088133d4daea9b6d0935f25d5362f9313de Mon Sep 17 00:00:00 2001 From: robertmh Date: Thu, 3 Sep 2009 16:32:14 +0000 Subject: [PATCH 50/85] 2009-09-03 Magnus Granberg * aclocal.m4: Add grub_CHECK_PIE. It check if the compiler include -fPIE in the default specs. * configure.ac: Check if pie_possible is yes and add -fno-PIE to TARGET_CFLAGS. --- ChangeLog | 7 +++++++ aclocal.m4 | 28 ++++++++++++++++++++++++++++ configure.ac | 8 ++++++++ 3 files changed, 43 insertions(+) diff --git a/ChangeLog b/ChangeLog index 84c051eee..fda47fe51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-09-03 Magnus Granberg + + * aclocal.m4: Add grub_CHECK_PIE. It check if the compiler + include -fPIE in the default specs. + * configure.ac: Check if pie_possible is yes and add -fno-PIE + to TARGET_CFLAGS. + 2009-09-03 Felix Zielcke * INSTALL: Note that GNU Bison 2.3 or later is required. diff --git a/aclocal.m4 b/aclocal.m4 index bde935dc9..313b241fa 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -413,3 +413,31 @@ else [fi rm -rf testdir] ]) + +dnl Check if the C compiler supports `-fPIE'. +AC_DEFUN(grub_CHECK_PIE,[ +[# Position independent executable. +pie_possible=yes] +AC_MSG_CHECKING([whether `$CC' has `-fPIE' as default]) +# Is this a reliable test case? +AC_LANG_CONFTEST([[ +#ifdef __PIE__ +int main() { + return 0; +} +#else +#error NO __PIE__ DEFINED +#endif +]]) + +[# `$CC -c -o ...' might not be portable. But, oh, well... Is calling +# `ac_compile' like this correct, after all? +if eval "$ac_compile -S -o conftest.s" 2> /dev/null; then] + AC_MSG_RESULT([yes]) + [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? + rm -f conftest.s +else + pie_possible=no] + AC_MSG_RESULT([no]) +[fi] +]) diff --git a/configure.ac b/configure.ac index cddd9fe2d..3c4c6dce6 100644 --- a/configure.ac +++ b/configure.ac @@ -346,6 +346,14 @@ fi # Need __enable_execute_stack() for nested function trampolines? grub_CHECK_ENABLE_EXECUTE_STACK +# Position independent executable. +grub_CHECK_PIE +[# Need that, because some distributions ship compilers that include +# `-fPIE' in the default specs. +if [ x"$pie_possible" = xyes ]; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE" +fi] + # Smashing stack protector. grub_CHECK_STACK_PROTECTOR # Need that, because some distributions ship compilers that include From f79572cdd6a05079fde64d4e48ae966da0c6961c Mon Sep 17 00:00:00 2001 From: blusseau Date: Thu, 3 Sep 2009 17:07:08 +0000 Subject: [PATCH 51/85] 2009-09-02 Yves BLUSSEAU Embedding loadenv module into grub-emu * conf/i386-pc.rmk (grub_emu_SOURCES): add lib/envblk.c and commands/loadenv.c * conf/i386-coreboot.rmk (grub_emu_SOURCES): Likewise * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise * conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise --- ChangeLog | 13 +++++++++++++ conf/i386-coreboot.rmk | 1 + conf/i386-efi.rmk | 1 + conf/i386-ieee1275.rmk | 1 + conf/i386-pc.rmk | 1 + conf/powerpc-ieee1275.rmk | 1 + conf/sparc64-ieee1275.rmk | 1 + conf/x86_64-efi.rmk | 1 + 8 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index fda47fe51..55f059bba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-09-02 Yves BLUSSEAU + + Embedding loadenv module into grub-emu + + * conf/i386-pc.rmk (grub_emu_SOURCES): add lib/envblk.c and + commands/loadenv.c + * conf/i386-coreboot.rmk (grub_emu_SOURCES): Likewise + * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise + * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise + * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise + * conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise + * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise + 2009-09-03 Magnus Granberg * aclocal.m4: Add grub_CHECK_PIE. It check if the compiler diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index 4e2d1f1ec..09ec7787c 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -112,6 +112,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ commands/password.c commands/keystatus.c \ lib/hexdump.c commands/i386/cpuid.c \ + lib/envblk.c commands/loadenv.c \ disk/host.c disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index 18a9a636b..99ab06f64 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -40,6 +40,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/halt.c commands/reboot.c commands/keystatus.c \ commands/i386/cpuid.c \ commands/password.c \ + lib/envblk.c commands/loadenv.c \ disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk index b426bdd80..4b640de49 100644 --- a/conf/i386-ieee1275.rmk +++ b/conf/i386-ieee1275.rmk @@ -64,6 +64,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/handler.c commands/ls.c commands/test.c \ commands/search.c commands/blocklist.c commands/hexdump.c \ lib/hexdump.c commands/halt.c commands/reboot.c \ + lib/envblk.c commands/loadenv.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ commands/i386/cpuid.c \ commands/password.c commands/keystatus.c \ diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 8d7d9fca9..bf8fbfb9d 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -122,6 +122,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/handler.c commands/ls.c commands/test.c \ commands/search.c commands/blocklist.c commands/hexdump.c \ lib/hexdump.c commands/i386/pc/halt.c commands/reboot.c \ + lib/envblk.c commands/loadenv.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ commands/i386/cpuid.c \ commands/password.c commands/keystatus.c \ diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index b294de917..ee7f9ec27 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -45,6 +45,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/search.c commands/handler.c commands/test.c \ commands/ls.c commands/blocklist.c commands/hexdump.c \ lib/hexdump.c commands/halt.c commands/reboot.c \ + lib/envblk.c commands/loadenv.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ commands/password.c commands/keystatus.c \ disk/loopback.c \ diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index c44c6ca78..62e951a5e 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -103,6 +103,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/search.c commands/handler.c commands/test.c \ commands/ls.c commands/blocklist.c commands/hexdump.c \ lib/hexdump.c commands/halt.c commands/reboot.c \ + lib/envblk.c commands/loadenv.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ commands/password.c commands/keystatus.c \ disk/loopback.c \ diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index 1a4cf89ed..934cd7284 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -38,6 +38,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/halt.c commands/reboot.c \ commands/i386/cpuid.c \ commands/password.c commands/keystatus.c \ + lib/envblk.c commands/loadenv.c \ disk/loopback.c \ \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ From 77c55a8749fb69a6a2946bfcab7a06c857d05c12 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Thu, 3 Sep 2009 23:00:25 +0000 Subject: [PATCH 52/85] 2009-09-03 Colin Watson * configure.ac: By default, GCC 4.4 generates .eh_frame sections containing unwind information in some cases where it previously did not. Use -fno-dwarf2-cfi-asm if available to restore the old behaviour. See http://patchwork.kernel.org/patch/8555/ for related discussion. --- ChangeLog | 8 ++++++++ configure.ac | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 55f059bba..bafb163e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-09-03 Colin Watson + + * configure.ac: By default, GCC 4.4 generates .eh_frame sections + containing unwind information in some cases where it previously did + not. Use -fno-dwarf2-cfi-asm if available to restore the old + behaviour. See http://patchwork.kernel.org/patch/8555/ for related + discussion. + 2009-09-02 Yves BLUSSEAU Embedding loadenv module into grub-emu diff --git a/configure.ac b/configure.ac index 3c4c6dce6..59e046363 100644 --- a/configure.ac +++ b/configure.ac @@ -246,6 +246,23 @@ if test "x$TARGET_CFLAGS" = x; then TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" fi fi + + # By default, GCC 4.4 generates .eh_frame sections containing unwind + # information in some cases where it previously did not. GRUB doesn't need + # these and they just use up vital space. Restore the old compiler + # behaviour. + AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [ + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_fno_dwarf2_cfi_asm=yes], + [grub_cv_cc_fno_dwarf2_cfi_asm=no]) + CFLAGS="$SAVE_CFLAGS" + ]) + + if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm" + fi fi grub_apple_target_cc From 4ff0d7a4b8e0345ce32fea4407b73bd08a9aa8ef Mon Sep 17 00:00:00 2001 From: robertmh Date: Fri, 4 Sep 2009 12:08:43 +0000 Subject: [PATCH 53/85] 2009-09-04 Robert Millan * configure.ac: Bump version to 1.97~beta2. * docs/version.texi: Likewise. --- ChangeLog | 5 +++++ configure.ac | 2 +- docs/version.texi | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index bafb163e5..a12ef99e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-04 Robert Millan + + * configure.ac: Bump version to 1.97~beta2. + * docs/version.texi: Likewise. + 2009-09-03 Colin Watson * configure.ac: By default, GCC 4.4 generates .eh_frame sections diff --git a/configure.ac b/configure.ac index 59e046363..551605812 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target dnl type. -AC_INIT([GRUB],[1.97~beta1],[bug-grub@gnu.org]) +AC_INIT([GRUB],[1.97~beta2],[bug-grub@gnu.org]) AC_PREREQ(2.59) AC_CONFIG_SRCDIR([include/grub/dl.h]) AC_CONFIG_HEADER([config.h]) diff --git a/docs/version.texi b/docs/version.texi index 4528c7b2e..04c8473f4 100644 --- a/docs/version.texi +++ b/docs/version.texi @@ -1,4 +1,4 @@ @set UPDATED 7 Ago 2009 @set UPDATED-MONTH Ago 2009 -@set EDITION 1.97~beta1 -@set VERSION 1.97~beta1 +@set EDITION 1.97~beta2 +@set VERSION 1.97~beta2 From 70ba68ce8264b5fbb5441e51863965db9baadb4a Mon Sep 17 00:00:00 2001 From: cjwatson Date: Fri, 4 Sep 2009 12:59:54 +0000 Subject: [PATCH 54/85] 2009-09-04 Colin Watson * NEWS: Mention `keystatus' and Unicode fonts. --- ChangeLog | 4 ++++ NEWS | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index a12ef99e3..826bbc2b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-09-04 Colin Watson + + * NEWS: Mention `keystatus' and Unicode fonts. + 2009-09-04 Robert Millan * configure.ac: Bump version to 1.97~beta2. diff --git a/NEWS b/NEWS index c54095e9b..03ba6a268 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ New in 1.97 - : +* Add `keystatus' command. + +* Unicode fonts are now used by default. + * Add `hdparm' command. * Add support for getting the current date and time from CMOS as variables. From 197f76c741caf9e67ba0f4bdf5a708f80f5cd049 Mon Sep 17 00:00:00 2001 From: phcoder Date: Fri, 4 Sep 2009 13:16:07 +0000 Subject: [PATCH 55/85] 2009-09-04 Vladimir Serbinenko * loader/i386/xnu.c (grub_cpu_xnu_fill_devicetree): Remove unnecessary calls to grub_error. --- ChangeLog | 5 +++++ loader/i386/xnu.c | 15 ++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 826bbc2b8..7d4946b6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-04 Vladimir Serbinenko + + * loader/i386/xnu.c (grub_cpu_xnu_fill_devicetree): Remove + unnecessary calls to grub_error. + 2009-09-04 Colin Watson * NEWS: Mention `keystatus' and Unicode fonts. diff --git a/loader/i386/xnu.c b/loader/i386/xnu.c index 06e375c69..39b02c7a3 100644 --- a/loader/i386/xnu.c +++ b/loader/i386/xnu.c @@ -247,7 +247,7 @@ grub_cpu_xnu_fill_devicetree (void) curval->datasize = (SYSTEM_TABLE_SIZEOF (firmware_revision)); curval->data = grub_malloc (curval->datasize); if (! curval->data) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't create device tree"); + return grub_errno; grub_memcpy (curval->data, (SYSTEM_TABLE_VAR(firmware_revision)), curval->datasize); @@ -268,7 +268,7 @@ grub_cpu_xnu_fill_devicetree (void) curval->datasize = sizeof ("EFI32"); curval->data = grub_malloc (curval->datasize); if (! curval->data) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't create device tree"); + return grub_errno; if (SIZEOF_OF_UINTN == 4) grub_memcpy (curval->data, "EFI32", curval->datasize); else @@ -287,7 +287,7 @@ grub_cpu_xnu_fill_devicetree (void) curval->datasize = sizeof (grub_uint64_t); curval->data = grub_malloc (curval->datasize); if (!curval->data) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't create device tree"); + return grub_errno; /* First see if user supplies the value. */ char *fsbvar = grub_env_get ("fsb"); @@ -373,8 +373,7 @@ grub_cpu_xnu_fill_devicetree (void) curval->datasize = SIZEOF_OF_UINTN; curval->data = grub_malloc (curval->datasize); if (! curval->data) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "couldn't create device tree"); + return grub_errno; if (SIZEOF_OF_UINTN == 4) *((grub_uint32_t *)curval->data) = PTR_TO_UINT32 (ptr); else @@ -392,8 +391,7 @@ grub_cpu_xnu_fill_devicetree (void) curval->datasize = grub_strlen (table_aliases[j].name) + 1; curval->data = grub_malloc (curval->datasize); if (!curval->data) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "couldn't create device tree"); + return grub_errno; grub_memcpy (curval->data, table_aliases[j].name, curval->datasize); } } @@ -409,8 +407,7 @@ grub_cpu_xnu_fill_devicetree (void) curval->datasize = SIZEOF_OF_UINTN; curval->data = grub_malloc (curval->datasize); if (! curval->data) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "couldn't create device tree"); + return grub_errno; if (SIZEOF_OF_UINTN == 4) *((grub_uint32_t *) curval->data) = PTR_TO_UINT32 (SYSTEM_TABLE_PTR (runtime_services)); From 975146895ca46b0c9dca1481d366c6a054aed851 Mon Sep 17 00:00:00 2001 From: phcoder Date: Fri, 4 Sep 2009 13:50:32 +0000 Subject: [PATCH 56/85] missing part of previous commit --- loader/i386/xnu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/loader/i386/xnu.c b/loader/i386/xnu.c index 39b02c7a3..275b50dbc 100644 --- a/loader/i386/xnu.c +++ b/loader/i386/xnu.c @@ -258,7 +258,7 @@ grub_cpu_xnu_fill_devicetree (void) 2 * (utf16_strlen (SYSTEM_TABLE_PTR (firmware_vendor)) + 1); curval->data = grub_malloc (curval->datasize); if (! curval->data) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't create device tree"); + return grub_errno; grub_memcpy (curval->data, SYSTEM_TABLE_PTR (firmware_vendor), curval->datasize); @@ -362,8 +362,7 @@ grub_cpu_xnu_fill_devicetree (void) curval->datasize = sizeof (guid); curval->data = grub_malloc (curval->datasize); if (! curval->data) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "couldn't create device tree"); + return grub_errno; grub_memcpy (curval->data, &guid, curval->datasize); /* The value "table". */ From 3a613259b5d4820c80dfa1009e43052c6c6cddde Mon Sep 17 00:00:00 2001 From: fzielcke Date: Sat, 5 Sep 2009 19:26:11 +0000 Subject: [PATCH 57/85] 2009-09-05 Felix Zielcke * gendistlist.sh: Add `grub-dumpdevtree' and `*.lua' to the list find searches for. --- ChangeLog | 5 +++++ gendistlist.sh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7d4946b6e..155a19b5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-05 Felix Zielcke + + * gendistlist.sh: Add `grub-dumpdevtree' and `*.lua' to the list + find searches for. + 2009-09-04 Vladimir Serbinenko * loader/i386/xnu.c (grub_cpu_xnu_fill_devicetree): Remove diff --git a/gendistlist.sh b/gendistlist.sh index 5fe5d186b..3278ed0b3 100644 --- a/gendistlist.sh +++ b/gendistlist.sh @@ -39,6 +39,6 @@ for dir in $DISTDIRS; do find $d -maxdepth 1 -name '*.[chSy]' -o -name '*.mk' -o -name '*.rmk' \ -o -name '*.rb' -o -name '*.in' -o -name '*.tex' -o -name '*.texi' \ -o -name 'grub.cfg' -o -name 'README' -o -name '*.sc' -o -name 'mdate-sh' \ - -o -name '*.sh' | sort + -o -name '*.sh' -o -name 'grub-dumpdevtree' -o -name '*.lua' | sort done done From 7f26d4665b4746980ae2231d17334e7be6dd3d55 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sat, 5 Sep 2009 20:36:49 +0000 Subject: [PATCH 58/85] 2009-09-05 Robert Millan * util/grub-probe.c (probe): Comment out buggy codepath, which was unexpectedly enabled by Colin Watson's 2009-09-02 fix. This should be re-enabled after 1.97. --- ChangeLog | 6 ++++++ util/grub-probe.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 155a19b5a..262a25076 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-09-05 Robert Millan + + * util/grub-probe.c (probe): Comment out buggy codepath, which + was unexpectedly enabled by Colin Watson's 2009-09-02 fix. This + should be re-enabled after 1.97. + 2009-09-05 Felix Zielcke * gendistlist.sh: Add `grub-dumpdevtree' and `*.lua' to the list diff --git a/util/grub-probe.c b/util/grub-probe.c index 3c54408c3..4e3f96451 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -235,6 +235,9 @@ probe (const char *path, char *device_name) if (print == PRINT_FS) { + /* FIXME: `path' can't be used to read a file via GRUB facilities, + because it's not relative to its root. */ +#if 0 struct stat st; stat (path, &st); @@ -258,6 +261,8 @@ probe (const char *path, char *device_name) if (memcmp (filebuf_via_grub, filebuf_via_sys, file->size)) grub_util_error ("files differ"); } +#endif + printf ("%s\n", fs->name); } From 9a86f1ecb90c57fd224fca6985325adef12870e1 Mon Sep 17 00:00:00 2001 From: blusseau Date: Sun, 6 Sep 2009 10:25:19 +0000 Subject: [PATCH 59/85] 2009-09-06 Yves Blusseau * Makefile.in (RMKFILES): add i386-qemu.rmk (MAINTAINER_CLEANFILES): add $(srcdir)/DISTLIST $(srcdir)/config.h.in $(srcdir)/stamp-h.in --- ChangeLog | 6 ++++++ Makefile.in | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 262a25076..d4967e1ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-09-06 Yves Blusseau + + * Makefile.in (RMKFILES): add i386-qemu.rmk + (MAINTAINER_CLEANFILES): add $(srcdir)/DISTLIST $(srcdir)/config.h.in + $(srcdir)/stamp-h.in + 2009-09-05 Robert Millan * util/grub-probe.c (probe): Comment out buggy codepath, which diff --git a/Makefile.in b/Makefile.in index 8e2cdc6c4..7c5adbc61 100644 --- a/Makefile.in +++ b/Makefile.in @@ -111,7 +111,7 @@ enable_efiemu = @enable_efiemu@ ### General variables. RMKFILES = $(addprefix conf/,common.rmk i386-coreboot.rmk i386-efi.rmk \ - i386-ieee1275.rmk i386-pc.rmk i386.rmk powerpc-ieee1275.rmk \ + i386-qemu.rmk i386-ieee1275.rmk i386-pc.rmk i386.rmk powerpc-ieee1275.rmk \ sparc64-ieee1275.rmk x86_64-efi.rmk) MKFILES = $(patsubst %.rmk,%.mk,$(RMKFILES)) @@ -128,7 +128,8 @@ MOSTLYCLEANFILES = DISTCLEANFILES = config.status config.cache config.log config.h \ Makefile stamp-h include/grub/cpu include/grub/machine \ gensymlist.sh genkernsyms.sh build_env.mk -MAINTAINER_CLEANFILES = $(srcdir)/configure $(addprefix $(srcdir)/,$(MKFILES)) +MAINTAINER_CLEANFILES = $(srcdir)/configure $(addprefix $(srcdir)/,$(MKFILES)) \ + $(srcdir)/DISTLIST $(srcdir)/config.h.in $(srcdir)/stamp-h.in # The default target. all: all-local From e30d87ad5524903d2425fb859e7e8dc87efd60d7 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sun, 6 Sep 2009 15:20:33 +0000 Subject: [PATCH 60/85] 2009-09-06 Robert Millan * INSTALL: Require GCC 4.1.3 or later. --- ChangeLog | 4 ++++ INSTALL | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d4967e1ed..b2d543687 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-09-06 Robert Millan + + * INSTALL: Require GCC 4.1.3 or later. + 2009-09-06 Yves Blusseau * Makefile.in (RMKFILES): add i386-qemu.rmk diff --git a/INSTALL b/INSTALL index 65993657f..e751d508f 100644 --- a/INSTALL +++ b/INSTALL @@ -11,7 +11,7 @@ GRUB depends on some software packages installed into your system. If you don't have any of them, please obtain and install them before configuring the GRUB. -* GCC 2.95 or later +* GCC 4.1.3 or later * GNU Make * GNU Bison 2.3 or later * GNU binutils 2.9.1.0.23 or later From 44454e4c2400fccb27dd194e6e85c81d209bbad3 Mon Sep 17 00:00:00 2001 From: fzielcke Date: Tue, 8 Sep 2009 15:00:28 +0000 Subject: [PATCH 61/85] 2009-09-08 Felix Zielcke * kern/rescue_parser.c (grub_rescue_parse_line): Only suggest to try `help' if the command exists. --- ChangeLog | 5 +++++ kern/rescue_parser.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b2d543687..8ac9309a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-08 Felix Zielcke + + * kern/rescue_parser.c (grub_rescue_parse_line): Only suggest to try + `help' if the command exists. + 2009-09-06 Robert Millan * INSTALL: Require GCC 4.1.3 or later. diff --git a/kern/rescue_parser.c b/kern/rescue_parser.c index 79f32b8fd..1e0841e49 100644 --- a/kern/rescue_parser.c +++ b/kern/rescue_parser.c @@ -61,7 +61,8 @@ grub_rescue_parse_line (char *line, grub_reader_getline_t getline) else { grub_printf ("Unknown command `%s'\n", name); - grub_printf ("Try `help' for usage\n"); + if (grub_command_find ("help")) + grub_printf ("Try `help' for usage\n"); } quit: From 99423078e4509200cbf0332116aade1412aed585 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Tue, 8 Sep 2009 19:10:34 +0000 Subject: [PATCH 62/85] 2009-09-08 Colin Watson * script/sh/execute.c (grub_script_execute_cmdline): Set "?" in unknown-command case. Fixes bug #27320. --- ChangeLog | 5 +++++ script/sh/execute.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8ac9309a4..a7aad1f70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-08 Colin Watson + + * script/sh/execute.c (grub_script_execute_cmdline): Set "?" in + unknown-command case. Fixes bug #27320. + 2009-09-08 Felix Zielcke * kern/rescue_parser.c (grub_rescue_parse_line): Only suggest to try diff --git a/script/sh/execute.c b/script/sh/execute.c index e0b7b2ebf..e9064ad2f 100644 --- a/script/sh/execute.c +++ b/script/sh/execute.c @@ -122,6 +122,10 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) grub_errno = GRUB_ERR_NONE; } grub_free (assign); + + grub_sprintf (errnobuf, "%d", grub_errno); + grub_env_set ("?", errnobuf); + return 0; } } From 80a608f3879e390442c2c31874b2efc977596288 Mon Sep 17 00:00:00 2001 From: fzielcke Date: Wed, 9 Sep 2009 12:53:11 +0000 Subject: [PATCH 63/85] 2009-09-09 Felix Zielcke * config.guess: Update to lastest versiom from config git. * config.sub: Likewise. --- ChangeLog | 5 ++++ config.guess | 81 ++++++++++++++++++++-------------------------------- config.sub | 34 ++++++++++++++++------ 3 files changed, 62 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7aad1f70..d72ef31ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-09 Felix Zielcke + + * config.guess: Update to lastest versiom from config git. + * config.sub: Likewise. + 2009-09-08 Colin Watson * script/sh/execute.c (grub_script_execute_cmdline): Set "?" in diff --git a/config.guess b/config.guess index 3f51f4ea9..bb0b03ea1 100644 --- a/config.guess +++ b/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. -timestamp='2008-12-19' +timestamp='2009-08-19' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -27,16 +27,16 @@ timestamp='2008-12-19' # the same distribution terms that you use for the rest of that program. -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# Originally written by Per Bothner. Please send patches (context +# diff format) to and include a ChangeLog +# entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` @@ -170,7 +170,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null + | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? @@ -324,6 +324,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; @@ -653,7 +656,7 @@ EOF # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null + grep -q __LP64__ then HP_ARCH="hppa2.0w" else @@ -819,6 +822,9 @@ EOF [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we @@ -879,40 +885,17 @@ EOF m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; - mips:Linux:*:*) + mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU - #undef mips - #undef mipsel + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel + CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 + CPU=${UNAME_MACHINE} #else CPU= #endif @@ -944,7 +927,7 @@ EOF EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; @@ -998,14 +981,6 @@ EOF elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build @@ -1071,7 +1046,7 @@ EOF i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) @@ -1115,8 +1090,11 @@ EOF pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 @@ -1176,7 +1154,7 @@ EOF rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) @@ -1350,6 +1328,9 @@ EOF i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 diff --git a/config.sub b/config.sub index d8573e81c..8ca084bf3 100644 --- a/config.sub +++ b/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. -timestamp='2009-01-19' +timestamp='2009-08-19' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -32,13 +32,16 @@ timestamp='2009-01-19' # Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. @@ -149,10 +152,13 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) + -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; + -bluegene*) + os=-cnk + ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 @@ -272,6 +278,7 @@ case $basic_machine in | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | moxie \ | mt \ | msp430 \ | nios | nios2 \ @@ -336,7 +343,7 @@ case $basic_machine in | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ @@ -446,6 +453,10 @@ case $basic_machine in basic_machine=m68k-apollo os=-bsd ;; + aros) + basic_machine=i386-pc + os=-aros + ;; aux) basic_machine=m68k-apple os=-aux @@ -462,6 +473,10 @@ case $basic_machine in basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; c90) basic_machine=c90-cray os=-unicos @@ -714,6 +729,9 @@ case $basic_machine in basic_machine=ns32k-utek os=-sysv ;; + microblaze) + basic_machine=microblaze-xilinx + ;; mingw32) basic_machine=i386-pc os=-mingw32 @@ -1255,11 +1273,11 @@ case $os in # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ + | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ @@ -1608,7 +1626,7 @@ case $basic_machine in -sunos*) vendor=sun ;; - -aix*) + -cnk*|-aix*) vendor=ibm ;; -beos*) From a2094832ae5e6ab14dcf827094e3a7711dfe1481 Mon Sep 17 00:00:00 2001 From: fzielcke Date: Wed, 9 Sep 2009 19:46:10 +0000 Subject: [PATCH 64/85] fix typos in previous changelog entry --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d72ef31ae..27046c39c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ 2009-09-09 Felix Zielcke - * config.guess: Update to lastest versiom from config git. + * config.guess: Update to latest version from config git. * config.sub: Likewise. 2009-09-08 Colin Watson From ad8ea1f4c25082dcb65f14f9971757c3e74af360 Mon Sep 17 00:00:00 2001 From: proski Date: Wed, 9 Sep 2009 21:40:17 +0000 Subject: [PATCH 65/85] Typo fixes --- ChangeLog | 8 ++++---- bus/usb/usbtrans.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 27046c39c..220bbaaf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -280,7 +280,7 @@ (grub_afs_to_cpu64): ...this. All users updated. (GRUB_AFS_BO_LITTLE_ENDIAN): Remove. (GRUB_AFS_BO_BIG_ENDIAN): Likewise. - (grub_afs_validate_sblock): Check only one endiannness. + (grub_afs_validate_sblock): Check only one endianness. (GRUB_MOD_INIT (befs)) [MODE_BIGENDIAN && MODE_BFS]: Rename to .. (GRUB_MOD_INIT (befs_be)) [MODE_BIGENDIAN && MODE_BFS]: ... this. (GRUB_MOD_INIT (afs)) [MODE_BIGENDIAN && !MODE_BFS]: Rename to .. @@ -449,7 +449,7 @@ and OPENBSD_MMAP_NVS. Add memory map terminator Explicit cast when calling grub_unix_real_boot. - (grub_nebsd_boot): Explicit cast when calling grub_unix_real_boot. + (grub_netbsd_boot): Explicit cast when calling grub_unix_real_boot. 2009-08-24 Vladimir Serbinenko @@ -1010,7 +1010,7 @@ 2009-07-30 Vladimir Serbinenko * util/i386/pc/grub-setup.c (setup): Check that no partition is in - embeding zone, not only the first one. + embedding zone, not only the first one. 2009-07-29 Joe Auricchio @@ -1083,7 +1083,7 @@ instead of WORDS_BIGENDIAN. Use grub_le_to_cpu32(), so that the case of little endian words becomes just an optimization. Respect const modifier. - (md5_final): Use code that doesn't depend on endianess. + (md5_final): Use code that doesn't depend on endianness. * include/grub/misc.h (ALIGN_UP): Cast align to the type of addr to avoid loss of upper bits if align is unsigned and shorter diff --git a/bus/usb/usbtrans.c b/bus/usb/usbtrans.c index e4beb4550..09e7af83e 100644 --- a/bus/usb/usbtrans.c +++ b/bus/usb/usbtrans.c @@ -74,7 +74,7 @@ grub_usb_control_msg (grub_usb_device_t dev, return grub_errno; } - /* Build a Setup packet. XXX: Endianess. */ + /* Build a Setup packet. XXX: Endianness. */ setupdata.reqtype = reqtype; setupdata.request = request; setupdata.value = value; From c0d343875af4064566652d04de3e9ef3a6637250 Mon Sep 17 00:00:00 2001 From: fzielcke Date: Wed, 9 Sep 2009 22:31:51 +0000 Subject: [PATCH 66/85] 2009-09-10 Felix Zielcke * docs/grub.cfg: Add an example menu entry for memtest86+. --- ChangeLog | 4 ++++ docs/grub.cfg | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 220bbaaf1..a744ca43d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-09-10 Felix Zielcke + + * docs/grub.cfg: Add an example menu entry for memtest86+. + 2009-09-09 Felix Zielcke * config.guess: Update to latest version from config git. diff --git a/docs/grub.cfg b/docs/grub.cfg index 7f02727d0..4d1582a8e 100644 --- a/docs/grub.cfg +++ b/docs/grub.cfg @@ -62,6 +62,12 @@ menuentry "Microsoft Windows" { chainloader +1 } +# For booting Memtest86+ +menuentry "Memtest86+" { + set root=(hd0,1) + linux16 /memtest86+.bin +} + # Change the colors. menuentry "Change the colors" { set menu_color_normal=light-green/brown From 50051d5542f6206ae4e7d9c9e6a04601121ec6f4 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Thu, 10 Sep 2009 12:10:33 +0000 Subject: [PATCH 67/85] 2009-09-10 Colin Watson * util/grub.d/40_custom.in: Make it a little clearer how to use this file. --- ChangeLog | 5 +++++ util/grub.d/40_custom.in | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a744ca43d..48580261c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-10 Colin Watson + + * util/grub.d/40_custom.in: Make it a little clearer how to use this + file. + 2009-09-10 Felix Zielcke * docs/grub.cfg: Add an example menu entry for memtest86+. diff --git a/util/grub.d/40_custom.in b/util/grub.d/40_custom.in index e16d6e3d6..5d967aca9 100644 --- a/util/grub.d/40_custom.in +++ b/util/grub.d/40_custom.in @@ -1,3 +1,5 @@ #!/bin/sh -exec tail -n +3 $0 -# This file is an example on how to add custom entries +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after the 'exec tail' line. Be careful not to +# change anything before the 'exec tail' line. +exec tail -n +6 $0 From 3b0521bed212f78c3c6efbf4ba0f86f76ee0209f Mon Sep 17 00:00:00 2001 From: cjwatson Date: Thu, 10 Sep 2009 12:44:24 +0000 Subject: [PATCH 68/85] 2009-09-10 Colin Watson * util/grub.d/40_custom.in: Make sure that the explanatory text is visible in grub.cfg. --- ChangeLog | 5 +++++ util/grub.d/40_custom.in | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 48580261c..a8d86e55d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-10 Colin Watson + + * util/grub.d/40_custom.in: Make sure that the explanatory text is + visible in grub.cfg. + 2009-09-10 Colin Watson * util/grub.d/40_custom.in: Make it a little clearer how to use this diff --git a/util/grub.d/40_custom.in b/util/grub.d/40_custom.in index 5d967aca9..694fc9bc2 100644 --- a/util/grub.d/40_custom.in +++ b/util/grub.d/40_custom.in @@ -1,5 +1,5 @@ #!/bin/sh +exec tail -n +3 $0 # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after the 'exec tail' line. Be careful not to # change anything before the 'exec tail' line. -exec tail -n +6 $0 From 48d9bb0a9378a4639bd44fd0b935bb9974b7b3ed Mon Sep 17 00:00:00 2001 From: robertmh Date: Thu, 10 Sep 2009 12:53:25 +0000 Subject: [PATCH 69/85] 2009-09-10 Robert Millan * util/grub.d/40_custom.in: Ask user to type custom entries below comment, rather than below 'exec tail' line. --- ChangeLog | 5 +++++ util/grub.d/40_custom.in | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8d86e55d..63924d917 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-10 Robert Millan + + * util/grub.d/40_custom.in: Ask user to type custom entries below + comment, rather than below 'exec tail' line. + 2009-09-10 Colin Watson * util/grub.d/40_custom.in: Make sure that the explanatory text is diff --git a/util/grub.d/40_custom.in b/util/grub.d/40_custom.in index 694fc9bc2..48068de46 100644 --- a/util/grub.d/40_custom.in +++ b/util/grub.d/40_custom.in @@ -1,5 +1,5 @@ #!/bin/sh exec tail -n +3 $0 -# This file provides an easy way to add custom menu entries. Simply type the -# menu entries you want to add after the 'exec tail' line. Be careful not to -# change anything before the 'exec tail' line. +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. From 8aa1541a419efa0cc201308ef5d68918b2567e80 Mon Sep 17 00:00:00 2001 From: fzielcke Date: Thu, 10 Sep 2009 19:04:43 +0000 Subject: [PATCH 70/85] 2009-09-10 Felix Zielcke * util/grub-mkconfig.in: Make the created config mode 400 and print a warning if it fails. --- ChangeLog | 5 +++++ util/grub-mkconfig.in | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 63924d917..df1ac0733 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-10 Felix Zielcke + + * util/grub-mkconfig.in: Make the created config mode 400 and + print a warning if it fails. + 2009-09-10 Robert Millan * util/grub.d/40_custom.in: Ask user to type custom entries below diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index d9640e910..a8c267518 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -232,7 +232,8 @@ if test "x${grub_cfg}" != "x"; then # Allow this to fail, since /boot/grub/ might need to be fatfs to support some # firmware implementations (e.g. OFW or EFI). - chmod 444 ${grub_cfg}.new || true + chmod 400 ${grub_cfg}.new || grub_warn "Could not make ${grub_cfg}.new readable by only root.\ + This means that if the generated config contains a password it is readable by everyone" fi echo "Generating grub.cfg ..." >&2 From 866953751fafe8eea2f1342442c5f42d416bd008 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Fri, 11 Sep 2009 14:17:35 +0000 Subject: [PATCH 71/85] 2009-09-11 Colin Watson * configure.ac: Don't look for help2man when cross-compiling. Fixes part of bug #27349. --- ChangeLog | 5 +++++ configure.ac | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index df1ac0733..4aa111936 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-11 Colin Watson + + * configure.ac: Don't look for help2man when cross-compiling. Fixes + part of bug #27349. + 2009-09-10 Felix Zielcke * util/grub-mkconfig.in: Make the created config mode 400 and diff --git a/configure.ac b/configure.ac index 551605812..b7fa044a5 100644 --- a/configure.ac +++ b/configure.ac @@ -147,7 +147,6 @@ AC_PROG_MAKE_SET # These are not a "must". AC_PATH_PROG(RUBY, ruby) -AC_PATH_PROG(HELP2MAN, help2man) # # Checks for host programs. @@ -171,6 +170,12 @@ if test x$grub_cv_apple_cc = xyes ; then ASFLAGS="$ASFLAGS -DAPPLE_CC=1" fi +if test "x$cross_compiling" = xyes; then + AC_MSG_WARN([cannot generate manual pages while cross compiling]) +else + AC_PATH_PROG(HELP2MAN, help2man) +fi + # Check for functions. AC_CHECK_FUNCS(posix_memalign memalign asprintf) From cda2a409b3d03f41738c33cf3c231b0e2e4a8b01 Mon Sep 17 00:00:00 2001 From: cjwatson Date: Fri, 11 Sep 2009 14:26:12 +0000 Subject: [PATCH 72/85] 2009-09-11 Colin Watson * include/grub/ntfs.h (struct grub_fshelp_node): Change `size' to grub_uint64_t. * fs/ntfs.c (init_file): Understand 64-bit sizes for non-resident files. --- ChangeLog | 7 +++++++ fs/ntfs.c | 2 +- include/grub/ntfs.h | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4aa111936..64b77d04d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-09-11 Colin Watson + + * include/grub/ntfs.h (struct grub_fshelp_node): Change `size' + to grub_uint64_t. + * fs/ntfs.c (init_file): Understand 64-bit sizes for + non-resident files. + 2009-09-11 Colin Watson * configure.ac: Don't look for help2man when cross-compiling. Fixes diff --git a/fs/ntfs.c b/fs/ntfs.c index 3ff487c6e..f1d0a374e 100644 --- a/fs/ntfs.c +++ b/fs/ntfs.c @@ -543,7 +543,7 @@ init_file (struct grub_ntfs_file *mft, grub_uint32_t mftno) if (!pa[8]) mft->size = u32at (pa, 0x10); else - mft->size = u32at (pa, 0x30); + mft->size = u64at (pa, 0x30); if ((mft->attr.flags & AF_ALST) == 0) mft->attr.attr_end = 0; /* Don't jump to attribute list */ diff --git a/include/grub/ntfs.h b/include/grub/ntfs.h index 9b2ae0a0c..6482e964b 100644 --- a/include/grub/ntfs.h +++ b/include/grub/ntfs.h @@ -133,7 +133,7 @@ struct grub_fshelp_node { struct grub_ntfs_data *data; char *buf; - grub_uint32_t size; + grub_uint64_t size; grub_uint32_t ino; int inode_read; struct grub_ntfs_attr attr; From e8f5d6e985b9e73ded8aac7f1cbdfa63605a099a Mon Sep 17 00:00:00 2001 From: blusseau Date: Sat, 12 Sep 2009 07:38:50 +0000 Subject: [PATCH 73/85] 2009-09-12 Yves Blusseau Change clean rules to properly remove files * genmk.rb: add new clean rules * Makefile.in (clean): add the new targets (mostlyclean): likewise --- ChangeLog | 8 ++++++++ Makefile.in | 4 ++-- genmk.rb | 55 +++++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 64b77d04d..0428aa726 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-09-12 Yves Blusseau + + Change clean rules to properly remove files + + * genmk.rb: add new clean rules + * Makefile.in (clean): add the new targets + (mostlyclean): likewise + 2009-09-11 Colin Watson * include/grub/ntfs.h (struct grub_fshelp_node): Change `size' diff --git a/Makefile.in b/Makefile.in index 7c5adbc61..ff84afb7b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -326,10 +326,10 @@ uninstall: rm -f $(DESTDIR)$(libdir)/grub/$$dest; \ done -clean: +clean: $(CLEAN_IMAGE_TARGETS) $(CLEAN_MODULE_TARGETS) $(CLEAN_UTILITY_TARGETS) -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) -mostlyclean: clean +mostlyclean: clean $(MOSTLYCLEAN_IMAGE_TARGETS) $(MOSTLYCLEAN_MODULE_TARGETS) $(MOSTLYCLEAN_UTILITY_TARGETS) -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) distclean: mostlyclean diff --git a/genmk.rb b/genmk.rb index 4aedb25c4..50bf88fe1 100644 --- a/genmk.rb +++ b/genmk.rb @@ -39,11 +39,13 @@ class Image def initialize(dir, name) @dir = dir @name = name + @rule_count = 0 end attr_reader :dir, :name def rule(sources) prefix = @name.to_var + @rule_count += 1 exe = @name.suffix('exec') objs = sources.collect do |src| raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src @@ -53,8 +55,16 @@ class Image deps = objs.collect {|obj| obj.suffix('d')} deps_str = deps.join(' ') - "CLEANFILES += #{@name} #{exe} #{objs_str} -MOSTLYCLEANFILES += #{deps_str} +" +clean-image-#{@name}.#{@rule_count}: + rm -f #{@name} #{exe} #{objs_str} + +CLEAN_IMAGE_TARGETS += clean-image-#{@name}.#{@rule_count} + +mostlyclean-image-#{@name}.#{@rule_count}: + rm -f #{deps_str} + +MOSTLYCLEAN_IMAGE_TARGETS += mostlyclean-image-#{@name}.#{@rule_count} ifneq ($(TARGET_APPLE_CC),1) #{@name}: #{exe} @@ -94,11 +104,13 @@ class PModule def initialize(dir, name) @dir = dir @name = name + @rule_count = 0 end attr_reader :dir, :name def rule(sources) prefix = @name.to_var + @rule_count += 1 objs = sources.collect do |src| raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src prefix + '-' + src.to_obj @@ -114,12 +126,23 @@ class PModule mod_name = File.basename(@name, '.mod') symbolic_name = mod_name.sub(/\.[^\.]*$/, '') - "CLEANFILES += #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{undsym} +" +clean-module-#{@name}.#{@rule_count}: + rm -f #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{undsym} + +CLEAN_MODULE_TARGETS += clean-module-#{@name}.#{@rule_count} + ifneq ($(#{prefix}_EXPORTS),no) -CLEANFILES += #{defsym} +clean-module-#{@name}-symbol.#{@rule_count}: + rm -f #{defsym} + +CLEAN_MODULE_TARGETS += clean-module-#{@name}-symbol.#{@rule_count} DEFSYMFILES += #{defsym} endif -MOSTLYCLEANFILES += #{deps_str} +mostlyclean-module-#{@name}.#{@rule_count}: + rm -f #{deps_str} + +MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count} UNDSYMFILES += #{undsym} ifneq ($(TARGET_APPLE_CC),1) @@ -164,6 +187,7 @@ endif " + objs.collect_with_index do |obj, i| src = sources[i] fake_obj = File.basename(src).suffix('o') + extra_target = obj.sub(/\.[^\.]*$/, '') + '-extra' command = 'cmd-' + obj.suffix('lst') fs = 'fs-' + obj.suffix('lst') partmap = 'partmap-' + obj.suffix('lst') @@ -178,7 +202,11 @@ endif $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $< -include #{dep} -CLEANFILES += #{command} #{fs} #{partmap} #{handler} #{parttool} +clean-module-#{extra_target}.#{@rule_count}: + rm -f #{command} #{fs} #{partmap} #{handler} #{parttool} + +CLEAN_MODULE_TARGETS += clean-module-#{extra_target}.#{@rule_count} + COMMANDFILES += #{command} FSFILES += #{fs} PARTTOOLFILES += #{parttool} @@ -219,6 +247,7 @@ class Utility def initialize(dir, name) @dir = dir @name = name + @rule_count = 0 end def print_tail() prefix = @name.to_var @@ -231,6 +260,7 @@ class Utility def rule(sources) prefix = @name.to_var + @rule_count += 1 objs = sources.collect do |src| raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src prefix + '-' + src.to_obj @@ -239,8 +269,17 @@ class Utility deps = objs.collect {|obj| obj.suffix('d')} deps_str = deps.join(' '); - "CLEANFILES += #{@name}$(EXEEXT) #{objs_str} -MOSTLYCLEANFILES += #{deps_str} + " +clean-utility-#{@name}.#{@rule_count}: + rm -f #{@name}$(EXEEXT) #{objs_str} + +CLEAN_UTILITY_TARGETS += clean-utility-#{@name}.#{@rule_count} + +mostlyclean-utility-#{@name}.#{@rule_count}: + rm -f #{deps_str} + +MOSTLYCLEAN_UTILITY_TARGETS += mostlyclean-utility-#{@name}.#{@rule_count} + #{prefix}_OBJECTS += #{objs_str} " + objs.collect_with_index do |obj, i| From 5c9f8d8427e57a8e0f8f87cb732e7462384d5655 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sat, 12 Sep 2009 13:05:25 +0000 Subject: [PATCH 74/85] 2009-09-12 Robert Millan Fix memory corruption issue (spotted by Colin Watson). * kern/i386/pc/startup.S (grub_vbe_bios_getset_dac_palette): Fix bug causing returned size to be stored in an incorrect memory location. Fix use of uninitialized value when storing the returned size. --- ChangeLog | 8 ++++++++ kern/i386/pc/startup.S | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0428aa726..5eea781f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-09-12 Robert Millan + + Fix memory corruption issue (spotted by Colin Watson). + + * kern/i386/pc/startup.S (grub_vbe_bios_getset_dac_palette): Fix bug + causing returned size to be stored in an incorrect memory location. + Fix use of uninitialized value when storing the returned size. + 2009-09-12 Yves Blusseau Change clean rules to properly remove files diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S index 529662b93..da3624c89 100644 --- a/kern/i386/pc/startup.S +++ b/kern/i386/pc/startup.S @@ -1761,18 +1761,18 @@ FUNCTION(grub_vbe_bios_getset_dac_palette_width) movw $0x4f08, %ax int $0x10 - movw %ax, %dx /* real_to_prot destroys %eax. */ + movw %ax, %cx /* real_to_prot destroys %eax. */ DATA32 call real_to_prot .code32 /* Move result back to *dac_mask_size. */ + xorl %eax, %eax movb %bh, %al movl %eax, (%edx) /* Return value in %eax. */ - xorl %eax, %eax - movw %dx, %ax + movw %cx, %ax popl %ebx popl %ebp From 6122955707a57a864667ead62cc05d4386f85e84 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sat, 12 Sep 2009 13:07:27 +0000 Subject: [PATCH 75/85] 2009-09-12 Robert Millan * video/i386/pc/vbe.c (grub_vbe_get_video_mode_info): Move packed mode special handling (grub_vbe_bios_set_dac_palette_width() call) from here ... * loader/i386/linux.c [GRUB_MACHINE_PCBIOS] (grub_linux_setup_video): ... to here (with some adjustments). --- ChangeLog | 8 ++++++++ loader/i386/linux.c | 28 ++++++++++++++++++++++++++++ video/i386/pc/vbe.c | 18 ------------------ 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5eea781f7..0d967d550 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-09-12 Robert Millan + + * video/i386/pc/vbe.c (grub_vbe_get_video_mode_info): Move packed + mode special handling (grub_vbe_bios_set_dac_palette_width() call) + from here ... + * loader/i386/linux.c [GRUB_MACHINE_PCBIOS] + (grub_linux_setup_video): ... to here (with some adjustments). + 2009-09-12 Robert Millan Fix memory corruption issue (spotted by Colin Watson). diff --git a/loader/i386/linux.c b/loader/i386/linux.c index 4144384db..4bdb09b24 100644 --- a/loader/i386/linux.c +++ b/loader/i386/linux.c @@ -33,6 +33,7 @@ #include #include #include +#include #define GRUB_LINUX_CL_OFFSET 0x1000 #define GRUB_LINUX_CL_END_OFFSET 0x2000 @@ -416,6 +417,33 @@ 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; + +#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) + { + struct grub_vbe_info_block controller_info; + int status; + int width = 8; + + status = grub_vbe_bios_get_controller_info (&controller_info); + + if (status == GRUB_VBE_STATUS_OK && + (controller_info.capabilities & GRUB_VBE_CAPABILITY_DACWIDTH)) + status = grub_vbe_bios_set_dac_palette_width (&width); + + if (status != GRUB_VBE_STATUS_OK) + /* 6 is default after mode reset. */ + width = 6; + + params->red_mask_size = params->green_mask_size + = params->blue_mask_size = width; + params->reserved_mask_size = 0; + } +#endif + return 0; } diff --git a/video/i386/pc/vbe.c b/video/i386/pc/vbe.c index b41e22fa2..a285b26ba 100644 --- a/video/i386/pc/vbe.c +++ b/video/i386/pc/vbe.c @@ -286,24 +286,6 @@ grub_vbe_get_video_mode_info (grub_uint32_t mode, /* Make copy of mode info block. */ grub_memcpy (mode_info, mi_tmp, sizeof (*mode_info)); - - /* Packed mode. Query DAC Palette width for color sizes. */ - if (mode_info->bits_per_pixel <= 8) - { - int width = 8; - status = 0; - - if (controller_info.capabilities & GRUB_VBE_CAPABILITY_DACWIDTH) - status = grub_vbe_bios_set_dac_palette_width (& width); - - if (status != GRUB_VBE_STATUS_OK) - /* 6 is default after mode reset. */ - width = 6; - - mode_info->red_mask_size = mode_info->green_mask_size - = mode_info->blue_mask_size = width; - mode_info->rsvd_mask_size = 0; - } } else /* Just clear mode info block if it isn't a VESA mode. */ From 8ef070f50dabd70e43a34e5138f4fc7049ff1773 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sat, 12 Sep 2009 13:08:38 +0000 Subject: [PATCH 76/85] 2009-09-12 Robert Millan * configure.ac: Bump version to 1.97~beta3. * docs/version.texi: Likewise. --- ChangeLog | 5 +++++ configure.ac | 2 +- docs/version.texi | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d967d550..c421ec633 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-12 Robert Millan + + * configure.ac: Bump version to 1.97~beta3. + * docs/version.texi: Likewise. + 2009-09-12 Robert Millan * video/i386/pc/vbe.c (grub_vbe_get_video_mode_info): Move packed diff --git a/configure.ac b/configure.ac index b7fa044a5..e025b50d6 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target dnl type. -AC_INIT([GRUB],[1.97~beta2],[bug-grub@gnu.org]) +AC_INIT([GRUB],[1.97~beta3],[bug-grub@gnu.org]) AC_PREREQ(2.59) AC_CONFIG_SRCDIR([include/grub/dl.h]) AC_CONFIG_HEADER([config.h]) diff --git a/docs/version.texi b/docs/version.texi index 04c8473f4..65ec1301d 100644 --- a/docs/version.texi +++ b/docs/version.texi @@ -1,4 +1,4 @@ @set UPDATED 7 Ago 2009 @set UPDATED-MONTH Ago 2009 -@set EDITION 1.97~beta2 -@set VERSION 1.97~beta2 +@set EDITION 1.97~beta3 +@set VERSION 1.97~beta3 From 5653217923f5a8eeb161ef7d30e5be7083a89e1f Mon Sep 17 00:00:00 2001 From: robertmh Date: Sun, 13 Sep 2009 01:30:18 +0000 Subject: [PATCH 77/85] 2009-09-13 Robert Millan * configure.ac: Remove --enable-grub-pe2elf. Only build grub-pe2elf when needed by the build system itself. * conf/common.rmk: Remove $(enable_grub_pe2elf) check. --- ChangeLog | 6 ++++++ conf/common.rmk | 13 +++---------- configure.ac | 12 ------------ 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index c421ec633..0ab86b8f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-09-13 Robert Millan + + * configure.ac: Remove --enable-grub-pe2elf. Only build + grub-pe2elf when needed by the build system itself. + * conf/common.rmk: Remove $(enable_grub_pe2elf) check. + 2009-09-12 Robert Millan * configure.ac: Bump version to 1.97~beta3. diff --git a/conf/common.rmk b/conf/common.rmk index 73cf02caa..e18dd1052 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -119,21 +119,14 @@ bin_UTILITIES += grub-editenv grub_editenv_SOURCES = util/grub-editenv.c lib/envblk.c util/misc.c kern/misc.c kern/err.c CLEANFILES += grub-editenv -# for grub-pe2elf -ifeq ($(enable_grub_pe2elf), yes) -bin_UTILITIES += grub-pe2elf +# Needed for genmk.rb to work +ifeq (0,1) +bin_UTILITIES += grub-macho2img grub-pe2elf endif grub_pe2elf_SOURCES = util/grub-pe2elf.c util/misc.c CLEANFILES += grub-pe2elf -# grub_macho2img assumes a lot about source file. -# So installing it definitively is useless -# But adding to bin_UTILITIES is needed for -# genmk.rb to work -ifeq (0,1) -bin_UTILITIES += grub-macho2img -endif grub_macho2img_SOURCES = util/grub-macho2img.c CLEANFILES += grub-macho2img diff --git a/configure.ac b/configure.ac index e025b50d6..37ecba759 100644 --- a/configure.ac +++ b/configure.ac @@ -557,11 +557,6 @@ enable_grub_fstest=no fi AC_SUBST([enable_grub_fstest]) -AC_ARG_ENABLE([grub-pe2elf], - [AS_HELP_STRING([--enable-grub-pe2elf], - [build and install the `grub-pe2elf' conversion utility])]) -AC_SUBST([enable_grub_pe2elf]) - AC_ARG_ENABLE([grub-mkfont], [AS_HELP_STRING([--enable-grub-mkfont], [build and install the `grub-mkfont' utility (default=guessed)])]) @@ -626,13 +621,6 @@ echo With memory debugging: Yes else echo With memory debugging: No fi -if [ x"$enable_grub_pe2elf" = xyes ]; then -echo grub-pe2elf will be built and installed -elif [ x$TARGET_OBJ2ELF = xgrub-pe2elf ]; then -echo grub-pe2elf will be built but not installed -else -echo grub-pe2elf will not be built -fi if [ x"$efiemu_excuse" = x ]; then echo efiemu runtime: Yes else From d52109a7a257ffcbc312042d2c9ea8f6331e1bfd Mon Sep 17 00:00:00 2001 From: cjwatson Date: Mon, 14 Sep 2009 11:32:00 +0000 Subject: [PATCH 78/85] 2009-09-14 Colin Watson * util/grub.d/30_os-prober.in: Cope with Windows 7 in os-prober output. --- ChangeLog | 5 +++++ util/grub.d/30_os-prober.in | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0ab86b8f8..69b65bf67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-14 Colin Watson + + * util/grub.d/30_os-prober.in: Cope with Windows 7 in os-prober + output. + 2009-09-13 Robert Millan * configure.ac: Remove --enable-grub-pe2elf. Only build diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index ffc46c9d4..4a1648881 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -57,11 +57,16 @@ menuentry "${LONGNAME} (on ${DEVICE})" { EOF prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" - if [ "${LONGNAME}" != "Windows Vista (loader)" ] ; then - cat << EOF + case ${LONGNAME} in + Windows\ Vista*|Windows\ 7*) + ;; + *) + cat << EOF drivemap -s (hd0) \${root} EOF - fi + ;; + esac + cat < Date: Mon, 14 Sep 2009 15:38:30 +0000 Subject: [PATCH 79/85] =?UTF-8?q?2009-09-14=20=20Jos=C3=A9=20Mart=C3=ADnez?= =?UTF-8?q?=20=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * commands/acpi.c (grub_cmd_acpi): Fix loading ACPI tables from file. --- ChangeLog | 4 ++++ commands/acpi.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 69b65bf67..42e141472 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-09-14 José Martínez + + * commands/acpi.c (grub_cmd_acpi): Fix loading ACPI tables from file. + 2009-09-14 Colin Watson * util/grub.d/30_os-prober.in: Cope with Windows 7 in os-prober diff --git a/commands/acpi.c b/commands/acpi.c index d903d446d..e7cb9e6b4 100644 --- a/commands/acpi.c +++ b/commands/acpi.c @@ -681,6 +681,9 @@ grub_cmd_acpi (struct grub_extcmd *cmd, table->size = size; table->addr = buf; playground_size += table->size; + + table->next = acpi_tables; + acpi_tables = table; } } From 07197f23220355132b3220199d5df232f04ce44a Mon Sep 17 00:00:00 2001 From: cjwatson Date: Mon, 14 Sep 2009 19:57:45 +0000 Subject: [PATCH 80/85] 2009-09-14 Colin Watson * commands/test.c (get_fileinfo): Return immediately if grub_fs_probe fails. --- ChangeLog | 5 +++++ commands/test.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 42e141472..2d1733ac3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-14 Colin Watson + + * commands/test.c (get_fileinfo): Return immediately if + grub_fs_probe fails. + 2009-09-14 José Martínez * commands/acpi.c (grub_cmd_acpi): Fix loading ACPI tables from file. diff --git a/commands/test.c b/commands/test.c index 26df8b5c5..9c813c820 100644 --- a/commands/test.c +++ b/commands/test.c @@ -88,6 +88,13 @@ test_parse (char **args, int *argn, int argc) } fs = grub_fs_probe (dev); + if (! fs) + { + grub_free (device_name); + grub_device_close (dev); + return; + } + pathname = grub_strchr (path, ')'); if (! pathname) pathname = path; From 77c24f1dc58373453e80e77f5d44e65691bc8906 Mon Sep 17 00:00:00 2001 From: phcoder Date: Tue, 15 Sep 2009 10:36:29 +0000 Subject: [PATCH 81/85] 2009-09-15 Vladimir Serbinenko * partmap/pc.c (pc_partition_map_iterate): Detect and break loops. --- ChangeLog | 4 ++++ partmap/msdos.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2d1733ac3..be7715f25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-09-15 Vladimir Serbinenko + + * partmap/pc.c (pc_partition_map_iterate): Detect and break loops. + 2009-09-14 Colin Watson * commands/test.c (get_fileinfo): Return immediately if diff --git a/partmap/msdos.c b/partmap/msdos.c index d0fc18efe..a5d55b64d 100644 --- a/partmap/msdos.c +++ b/partmap/msdos.c @@ -97,6 +97,8 @@ pc_partition_map_iterate (grub_disk_t disk, struct grub_msdos_partition_mbr mbr; struct grub_msdos_partition_disk_label label; struct grub_disk raw; + int labeln = 0; + grub_disk_addr_t lastaddr; /* Enforce raw disk access. */ raw = *disk; @@ -117,6 +119,18 @@ pc_partition_map_iterate (grub_disk_t disk, if (grub_disk_read (&raw, p.offset, 0, sizeof (mbr), &mbr)) goto finish; + /* This is our loop-detection algorithm. It works the following way: + It saves last position which was a power of two. Then it compares the + saved value with a current one. This way it's guaranteed that the loop + will be broken by at most third walk. + */ + if (labeln && lastaddr == p.offset) + return grub_error (GRUB_ERR_BAD_PART_TABLE, "loop detected"); + + labeln++; + if ((labeln & (labeln - 1)) == 0) + lastaddr = p.offset; + /* Check if it is valid. */ if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE)) return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature"); From 0f0b8c878dec3844e52814eec15fd833d5ac0abe Mon Sep 17 00:00:00 2001 From: robertmh Date: Wed, 16 Sep 2009 19:01:53 +0000 Subject: [PATCH 82/85] fix last changelog entry --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index be7715f25..c8f1b9cbf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ 2009-09-15 Vladimir Serbinenko - * partmap/pc.c (pc_partition_map_iterate): Detect and break loops. + * partmap/msdos.c (pc_partition_map_iterate): Detect and break loops. 2009-09-14 Colin Watson From bbb2a70f51732b63d64e2d927c6a6536b01dd175 Mon Sep 17 00:00:00 2001 From: robertmh Date: Wed, 16 Sep 2009 19:23:33 +0000 Subject: [PATCH 83/85] 2009-09-16 Robert Millan * partmap/msdos.c (pc_partition_map_iterate): Fix possible use of uninitialized `lastaddr'. --- ChangeLog | 5 +++++ partmap/msdos.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index c8f1b9cbf..722f55c3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-16 Robert Millan + + * partmap/msdos.c (pc_partition_map_iterate): Fix possible use of + uninitialized `lastaddr'. + 2009-09-15 Vladimir Serbinenko * partmap/msdos.c (pc_partition_map_iterate): Detect and break loops. diff --git a/partmap/msdos.c b/partmap/msdos.c index a5d55b64d..6ba7fb927 100644 --- a/partmap/msdos.c +++ b/partmap/msdos.c @@ -110,6 +110,10 @@ pc_partition_map_iterate (grub_disk_t disk, p.data = &pcdata; p.partmap = &grub_msdos_partition_map; + /* Any value different than `p.offset' will satisfy the check during + first loop. */ + lastaddr = !p.offset; + while (1) { int i; From 63f745e8570f3cd8cfdf43dffa4da40877d2a39d Mon Sep 17 00:00:00 2001 From: robertmh Date: Wed, 16 Sep 2009 19:32:44 +0000 Subject: [PATCH 84/85] 2009-09-16 Robert Millan * aclocal.m4 (AC_LANG_PROGRAM): New macro. Overrides stock AC_LANG_PROGRAM from autoconf. (grub_ASM_USCORE, grub_PROG_OBJCOPY_ABSOLUTE): Add missing prototypes (fixes warning). * configure.ac: Add `-Werror' to TARGET_CFLAGS unless `--disable-werror' was used. --- ChangeLog | 10 ++++++++++ aclocal.m4 | 17 +++++++++++++++++ configure.ac | 7 +++++++ 3 files changed, 34 insertions(+) diff --git a/ChangeLog b/ChangeLog index 722f55c3b..efbc7a786 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-09-16 Robert Millan + + * aclocal.m4 (AC_LANG_PROGRAM): New macro. Overrides stock + AC_LANG_PROGRAM from autoconf. + (grub_ASM_USCORE, grub_PROG_OBJCOPY_ABSOLUTE): Add missing + prototypes (fixes warning). + + * configure.ac: Add `-Werror' to TARGET_CFLAGS unless + `--disable-werror' was used. + 2009-09-16 Robert Millan * partmap/msdos.c (pc_partition_map_iterate): Fix possible use of diff --git a/aclocal.m4 b/aclocal.m4 index 313b241fa..899eca409 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,3 +1,18 @@ +dnl Redefine AC_LANG_PROGRAM with a "-Wstrict-prototypes -Werror"-friendly +dnl version. Patch submitted to bug-autoconf in 2009-09-16. +m4_define([AC_LANG_PROGRAM(C)], +[$1 +int +main (void) +{ +dnl Do *not* indent the following line: there may be CPP directives. +dnl Don't move the `;' right after for the same reason. +$2 + ; + return 0; +}]) + + dnl Check whether target compiler is working AC_DEFUN(grub_PROG_TARGET_CC, [AC_MSG_CHECKING([whether target compiler is working]) @@ -26,6 +41,7 @@ AC_DEFUN(grub_ASM_USCORE, AC_MSG_CHECKING([if C symbols get an underscore after compilation]) AC_CACHE_VAL(grub_cv_asm_uscore, [cat > conftest.c <<\EOF +int func (int *); int func (int *list) { @@ -63,6 +79,7 @@ AC_DEFUN(grub_PROG_OBJCOPY_ABSOLUTE, [AC_MSG_CHECKING([whether ${OBJCOPY} works for absolute addresses]) AC_CACHE_VAL(grub_cv_prog_objcopy_absolute, [cat > conftest.c <<\EOF +void cmain (void); void cmain (void) { diff --git a/configure.ac b/configure.ac index 37ecba759..59e8510d3 100644 --- a/configure.ac +++ b/configure.ac @@ -390,6 +390,13 @@ if test x"$sap_possible" = xyes; then TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe" fi +AC_ARG_ENABLE([werror], + [AS_HELP_STRING([--disable-werror], + [do not use -Werror when building GRUB])]) +if test x"$enable_werror" != xno ; then + TARGET_CFLAGS="$TARGET_CFLAGS -Werror" +fi + AC_SUBST(TARGET_CFLAGS) AC_SUBST(TARGET_MODULE_FORMAT) AC_SUBST(OBJCONV) From be94a509bb4f3c77aca6b5c12403820b3d04b4ab Mon Sep 17 00:00:00 2001 From: phcoder Date: Thu, 17 Sep 2009 11:38:50 +0000 Subject: [PATCH 85/85] 2009-09-16 Vladimir Serbinenko * mmap/mmap.c (grub_cmd_badram): Fix off-by-one error. --- ChangeLog | 4 ++++ mmap/mmap.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index efbc7a786..5d836659c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-09-16 Vladimir Serbinenko + + * mmap/mmap.c (grub_cmd_badram): Fix off-by-one error. + 2009-09-16 Robert Millan * aclocal.m4 (AC_LANG_PROGRAM): New macro. Overrides stock diff --git a/mmap/mmap.c b/mmap/mmap.c index f2407c0bd..7598cf501 100644 --- a/mmap/mmap.c +++ b/mmap/mmap.c @@ -368,8 +368,8 @@ grub_cmd_badram (grub_command_t cmd __attribute__ ((unused)), iterator++) { grub_dprintf ("badram", "%llx (size %llx) is a badram range\n", - (long long) cur, (long long) (1ULL << tail) - 1); - grub_mmap_register (cur, (1ULL << tail) - 1, GRUB_MACHINE_MEMORY_HOLE); + (unsigned long long) cur, (1ULL << tail)); + grub_mmap_register (cur, (1ULL << tail), GRUB_MACHINE_MEMORY_HOLE); } return 0; }