From 063e925fb0370f2753f5122f8dacb26d67ce7713 Mon Sep 17 00:00:00 2001 From: phcoder Date: Tue, 22 Sep 2009 09:27:59 +0200 Subject: [PATCH 001/208] split search --- commands/search.c | 101 ++++++++++++++++---------------------- conf/common.rmk | 20 +++++++- 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 +- 9 files changed, 66 insertions(+), 69 deletions(-) diff --git a/commands/search.c b/commands/search.c index 0cfd0ebbc..60b5bbf04 100644 --- a/commands/search.c +++ b/commands/search.c @@ -27,27 +27,8 @@ #include #include -static const struct grub_arg_option options[] = - { - {"file", 'f', 0, "search devices by a file", 0, 0}, - {"label", 'l', 0, "search devices by a filesystem label", 0, 0}, - {"fs-uuid", 'u', 0, "search devices by a filesystem UUID", 0, 0}, - {"set", 's', GRUB_ARG_OPTION_OPTIONAL, "set a variable to the first device found", "VAR", ARG_TYPE_STRING}, - {"no-floppy", 'n', 0, "do not probe any floppy drive", 0, 0}, - {0, 0, 0, 0, 0, 0} - }; - -enum options - { - SEARCH_FILE, - SEARCH_LABEL, - SEARCH_FS_UUID, - SEARCH_SET, - SEARCH_NO_FLOPPY, - }; - -static void -search_fs (const char *key, const char *var, int no_floppy, enum options type) +void +FUNC_NAME (const char *key, const char *var, int no_floppy) { int count = 0; char *buf = NULL; @@ -63,7 +44,7 @@ search_fs (const char *key, const char *var, int no_floppy, enum options type) name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9') return 0; - if (type == SEARCH_FILE) +#ifdef DO_SEARCH_FILE { grub_size_t len; char *p; @@ -84,27 +65,29 @@ search_fs (const char *key, const char *var, int no_floppy, enum options type) grub_file_close (file); } } - else +#else { - /* type is SEARCH_FS_UUID or SEARCH_LABEL */ + /* SEARCH_FS_UUID or SEARCH_LABEL */ grub_device_t dev; grub_fs_t fs; - int (*compare_fn) (const char *, const char *); char *quid; dev = grub_device_open (name); if (dev) { fs = grub_fs_probe (dev); - compare_fn = - (type == SEARCH_FS_UUID) ? grub_strcasecmp : grub_strcmp; - if (fs && ((type == SEARCH_FS_UUID) ? fs->uuid : fs->label)) +#ifdef DO_SEARCH_FS_UUID +#define compare_fn grub_strcasecmp +#define read_fn uuid +#else +#define compare_fn grub_strcmp +#define read_fn label +#endif + + if (fs && fs->read_fn) { - if (type == SEARCH_FS_UUID) - fs->uuid (dev, &quid); - else - fs->label (dev, &quid); + fs->read_fn (dev, &quid); if (grub_errno == GRUB_ERR_NONE && quid) { @@ -118,6 +101,7 @@ search_fs (const char *key, const char *var, int no_floppy, enum options type) grub_device_close (dev); } } +#endif if (found) { @@ -156,45 +140,42 @@ search_fs (const char *key, const char *var, int no_floppy, enum options type) } static grub_err_t -grub_cmd_search (grub_extcmd_t cmd, int argc, char **args) +grub_cmd_do_search (grub_command_t cmd __attribute__ ((unused)), int argc, + char **args) { - struct grub_arg_list *state = cmd->state; - const char *var = 0; - if (argc == 0) - return grub_error (GRUB_ERR_INVALID_COMMAND, "no argument specified"); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "no argument specified"); - if (state[SEARCH_SET].set) - var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root"; - - if (state[SEARCH_LABEL].set) - search_fs (args[0], var, state[SEARCH_NO_FLOPPY].set, SEARCH_LABEL); - else if (state[SEARCH_FS_UUID].set) - search_fs (args[0], var, state[SEARCH_NO_FLOPPY].set, SEARCH_FS_UUID); - else if (state[SEARCH_FILE].set) - search_fs (args[0], var, state[SEARCH_NO_FLOPPY].set, SEARCH_FILE); - else - return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type"); + FUNC_NAME (args[0], argc == 1 ? 0 : args[1], 0); return grub_errno; } -static grub_extcmd_t cmd; +static grub_command_t cmd; -GRUB_MOD_INIT(search) +#ifdef SEARCH_FILE +GRUB_MOD_INIT(search_file) +#elif defined (SEARCH_FS_UUID) +GRUB_MOD_INIT(search_fs_uuid) +#else +GRUB_MOD_INIT(search_fs_label) +#endif { cmd = - grub_register_extcmd ("search", grub_cmd_search, - GRUB_COMMAND_FLAG_BOTH, - "search [-f|-l|-u|-s|-n] NAME", - "Search devices by file, filesystem label or filesystem UUID." - " If --set is specified, the first device found is" - " set to a variable. If no variable name is" - " specified, \"root\" is used.", - options); + grub_register_command (COMMAND_NAME, grub_cmd_do_search, + COMMAND_NAME " NAME [VARIABLE]", + "Search devices by " SEARCH_TARGET "." + " If VARIABLE is specified, the first device found is" + " set to a variable."); } -GRUB_MOD_FINI(search) +#ifdef SEARCH_FILE +GRUB_MOD_FINI(search_file) +#elif defined (SEARCH_FS_UUID) +GRUB_MOD_FINI(search_fs_uuid) +#else +GRUB_MOD_FINI(search_fs_label) +#endif { - grub_unregister_extcmd (cmd); + grub_unregister_command (cmd); } diff --git a/conf/common.rmk b/conf/common.rmk index e18dd1052..9c8ac078d 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -363,7 +363,8 @@ scsi_mod_LDFLAGS = $(COMMON_LDFLAGS) # Commands. pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \ - ls.mod cmp.mod cat.mod help.mod search.mod loopback.mod \ + ls.mod cmp.mod cat.mod help.mod search_file.mod \ + search_fs_uuid.mod search_fs_label.mod search.mod loopback.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 \ @@ -437,10 +438,25 @@ help_mod_CFLAGS = $(COMMON_CFLAGS) help_mod_LDFLAGS = $(COMMON_LDFLAGS) # For search.mod. -search_mod_SOURCES = commands/search.c +search_mod_SOURCES = commands/search_wrap.c search_mod_CFLAGS = $(COMMON_CFLAGS) search_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For search.mod. +search_file_mod_SOURCES = commands/search_file.c +search_file_mod_CFLAGS = $(COMMON_CFLAGS) +search_file_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For search.mod. +search_label_mod_SOURCES = commands/search_label.c +search_label_mod_CFLAGS = $(COMMON_CFLAGS) +search_label_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For search.mod. +search_uuid_mod_SOURCES = commands/search_uuid.c +search_uuid_mod_CFLAGS = $(COMMON_CFLAGS) +search_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For test.mod. test_mod_SOURCES = commands/test.c test_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index 09ec7787c..79c36eec1 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -108,7 +108,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/configfile.c commands/echo.c commands/help.c \ commands/handler.c commands/ls.c commands/test.c \ - commands/search.c commands/blocklist.c commands/hexdump.c \ + commands/search_file.c commands/search_label.c commands/search_uuid.c commands/search_wrap.c commands/blocklist.c commands/hexdump.c \ commands/gptsync.c commands/probe.c commands/xnu_uuid.c \ commands/password.c commands/keystatus.c \ lib/hexdump.c commands/i386/cpuid.c \ diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index 99ab06f64..c9a412aaf 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -36,7 +36,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h 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/search_file.c commands/search_label.c commands/search_uuid.c commands/search_wrap.c commands/hexdump.c lib/hexdump.c \ commands/halt.c commands/reboot.c commands/keystatus.c \ commands/i386/cpuid.c \ commands/password.c \ diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk index 4b640de49..6b15b1473 100644 --- a/conf/i386-ieee1275.rmk +++ b/conf/i386-ieee1275.rmk @@ -62,7 +62,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/configfile.c commands/echo.c commands/help.c \ commands/handler.c commands/ls.c commands/test.c \ - commands/search.c commands/blocklist.c commands/hexdump.c \ + commands/search_file.c commands/search_label.c commands/search_uuid.c commands/search_wrap.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 \ diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index bf8fbfb9d..87364223c 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -120,7 +120,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/configfile.c commands/echo.c commands/help.c \ commands/handler.c commands/ls.c commands/test.c \ - commands/search.c commands/blocklist.c commands/hexdump.c \ + commands/search_file.c commands/search_label.c commands/search_uuid.c commands/search_wrap.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 \ diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index ee7f9ec27..df594cfd0 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -42,7 +42,7 @@ grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/deviceiter.c \ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/configfile.c commands/help.c \ - commands/search.c commands/handler.c commands/test.c \ + commands/search_file.c commands/search_label.c commands/search_uuid.c commands/search_wrap.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 \ diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index 62e951a5e..936d4818a 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -100,7 +100,7 @@ grub_ofpathname_SOURCES = util/sparc64/ieee1275/grub-ofpathname.c \ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ commands/configfile.c commands/help.c \ - commands/search.c commands/handler.c commands/test.c \ + commands/search_file.c commands/search_label.c commands/search_uuid.c commands/search_wrap.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 \ diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index 934cd7284..a17cd5928 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -34,7 +34,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h 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/search_file.c commands/search_label.c commands/search_uuid.c commands/search_wrap.c commands/hexdump.c lib/hexdump.c \ commands/halt.c commands/reboot.c \ commands/i386/cpuid.c \ commands/password.c commands/keystatus.c \ From dab7cb49133a6a2eac0d39f6403b4eac388d012e Mon Sep 17 00:00:00 2001 From: phcoder Date: Tue, 22 Sep 2009 09:29:32 +0200 Subject: [PATCH 002/208] missed files --- commands/search_file.c | 5 +++ commands/search_label.c | 5 +++ commands/search_uuid.c | 5 +++ commands/search_wrap.c | 81 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 commands/search_file.c create mode 100644 commands/search_label.c create mode 100644 commands/search_uuid.c create mode 100644 commands/search_wrap.c diff --git a/commands/search_file.c b/commands/search_file.c new file mode 100644 index 000000000..265220001 --- /dev/null +++ b/commands/search_file.c @@ -0,0 +1,5 @@ +#define DO_SEARCH_FILE 1 +#define FUNC_NAME grub_search_fs_file +#define COMMAND_NAME "search.file" +#define SEARCH_TARGET "file" +#include "search.c" diff --git a/commands/search_label.c b/commands/search_label.c new file mode 100644 index 000000000..0047b0e8c --- /dev/null +++ b/commands/search_label.c @@ -0,0 +1,5 @@ +#define DO_SEARCH_FS_LABEL 1 +#define FUNC_NAME grub_search_label +#define COMMAND_NAME "search.fs_label" +#define SEARCH_TARGET "filesystem label" +#include "search.c" diff --git a/commands/search_uuid.c b/commands/search_uuid.c new file mode 100644 index 000000000..9767d6501 --- /dev/null +++ b/commands/search_uuid.c @@ -0,0 +1,5 @@ +#define DO_SEARCH_FS_UUID 1 +#define FUNC_NAME grub_search_fs_uuid +#define COMMAND_NAME "search.fs_uuid" +#define SEARCH_TARGET "filesystem UUID" +#include "search.c" diff --git a/commands/search_wrap.c b/commands/search_wrap.c new file mode 100644 index 000000000..35cce3f5e --- /dev/null +++ b/commands/search_wrap.c @@ -0,0 +1,81 @@ +/* search.c - search devices based on a file or a filesystem label */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 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 + * 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 . + */ + +static const struct grub_arg_option options[] = + { + {"file", 'f', 0, "search devices by a file", 0, 0}, + {"label", 'l', 0, "search devices by a filesystem label", 0, 0}, + {"fs-uuid", 'u', 0, "search devices by a filesystem UUID", 0, 0}, + {"set", 's', GRUB_ARG_OPTION_OPTIONAL, "set a variable to the first device found", "VAR", ARG_TYPE_STRING}, + {"no-floppy", 'n', 0, "do not probe any floppy drive", 0, 0}, + {0, 0, 0, 0, 0, 0} + }; + +enum options + { + SEARCH_FILE, + SEARCH_LABEL, + SEARCH_FS_UUID, + SEARCH_SET, + SEARCH_NO_FLOPPY, + }; + +static grub_err_t +grub_cmd_search (grub_extcmd_t cmd, int argc, char **args) +{ + struct grub_arg_list *state = cmd->state; + const char *var = 0; + + if (argc == 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "no argument specified"); + + if (state[SEARCH_SET].set) + var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root"; + + if (state[SEARCH_LABEL].set) + grub_search_label (args[0], var, state[SEARCH_NO_FLOPPY].set); + else if (state[SEARCH_FS_UUID].set) + grub_search_fs_uuid (args[0], var, state[SEARCH_NO_FLOPPY].set); + else if (state[SEARCH_FILE].set) + grub_search_fs_file (args[0], var, state[SEARCH_NO_FLOPPY].set); + else + return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type"); + + return grub_errno; +} + +static grub_extcmd_t cmd; + +GRUB_MOD_INIT(search) +{ + cmd = + grub_register_extcmd ("search", grub_cmd_search, + GRUB_COMMAND_FLAG_BOTH, + "search [-f|-l|-u|-s|-n] NAME", + "Search devices by file, filesystem label or filesystem UUID." + " If --set is specified, the first device found is" + " set to a variable. If no variable name is" + " specified, \"root\" is used.", + options); +} + +GRUB_MOD_FINI(search) +{ + grub_unregister_extcmd (cmd); +} From d6cb87a6351caef982c897523ee8171a1542be60 Mon Sep 17 00:00:00 2001 From: phcoder Date: Tue, 22 Sep 2009 09:31:18 +0200 Subject: [PATCH 003/208] remove fs_*.c --- conf/common.rmk | 12 +--- disk/fs_file.c | 136 ------------------------------------------- disk/fs_uuid.c | 149 ------------------------------------------------ 3 files changed, 1 insertion(+), 296 deletions(-) delete mode 100644 disk/fs_file.c delete mode 100644 disk/fs_uuid.c diff --git a/conf/common.rmk b/conf/common.rmk index 9c8ac078d..1dc13159c 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -365,7 +365,7 @@ scsi_mod_LDFLAGS = $(COMMON_LDFLAGS) pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \ ls.mod cmp.mod cat.mod help.mod search_file.mod \ search_fs_uuid.mod search_fs_label.mod search.mod loopback.mod \ - fs_file.mod fs_uuid.mod configfile.mod echo.mod \ + configfile.mod echo.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 \ @@ -467,16 +467,6 @@ loopback_mod_SOURCES = disk/loopback.c loopback_mod_CFLAGS = $(COMMON_CFLAGS) loopback_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For fs_file.mod -fs_file_mod_SOURCES = disk/fs_file.c -fs_file_mod_CFLAGS = $(COMMON_CFLAGS) -fs_file_mod_LDFLAGS = $(COMMON_LDFLAGS) - -# For fs_uuid.mod -fs_uuid_mod_SOURCES = disk/fs_uuid.c -fs_uuid_mod_CFLAGS = $(COMMON_CFLAGS) -fs_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS) - # For configfile.mod configfile_mod_SOURCES = commands/configfile.c configfile_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/disk/fs_file.c b/disk/fs_file.c deleted file mode 100644 index e09568250..000000000 --- a/disk/fs_file.c +++ /dev/null @@ -1,136 +0,0 @@ -/* fs_file.c - Access partition by a file it contains. */ -/* - * 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 - -static grub_device_t -search_fs_file (const char *key, unsigned long *count) -{ - char *filename = NULL; - grub_device_t ret = NULL; - *count = 0; - - auto int iterate_device (const char *name); - int iterate_device (const char *name) - { - int len; - grub_file_t file; - - (*count)++; - - len = grub_strlen (name) + 2 + grub_strlen (key) + 1; - filename = grub_realloc (filename, len); - if (! filename) - return 1; - - grub_sprintf (filename, "(%s)%s", name, key); - file = grub_file_open (filename); - if (file) - { - grub_file_close (file); - ret = grub_device_open (name); - return 1; - } - - grub_errno = GRUB_ERR_NONE; - return 0; - } - - grub_device_iterate (iterate_device); - grub_free (filename); - - return ret; -} - -static grub_err_t -grub_fs_file_open (const char *name, grub_disk_t disk) -{ - grub_device_t dev; - - if (grub_strncmp (name, "FILE=", sizeof ("FILE=") - 1)) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a FILE virtual volume"); - - dev = search_fs_file (name + sizeof ("FILE=") - 1, &disk->id); - if (! dev) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching file found"); - - disk->total_sectors = dev->disk->total_sectors; - disk->has_partitions = 0; - if (dev->disk->partition) - { - disk->partition = grub_malloc (sizeof (*disk->partition)); - if (disk->partition) - grub_memcpy (disk->partition, dev->disk->partition, - sizeof (*disk->partition)); - } - else - disk->partition = NULL; - - disk->data = dev; - - return GRUB_ERR_NONE; -} - -static void -grub_fs_file_close (grub_disk_t disk) -{ - grub_device_t parent = disk->data; - grub_device_close (parent); -} - -static grub_err_t -grub_fs_file_read (grub_disk_t disk, grub_disk_addr_t sector, - grub_size_t size, char *buf) -{ - grub_device_t parent = disk->data; - return parent->disk->dev->read (parent->disk, sector, size, buf); -} - -static grub_err_t -grub_fs_file_write (grub_disk_t disk, grub_disk_addr_t sector, - grub_size_t size, const char *buf) -{ - grub_device_t parent = disk->data; - return parent->disk->dev->write (parent->disk, sector, size, buf); -} - -static struct grub_disk_dev grub_fs_file_dev = { - .name = "fs_file", - .id = GRUB_DISK_DEVICE_FILE_ID, - .open = grub_fs_file_open, - .close = grub_fs_file_close, - .read = grub_fs_file_read, - .write = grub_fs_file_write, - .next = 0 -}; - -GRUB_MOD_INIT (fs_file) -{ - grub_disk_dev_register (&grub_fs_file_dev); -} - -GRUB_MOD_FINI (fs_file) -{ - grub_disk_dev_unregister (&grub_fs_file_dev); -} diff --git a/disk/fs_uuid.c b/disk/fs_uuid.c deleted file mode 100644 index 6901dbacf..000000000 --- a/disk/fs_uuid.c +++ /dev/null @@ -1,149 +0,0 @@ -/* fs_uuid.c - Access disks by their filesystem UUID. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2008 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 -#include - -static grub_device_t -search_fs_uuid (const char *key, unsigned long *count) -{ - *count = 0; - grub_device_t ret = NULL; - - auto int iterate_device (const char *name); - int iterate_device (const char *name) - { - grub_device_t dev; - - dev = grub_device_open (name); - if (dev) - { - grub_fs_t fs; - - fs = grub_fs_probe (dev); - if (fs && fs->uuid) - { - char *uuid; - - (fs->uuid) (dev, &uuid); - if (grub_errno == GRUB_ERR_NONE && uuid) - { - (*count)++; - - if (grub_strcasecmp (uuid, key) == 0) - { - ret = dev; - grub_free (uuid); - return 1; - } - grub_free (uuid); - } - } - - grub_device_close (dev); - } - - grub_errno = GRUB_ERR_NONE; - return 0; - } - - grub_device_iterate (iterate_device); - - return ret; -} - -static grub_err_t -grub_fs_uuid_open (const char *name, grub_disk_t disk) -{ - grub_device_t dev; - - if (grub_strncmp (name, "UUID=", sizeof ("UUID=")-1)) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a UUID virtual volume"); - - dev = search_fs_uuid (name + sizeof ("UUID=") - 1, &disk->id); - if (! dev) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching UUID found"); - - disk->total_sectors = dev->disk->total_sectors; - disk->has_partitions = 0; - if (dev->disk->partition) - { - disk->partition = grub_malloc (sizeof (*disk->partition)); - if (disk->partition) - grub_memcpy (disk->partition, dev->disk->partition, - sizeof (*disk->partition)); - } - else - disk->partition = NULL; - - disk->data = dev; - - return GRUB_ERR_NONE; -} - -static void -grub_fs_uuid_close (grub_disk_t disk __attribute((unused))) -{ - grub_device_t parent = disk->data; - grub_device_close (parent); -} - -static grub_err_t -grub_fs_uuid_read (grub_disk_t disk, grub_disk_addr_t sector, - grub_size_t size, char *buf) -{ - grub_device_t parent = disk->data; - return parent->disk->dev->read (parent->disk, sector, size, buf); -} - -static grub_err_t -grub_fs_uuid_write (grub_disk_t disk, grub_disk_addr_t sector, - grub_size_t size, const char *buf) -{ - grub_device_t parent = disk->data; - return parent->disk->dev->write (parent->disk, sector, size, buf); -} - -static struct grub_disk_dev grub_fs_uuid_dev = - { - .name = "fs_uuid", - .id = GRUB_DISK_DEVICE_UUID_ID, - .open = grub_fs_uuid_open, - .close = grub_fs_uuid_close, - .read = grub_fs_uuid_read, - .write = grub_fs_uuid_write, - .next = 0 - }; - -GRUB_MOD_INIT(fs_uuid) -{ - grub_disk_dev_register (&grub_fs_uuid_dev); -} - -GRUB_MOD_FINI(fs_uuid) -{ - grub_disk_dev_unregister (&grub_fs_uuid_dev); -} From afba34eb21c649c8874b3ba58cad990a08557fbe Mon Sep 17 00:00:00 2001 From: phcoder Date: Tue, 22 Sep 2009 09:38:12 +0200 Subject: [PATCH 004/208] use search_fs_uuid --- util/i386/pc/grub-install.in | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/util/i386/pc/grub-install.in b/util/i386/pc/grub-install.in index 8ceb811dd..78500766c 100644 --- a/util/i386/pc/grub-install.in +++ b/util/i386/pc/grub-install.in @@ -271,6 +271,7 @@ modules="$modules $disk_module" modules="$modules $fs_module $partmap_module $devabstraction_module" prefix_drive= +config= if [ "x${devabstraction_module}" = "x" ] ; then if echo "${install_device}" | grep -qx "(.*)" ; then install_drive="${install_device}" @@ -289,16 +290,16 @@ if [ "x${devabstraction_module}" = "x" ] ; then echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 exit 1 fi - prefix_drive="(UUID=${uuid})" - modules="$modules fs_uuid" + config="search_fs_uuid ${uuid} root" + modules="$modules search_fs_uuid" elif [ "x${grub_drive}" != "x${install_drive}" ] ; then uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`" if [ "x${uuid}" = "x" ] ; then echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 exit 1 fi - prefix_drive="(UUID=${uuid})" - modules="$modules fs_uuid" + config="search_fs_uuid ${uuid} root" + modules="$modules search_fs_uuid" fi else prefix_drive=`$grub_probe --target=drive --device ${grub_device}` @@ -309,14 +310,20 @@ if [ "x${relative_grubdir}" = "x" ] ; then relative_grubdir=/ fi +config_opt= +echo $config > ${grubdir}/load.cfg +if [ x$config != x ]; then + config_opt="-c $config " +fi + if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then - $grub_mkimage --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1 + $grub_mkimage ${config_opt} --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1 # Now perform the installation. $grub_setup ${setup_verbose} ${setup_force} --directory=${grubdir} --device-map=${device_map} \ ${install_device} || exit 1 else - $grub_mkimage -d ${pkglibdir} --output=/boot/multiboot.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1 + $grub_mkimage ${config_opt} -d ${pkglibdir} --output=/boot/multiboot.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1 fi # Prompt the user to check if the device map is correct. From e880248e79587a962f9b21189d2202060d39e54a Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 9 Nov 2009 14:55:27 +0000 Subject: [PATCH 005/208] Fix *.lst handling after ${prefix} redefinition. --- normal/autofs.c | 15 +++++++++------ normal/dyncmd.c | 16 ++++++++++------ normal/handler.c | 16 ++++++++++------ normal/main.c | 15 ++++++++++++--- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/normal/autofs.c b/normal/autofs.c index ce354a22c..cf552052a 100644 --- a/normal/autofs.c +++ b/normal/autofs.c @@ -51,12 +51,6 @@ void read_fs_list (void) { const char *prefix; - static int first_time = 1; - - /* Make sure that this function does not get executed twice. */ - if (! first_time) - return; - first_time = 0; prefix = grub_env_get ("prefix"); if (prefix) @@ -72,6 +66,15 @@ read_fs_list (void) file = grub_file_open (filename); if (file) { + /* Override previous fs.lst. */ + while (fs_module_list) + { + grub_named_list_t tmp; + tmp = fs_module_list->next; + grub_free (fs_module_list); + fs_module_list = tmp; + } + while (1) { char *buf; diff --git a/normal/dyncmd.c b/normal/dyncmd.c index dc530b07b..6e5028906 100644 --- a/normal/dyncmd.c +++ b/normal/dyncmd.c @@ -62,12 +62,6 @@ void read_command_list (void) { const char *prefix; - static int first_time = 1; - - /* Make sure that this function does not get executed twice. */ - if (! first_time) - return; - first_time = 0; prefix = grub_env_get ("prefix"); if (prefix) @@ -84,6 +78,16 @@ read_command_list (void) if (file) { char *buf = NULL; + + /* Override previous commands.lst. */ + while (grub_command_list) + { + grub_command_t tmp; + tmp = grub_command_list->next; + grub_free (grub_command_list); + grub_command_list = tmp; + } + for (;; grub_free (buf)) { char *p, *name, *modname; diff --git a/normal/handler.c b/normal/handler.c index eb19f912f..b32209a44 100644 --- a/normal/handler.c +++ b/normal/handler.c @@ -135,7 +135,6 @@ void read_handler_list (void) { const char *prefix; - static int first_time = 1; const char *class_name; auto int iterate_handler (grub_handler_t handler); @@ -162,11 +161,6 @@ read_handler_list (void) return 0; } - /* Make sure that this function does not get executed twice. */ - if (! first_time) - return; - first_time = 0; - prefix = grub_env_get ("prefix"); if (prefix) { @@ -182,6 +176,16 @@ read_handler_list (void) if (file) { char *buf = NULL; + + /* Override previous handler.lst. */ + while (grub_handler_class_list) + { + grub_handler_class_t tmp; + tmp = grub_handler_class_list->next; + grub_free (grub_handler_class_list); + grub_handler_class_list = tmp; + } + for (;; grub_free (buf)) { char *p; diff --git a/normal/main.c b/normal/main.c index 748eef805..499eb59f6 100644 --- a/normal/main.c +++ b/normal/main.c @@ -404,6 +404,16 @@ grub_normal_init_page (void) static int reader_nested; +static char * +read_lists (struct grub_env_var *var __attribute__ ((unused)), + const char *val) +{ + read_command_list (); + read_fs_list (); + read_handler_list (); + return val ? grub_strdup (val) : NULL; +} + /* Read the config file CONFIG and execute the menu interface or the command line interface if BATCH is false. */ void @@ -411,9 +421,8 @@ grub_normal_execute (const char *config, int nested, int batch) { grub_menu_t menu = 0; - read_command_list (); - read_fs_list (); - read_handler_list (); + read_lists (NULL, NULL); + grub_register_variable_hook ("prefix", NULL, read_lists); grub_command_execute ("parser.sh", 0, 0); reader_nested = nested; From c9b1ebc10bea80b7be294d75cada90c668b14ed6 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 9 Nov 2009 17:13:17 +0100 Subject: [PATCH 006/208] First try to gcry glue --- conf/common.rmk | 2 + conf/gcry.rmk | 52 +++++++++++++++ conf/i386-pc.rmk | 4 +- import_gcry.py | 136 ++++++++++++++++++++++++++++++++++++++ include/grub/crypto.h | 138 +++++++++++++++++++++++++++++++++++++++ include/grub/gcry_wrap.h | 36 ++++++++++ kern/crypto.c | 34 ++++++++++ 7 files changed, 401 insertions(+), 1 deletion(-) create mode 100644 conf/gcry.rmk create mode 100644 import_gcry.py create mode 100644 include/grub/crypto.h create mode 100644 include/grub/gcry_wrap.h create mode 100644 kern/crypto.c diff --git a/conf/common.rmk b/conf/common.rmk index e1ac5274c..0d19344a7 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -618,3 +618,5 @@ pkglib_MODULES += setjmp.mod setjmp_mod_SOURCES = lib/$(target_cpu)/setjmp.S setjmp_mod_ASFLAGS = $(COMMON_ASFLAGS) setjmp_mod_LDFLAGS = $(COMMON_LDFLAGS) + +include $(srcdir)/conf/gcry.mk diff --git a/conf/gcry.rmk b/conf/gcry.rmk new file mode 100644 index 000000000..0eb3c79bc --- /dev/null +++ b/conf/gcry.rmk @@ -0,0 +1,52 @@ +# -*- makefile -*- + +pkglib_MODULES += seed.mod +seed_mod_SOURCES = gcry/cipher/seed.c +seed_mod_ASFLAGS = $(COMMON_ASFLAGS) +seed_mod_LDFLAGS = $(COMMON_ASFLAGS) + +pkglib_MODULES += twofish.mod +twofish_mod_SOURCES = gcry/cipher/twofish.c +twofish_mod_ASFLAGS = $(COMMON_ASFLAGS) +twofish_mod_LDFLAGS = $(COMMON_ASFLAGS) + +pkglib_MODULES += des.mod +des_mod_SOURCES = gcry/cipher/des.c +des_mod_ASFLAGS = $(COMMON_ASFLAGS) +des_mod_LDFLAGS = $(COMMON_ASFLAGS) + +pkglib_MODULES += arcfour.mod +arcfour_mod_SOURCES = gcry/cipher/arcfour.c +arcfour_mod_ASFLAGS = $(COMMON_ASFLAGS) +arcfour_mod_LDFLAGS = $(COMMON_ASFLAGS) + +pkglib_MODULES += rfc2268.mod +rfc2268_mod_SOURCES = gcry/cipher/rfc2268.c +rfc2268_mod_ASFLAGS = $(COMMON_ASFLAGS) +rfc2268_mod_LDFLAGS = $(COMMON_ASFLAGS) + +pkglib_MODULES += cast5.mod +cast5_mod_SOURCES = gcry/cipher/cast5.c +cast5_mod_ASFLAGS = $(COMMON_ASFLAGS) +cast5_mod_LDFLAGS = $(COMMON_ASFLAGS) + +pkglib_MODULES += camellia-glue.mod +camellia-glue_mod_SOURCES = gcry/cipher/camellia-glue.c +camellia-glue_mod_ASFLAGS = $(COMMON_ASFLAGS) +camellia-glue_mod_LDFLAGS = $(COMMON_ASFLAGS) + +pkglib_MODULES += rijndael.mod +rijndael_mod_SOURCES = gcry/cipher/rijndael.c +rijndael_mod_ASFLAGS = $(COMMON_ASFLAGS) +rijndael_mod_LDFLAGS = $(COMMON_ASFLAGS) + +pkglib_MODULES += serpent.mod +serpent_mod_SOURCES = gcry/cipher/serpent.c +serpent_mod_ASFLAGS = $(COMMON_ASFLAGS) +serpent_mod_LDFLAGS = $(COMMON_ASFLAGS) + +pkglib_MODULES += blowfish.mod +blowfish_mod_SOURCES = gcry/cipher/blowfish.c +blowfish_mod_ASFLAGS = $(COMMON_ASFLAGS) +blowfish_mod_LDFLAGS = $(COMMON_ASFLAGS) + diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 373b942cc..0e3291782 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -58,13 +58,15 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \ kern/generic/millisleep.c \ kern/env.c \ term/i386/pc/console.c term/i386/vga_common.c \ + kern/crypto.c \ 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 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 + machine/kernel.h machine/pxe.h i386/pit.h list.h handler.h command.h \ + crypto.h kernel_img_CFLAGS = $(COMMON_CFLAGS) $(TARGET_IMG_CFLAGS) kernel_img_ASFLAGS = $(COMMON_ASFLAGS) kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR) $(COMMON_CFLAGS) diff --git a/import_gcry.py b/import_gcry.py new file mode 100644 index 000000000..c751f5e6f --- /dev/null +++ b/import_gcry.py @@ -0,0 +1,136 @@ +import re +import sys +import os +import datetime + +if len (sys.argv) < 3: + print ("Usage: %s SOURCE DESTINATION" % sys.argv[0]) + exit (0) +indir = sys.argv[1] +outdir = sys.argv[2] + +basedir = os.path.join (outdir, "gcry") +os.makedirs (basedir) +cipher_dir_in = os.path.join (indir, "cipher") +cipher_dir_out = os.path.join (basedir, "cipher") +os.makedirs (cipher_dir_out) +cipher_files = os.listdir (cipher_dir_in) +conf = open (os.path.join (outdir, "conf", "gcry.rmk"), "w") +conf.write ("# -*- makefile -*-\n\n") +chlog = "" + +for cipher_file in cipher_files: + infile = os.path.join (cipher_dir_in, cipher_file) + outfile = os.path.join (cipher_dir_out, cipher_file) + if cipher_file == "ChangeLog": + continue + chlognew = " * %s" % cipher_file + nch = False + if re.match (".*\.[ch]$", cipher_file): + isc = re.match (".*\.c$", cipher_file) + f = open (infile, "r") + fw = open (outfile, "w") + fw.write ("/* This file was automatically imported with \n") + fw.write (" import_gcry.py. Please don't modify it */\n"); + ciphernames = [] + for line in f: + m = re.match ("#include <.*>", line) + if not m is None: + chmsg = "Removed including of %s" % \ + m.group () [len ("#include <"):len (m.group ()) - 1] + if nch: + chlognew = "%s\n %s" % (chlognew, chmsg) + else: + chlognew = "%s: %s" % (chlognew, chmsg) + nch = True + continue + m = re.match ("gcry_cipher_spec_t", line) + if isc and not m is None: + ciphername = line [len ("gcry_cipher_spec_t"):].strip () + ciphername = re.match("[a-zA-Z0-9_]*",ciphername).group () + ciphernames.append (ciphername) + fw.write (line) + if len (ciphernames) > 0: + modname = cipher_file [0:len(cipher_file) - 2] + chmsg = "(GRUB_MOD_INIT(%s)): New function\n" % modname + if nch: + chlognew = "%s\n %s" % (chlognew, chmsg) + else: + chlognew = "%s%s" % (chlognew, chmsg) + nch = True + fw.write ("\n\nGRUB_MOD_INIT(%s)\n" % modname) + fw.write ("{\n") + for ciphername in ciphernames: + chmsg = "Register cipher %s" % ciphername + chlognew = "%s\n %s" % (chlognew, chmsg) + fw.write (" grub_cipher_register (&%s);\n" % ciphername) + fw.write ("}") + chmsg = "(GRUB_MOD_FINI(%s)): New function\n" % modname + chlognew = "%s\n %s" % (chlognew, chmsg) + fw.write ("\n\nGRUB_MOD_FINI(%s)\n" % modname) + fw.write ("{\n") + for ciphername in ciphernames: + chmsg = "Unregister cipher %s" % ciphername + chlognew = "%s\n %s" % (chlognew, chmsg) + fw.write (" grub_cipher_unregister (&%s);\n" % ciphername) + fw.write ("}\n") + conf.write ("pkglib_MODULES += %s.mod\n" % modname) + conf.write ("%s_mod_SOURCES = gcry/cipher/%s\n" %\ + (modname, cipher_file)) + conf.write ("%s_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error\n" % modname) + conf.write ("%s_mod_LDFLAGS = $(COMMON_ASFLAGS)\n\n" % modname) + elif isc: + print ("WARNING: c file isn't a module: %s" % cipher_file) + f.close () + fw.close () + if nch: + chlog = "%s%s\n" % (chlog, chlognew) + continue + if re.match ("(Manifest|Makefile\.am)$", cipher_file): + chlog = "%s%sRemoved\n" % (chlog, chlognew) + continue + # Autogenerated files. Not even worth mentionning in ChangeLog + if re.match ("Makefile\.in$", cipher_file): + chlog = "%s%sRemoved\n" % (chlog, chlognew) + continue + chlog = "%s%sSkipped unknown file\n" % (chlog, chlognew) + print ("WARNING: unknown file %s" % cipher_file) + +outfile = os.path.join (cipher_dir_out, "types.h") +fw=open (outfile, "w") +fw.write ("#include \n") +fw.write ("#include \n") +chlog = "%s * types.h: New file.\n" % chlog +fw.close () + +outfile = os.path.join (cipher_dir_out, "cipher.h") +fw=open (outfile, "w") +fw.write ("#include \n") +fw.write ("#include \n") +chlog = "%s * cipher.h: Likewise.\n" % chlog +fw.close () + +outfile = os.path.join (cipher_dir_out, "g10lib.h") +fw=open (outfile, "w") +fw.write ("#include \n") +chlog = "%s * g10lib.h: Likewise.\n" % chlog +fw.close () + +infile = os.path.join (cipher_dir_in, "ChangeLog") +outfile = os.path.join (cipher_dir_out, "ChangeLog") + + +f=open (infile, "r") +fw=open (outfile, "w") +dt = datetime.date.today () +fw.write ("%04d-%02d-%02d Automatic import tool\n" % \ + (dt.year,dt.month, dt.day)) +fw.write ("\n") +fw.write (" Imported ciphers to GRUB\n") +fw.write ("\n") +fw.write (chlog) +fw.write ("\n") +for line in f: + fw.write (line) +f.close () +fw.close () diff --git a/include/grub/crypto.h b/include/grub/crypto.h new file mode 100644 index 000000000..36503c1a1 --- /dev/null +++ b/include/grub/crypto.h @@ -0,0 +1,138 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 + * 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 + * 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 . + */ + +/* Contains elements based on gcrypt-module.h and gcrypt.h.in. + If it's changed please update this file. */ + +#ifndef GRUB_CIPHER_HEADER +#define GRUB_CIPHER_HEADER 1 + +#include +#include + +typedef enum + { + GPG_ERR_NO_ERROR, + GPG_ERR_BAD_MPI, + GPG_ERR_BAD_SECKEY, + GPG_ERR_BAD_SIGNATURE, + GPG_ERR_CIPHER_ALGO, + GPG_ERR_CONFLICT, + GPG_ERR_DECRYPT_FAILED, + GPG_ERR_DIGEST_ALGO, + GPG_ERR_GENERAL, + GPG_ERR_INTERNAL, + GPG_ERR_INV_ARG, + GPG_ERR_INV_CIPHER_MODE, + GPG_ERR_INV_FLAG, + GPG_ERR_INV_KEYLEN, + GPG_ERR_INV_OBJ, + GPG_ERR_INV_OP, + GPG_ERR_INV_SEXP, + GPG_ERR_INV_VALUE, + GPG_ERR_MISSING_VALUE, + GPG_ERR_NO_ENCRYPTION_SCHEME, + GPG_ERR_NO_OBJ, + GPG_ERR_NO_PRIME, + GPG_ERR_NO_SIGNATURE_SCHEME, + GPG_ERR_NOT_FOUND, + GPG_ERR_NOT_IMPLEMENTED, + GPG_ERR_NOT_SUPPORTED, + GPG_ERROR_CFLAGS, + GPG_ERR_PUBKEY_ALGO, + GPG_ERR_SELFTEST_FAILED, + GPG_ERR_TOO_SHORT, + GPG_ERR_UNSUPPORTED, + GPG_ERR_WEAK_KEY, + GPG_ERR_WRONG_KEY_USAGE, + GPG_ERR_WRONG_PUBKEY_ALGO, + } gcry_err_code_t; + +enum gcry_cipher_modes + { + GCRY_CIPHER_MODE_NONE = 0, /* Not yet specified. */ + GCRY_CIPHER_MODE_ECB = 1, /* Electronic codebook. */ + GCRY_CIPHER_MODE_CFB = 2, /* Cipher feedback. */ + GCRY_CIPHER_MODE_CBC = 3, /* Cipher block chaining. */ + GCRY_CIPHER_MODE_STREAM = 4, /* Used with stream ciphers. */ + GCRY_CIPHER_MODE_OFB = 5, /* Outer feedback. */ + GCRY_CIPHER_MODE_CTR = 6 /* Counter. */ + }; + +/* Type for the cipher_setkey function. */ +typedef gcry_err_code_t (*gcry_cipher_setkey_t) (void *c, + const unsigned char *key, + unsigned keylen); + +/* Type for the cipher_encrypt function. */ +typedef void (*gcry_cipher_encrypt_t) (void *c, + unsigned char *outbuf, + const unsigned char *inbuf); + +/* Type for the cipher_decrypt function. */ +typedef void (*gcry_cipher_decrypt_t) (void *c, + unsigned char *outbuf, + const unsigned char *inbuf); + +/* Type for the cipher_stencrypt function. */ +typedef void (*gcry_cipher_stencrypt_t) (void *c, + unsigned char *outbuf, + const unsigned char *inbuf, + unsigned int n); + +/* Type for the cipher_stdecrypt function. */ +typedef void (*gcry_cipher_stdecrypt_t) (void *c, + unsigned char *outbuf, + const unsigned char *inbuf, + unsigned int n); + +typedef struct gcry_cipher_oid_spec +{ + const char *oid; + int mode; +} gcry_cipher_oid_spec_t; + +/* Module specification structure for ciphers. */ +typedef struct gcry_cipher_spec +{ + const char *name; + const char **aliases; + gcry_cipher_oid_spec_t *oids; + grub_size_t blocksize; + grub_size_t keylen; + grub_size_t contextsize; + gcry_cipher_setkey_t setkey; + gcry_cipher_encrypt_t encrypt; + gcry_cipher_decrypt_t decrypt; + gcry_cipher_stencrypt_t stencrypt; + gcry_cipher_stdecrypt_t stdecrypt; +} gcry_cipher_spec_t; + +struct grub_cipher +{ + struct grub_cipher *next; + const char *name; +}; +typedef struct grub_cipher *grub_cipher_t; + +extern grub_cipher_t EXPORT_VAR (grub_ciphers); +void EXPORT_FUNC(grub_burn_stack) (grub_size_t size); + + +#endif diff --git a/include/grub/gcry_wrap.h b/include/grub/gcry_wrap.h new file mode 100644 index 000000000..364946d1b --- /dev/null +++ b/include/grub/gcry_wrap.h @@ -0,0 +1,36 @@ +/* + * 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_GCRY_WRAP_HEADER +#define GRUB_GCRY_WRAP_HEADER 1 + +#include +#include +#include +#include +#include + +typedef grub_uint32_t u32; +typedef grub_uint16_t u16; +typedef grub_uint8_t byte; +typedef grub_size_t size_t; + +#define _gcry_burn_stack grub_burn_stack +#define log_error(fmt, args...) grub_dprintf ("crypto", fmt, ## args) + +#endif diff --git a/kern/crypto.c b/kern/crypto.c new file mode 100644 index 000000000..7dd00c84d --- /dev/null +++ b/kern/crypto.c @@ -0,0 +1,34 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999, 2001, 2002, 2003, 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 + * 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 + +grub_cipher_t grub_ciphers; + +/* Based on libgcrypt-1.4.4/src/misc.c. */ +void +grub_burn_stack (grub_size_t size) +{ + char buf[64]; + + grub_memset (buf, 0, sizeof (buf)); + size -= sizeof (buf); + if (size > 0) + grub_burn_stack (size); +} From 58806db8473505662ce9809a4ac996067808e7bf Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 9 Nov 2009 20:30:40 +0100 Subject: [PATCH 007/208] Improvements in headers --- conf/gcry.rmk | 52 ---------------------------------------- import_gcry.py | 4 ++-- include/grub/crypto.h | 48 +++++++++++++++++++++++++++++++++++++ include/grub/gcry_wrap.h | 2 ++ 4 files changed, 52 insertions(+), 54 deletions(-) delete mode 100644 conf/gcry.rmk diff --git a/conf/gcry.rmk b/conf/gcry.rmk deleted file mode 100644 index 0eb3c79bc..000000000 --- a/conf/gcry.rmk +++ /dev/null @@ -1,52 +0,0 @@ -# -*- makefile -*- - -pkglib_MODULES += seed.mod -seed_mod_SOURCES = gcry/cipher/seed.c -seed_mod_ASFLAGS = $(COMMON_ASFLAGS) -seed_mod_LDFLAGS = $(COMMON_ASFLAGS) - -pkglib_MODULES += twofish.mod -twofish_mod_SOURCES = gcry/cipher/twofish.c -twofish_mod_ASFLAGS = $(COMMON_ASFLAGS) -twofish_mod_LDFLAGS = $(COMMON_ASFLAGS) - -pkglib_MODULES += des.mod -des_mod_SOURCES = gcry/cipher/des.c -des_mod_ASFLAGS = $(COMMON_ASFLAGS) -des_mod_LDFLAGS = $(COMMON_ASFLAGS) - -pkglib_MODULES += arcfour.mod -arcfour_mod_SOURCES = gcry/cipher/arcfour.c -arcfour_mod_ASFLAGS = $(COMMON_ASFLAGS) -arcfour_mod_LDFLAGS = $(COMMON_ASFLAGS) - -pkglib_MODULES += rfc2268.mod -rfc2268_mod_SOURCES = gcry/cipher/rfc2268.c -rfc2268_mod_ASFLAGS = $(COMMON_ASFLAGS) -rfc2268_mod_LDFLAGS = $(COMMON_ASFLAGS) - -pkglib_MODULES += cast5.mod -cast5_mod_SOURCES = gcry/cipher/cast5.c -cast5_mod_ASFLAGS = $(COMMON_ASFLAGS) -cast5_mod_LDFLAGS = $(COMMON_ASFLAGS) - -pkglib_MODULES += camellia-glue.mod -camellia-glue_mod_SOURCES = gcry/cipher/camellia-glue.c -camellia-glue_mod_ASFLAGS = $(COMMON_ASFLAGS) -camellia-glue_mod_LDFLAGS = $(COMMON_ASFLAGS) - -pkglib_MODULES += rijndael.mod -rijndael_mod_SOURCES = gcry/cipher/rijndael.c -rijndael_mod_ASFLAGS = $(COMMON_ASFLAGS) -rijndael_mod_LDFLAGS = $(COMMON_ASFLAGS) - -pkglib_MODULES += serpent.mod -serpent_mod_SOURCES = gcry/cipher/serpent.c -serpent_mod_ASFLAGS = $(COMMON_ASFLAGS) -serpent_mod_LDFLAGS = $(COMMON_ASFLAGS) - -pkglib_MODULES += blowfish.mod -blowfish_mod_SOURCES = gcry/cipher/blowfish.c -blowfish_mod_ASFLAGS = $(COMMON_ASFLAGS) -blowfish_mod_LDFLAGS = $(COMMON_ASFLAGS) - diff --git a/import_gcry.py b/import_gcry.py index c751f5e6f..738c2c479 100644 --- a/import_gcry.py +++ b/import_gcry.py @@ -77,8 +77,8 @@ for cipher_file in cipher_files: conf.write ("pkglib_MODULES += %s.mod\n" % modname) conf.write ("%s_mod_SOURCES = gcry/cipher/%s\n" %\ (modname, cipher_file)) - conf.write ("%s_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error\n" % modname) - conf.write ("%s_mod_LDFLAGS = $(COMMON_ASFLAGS)\n\n" % modname) + conf.write ("%s_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-missing-field-initializers -Wno-error\n" % modname) + conf.write ("%s_mod_LDFLAGS = $(COMMON_LDFLAGS)\n\n" % modname) elif isc: print ("WARNING: c file isn't a module: %s" % cipher_file) f.close () diff --git a/include/grub/crypto.h b/include/grub/crypto.h index 36503c1a1..ab482f467 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -63,6 +63,7 @@ typedef enum GPG_ERR_WRONG_KEY_USAGE, GPG_ERR_WRONG_PUBKEY_ALGO, } gcry_err_code_t; +#define gpg_err_code_t gcry_err_code_t enum gcry_cipher_modes { @@ -124,6 +125,53 @@ typedef struct gcry_cipher_spec gcry_cipher_stdecrypt_t stdecrypt; } gcry_cipher_spec_t; +/* Definition of a function used to report selftest failures. + DOMAIN is a string describing the function block: + "cipher", "digest", "pubkey or "random", + ALGO is the algorithm under test, + WHAT is a string describing what has been tested, + DESC is a string describing the error. */ +typedef void (*selftest_report_func_t)(const char *domain, + int algo, + const char *what, + const char *errdesc); + +/* Definition of the selftest functions. */ +typedef gpg_err_code_t (*selftest_func_t) + (int algo, int extended, selftest_report_func_t report); + +/* The type used to convey additional information to a cipher. */ +typedef gpg_err_code_t (*cipher_set_extra_info_t) + (void *c, int what, const void *buffer, grub_size_t buflen); + + +/* Extra module specification structures. These are used for internal + modules which provide more functions than available through the + public algorithm register APIs. */ +typedef struct cipher_extra_spec +{ + selftest_func_t selftest; + cipher_set_extra_info_t set_extra_info; +} cipher_extra_spec_t; + +/* (Forward declaration.) */ +struct gcry_md_context; + +/* This object is used to hold a handle to a message digest object. + This structure is private - only to be used by the public gcry_md_* + macros. */ +typedef struct gcry_md_handle +{ + /* Actual context. */ + struct gcry_md_context *ctx; + + /* Buffer management. */ + int bufpos; + int bufsize; + unsigned char buf[1]; +} *gcry_md_hd_t; + + struct grub_cipher { struct grub_cipher *next; diff --git a/include/grub/gcry_wrap.h b/include/grub/gcry_wrap.h index 364946d1b..6f415a2e5 100644 --- a/include/grub/gcry_wrap.h +++ b/include/grub/gcry_wrap.h @@ -25,6 +25,8 @@ #include #include +#define __GNU_LIBRARY__ + typedef grub_uint32_t u32; typedef grub_uint16_t u16; typedef grub_uint8_t byte; From 47972a242007a3739afdda393adc88d0b6db5265 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 9 Nov 2009 21:33:15 +0000 Subject: [PATCH 008/208] Save & restore grub_fs_autoload_hook while we're in read_fs_list() --- normal/autofs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/normal/autofs.c b/normal/autofs.c index cf552052a..d1ef761fb 100644 --- a/normal/autofs.c +++ b/normal/autofs.c @@ -61,8 +61,15 @@ read_fs_list (void) if (filename) { grub_file_t file; + grub_fs_autoload_hook_t tmp_autoload_hook; grub_sprintf (filename, "%s/fs.lst", prefix); + + /* This rules out the possibility that read_fs_list() is invoked + recursively when we call grub_file_open() below. */ + tmp_autoload_hook = grub_fs_autoload_hook; + grub_fs_autoload_hook = NULL; + file = grub_file_open (filename); if (file) { @@ -116,6 +123,7 @@ read_fs_list (void) } grub_file_close (file); + grub_fs_autoload_hook = tmp_autoload_hook; } grub_free (filename); From 8fbfe0d68b777b199ae6f9521669399e443cb9d4 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 9 Nov 2009 21:44:48 +0000 Subject: [PATCH 009/208] Write ChangeLog entry. --- ChangeLog.prefix-redefinition-fix | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 ChangeLog.prefix-redefinition-fix diff --git a/ChangeLog.prefix-redefinition-fix b/ChangeLog.prefix-redefinition-fix new file mode 100644 index 000000000..0d47db753 --- /dev/null +++ b/ChangeLog.prefix-redefinition-fix @@ -0,0 +1,12 @@ +2009-11-09 Robert Millan + + * normal/autofs.c (read_fs_list): Make function capable of being + run multiple times, gracefuly replacing the previous data + structures. + * normal/dyncmd.c (read_command_list): Likewise. + * normal/handler.c (read_handler_list): Likewise. + * normal/main.c (read_lists): New function. Calls all the + list reading functions. + (grub_normal_execute): Use read_lists() instead of calling all + list reading functions explicitly. Register read_lists() as a + variable hook attached to ${prefix}. From 81faaf6c56735499e7e3ab3236103fd17c25bad2 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 9 Nov 2009 23:51:01 +0100 Subject: [PATCH 010/208] 2009-11-09 Vladimir Serbinenko * kern/i386/pc/startup.S (grub_biosdisk_get_diskinfo_int13_extensions): Ignore return status if CF is cleared. --- kern/i386/pc/startup.S | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S index da3624c89..83f0b4ef8 100644 --- a/kern/i386/pc/startup.S +++ b/kern/i386/pc/startup.S @@ -776,6 +776,11 @@ FUNCTION(grub_biosdisk_get_diskinfo_int13_extensions) movw %cx, %ax movw %bx, %ds int $0x13 /* do the operation */ + jc noclean + /* Clean return value if carry isn't set to workaround + some buggy BIOSes. */ + xor %ax, %ax +noclean: movb %ah, %bl /* save return value in %bl */ /* back to protected mode */ DATA32 call real_to_prot From b8baeed9eef7543e78e25ca9861544e9909c8e05 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 9 Nov 2009 23:59:59 +0100 Subject: [PATCH 011/208] ChangeLog --- ChangeLog.lbafix | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 ChangeLog.lbafix diff --git a/ChangeLog.lbafix b/ChangeLog.lbafix new file mode 100644 index 000000000..add35fb83 --- /dev/null +++ b/ChangeLog.lbafix @@ -0,0 +1,5 @@ +2009-11-09 Vladimir Serbinenko + + * kern/i386/pc/startup.S (grub_biosdisk_get_diskinfo_int13_extensions): + Ignore return status if CF is cleared. + From 39f7c91b5088152adfd8a4e851a9d425125681b3 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 10 Nov 2009 01:01:11 +0100 Subject: [PATCH 012/208] base for ciphers and digests --- import_gcry.py | 31 ++++++++++++--- include/grub/crypto.h | 85 ++++++++++++++++++++++++++++++---------- include/grub/gcry_wrap.h | 33 ++++++++++++++++ kern/crypto.c | 4 +- 4 files changed, 126 insertions(+), 27 deletions(-) diff --git a/import_gcry.py b/import_gcry.py index 738c2c479..cc06142e6 100644 --- a/import_gcry.py +++ b/import_gcry.py @@ -33,6 +33,7 @@ for cipher_file in cipher_files: fw.write ("/* This file was automatically imported with \n") fw.write (" import_gcry.py. Please don't modify it */\n"); ciphernames = [] + mdnames = [] for line in f: m = re.match ("#include <.*>", line) if not m is None: @@ -49,9 +50,21 @@ for cipher_file in cipher_files: ciphername = line [len ("gcry_cipher_spec_t"):].strip () ciphername = re.match("[a-zA-Z0-9_]*",ciphername).group () ciphernames.append (ciphername) + m = re.match ("gcry_md_spec_t", line) + if isc and not m is None: + mdname = line [len ("gcry_md_spec_t"):].strip () + mdname = re.match("[a-zA-Z0-9_]*",mdname).group () + mdnames.append (mdname) fw.write (line) - if len (ciphernames) > 0: + if len (ciphernames) > 0 or len (mdnames) > 0: modname = cipher_file [0:len(cipher_file) - 2] + if re.match (".*-glue$", modname): + modfiles = "gcry/cipher/%s gcry/cipher/%s" \ + % (cipher_file, cipher_file.replace ("-glue.c", ".c")) + modname = modname.replace ("-glue", "") + else: + modfiles = "gcry/cipher/%s" % cipher_file + modname = "gcry_%s" % modname chmsg = "(GRUB_MOD_INIT(%s)): New function\n" % modname if nch: chlognew = "%s\n %s" % (chlognew, chmsg) @@ -64,6 +77,10 @@ for cipher_file in cipher_files: chmsg = "Register cipher %s" % ciphername chlognew = "%s\n %s" % (chlognew, chmsg) fw.write (" grub_cipher_register (&%s);\n" % ciphername) + for mdname in mdnames: + chmsg = "Register digest %s" % mdname + chlognew = "%s\n %s" % (chlognew, chmsg) + fw.write (" grub_md_register (&%s);\n" % mdname) fw.write ("}") chmsg = "(GRUB_MOD_FINI(%s)): New function\n" % modname chlognew = "%s\n %s" % (chlognew, chmsg) @@ -73,14 +90,18 @@ for cipher_file in cipher_files: chmsg = "Unregister cipher %s" % ciphername chlognew = "%s\n %s" % (chlognew, chmsg) fw.write (" grub_cipher_unregister (&%s);\n" % ciphername) + for mdname in mdnames: + chmsg = "Unregister MD %s" % mdname + chlognew = "%s\n %s" % (chlognew, chmsg) + fw.write (" grub_md_unregister (&%s);\n" % mdname) fw.write ("}\n") conf.write ("pkglib_MODULES += %s.mod\n" % modname) - conf.write ("%s_mod_SOURCES = gcry/cipher/%s\n" %\ - (modname, cipher_file)) + conf.write ("%s_mod_SOURCES = %s\n" %\ + (modname, modfiles)) conf.write ("%s_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-missing-field-initializers -Wno-error\n" % modname) conf.write ("%s_mod_LDFLAGS = $(COMMON_LDFLAGS)\n\n" % modname) - elif isc: - print ("WARNING: c file isn't a module: %s" % cipher_file) + elif isc and cipher_file != "camellia.c": + print ("WARNING: C file isn't a module: %s" % cipher_file) f.close () fw.close () if nch: diff --git a/include/grub/crypto.h b/include/grub/crypto.h index ab482f467..bd236116d 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -123,6 +123,7 @@ typedef struct gcry_cipher_spec gcry_cipher_decrypt_t decrypt; gcry_cipher_stencrypt_t stencrypt; gcry_cipher_stdecrypt_t stdecrypt; + struct gcry_cipher_spec *next; } gcry_cipher_spec_t; /* Definition of a function used to report selftest failures. @@ -154,33 +155,75 @@ typedef struct cipher_extra_spec cipher_set_extra_info_t set_extra_info; } cipher_extra_spec_t; -/* (Forward declaration.) */ -struct gcry_md_context; +/* Type for the md_init function. */ +typedef void (*gcry_md_init_t) (void *c); -/* This object is used to hold a handle to a message digest object. - This structure is private - only to be used by the public gcry_md_* - macros. */ -typedef struct gcry_md_handle +/* Type for the md_write function. */ +typedef void (*gcry_md_write_t) (void *c, const void *buf, grub_size_t nbytes); + +/* Type for the md_final function. */ +typedef void (*gcry_md_final_t) (void *c); + +/* Type for the md_read function. */ +typedef unsigned char *(*gcry_md_read_t) (void *c); + +typedef struct gcry_md_oid_spec { - /* Actual context. */ - struct gcry_md_context *ctx; - - /* Buffer management. */ - int bufpos; - int bufsize; - unsigned char buf[1]; -} *gcry_md_hd_t; + const char *oidstring; +} gcry_md_oid_spec_t; - -struct grub_cipher +/* Module specification structure for message digests. */ +typedef struct gcry_md_spec { - struct grub_cipher *next; const char *name; -}; -typedef struct grub_cipher *grub_cipher_t; + unsigned char *asnoid; + int asnlen; + gcry_md_oid_spec_t *oids; + int mdlen; + gcry_md_init_t init; + gcry_md_write_t write; + gcry_md_final_t final; + gcry_md_read_t read; + grub_size_t contextsize; /* allocate this amount of context */ + struct gcry_md_spec *next; +} gcry_md_spec_t; + +extern gcry_cipher_spec_t *EXPORT_VAR (grub_ciphers); +extern gcry_md_spec_t *EXPORT_VAR (grub_digests); + +static inline void +grub_cipher_register (gcry_cipher_spec_t *cipher) +{ + cipher->next = grub_ciphers; + grub_ciphers = cipher; +} + +static inline void +grub_cipher_unregister (gcry_cipher_spec_t *cipher) +{ + gcry_cipher_spec_t **ciph; + for (ciph = &grub_ciphers; *ciph; ciph = &((*ciph)->next)) + if (*ciph == cipher) + *ciph = (*ciph)->next; +} + +static inline void +grub_md_register (gcry_md_spec_t *digest) +{ + digest->next = grub_digests; + grub_digests = digest; +} + +static inline void +grub_md_unregister (gcry_md_spec_t *cipher) +{ + gcry_md_spec_t **ciph; + for (ciph = &grub_digests; *ciph; ciph = &((*ciph)->next)) + if (*ciph == cipher) + *ciph = (*ciph)->next; +} + -extern grub_cipher_t EXPORT_VAR (grub_ciphers); void EXPORT_FUNC(grub_burn_stack) (grub_size_t size); - #endif diff --git a/include/grub/gcry_wrap.h b/include/grub/gcry_wrap.h index 6f415a2e5..37a1ee4d7 100644 --- a/include/grub/gcry_wrap.h +++ b/include/grub/gcry_wrap.h @@ -27,12 +27,45 @@ #define __GNU_LIBRARY__ +#define DIM ARRAY_SIZE + +typedef grub_uint64_t u64; typedef grub_uint32_t u32; typedef grub_uint16_t u16; typedef grub_uint8_t byte; typedef grub_size_t size_t; +#define U64_C(c) (c ## ULL) + #define _gcry_burn_stack grub_burn_stack #define log_error(fmt, args...) grub_dprintf ("crypto", fmt, ## args) + +#define PUBKEY_FLAG_NO_BLINDING (1 << 0) + +#define CIPHER_INFO_NO_WEAK_KEY 1 + +#define HAVE_U64_TYPEDEF 1 + +typedef union { + int a; + short b; + char c[1]; + long d; +#ifdef HAVE_U64_TYPEDEF + u64 e; +#endif + float f; + double g; +} PROPERLY_ALIGNED_TYPE; + +#define gcry_assert(x) grub_assert_real(__FILE__, __LINE__, x) + +static inline void +grub_assert_real (const char *file, int line, int cond) +{ + if (cond) + grub_fatal ("Assertion failed at %s:%d\n", file, line); +} + #endif diff --git a/kern/crypto.c b/kern/crypto.c index 7dd00c84d..83e2d96df 100644 --- a/kern/crypto.c +++ b/kern/crypto.c @@ -18,8 +18,10 @@ */ #include #include +#include -grub_cipher_t grub_ciphers; +gcry_cipher_spec_t *grub_ciphers = NULL; +gcry_md_spec_t *grub_digests = NULL; /* Based on libgcrypt-1.4.4/src/misc.c. */ void From 9f08f2a1fd8104b9038c14c8f3d487d4fa192837 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 10 Nov 2009 20:46:05 +0100 Subject: [PATCH 013/208] bugfix burn_stack --- kern/crypto.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kern/crypto.c b/kern/crypto.c index 83e2d96df..d097e1668 100644 --- a/kern/crypto.c +++ b/kern/crypto.c @@ -30,7 +30,6 @@ grub_burn_stack (grub_size_t size) char buf[64]; grub_memset (buf, 0, sizeof (buf)); - size -= sizeof (buf); - if (size > 0) - grub_burn_stack (size); + if (size > sizeof (buf)) + grub_burn_stack (size - sizeof (buf)); } From 20de16bb918776f0183069c82d5afa3356e0f809 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 10 Nov 2009 20:47:06 +0100 Subject: [PATCH 014/208] bugfix burn_stack --- commands/xnu_uuid.c | 311 ++------------------------------------------ conf/i386-pc.rmk | 2 +- 2 files changed, 13 insertions(+), 300 deletions(-) diff --git a/commands/xnu_uuid.c b/commands/xnu_uuid.c index 06e88e560..d7f86276b 100644 --- a/commands/xnu_uuid.c +++ b/commands/xnu_uuid.c @@ -31,12 +31,9 @@ #include #include #include +#include -struct tohash -{ - grub_uint8_t prefix[16]; - grub_uint64_t serial; -} __attribute__ ((packed)); +extern gcry_md_spec_t _gcry_digest_spec_md5; /* This prefix is used by xnu and boot-132 to hash together with volume serial. */ @@ -44,311 +41,27 @@ static grub_uint8_t hash_prefix[16] = {0xB3, 0xE2, 0x0F, 0x39, 0xF2, 0x92, 0x11, 0xD6, 0x97, 0xA4, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC}; -#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) ) -#define ror(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) ) - -typedef struct { - grub_uint32_t A,B,C,D; /* chaining variables */ - grub_uint32_t nblocks; - grub_uint8_t buf[64]; - int count; -} MD5_CONTEXT; - -static void -md5_init( void *context ) -{ - MD5_CONTEXT *ctx = context; - - ctx->A = 0x67452301; - ctx->B = 0xefcdab89; - ctx->C = 0x98badcfe; - ctx->D = 0x10325476; - - ctx->nblocks = 0; - ctx->count = 0; -} - -/* These are the four functions used in the four steps of the MD5 algorithm - and defined in the RFC 1321. The first function is a little bit optimized - (as found in Colin Plumbs public domain implementation). */ -/* #define FF(b, c, d) ((b & c) | (~b & d)) */ -#define FF(b, c, d) (d ^ (b & (c ^ d))) -#define FG(b, c, d) FF (d, b, c) -#define FH(b, c, d) (b ^ c ^ d) -#define FI(b, c, d) (c ^ (b | ~d)) - - -/**************** - * transform n*64 grub_uint8_ts - */ -static void -transform ( MD5_CONTEXT *ctx, const unsigned char *data ) -{ - grub_uint32_t correct_words[16]; - register grub_uint32_t A = ctx->A; - register grub_uint32_t B = ctx->B; - register grub_uint32_t C = ctx->C; - register grub_uint32_t D = ctx->D; - grub_uint32_t *cwp = correct_words; - -#ifdef GRUB_CPU_WORDS_BIGENDIAN - { - int i; - const grub_uint32_t *p = (const grub_uint32_t *) data; - - for (i = 0; i < 16; i++) - correct_words[i] = grub_le_to_cpu32 (p[i]); - } -#else - grub_memcpy (correct_words, data, 64); -#endif - -#define OP(a, b, c, d, s, T) \ - do \ - { \ - a += FF (b, c, d) + (*cwp++) + T; \ - a = rol(a, s); \ - a += b; \ - } \ - while (0) - - /* Before we start, one word about the strange constants. - They are defined in RFC 1321 as - - T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 - */ - - /* Round 1. */ - OP (A, B, C, D, 7, 0xd76aa478); - OP (D, A, B, C, 12, 0xe8c7b756); - OP (C, D, A, B, 17, 0x242070db); - OP (B, C, D, A, 22, 0xc1bdceee); - OP (A, B, C, D, 7, 0xf57c0faf); - OP (D, A, B, C, 12, 0x4787c62a); - OP (C, D, A, B, 17, 0xa8304613); - OP (B, C, D, A, 22, 0xfd469501); - OP (A, B, C, D, 7, 0x698098d8); - OP (D, A, B, C, 12, 0x8b44f7af); - OP (C, D, A, B, 17, 0xffff5bb1); - OP (B, C, D, A, 22, 0x895cd7be); - OP (A, B, C, D, 7, 0x6b901122); - OP (D, A, B, C, 12, 0xfd987193); - OP (C, D, A, B, 17, 0xa679438e); - OP (B, C, D, A, 22, 0x49b40821); - -#undef OP -#define OP(f, a, b, c, d, k, s, T) \ - do \ - { \ - a += f (b, c, d) + correct_words[k] + T; \ - a = rol(a, s); \ - a += b; \ - } \ - while (0) - - /* Round 2. */ - OP (FG, A, B, C, D, 1, 5, 0xf61e2562); - OP (FG, D, A, B, C, 6, 9, 0xc040b340); - OP (FG, C, D, A, B, 11, 14, 0x265e5a51); - OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); - OP (FG, A, B, C, D, 5, 5, 0xd62f105d); - OP (FG, D, A, B, C, 10, 9, 0x02441453); - OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); - OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); - OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); - OP (FG, D, A, B, C, 14, 9, 0xc33707d6); - OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); - OP (FG, B, C, D, A, 8, 20, 0x455a14ed); - OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); - OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); - OP (FG, C, D, A, B, 7, 14, 0x676f02d9); - OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); - - /* Round 3. */ - OP (FH, A, B, C, D, 5, 4, 0xfffa3942); - OP (FH, D, A, B, C, 8, 11, 0x8771f681); - OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); - OP (FH, B, C, D, A, 14, 23, 0xfde5380c); - OP (FH, A, B, C, D, 1, 4, 0xa4beea44); - OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); - OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); - OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); - OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); - OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); - OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); - OP (FH, B, C, D, A, 6, 23, 0x04881d05); - OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); - OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); - OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); - OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); - - /* Round 4. */ - OP (FI, A, B, C, D, 0, 6, 0xf4292244); - OP (FI, D, A, B, C, 7, 10, 0x432aff97); - OP (FI, C, D, A, B, 14, 15, 0xab9423a7); - OP (FI, B, C, D, A, 5, 21, 0xfc93a039); - OP (FI, A, B, C, D, 12, 6, 0x655b59c3); - OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); - OP (FI, C, D, A, B, 10, 15, 0xffeff47d); - OP (FI, B, C, D, A, 1, 21, 0x85845dd1); - OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); - OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); - OP (FI, C, D, A, B, 6, 15, 0xa3014314); - OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); - OP (FI, A, B, C, D, 4, 6, 0xf7537e82); - OP (FI, D, A, B, C, 11, 10, 0xbd3af235); - OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); - OP (FI, B, C, D, A, 9, 21, 0xeb86d391); - - /* Put checksum in context given as argument. */ - ctx->A += A; - ctx->B += B; - ctx->C += C; - ctx->D += D; -} - -/* The routine updates the message-digest context to - * account for the presence of each of the characters inBuf[0..inLen-1] - * in the message whose digest is being computed. - */ -static void -md5_write( void *context, const void *inbuf_arg , grub_size_t inlen) -{ - const unsigned char *inbuf = inbuf_arg; - MD5_CONTEXT *hd = context; - - if( hd->count == 64 ) /* flush the buffer */ - { - transform( hd, hd->buf ); - // _gcry_burn_stack (80+6*sizeof(void*)); - hd->count = 0; - hd->nblocks++; - } - if( !inbuf ) - return; - - if( hd->count ) - { - for( ; inlen && hd->count < 64; inlen-- ) - hd->buf[hd->count++] = *inbuf++; - md5_write( hd, NULL, 0 ); - if( !inlen ) - return; - } - // _gcry_burn_stack (80+6*sizeof(void*)); - - while( inlen >= 64 ) - { - transform( hd, inbuf ); - hd->count = 0; - hd->nblocks++; - inlen -= 64; - inbuf += 64; - } - for( ; inlen && hd->count < 64; inlen-- ) - hd->buf[hd->count++] = *inbuf++; - -} - - - -/* The routine final terminates the message-digest computation and - * ends with the desired message digest in mdContext->digest[0...15]. - * The handle is prepared for a new MD5 cycle. - * Returns 16 grub_uint8_ts representing the digest. - */ -static void -md5_final( void *context) -{ - MD5_CONTEXT *hd = context; - grub_uint32_t t, msb, lsb; - grub_uint32_t *p; - - md5_write(hd, NULL, 0); /* flush */; - - t = hd->nblocks; - /* multiply by 64 to make a grub_uint8_t count */ - lsb = t << 6; - msb = t >> 26; - /* add the count */ - t = lsb; - if( (lsb += hd->count) < t ) - msb++; - /* multiply by 8 to make a bit count */ - t = lsb; - lsb <<= 3; - msb <<= 3; - msb |= t >> 29; - - if( hd->count < 56 ) /* enough room */ - { - hd->buf[hd->count++] = 0x80; /* pad */ - while( hd->count < 56 ) - hd->buf[hd->count++] = 0; /* pad */ - } - else /* need one extra block */ - { - hd->buf[hd->count++] = 0x80; /* pad character */ - while( hd->count < 64 ) - hd->buf[hd->count++] = 0; - md5_write(hd, NULL, 0); /* flush */; - grub_memset(hd->buf, 0, 56 ); /* fill next block with zeroes */ - } - /* append the 64 bit count */ - hd->buf[56] = lsb ; - hd->buf[57] = lsb >> 8; - hd->buf[58] = lsb >> 16; - hd->buf[59] = lsb >> 24; - hd->buf[60] = msb ; - hd->buf[61] = msb >> 8; - hd->buf[62] = msb >> 16; - hd->buf[63] = msb >> 24; - transform( hd, hd->buf ); - // _gcry_burn_stack (80+6*sizeof(void*)); - - p = (grub_uint32_t *) hd->buf; -#define X(a) do { *p = grub_le_to_cpu32 (hd->a); p++; } while (0) - X(A); - X(B); - X(C); - X(D); -#undef X - -} - -/** - * GRUB2 Crypto Interface - * Written by Michael Gorven - */ -static grub_err_t -md5 (const char *in, grub_size_t insize, char *out) -{ - MD5_CONTEXT hd; - - md5_init (&hd); - md5_write (&hd, in, insize); - md5_final (&hd); - grub_memcpy (out, hd.buf, 16); - - return GRUB_ERR_NONE; -} - static grub_err_t grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) { - struct tohash hashme; - grub_uint8_t xnu_uuid[16]; + grub_uint64_t serial; + grub_uint8_t *xnu_uuid; char uuid_string[sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]; char *ptr; + grub_uint8_t ctx[_gcry_digest_spec_md5.contextsize]; if (argc < 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "UUID required"); - hashme.serial = grub_cpu_to_be64 (grub_strtoull (args[0], 0, 16)); - grub_memcpy (hashme.prefix, hash_prefix, sizeof (hashme.prefix)); + serial = grub_cpu_to_be64 (grub_strtoull (args[0], 0, 16)); + + _gcry_digest_spec_md5.init (&ctx); + _gcry_digest_spec_md5.write (&ctx, hash_prefix, sizeof (hash_prefix)); + _gcry_digest_spec_md5.write (&ctx, &serial, sizeof (serial)); + _gcry_digest_spec_md5.final (&ctx); + xnu_uuid = _gcry_digest_spec_md5.read (&ctx); - md5 ((char *) &hashme, sizeof (hashme), (char *) xnu_uuid); grub_sprintf (uuid_string, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", (unsigned int) xnu_uuid[0], (unsigned int) xnu_uuid[1], diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 0e3291782..45e1ccf91 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -125,7 +125,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.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/gptsync.c commands/probe.c \ commands/i386/cpuid.c \ commands/password.c commands/keystatus.c \ disk/host.c disk/loopback.c disk/scsi.c \ From a4bafc47107165a839d6aec22e4cef1724785914 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 10 Nov 2009 20:51:22 +0100 Subject: [PATCH 015/208] First working cipher import --- import_gcry.py | 90 +++++++++++++++++++-- include/grub/{gcry_wrap.h => cipher_wrap.h} | 13 +++ include/grub/crypto.h | 1 + 3 files changed, 99 insertions(+), 5 deletions(-) rename include/grub/{gcry_wrap.h => cipher_wrap.h} (92%) diff --git a/import_gcry.py b/import_gcry.py index cc06142e6..9a53a356a 100644 --- a/import_gcry.py +++ b/import_gcry.py @@ -10,10 +10,17 @@ indir = sys.argv[1] outdir = sys.argv[2] basedir = os.path.join (outdir, "gcry") -os.makedirs (basedir) +try: + os.makedirs (basedir) +except: + print ("WARNING: %s already exists" % basedir) cipher_dir_in = os.path.join (indir, "cipher") cipher_dir_out = os.path.join (basedir, "cipher") -os.makedirs (cipher_dir_out) +try: + os.makedirs (cipher_dir_out) +except: + print ("WARNING: %s already exists" % cipher_dir_out) + cipher_files = os.listdir (cipher_dir_in) conf = open (os.path.join (outdir, "conf", "gcry.rmk"), "w") conf.write ("# -*- makefile -*-\n\n") @@ -34,7 +41,33 @@ for cipher_file in cipher_files: fw.write (" import_gcry.py. Please don't modify it */\n"); ciphernames = [] mdnames = [] + hold = False + skip = False + skip2 = False for line in f: + if skip: + if line[0] == "}": + skip = False + continue + if skip2: + if not re.search (" *};", line) is None: + skip2 = False + continue + if hold: + hold = False + # We're optimising for size. + elif not re.match ("(run_selftests|selftest|_gcry_aes_c.._..c|_gcry_[a-z0-9]*_hash_buffer)", line) is None: + skip = True + fname = re.match ("[a-zA-Z0-9_]*", line).group () + chmsg = "(%s): Removed." % fname + if nch: + chlognew = "%s\n %s" % (chlognew, chmsg) + else: + chlognew = "%s %s" % (chlognew, chmsg) + nch = True + continue + else: + fw.write (holdline) m = re.match ("#include <.*>", line) if not m is None: chmsg = "Removed including of %s" % \ @@ -55,6 +88,46 @@ for cipher_file in cipher_files: mdname = line [len ("gcry_md_spec_t"):].strip () mdname = re.match("[a-zA-Z0-9_]*",mdname).group () mdnames.append (mdname) + m = re.match ("static const char \*selftest.*;$", line) + if not m is None: + fname = line[len ("static const char \*"):] + fname = re.match ("[a-zA-Z0-9_]*", fname).group () + chmsg = "(%s): Removed declaration." % fname + if nch: + chlognew = "%s\n %s" % (chlognew, chmsg) + else: + chlognew = "%s %s" % (chlognew, chmsg) + nch = True + continue + m = re.match ("(static const char( |)\*|static gpg_err_code_t|void)$", line) + if not m is None: + hold = True + holdline = line + continue + m = re.match ("cipher_extra_spec_t", line) + if isc and not m is None: + skip2 = True + fname = line[len ("cipher_extra_spec_t "):] + fname = re.match ("[a-zA-Z0-9_]*", fname).group () + chmsg = "(%s): Removed." % fname + if nch: + chlognew = "%s\n %s" % (chlognew, chmsg) + else: + chlognew = "%s %s" % (chlognew, chmsg) + nch = True + continue + m = re.match ("md_extra_spec_t", line) + if isc and not m is None: + skip2 = True + fname = line[len ("md_extra_spec_t "):] + fname = re.match ("[a-zA-Z0-9_]*", fname).group () + chmsg = "(%s): Removed." % fname + if nch: + chlognew = "%s\n %s" % (chlognew, chmsg) + else: + chlognew = "%s %s" % (chlognew, chmsg) + nch = True + continue fw.write (line) if len (ciphernames) > 0 or len (mdnames) > 0: modname = cipher_file [0:len(cipher_file) - 2] @@ -120,20 +193,27 @@ for cipher_file in cipher_files: outfile = os.path.join (cipher_dir_out, "types.h") fw=open (outfile, "w") fw.write ("#include \n") -fw.write ("#include \n") +fw.write ("#include \n") chlog = "%s * types.h: New file.\n" % chlog fw.close () +outfile = os.path.join (cipher_dir_out, "memory.h") +fw=open (outfile, "w") +fw.write ("#include \n") +chlog = "%s * memory.h: New file.\n" % chlog +fw.close () + + outfile = os.path.join (cipher_dir_out, "cipher.h") fw=open (outfile, "w") fw.write ("#include \n") -fw.write ("#include \n") +fw.write ("#include \n") chlog = "%s * cipher.h: Likewise.\n" % chlog fw.close () outfile = os.path.join (cipher_dir_out, "g10lib.h") fw=open (outfile, "w") -fw.write ("#include \n") +fw.write ("#include \n") chlog = "%s * g10lib.h: Likewise.\n" % chlog fw.close () diff --git a/include/grub/gcry_wrap.h b/include/grub/cipher_wrap.h similarity index 92% rename from include/grub/gcry_wrap.h rename to include/grub/cipher_wrap.h index 37a1ee4d7..9e6242b7f 100644 --- a/include/grub/gcry_wrap.h +++ b/include/grub/cipher_wrap.h @@ -68,4 +68,17 @@ grub_assert_real (const char *file, int line, int cond) grub_fatal ("Assertion failed at %s:%d\n", file, line); } +/* Selftests are in separate modules. */ +static inline char * +selftest (void) +{ + return NULL; +} + +static inline int +fips_mode (void) +{ + return 0; +} + #endif diff --git a/include/grub/crypto.h b/include/grub/crypto.h index bd236116d..17f14de86 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -64,6 +64,7 @@ typedef enum GPG_ERR_WRONG_PUBKEY_ALGO, } gcry_err_code_t; #define gpg_err_code_t gcry_err_code_t +#define gpg_error_t gcry_err_code_t enum gcry_cipher_modes { From 63d7ad01ebf629007f8f42a9d3ae32a81d8fa805 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 10 Nov 2009 20:59:09 +0100 Subject: [PATCH 016/208] Fixed splitting error --- import_gcry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/import_gcry.py b/import_gcry.py index 9a53a356a..ca03729af 100644 --- a/import_gcry.py +++ b/import_gcry.py @@ -56,7 +56,7 @@ for cipher_file in cipher_files: if hold: hold = False # We're optimising for size. - elif not re.match ("(run_selftests|selftest|_gcry_aes_c.._..c|_gcry_[a-z0-9]*_hash_buffer)", line) is None: + if not re.match ("(run_selftests|selftest|_gcry_aes_c.._..c|_gcry_[a-z0-9]*_hash_buffer)", line) is None: skip = True fname = re.match ("[a-zA-Z0-9_]*", line).group () chmsg = "(%s): Removed." % fname From 414f919237bd02e53a11066fcdc0c08e9adc8e2e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 12 Nov 2009 18:08:44 +0100 Subject: [PATCH 017/208] Various cleanups and wrapper functions. Allocate disk id for LUKS. --- commands/xnu_uuid.c | 14 ++- import_gcry.py | 28 ++++++ include/grub/crypto.h | 202 +++++++++++++++++++++++++++++++++++------- include/grub/disk.h | 1 + 4 files changed, 206 insertions(+), 39 deletions(-) diff --git a/commands/xnu_uuid.c b/commands/xnu_uuid.c index d7f86276b..48c67d18e 100644 --- a/commands/xnu_uuid.c +++ b/commands/xnu_uuid.c @@ -33,8 +33,6 @@ #include #include -extern gcry_md_spec_t _gcry_digest_spec_md5; - /* This prefix is used by xnu and boot-132 to hash together with volume serial. */ static grub_uint8_t hash_prefix[16] @@ -49,18 +47,18 @@ grub_cmd_xnu_uuid (grub_command_t cmd __attribute__ ((unused)), grub_uint8_t *xnu_uuid; char uuid_string[sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]; char *ptr; - grub_uint8_t ctx[_gcry_digest_spec_md5.contextsize]; + grub_uint8_t ctx[GRUB_MD_MD5->contextsize]; if (argc < 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "UUID required"); serial = grub_cpu_to_be64 (grub_strtoull (args[0], 0, 16)); - _gcry_digest_spec_md5.init (&ctx); - _gcry_digest_spec_md5.write (&ctx, hash_prefix, sizeof (hash_prefix)); - _gcry_digest_spec_md5.write (&ctx, &serial, sizeof (serial)); - _gcry_digest_spec_md5.final (&ctx); - xnu_uuid = _gcry_digest_spec_md5.read (&ctx); + GRUB_MD_MD5->init (&ctx); + GRUB_MD_MD5->write (&ctx, hash_prefix, sizeof (hash_prefix)); + GRUB_MD_MD5->write (&ctx, &serial, sizeof (serial)); + GRUB_MD_MD5->final (&ctx); + xnu_uuid = GRUB_MD_MD5->read (&ctx); grub_sprintf (uuid_string, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", diff --git a/import_gcry.py b/import_gcry.py index ca03729af..39542d8c4 100644 --- a/import_gcry.py +++ b/import_gcry.py @@ -26,6 +26,20 @@ conf = open (os.path.join (outdir, "conf", "gcry.rmk"), "w") conf.write ("# -*- makefile -*-\n\n") chlog = "" +mdblocksizes = {"_gcry_digest_spec_crc32" : 1, + "_gcry_digest_spec_crc32_rfc1510" : 1, + "_gcry_digest_spec_crc24_rfc2440" : 1, + "_gcry_digest_spec_md4" : 64, + "_gcry_digest_spec_md5" : 64, + "_gcry_digest_spec_rmd160" : 64, + "_gcry_digest_spec_sha1" : 64, + "_gcry_digest_spec_sha224" : 64, + "_gcry_digest_spec_sha256" : 64, + "_gcry_digest_spec_sha384" : 128, + "_gcry_digest_spec_sha512" : 128, + "_gcry_digest_spec_tiger" : 64, + "_gcry_digest_spec_whirlpool" : 64} + for cipher_file in cipher_files: infile = os.path.join (cipher_dir_in, cipher_file) outfile = os.path.join (cipher_dir_out, cipher_file) @@ -44,6 +58,8 @@ for cipher_file in cipher_files: hold = False skip = False skip2 = False + ismd = False + iscomma = False for line in f: if skip: if line[0] == "}": @@ -53,6 +69,16 @@ for cipher_file in cipher_files: if not re.search (" *};", line) is None: skip2 = False continue + if ismd: + if not re.search (" *};", line) is None: + if not mdblocksizes.has_key (mdname): + print ("ERROR: Unknown digest blocksize: %s\n" % mdname) + exit (1) + if not iscomma: + fw.write (" ,\n") + fw.write (" .blocksize = %s\n" % mdblocksizes [mdname]) + ismd = False + iscomma = not re.search (",$", line) is None if hold: hold = False # We're optimising for size. @@ -85,9 +111,11 @@ for cipher_file in cipher_files: ciphernames.append (ciphername) m = re.match ("gcry_md_spec_t", line) if isc and not m is None: + assert (not ismd) mdname = line [len ("gcry_md_spec_t"):].strip () mdname = re.match("[a-zA-Z0-9_]*",mdname).group () mdnames.append (mdname) + ismd = True m = re.match ("static const char \*selftest.*;$", line) if not m is None: fname = line[len ("static const char \*"):] diff --git a/include/grub/crypto.h b/include/grub/crypto.h index 17f14de86..239b46666 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -25,6 +25,8 @@ #include #include +#include +#include typedef enum { @@ -127,35 +129,6 @@ typedef struct gcry_cipher_spec struct gcry_cipher_spec *next; } gcry_cipher_spec_t; -/* Definition of a function used to report selftest failures. - DOMAIN is a string describing the function block: - "cipher", "digest", "pubkey or "random", - ALGO is the algorithm under test, - WHAT is a string describing what has been tested, - DESC is a string describing the error. */ -typedef void (*selftest_report_func_t)(const char *domain, - int algo, - const char *what, - const char *errdesc); - -/* Definition of the selftest functions. */ -typedef gpg_err_code_t (*selftest_func_t) - (int algo, int extended, selftest_report_func_t report); - -/* The type used to convey additional information to a cipher. */ -typedef gpg_err_code_t (*cipher_set_extra_info_t) - (void *c, int what, const void *buffer, grub_size_t buflen); - - -/* Extra module specification structures. These are used for internal - modules which provide more functions than available through the - public algorithm register APIs. */ -typedef struct cipher_extra_spec -{ - selftest_func_t selftest; - cipher_set_extra_info_t set_extra_info; -} cipher_extra_spec_t; - /* Type for the md_init function. */ typedef void (*gcry_md_init_t) (void *c); @@ -180,12 +153,14 @@ typedef struct gcry_md_spec unsigned char *asnoid; int asnlen; gcry_md_oid_spec_t *oids; - int mdlen; + grub_size_t mdlen; gcry_md_init_t init; gcry_md_write_t write; gcry_md_final_t final; gcry_md_read_t read; grub_size_t contextsize; /* allocate this amount of context */ + /* Block size, needed for HMAC. */ + grub_size_t blocksize; struct gcry_md_spec *next; } gcry_md_spec_t; @@ -199,7 +174,7 @@ grub_cipher_register (gcry_cipher_spec_t *cipher) grub_ciphers = cipher; } -static inline void +static inline void grub_cipher_unregister (gcry_cipher_spec_t *cipher) { gcry_cipher_spec_t **ciph; @@ -224,7 +199,172 @@ grub_md_unregister (gcry_md_spec_t *cipher) *ciph = (*ciph)->next; } +static inline void +grub_crypto_hash (const gcry_md_spec_t *hash, void *out, void *in, + grub_size_t inlen) +{ + grub_uint8_t ctx[hash->contextsize]; + hash->init (&ctx); + hash->write (&ctx, in, inlen); + hash->final (&ctx); + grub_memcpy (out, hash->read (&ctx), hash->mdlen); +} + +static inline const gcry_md_spec_t * +grub_crypto_lookup_md_by_name (const char *name) +{ + const gcry_md_spec_t *md; + for (md = grub_digests; md; md = md->next) + if (grub_strcasecmp (name, md->name) == 0) + return md; + return NULL; +} + +typedef struct grub_crypto_cipher_handle +{ + const struct gcry_cipher_spec *cipher; + char ctx[0]; +} *grub_crypto_cipher_handle_t; + +static inline const gcry_cipher_spec_t * +grub_crypto_lookup_cipher_by_name (const char *name) +{ + const gcry_cipher_spec_t *ciph; + for (ciph = grub_ciphers; ciph; ciph = ciph->next) + { + const char **alias; + if (grub_strcasecmp (name, ciph->name) == 0) + return ciph; + if (!ciph->aliases) + continue; + for (alias = ciph->aliases; *alias; alias++) + if (grub_strcasecmp (name, *alias) == 0) + return ciph; + } + return NULL; +} + + +static inline grub_crypto_cipher_handle_t +grub_crypto_cipher_open (const struct gcry_cipher_spec *cipher) +{ + grub_crypto_cipher_handle_t ret; + ret = grub_malloc (sizeof (*ret) + cipher->contextsize); + if (!ret) + return NULL; + ret->cipher = cipher; + return ret; +} + +static inline gcry_err_code_t +grub_crypto_cipher_set_key (grub_crypto_cipher_handle_t cipher, + const unsigned char *key, + unsigned keylen) +{ + return cipher->cipher->setkey (cipher->ctx, key, keylen); +} + + +static inline void +grub_crypto_cipher_close (grub_crypto_cipher_handle_t cipher) +{ + grub_free (cipher); +} + + +static inline void +grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size) +{ + const grub_uint8_t *in1ptr = in1, *in2ptr = in2; + grub_uint8_t *outptr = out; + while (size--) + { + *outptr = *in1ptr ^ *in2ptr; + in1ptr++; + in2ptr++; + outptr++; + } +} + +static inline grub_err_t +grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher, + void *out, void *in, grub_size_t size) +{ + grub_uint8_t *inptr, *outptr, *end; + if (size % cipher->cipher->blocksize != 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "This encryption can't decrypt partial blocks"); + end = (grub_uint8_t *) in + size; + for (inptr = in, outptr = out; inptr < end; + inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + cipher->cipher->decrypt (cipher->ctx, outptr, inptr); + return GRUB_ERR_NONE; +} + +static inline grub_err_t +grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher, + void *out, void *in, grub_size_t size) +{ + grub_uint8_t *inptr, *outptr, *end; + if (size % cipher->cipher->blocksize != 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "This encryption can't decrypt partial blocks"); + end = (grub_uint8_t *) in + size; + for (inptr = in, outptr = out; inptr < end; + inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + cipher->cipher->encrypt (cipher->ctx, outptr, inptr); + return GRUB_ERR_NONE; +} + +static inline grub_err_t +grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher, + void *out, void *in, grub_size_t size, + void *iv_in) +{ + grub_uint8_t *inptr, *outptr, *end; + void *iv; + if (size % cipher->cipher->blocksize != 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "This encryption can't decrypt partial blocks"); + end = (grub_uint8_t *) in + size; + iv = iv_in; + for (inptr = in, outptr = out; inptr < end; + inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + { + grub_crypto_xor (outptr, inptr, iv, cipher->cipher->blocksize); + cipher->cipher->encrypt (cipher->ctx, outptr, outptr); + iv = outptr; + } + grub_memcpy (iv_in, iv, cipher->cipher->blocksize); + return GRUB_ERR_NONE; +} + +static inline grub_err_t +grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher, + void *out, void *in, grub_size_t size, + void *iv) +{ + grub_uint8_t *inptr, *outptr, *end; + grub_uint8_t ivt[cipher->cipher->blocksize]; + if (size % cipher->cipher->blocksize != 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "This encryption can't decrypt partial blocks"); + end = (grub_uint8_t *) in + size; + for (inptr = in, outptr = out; inptr < end; + inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + { + grub_memcpy (ivt, inptr, cipher->cipher->blocksize); + cipher->cipher->decrypt (cipher->ctx, outptr, inptr); + grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); + grub_memcpy (iv, ivt, cipher->cipher->blocksize); + } + return GRUB_ERR_NONE; +} + void EXPORT_FUNC(grub_burn_stack) (grub_size_t size); +extern gcry_md_spec_t _gcry_digest_spec_md5; +#define GRUB_MD_MD5 ((const gcry_md_spec_t *) &_gcry_digest_spec_md5) + #endif diff --git a/include/grub/disk.h b/include/grub/disk.h index de71bb588..cc801bc67 100644 --- a/include/grub/disk.h +++ b/include/grub/disk.h @@ -42,6 +42,7 @@ enum grub_disk_dev_id GRUB_DISK_DEVICE_PXE_ID, GRUB_DISK_DEVICE_SCSI_ID, GRUB_DISK_DEVICE_FILE_ID, + GRUB_DISK_DEVICE_LUKS_ID }; struct grub_disk; From d944246c6aa076458bc3ee4dbd8026e39015e8e8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 12 Nov 2009 22:40:14 +0100 Subject: [PATCH 018/208] Created crypto module. Moved some functions to it. --- conf/common.rmk | 5 + conf/i386-pc.rmk | 4 +- include/grub/crypto.h | 211 ++++++--------------------------------- lib/crypto.c | 225 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 263 insertions(+), 182 deletions(-) create mode 100644 lib/crypto.c diff --git a/conf/common.rmk b/conf/common.rmk index 0d19344a7..35b4620f4 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -619,4 +619,9 @@ setjmp_mod_SOURCES = lib/$(target_cpu)/setjmp.S setjmp_mod_ASFLAGS = $(COMMON_ASFLAGS) setjmp_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += crypto.mod +crypto_mod_SOURCES = lib/crypto.c +crypto_mod_CFLAGS = $(COMMON_CFLAGS) +crypto_mod_LDFLAGS = $(COMMON_LDFLAGS) + include $(srcdir)/conf/gcry.mk diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 45e1ccf91..ac9337e41 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -58,15 +58,13 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \ kern/generic/millisleep.c \ kern/env.c \ term/i386/pc/console.c term/i386/vga_common.c \ - kern/crypto.c \ 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 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 \ - crypto.h + machine/kernel.h machine/pxe.h i386/pit.h list.h handler.h command.h kernel_img_CFLAGS = $(COMMON_CFLAGS) $(TARGET_IMG_CFLAGS) kernel_img_ASFLAGS = $(COMMON_ASFLAGS) kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR) $(COMMON_CFLAGS) diff --git a/include/grub/crypto.h b/include/grub/crypto.h index 239b46666..5cd7f02b4 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -164,205 +164,58 @@ typedef struct gcry_md_spec struct gcry_md_spec *next; } gcry_md_spec_t; -extern gcry_cipher_spec_t *EXPORT_VAR (grub_ciphers); -extern gcry_md_spec_t *EXPORT_VAR (grub_digests); - -static inline void -grub_cipher_register (gcry_cipher_spec_t *cipher) -{ - cipher->next = grub_ciphers; - grub_ciphers = cipher; -} - -static inline void -grub_cipher_unregister (gcry_cipher_spec_t *cipher) -{ - gcry_cipher_spec_t **ciph; - for (ciph = &grub_ciphers; *ciph; ciph = &((*ciph)->next)) - if (*ciph == cipher) - *ciph = (*ciph)->next; -} - -static inline void -grub_md_register (gcry_md_spec_t *digest) -{ - digest->next = grub_digests; - grub_digests = digest; -} - -static inline void -grub_md_unregister (gcry_md_spec_t *cipher) -{ - gcry_md_spec_t **ciph; - for (ciph = &grub_digests; *ciph; ciph = &((*ciph)->next)) - if (*ciph == cipher) - *ciph = (*ciph)->next; -} - -static inline void -grub_crypto_hash (const gcry_md_spec_t *hash, void *out, void *in, - grub_size_t inlen) -{ - grub_uint8_t ctx[hash->contextsize]; - hash->init (&ctx); - hash->write (&ctx, in, inlen); - hash->final (&ctx); - grub_memcpy (out, hash->read (&ctx), hash->mdlen); -} - -static inline const gcry_md_spec_t * -grub_crypto_lookup_md_by_name (const char *name) -{ - const gcry_md_spec_t *md; - for (md = grub_digests; md; md = md->next) - if (grub_strcasecmp (name, md->name) == 0) - return md; - return NULL; -} - typedef struct grub_crypto_cipher_handle { const struct gcry_cipher_spec *cipher; char ctx[0]; } *grub_crypto_cipher_handle_t; -static inline const gcry_cipher_spec_t * -grub_crypto_lookup_cipher_by_name (const char *name) -{ - const gcry_cipher_spec_t *ciph; - for (ciph = grub_ciphers; ciph; ciph = ciph->next) - { - const char **alias; - if (grub_strcasecmp (name, ciph->name) == 0) - return ciph; - if (!ciph->aliases) - continue; - for (alias = ciph->aliases; *alias; alias++) - if (grub_strcasecmp (name, *alias) == 0) - return ciph; - } - return NULL; -} +const gcry_cipher_spec_t * +grub_crypto_lookup_cipher_by_name (const char *name); +grub_crypto_cipher_handle_t +grub_crypto_cipher_open (const struct gcry_cipher_spec *cipher); -static inline grub_crypto_cipher_handle_t -grub_crypto_cipher_open (const struct gcry_cipher_spec *cipher) -{ - grub_crypto_cipher_handle_t ret; - ret = grub_malloc (sizeof (*ret) + cipher->contextsize); - if (!ret) - return NULL; - ret->cipher = cipher; - return ret; -} - -static inline gcry_err_code_t +gcry_err_code_t grub_crypto_cipher_set_key (grub_crypto_cipher_handle_t cipher, const unsigned char *key, - unsigned keylen) -{ - return cipher->cipher->setkey (cipher->ctx, key, keylen); -} + unsigned keylen); +void +grub_crypto_cipher_close (grub_crypto_cipher_handle_t cipher); -static inline void -grub_crypto_cipher_close (grub_crypto_cipher_handle_t cipher) -{ - grub_free (cipher); -} - - -static inline void -grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size) -{ - const grub_uint8_t *in1ptr = in1, *in2ptr = in2; - grub_uint8_t *outptr = out; - while (size--) - { - *outptr = *in1ptr ^ *in2ptr; - in1ptr++; - in2ptr++; - outptr++; - } -} - -static inline grub_err_t +void +grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size); +grub_err_t grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher, - void *out, void *in, grub_size_t size) -{ - grub_uint8_t *inptr, *outptr, *end; - if (size % cipher->cipher->blocksize != 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "This encryption can't decrypt partial blocks"); - end = (grub_uint8_t *) in + size; - for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) - cipher->cipher->decrypt (cipher->ctx, outptr, inptr); - return GRUB_ERR_NONE; -} + void *out, void *in, grub_size_t size); -static inline grub_err_t +grub_err_t grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher, - void *out, void *in, grub_size_t size) -{ - grub_uint8_t *inptr, *outptr, *end; - if (size % cipher->cipher->blocksize != 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "This encryption can't decrypt partial blocks"); - end = (grub_uint8_t *) in + size; - for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) - cipher->cipher->encrypt (cipher->ctx, outptr, inptr); - return GRUB_ERR_NONE; -} - -static inline grub_err_t + void *out, void *in, grub_size_t size); +grub_err_t grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size, - void *iv_in) -{ - grub_uint8_t *inptr, *outptr, *end; - void *iv; - if (size % cipher->cipher->blocksize != 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "This encryption can't decrypt partial blocks"); - end = (grub_uint8_t *) in + size; - iv = iv_in; - for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) - { - grub_crypto_xor (outptr, inptr, iv, cipher->cipher->blocksize); - cipher->cipher->encrypt (cipher->ctx, outptr, outptr); - iv = outptr; - } - grub_memcpy (iv_in, iv, cipher->cipher->blocksize); - return GRUB_ERR_NONE; -} - -static inline grub_err_t + void *iv_in); +grub_err_t grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size, - void *iv) -{ - grub_uint8_t *inptr, *outptr, *end; - grub_uint8_t ivt[cipher->cipher->blocksize]; - if (size % cipher->cipher->blocksize != 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "This encryption can't decrypt partial blocks"); - end = (grub_uint8_t *) in + size; - for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) - { - grub_memcpy (ivt, inptr, cipher->cipher->blocksize); - cipher->cipher->decrypt (cipher->ctx, outptr, inptr); - grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); - grub_memcpy (iv, ivt, cipher->cipher->blocksize); - } - return GRUB_ERR_NONE; -} + void *iv); +void +grub_cipher_register (gcry_cipher_spec_t *cipher); +void +grub_cipher_unregister (gcry_cipher_spec_t *cipher); +void +grub_md_register (gcry_md_spec_t *digest); +void +grub_md_unregister (gcry_md_spec_t *cipher); +void +grub_crypto_hash (const gcry_md_spec_t *hash, void *out, void *in, + grub_size_t inlen); +const gcry_md_spec_t * +grub_crypto_lookup_md_by_name (const char *name); - -void EXPORT_FUNC(grub_burn_stack) (grub_size_t size); +void grub_burn_stack (grub_size_t size); extern gcry_md_spec_t _gcry_digest_spec_md5; #define GRUB_MD_MD5 ((const gcry_md_spec_t *) &_gcry_digest_spec_md5) diff --git a/lib/crypto.c b/lib/crypto.c new file mode 100644 index 000000000..64c386dae --- /dev/null +++ b/lib/crypto.c @@ -0,0 +1,225 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 + * 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 + * 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 + +static gcry_cipher_spec_t *grub_ciphers = NULL; +static gcry_md_spec_t *grub_digests = NULL; + +/* Based on libgcrypt-1.4.4/src/misc.c. */ +void +grub_burn_stack (grub_size_t size) +{ + char buf[64]; + + grub_memset (buf, 0, sizeof (buf)); + if (size > sizeof (buf)) + grub_burn_stack (size - sizeof (buf)); +} + + +void +grub_cipher_register (gcry_cipher_spec_t *cipher) +{ + cipher->next = grub_ciphers; + grub_ciphers = cipher; +} + +void +grub_cipher_unregister (gcry_cipher_spec_t *cipher) +{ + gcry_cipher_spec_t **ciph; + for (ciph = &grub_ciphers; *ciph; ciph = &((*ciph)->next)) + if (*ciph == cipher) + *ciph = (*ciph)->next; +} + +void +grub_md_register (gcry_md_spec_t *digest) +{ + digest->next = grub_digests; + grub_digests = digest; +} + +void +grub_md_unregister (gcry_md_spec_t *cipher) +{ + gcry_md_spec_t **ciph; + for (ciph = &grub_digests; *ciph; ciph = &((*ciph)->next)) + if (*ciph == cipher) + *ciph = (*ciph)->next; +} + +void +grub_crypto_hash (const gcry_md_spec_t *hash, void *out, void *in, + grub_size_t inlen) +{ + grub_uint8_t ctx[hash->contextsize]; + hash->init (&ctx); + hash->write (&ctx, in, inlen); + hash->final (&ctx); + grub_memcpy (out, hash->read (&ctx), hash->mdlen); +} + +const gcry_md_spec_t * +grub_crypto_lookup_md_by_name (const char *name) +{ + const gcry_md_spec_t *md; + for (md = grub_digests; md; md = md->next) + if (grub_strcasecmp (name, md->name) == 0) + return md; + return NULL; +} + +const gcry_cipher_spec_t * +grub_crypto_lookup_cipher_by_name (const char *name) +{ + const gcry_cipher_spec_t *ciph; + for (ciph = grub_ciphers; ciph; ciph = ciph->next) + { + const char **alias; + if (grub_strcasecmp (name, ciph->name) == 0) + return ciph; + if (!ciph->aliases) + continue; + for (alias = ciph->aliases; *alias; alias++) + if (grub_strcasecmp (name, *alias) == 0) + return ciph; + } + return NULL; +} + + +grub_crypto_cipher_handle_t +grub_crypto_cipher_open (const struct gcry_cipher_spec *cipher) +{ + grub_crypto_cipher_handle_t ret; + ret = grub_malloc (sizeof (*ret) + cipher->contextsize); + if (!ret) + return NULL; + ret->cipher = cipher; + return ret; +} + +gcry_err_code_t +grub_crypto_cipher_set_key (grub_crypto_cipher_handle_t cipher, + const unsigned char *key, + unsigned keylen) +{ + return cipher->cipher->setkey (cipher->ctx, key, keylen); +} + + +void +grub_crypto_cipher_close (grub_crypto_cipher_handle_t cipher) +{ + grub_free (cipher); +} + + +void +grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size) +{ + const grub_uint8_t *in1ptr = in1, *in2ptr = in2; + grub_uint8_t *outptr = out; + while (size--) + { + *outptr = *in1ptr ^ *in2ptr; + in1ptr++; + in2ptr++; + outptr++; + } +} + +grub_err_t +grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher, + void *out, void *in, grub_size_t size) +{ + grub_uint8_t *inptr, *outptr, *end; + if (size % cipher->cipher->blocksize != 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "This encryption can't decrypt partial blocks"); + end = (grub_uint8_t *) in + size; + for (inptr = in, outptr = out; inptr < end; + inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + cipher->cipher->decrypt (cipher->ctx, outptr, inptr); + return GRUB_ERR_NONE; +} + +grub_err_t +grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher, + void *out, void *in, grub_size_t size) +{ + grub_uint8_t *inptr, *outptr, *end; + if (size % cipher->cipher->blocksize != 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "This encryption can't decrypt partial blocks"); + end = (grub_uint8_t *) in + size; + for (inptr = in, outptr = out; inptr < end; + inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + cipher->cipher->encrypt (cipher->ctx, outptr, inptr); + return GRUB_ERR_NONE; +} + +grub_err_t +grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher, + void *out, void *in, grub_size_t size, + void *iv_in) +{ + grub_uint8_t *inptr, *outptr, *end; + void *iv; + if (size % cipher->cipher->blocksize != 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "This encryption can't decrypt partial blocks"); + end = (grub_uint8_t *) in + size; + iv = iv_in; + for (inptr = in, outptr = out; inptr < end; + inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + { + grub_crypto_xor (outptr, inptr, iv, cipher->cipher->blocksize); + cipher->cipher->encrypt (cipher->ctx, outptr, outptr); + iv = outptr; + } + grub_memcpy (iv_in, iv, cipher->cipher->blocksize); + return GRUB_ERR_NONE; +} + +grub_err_t +grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher, + void *out, void *in, grub_size_t size, + void *iv) +{ + grub_uint8_t *inptr, *outptr, *end; + grub_uint8_t ivt[cipher->cipher->blocksize]; + if (size % cipher->cipher->blocksize != 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "This encryption can't decrypt partial blocks"); + end = (grub_uint8_t *) in + size; + for (inptr = in, outptr = out; inptr < end; + inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + { + grub_memcpy (ivt, inptr, cipher->cipher->blocksize); + cipher->cipher->decrypt (cipher->ctx, outptr, inptr); + grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); + grub_memcpy (iv, ivt, cipher->cipher->blocksize); + } + return GRUB_ERR_NONE; +} From fbf62978dcd4d42facffdcf99831e82a1979cdc3 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 13 Nov 2009 00:27:04 +0100 Subject: [PATCH 019/208] Improved error handling --- include/grub/crypto.h | 26 +++++++++++++------------ lib/crypto.c | 44 +++++++++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/include/grub/crypto.h b/include/grub/crypto.h index 5cd7f02b4..7a3461e3b 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -20,13 +20,14 @@ /* Contains elements based on gcrypt-module.h and gcrypt.h.in. If it's changed please update this file. */ -#ifndef GRUB_CIPHER_HEADER -#define GRUB_CIPHER_HEADER 1 +#ifndef GRUB_CRYPTO_HEADER +#define GRUB_CRYPTO_HEADER 1 #include #include -#include -#include +#include +/* For GRUB_ACCESS_DENIED. */ +#include typedef enum { @@ -64,6 +65,7 @@ typedef enum GPG_ERR_WEAK_KEY, GPG_ERR_WRONG_KEY_USAGE, GPG_ERR_WRONG_PUBKEY_ALGO, + GPG_ERR_OUT_OF_MEMORY } gcry_err_code_t; #define gpg_err_code_t gcry_err_code_t #define gpg_error_t gcry_err_code_t @@ -186,26 +188,23 @@ grub_crypto_cipher_close (grub_crypto_cipher_handle_t cipher); void grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size); -grub_err_t + +gcry_err_code_t grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size); -grub_err_t +gcry_err_code_t grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size); -grub_err_t +gcry_err_code_t grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size, void *iv_in); -grub_err_t +gcry_err_code_t grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size, void *iv); void -grub_cipher_register (gcry_cipher_spec_t *cipher); -void -grub_cipher_unregister (gcry_cipher_spec_t *cipher); -void grub_md_register (gcry_md_spec_t *digest); void grub_md_unregister (gcry_md_spec_t *cipher); @@ -215,6 +214,9 @@ grub_crypto_hash (const gcry_md_spec_t *hash, void *out, void *in, const gcry_md_spec_t * grub_crypto_lookup_md_by_name (const char *name); +grub_err_t +grub_crypto_gcry_error (gcry_err_code_t in); + void grub_burn_stack (grub_size_t size); extern gcry_md_spec_t _gcry_digest_spec_md5; diff --git a/lib/crypto.c b/lib/crypto.c index 64c386dae..718d6e278 100644 --- a/lib/crypto.c +++ b/lib/crypto.c @@ -149,46 +149,49 @@ grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size) } } -grub_err_t +gcry_err_code_t grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size) { grub_uint8_t *inptr, *outptr, *end; + if (!cipher->cipher->decrypt) + return GPG_ERR_NOT_SUPPORTED; if (size % cipher->cipher->blocksize != 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "This encryption can't decrypt partial blocks"); + return GPG_ERR_INV_ARG; end = (grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) cipher->cipher->decrypt (cipher->ctx, outptr, inptr); - return GRUB_ERR_NONE; + return GPG_ERR_NO_ERROR; } -grub_err_t +gcry_err_code_t grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size) { grub_uint8_t *inptr, *outptr, *end; + if (!cipher->cipher->encrypt) + return GPG_ERR_NOT_SUPPORTED; if (size % cipher->cipher->blocksize != 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "This encryption can't decrypt partial blocks"); + return GPG_ERR_INV_ARG; end = (grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) cipher->cipher->encrypt (cipher->ctx, outptr, inptr); - return GRUB_ERR_NONE; + return GPG_ERR_NO_ERROR; } -grub_err_t +gcry_err_code_t grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size, void *iv_in) { grub_uint8_t *inptr, *outptr, *end; void *iv; + if (!cipher->cipher->decrypt) + return GPG_ERR_NOT_SUPPORTED; if (size % cipher->cipher->blocksize != 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "This encryption can't decrypt partial blocks"); + return GPG_ERR_INV_ARG; end = (grub_uint8_t *) in + size; iv = iv_in; for (inptr = in, outptr = out; inptr < end; @@ -199,19 +202,20 @@ grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher, iv = outptr; } grub_memcpy (iv_in, iv, cipher->cipher->blocksize); - return GRUB_ERR_NONE; + return GPG_ERR_NO_ERROR; } -grub_err_t +gcry_err_code_t grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size, void *iv) { grub_uint8_t *inptr, *outptr, *end; grub_uint8_t ivt[cipher->cipher->blocksize]; + if (!cipher->cipher->decrypt) + return GPG_ERR_NOT_SUPPORTED; if (size % cipher->cipher->blocksize != 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "This encryption can't decrypt partial blocks"); + return GPG_ERR_INV_ARG; end = (grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) @@ -221,5 +225,13 @@ grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher, grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); grub_memcpy (iv, ivt, cipher->cipher->blocksize); } - return GRUB_ERR_NONE; + return GPG_ERR_NO_ERROR; +} + +grub_err_t +grub_crypto_gcry_error (gcry_err_code_t in) +{ + if (in == GPG_ERR_NO_ERROR) + return GRUB_ERR_NONE; + return GRUB_ACCESS_DENIED; } From 37f7911f01628181288aaf7fe9e3b871137d7972 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 13 Nov 2009 01:27:38 +0100 Subject: [PATCH 020/208] Fix compilation error --- include/grub/crypto.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/grub/crypto.h b/include/grub/crypto.h index 7a3461e3b..34b1cb078 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -205,6 +205,10 @@ grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher, void *out, void *in, grub_size_t size, void *iv); void +grub_cipher_register (gcry_cipher_spec_t *cipher); +void +grub_cipher_unregister (gcry_cipher_spec_t *cipher); +void grub_md_register (gcry_md_spec_t *digest); void grub_md_unregister (gcry_md_spec_t *cipher); From 6e7d9194d1e8d605d0462260836f723ac7d6ef1a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 24 Nov 2009 02:32:29 +0100 Subject: [PATCH 021/208] Add HMAC and PBKDF2 --- conf/common.rmk | 5 ++ import_gcry.py | 27 +++++++- include/grub/cipher_wrap.h | 2 +- include/grub/crypto.h | 38 +++++++++- lib/crypto.c | 137 ++++++++++++++++++++++++++++++++++++- lib/pbkdf2.c | 101 +++++++++++++++++++++++++++ 6 files changed, 302 insertions(+), 8 deletions(-) create mode 100644 lib/pbkdf2.c diff --git a/conf/common.rmk b/conf/common.rmk index 35b4620f4..3356c556b 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -624,4 +624,9 @@ crypto_mod_SOURCES = lib/crypto.c crypto_mod_CFLAGS = $(COMMON_CFLAGS) crypto_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += pbkdf2.mod +pbkdf2_mod_SOURCES = lib/pbkdf2.c +pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS) +pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS) + include $(srcdir)/conf/gcry.mk diff --git a/import_gcry.py b/import_gcry.py index 39542d8c4..ae5b76778 100644 --- a/import_gcry.py +++ b/import_gcry.py @@ -1,3 +1,21 @@ +#* +#* 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 . +#* + import re import sys import os @@ -26,9 +44,12 @@ conf = open (os.path.join (outdir, "conf", "gcry.rmk"), "w") conf.write ("# -*- makefile -*-\n\n") chlog = "" -mdblocksizes = {"_gcry_digest_spec_crc32" : 1, - "_gcry_digest_spec_crc32_rfc1510" : 1, - "_gcry_digest_spec_crc24_rfc2440" : 1, +# Strictly speaking CRC32/CRC24 work on bytes so this value should be 1 +# But libgcrypt uses 64. Let's keep the value for compatibility. Since +# noone uses CRC24/CRC32 for HMAC this is no problem +mdblocksizes = {"_gcry_digest_spec_crc32" : 64, + "_gcry_digest_spec_crc32_rfc1510" : 64, + "_gcry_digest_spec_crc24_rfc2440" : 64, "_gcry_digest_spec_md4" : 64, "_gcry_digest_spec_md5" : 64, "_gcry_digest_spec_rmd160" : 64, diff --git a/include/grub/cipher_wrap.h b/include/grub/cipher_wrap.h index 9e6242b7f..60ab369f0 100644 --- a/include/grub/cipher_wrap.h +++ b/include/grub/cipher_wrap.h @@ -64,7 +64,7 @@ typedef union { static inline void grub_assert_real (const char *file, int line, int cond) { - if (cond) + if (!cond) grub_fatal ("Assertion failed at %s:%d\n", file, line); } diff --git a/include/grub/crypto.h b/include/grub/crypto.h index 34b1cb078..df15f9bb9 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -166,11 +166,15 @@ typedef struct gcry_md_spec struct gcry_md_spec *next; } gcry_md_spec_t; -typedef struct grub_crypto_cipher_handle +struct grub_crypto_cipher_handle { const struct gcry_cipher_spec *cipher; char ctx[0]; -} *grub_crypto_cipher_handle_t; +}; + +typedef struct grub_crypto_cipher_handle *grub_crypto_cipher_handle_t; + +struct grub_crypto_hmac_handle; const gcry_cipher_spec_t * grub_crypto_lookup_cipher_by_name (const char *name); @@ -213,7 +217,7 @@ grub_md_register (gcry_md_spec_t *digest); void grub_md_unregister (gcry_md_spec_t *cipher); void -grub_crypto_hash (const gcry_md_spec_t *hash, void *out, void *in, +grub_crypto_hash (const gcry_md_spec_t *hash, void *out, const void *in, grub_size_t inlen); const gcry_md_spec_t * grub_crypto_lookup_md_by_name (const char *name); @@ -223,7 +227,35 @@ grub_crypto_gcry_error (gcry_err_code_t in); void grub_burn_stack (grub_size_t size); +struct grub_crypto_hmac_handle * +grub_crypto_hmac_init (const struct gcry_md_spec *md, + const void *key, grub_size_t keylen); +void +grub_crypto_hmac_write (struct grub_crypto_hmac_handle *hnd, void *data, + grub_size_t datalen); +gcry_err_code_t +grub_crypto_hmac_fini (struct grub_crypto_hmac_handle *hnd, void *out); + +gcry_err_code_t +grub_crypto_hmac_buffer (const struct gcry_md_spec *md, + const void *key, grub_size_t keylen, + void *data, grub_size_t datalen, void *out); + extern gcry_md_spec_t _gcry_digest_spec_md5; #define GRUB_MD_MD5 ((const gcry_md_spec_t *) &_gcry_digest_spec_md5) +#define GRUB_MD_SHA1 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha1) + +/* Implement PKCS#5 PBKDF2 as per RFC 2898. The PRF to use is HMAC variant + of digest supplied by MD. Inputs are the password P of length PLEN, + the salt S of length SLEN, the iteration counter C (> 0), and the + desired derived output length DKLEN. Output buffer is DK which + must have room for at least DKLEN octets. The output buffer will + be filled with the derived data. */ +gcry_err_code_t +grub_crypto_pbkdf2 (const struct gcry_md_spec *md, + const grub_uint8_t *P, grub_size_t Plen, + const grub_uint8_t *S, grub_size_t Slen, + unsigned int c, + grub_uint8_t *DK, grub_size_t dkLen); #endif diff --git a/lib/crypto.c b/lib/crypto.c index 718d6e278..3cb66f942 100644 --- a/lib/crypto.c +++ b/lib/crypto.c @@ -21,6 +21,13 @@ #include #include +struct grub_crypto_hmac_handle +{ + const struct gcry_md_spec *md; + void *ctx; + void *opad; +}; + static gcry_cipher_spec_t *grub_ciphers = NULL; static gcry_md_spec_t *grub_digests = NULL; @@ -69,7 +76,7 @@ grub_md_unregister (gcry_md_spec_t *cipher) } void -grub_crypto_hash (const gcry_md_spec_t *hash, void *out, void *in, +grub_crypto_hash (const gcry_md_spec_t *hash, void *out, const void *in, grub_size_t inlen) { grub_uint8_t ctx[hash->contextsize]; @@ -228,6 +235,134 @@ grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher, return GPG_ERR_NO_ERROR; } +/* Based on gcry/cipher/md.c. */ +struct grub_crypto_hmac_handle * +grub_crypto_hmac_init (const struct gcry_md_spec *md, + const void *key, grub_size_t keylen) +{ + grub_uint8_t *helpkey = NULL; + grub_uint8_t *ipad = NULL, *opad = NULL; + void *ctx = NULL; + struct grub_crypto_hmac_handle *ret = NULL; + unsigned i; + + if (md->mdlen > md->blocksize) + return NULL; + + ctx = grub_malloc (md->contextsize); + if (!ctx) + goto err; + + if ( keylen > md->blocksize ) + { + helpkey = grub_malloc (md->mdlen); + if (!helpkey) + goto err; + grub_crypto_hash (md, helpkey, key, keylen); + + key = helpkey; + keylen = md->mdlen; + } + + ipad = grub_zalloc (md->blocksize); + if (!ipad) + goto err; + + opad = grub_zalloc (md->blocksize); + if (!opad) + goto err; + + grub_memcpy ( ipad, key, keylen ); + grub_memcpy ( opad, key, keylen ); + for (i=0; i < md->blocksize; i++ ) + { + ipad[i] ^= 0x36; + opad[i] ^= 0x5c; + } + grub_free (helpkey); + helpkey = NULL; + + md->init (ctx); + + md->write (ctx, ipad, md->blocksize); /* inner pad */ + grub_memset (ipad, 0, md->blocksize); + grub_free (ipad); + ipad = NULL; + + ret = grub_malloc (sizeof (*ret)); + if (!ret) + goto err; + + ret->md = md; + ret->ctx = ctx; + ret->opad = opad; + + return ret; + + err: + grub_free (helpkey); + grub_free (ctx); + grub_free (ipad); + grub_free (opad); + return NULL; +} + +void +grub_crypto_hmac_write (struct grub_crypto_hmac_handle *hnd, void *data, + grub_size_t datalen) +{ + hnd->md->write (hnd->ctx, data, datalen); +} + +gcry_err_code_t +grub_crypto_hmac_fini (struct grub_crypto_hmac_handle *hnd, void *out) +{ + grub_uint8_t *p; + grub_uint8_t *ctx2; + + ctx2 = grub_malloc (hnd->md->contextsize); + if (!ctx2) + return GPG_ERR_OUT_OF_MEMORY; + + hnd->md->final (hnd->ctx); + hnd->md->read (hnd->ctx); + p = hnd->md->read (hnd->ctx); + + hnd->md->init (ctx2); + hnd->md->write (ctx2, hnd->opad, hnd->md->blocksize); + hnd->md->write (ctx2, p, hnd->md->mdlen); + hnd->md->final (ctx2); + grub_memset (hnd->opad, 0, hnd->md->blocksize); + grub_free (hnd->opad); + grub_memset (hnd->ctx, 0, hnd->md->contextsize); + grub_free (hnd->ctx); + + grub_memcpy (out, hnd->md->read (ctx2), hnd->md->mdlen); + grub_memset (ctx2, 0, hnd->md->contextsize); + grub_free (ctx2); + + grub_memset (hnd, 0, sizeof (*hnd)); + grub_free (hnd); + + return GPG_ERR_NO_ERROR; +} + +gcry_err_code_t +grub_crypto_hmac_buffer (const struct gcry_md_spec *md, + const void *key, grub_size_t keylen, + void *data, grub_size_t datalen, void *out) +{ + struct grub_crypto_hmac_handle *hnd; + + hnd = grub_crypto_hmac_init (md, key, keylen); + if (!hnd) + return GPG_ERR_OUT_OF_MEMORY; + + grub_crypto_hmac_write (hnd, data, datalen); + return grub_crypto_hmac_fini (hnd, out); +} + + grub_err_t grub_crypto_gcry_error (gcry_err_code_t in) { diff --git a/lib/pbkdf2.c b/lib/pbkdf2.c new file mode 100644 index 000000000..f2d3ca97f --- /dev/null +++ b/lib/pbkdf2.c @@ -0,0 +1,101 @@ +/* gc-pbkdf2-sha1.c --- Password-Based Key Derivation Function a'la PKCS#5 + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc. + + This program 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 2, or (at your option) + any later version. + + This program 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 this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Simon Josefsson. */ + +#include +#include +#include + +/* Implement PKCS#5 PBKDF2 as per RFC 2898. The PRF to use is HMAC variant + of digest supplied by MD. Inputs are the password P of length PLEN, + the salt S of length SLEN, the iteration counter C (> 0), and the + desired derived output length DKLEN. Output buffer is DK which + must have room for at least DKLEN octets. The output buffer will + be filled with the derived data. */ +gcry_err_code_t +grub_crypto_pbkdf2 (const struct gcry_md_spec *md, + const grub_uint8_t *P, grub_size_t Plen, + const grub_uint8_t *S, grub_size_t Slen, + unsigned int c, + grub_uint8_t *DK, grub_size_t dkLen) +{ + unsigned int hLen = md->mdlen; + grub_uint8_t U[md->mdlen]; + grub_uint8_t T[md->mdlen]; + unsigned int u; + unsigned int l; + unsigned int r; + unsigned int i; + unsigned int k; + gcry_err_code_t rc; + grub_uint8_t *tmp; + grub_size_t tmplen = Slen + 4; + + if (c == 0) + return GPG_ERR_INV_ARG; + + if (dkLen == 0) + return GPG_ERR_INV_ARG; + + if (dkLen > 4294967295U) + return GPG_ERR_INV_ARG; + + l = ((dkLen - 1) / hLen) + 1; + r = dkLen - (l - 1) * hLen; + + tmp = grub_malloc (tmplen); + if (tmp == NULL) + return GPG_ERR_OUT_OF_MEMORY; + + grub_memcpy (tmp, S, Slen); + + for (i = 1; i <= l; i++) + { + grub_memset (T, 0, hLen); + + for (u = 1; u <= c; u++) + { + if (u == 1) + { + tmp[Slen + 0] = (i & 0xff000000) >> 24; + tmp[Slen + 1] = (i & 0x00ff0000) >> 16; + tmp[Slen + 2] = (i & 0x0000ff00) >> 8; + tmp[Slen + 3] = (i & 0x000000ff) >> 0; + + rc = grub_crypto_hmac_buffer (md, P, Plen, tmp, tmplen, U); + } + else + rc = grub_crypto_hmac_buffer (md, P, Plen, U, hLen, U); + + if (rc != GPG_ERR_NO_ERROR) + { + grub_free (tmp); + return rc; + } + + for (k = 0; k < hLen; k++) + T[k] ^= U[k]; + } + + grub_memcpy (DK + (i - 1) * hLen, T, i == l ? r : hLen); + } + + grub_free (tmp); + + return GPG_ERR_NO_ERROR; +} From 10e53efaee09c05c91f3f8b79230d45e3db6c496 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 15 Nov 2009 23:31:27 +0100 Subject: [PATCH 022/208] crypto_memcmp --- include/grub/crypto.h | 6 ++++++ lib/crypto.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/grub/crypto.h b/include/grub/crypto.h index df15f9bb9..4d8ce88b8 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -242,8 +242,11 @@ grub_crypto_hmac_buffer (const struct gcry_md_spec *md, void *data, grub_size_t datalen, void *out); extern gcry_md_spec_t _gcry_digest_spec_md5; +extern gcry_md_spec_t _gcry_digest_spec_sha1; +extern gcry_md_spec_t _gcry_digest_spec_sha256; #define GRUB_MD_MD5 ((const gcry_md_spec_t *) &_gcry_digest_spec_md5) #define GRUB_MD_SHA1 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha1) +#define GRUB_MD_SHA256 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha256) /* Implement PKCS#5 PBKDF2 as per RFC 2898. The PRF to use is HMAC variant of digest supplied by MD. Inputs are the password P of length PLEN, @@ -258,4 +261,7 @@ grub_crypto_pbkdf2 (const struct gcry_md_spec *md, unsigned int c, grub_uint8_t *DK, grub_size_t dkLen); +int +grub_crypto_memcmp (void *a, void *b, grub_size_t n); + #endif diff --git a/lib/crypto.c b/lib/crypto.c index 3cb66f942..4b36dde6f 100644 --- a/lib/crypto.c +++ b/lib/crypto.c @@ -370,3 +370,18 @@ grub_crypto_gcry_error (gcry_err_code_t in) return GRUB_ERR_NONE; return GRUB_ACCESS_DENIED; } + +int +grub_crypto_memcmp (void *a, void *b, grub_size_t n) +{ + register grub_size_t counter = 0; + grub_uint8_t *pa, *pb; + + for (pa = a, pb = b; n; pa++, pb++, n--) + { + if (*pa != *pb) + counter++; + } + + return !!counter; +} From 228734ab023191ff8df42e83c615d7ab610a3aea Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 15 Nov 2009 23:36:42 +0100 Subject: [PATCH 023/208] MAX_PASSLEN based authentication --- commands/password.c | 13 ++++++++--- include/grub/auth.h | 7 +----- normal/auth.c | 56 ++------------------------------------------- 3 files changed, 13 insertions(+), 63 deletions(-) diff --git a/commands/password.c b/commands/password.c index 0e048797e..247e0bffd 100644 --- a/commands/password.c +++ b/commands/password.c @@ -26,18 +26,20 @@ static grub_dl_t my_mod; +#define MAX_PASSLEN 1024 + static grub_err_t check_password (const char *user, void *password) { - char entered[1024]; + char entered[MAX_PASSLEN]; 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) + if (grub_crypto_memcmp (entered, password, MAX_PASSLEN) != 0) return GRUB_ACCESS_DENIED; grub_auth_authenticate (user); @@ -51,13 +53,18 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)), { grub_err_t err; char *pass; + int copylen; if (argc != 2) return grub_error (GRUB_ERR_BAD_ARGUMENT, "Two arguments expected."); - pass = grub_strdup (args[1]); + pass = grub_zalloc (MAX_PASSLEN); if (!pass) return grub_errno; + copylen = grub_strlen (argv[1]); + if (copylen >= MAX_PASSLEN) + copylen = MAX_PASSLEN - 1; + grub_memcpy (pass, argv[1], copylen); err = grub_auth_register_authentication (args[0], check_password, pass); if (err) diff --git a/include/grub/auth.h b/include/grub/auth.h index da930eeda..e72d984ae 100644 --- a/include/grub/auth.h +++ b/include/grub/auth.h @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with GRUB. If not, see . */ -#ifndef GRUB_AURH_HEADER +#ifndef GRUB_AUTH_HEADER #define GRUB_AUTH_HEADER 1 #include @@ -26,11 +26,6 @@ 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, diff --git a/normal/auth.c b/normal/auth.c index c71262584..7d5a07d26 100644 --- a/normal/auth.c +++ b/normal/auth.c @@ -35,58 +35,6 @@ struct grub_auth_user struct grub_auth_user *users = NULL; -int -grub_auth_strcmp (const char *s1, const char *s2) -{ - int ret; - grub_uint64_t end; - - end = grub_get_time_ms () + 100; - ret = grub_strcmp (s1, s2); - - /* This prevents an attacker from deriving information about the - password from the time it took to execute this function. */ - while (grub_get_time_ms () < end); - - return ret; -} - -static int -grub_iswordseparator (int c) -{ - return (grub_isspace (c) || c == ',' || c == ';' || c == '|' || c == '&'); -} - -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, @@ -193,8 +141,8 @@ is_authenticated (const char *userlist) return 0; name = ((struct grub_auth_user *) item)->name; - return (userlist && grub_auth_strword (userlist, name)) - || grub_auth_strword (superusers, name); + return (userlist && grub_strword (userlist, name)) + || grub_strword (superusers, name); } superusers = grub_env_get ("superusers"); From 53eb42a6fac7fa4dc13f485b2dff6127a484b036 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 15 Nov 2009 23:42:11 +0100 Subject: [PATCH 024/208] Compilation error fixed --- commands/password.c | 5 +++-- normal/auth.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/commands/password.c b/commands/password.c index 247e0bffd..99b993839 100644 --- a/commands/password.c +++ b/commands/password.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -61,10 +62,10 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)), pass = grub_zalloc (MAX_PASSLEN); if (!pass) return grub_errno; - copylen = grub_strlen (argv[1]); + copylen = grub_strlen (args[1]); if (copylen >= MAX_PASSLEN) copylen = MAX_PASSLEN - 1; - grub_memcpy (pass, argv[1], copylen); + grub_memcpy (pass, args[1], copylen); err = grub_auth_register_authentication (args[0], check_password, pass); if (err) diff --git a/normal/auth.c b/normal/auth.c index 7d5a07d26..0a8b5bc82 100644 --- a/normal/auth.c +++ b/normal/auth.c @@ -164,7 +164,7 @@ grub_auth_check_authentication (const char *userlist) 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) + if (grub_strcmp (login, ((struct grub_auth_user *) item)->name) == 0) cur = (struct grub_auth_user *) item; return 0; } From 0e3c54a5c515e4d3b956b46e800396c55b244804 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 24 Nov 2009 02:36:21 +0100 Subject: [PATCH 025/208] PBKDF2 passwords available --- .bzrignore | 56 ++++++ commands/password_pbkdf2.c | 202 ++++++++++++++++++++++ conf/common.rmk | 9 + 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/crypto.h | 2 + util/grub-pbkdf2.c | 337 +++++++++++++++++++++++++++++++++++++ 12 files changed, 613 insertions(+), 7 deletions(-) create mode 100644 .bzrignore create mode 100644 commands/password_pbkdf2.c create mode 100644 util/grub-pbkdf2.c diff --git a/.bzrignore b/.bzrignore new file mode 100644 index 000000000..e5d7be2d4 --- /dev/null +++ b/.bzrignore @@ -0,0 +1,56 @@ +00_header +10_* +30_os-prober +40_custom +autom4te.cache +build_env.mk +.bzrignore +config.cache +config.h +config.h.in +config.log +config.status +configure +conf/*.mk +*.d +DISTLIST +docs/*.info +docs/stamp-vti +docs/version.texi +*.elf +*.exec +genkernsyms.sh +gensymlist.sh +grub-dumpbios +grub-editenv +grub-emu +grub_emu_init.c +grub_emu_init.h +grub-fstest +grub_fstest_init.c +grub_fstest_init.h +grub-install +grub-mk* +grub-pbkdf2 +grub-pe2elf +grub-probe +grub_probe_init.c +grub_probe_init.h +grub_script.tab.c +grub_script.tab.h +grub-setup +grub_setup_init.c +grub_setup_init.h +*.img +include/grub/cpu +include/grub/machine +*.lst +Makefile +*.mod +mod-*.c +*.pf2 +stamp-h +stamp-h1 +stamp-h.in +symlist.c +update-grub_lib diff --git a/commands/password_pbkdf2.c b/commands/password_pbkdf2.c new file mode 100644 index 000000000..44da0101e --- /dev/null +++ b/commands/password_pbkdf2.c @@ -0,0 +1,202 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * Copyright (C) 2009 Vladimir 'phcoder' Serbineko + * + * 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; + +struct pbkdf2_password +{ + grub_uint8_t *salt; + grub_size_t saltlen; + unsigned int c; + grub_uint8_t *expected; + grub_size_t buflen; +}; + +static grub_err_t +check_password (const char *user, void *pin) +{ + char entered[1024]; + grub_uint8_t *buf; + struct pbkdf2_password *pass = pin; + gcry_err_code_t err; + + grub_memset (entered, 0, sizeof (entered)); + + if (!GRUB_GET_PASSWORD (entered, sizeof (entered) - 1)) + return GRUB_ACCESS_DENIED; + + buf = grub_malloc (pass->buflen); + if (!buf) + return grub_crypto_gcry_error (GPG_ERR_OUT_OF_MEMORY); + + err = grub_crypto_pbkdf2 (GRUB_MD_SHA512, (grub_uint8_t *) &entered, + grub_strlen (entered), + pass->salt, pass->saltlen, pass->c, + buf, pass->buflen); + if (err) + { + grub_free (buf); + return grub_crypto_gcry_error (err); + } + + if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0) + return GRUB_ACCESS_DENIED; + + grub_auth_authenticate (user); + + return GRUB_ERR_NONE; +} + +static inline int +hex2val (char hex) +{ + if ('0' <= hex && hex <= '9') + return hex - '0'; + if ('a' <= hex && hex <= 'f') + return hex - 'a' + 10; + if ('A' <= hex && hex <= 'F') + return hex - 'A' + 10; + return -1; +} + +static grub_err_t +grub_cmd_password (grub_command_t cmd __attribute__ ((unused)), + int argc, char **args) +{ + grub_err_t err; + char *ptr, *ptr2; + grub_uint8_t *ptro; + struct pbkdf2_password *pass; + + if (argc != 2) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Two arguments expected."); + + if (grub_memcmp (args[1], "grub.pbkdf2.sha512.", + sizeof ("grub.pbkdf2.sha512.") - 1) != 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Incorrect PBKDF2 password."); + + ptr = args[1] + sizeof ("grub.pbkdf2.sha512.") - 1; + + pass = grub_malloc (sizeof (*pass)); + if (!pass) + return grub_errno; + + pass->c = grub_strtoul (ptr, &ptr, 0); + if (*ptr != '.') + { + grub_free (pass); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Incorrect PBKDF2 password."); + } + ptr++; + + ptr2 = grub_strchr (ptr, '.'); + if (!ptr2 || ((ptr2 - ptr) & 1) || grub_strlen (ptr2 + 1) & 1) + { + grub_free (pass); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "Incorrect PBKDF2 password."); + } + + pass->saltlen = (ptr2 - ptr) >> 1; + pass->buflen = grub_strlen (ptr2 + 1) >> 1; + ptro = pass->salt = grub_malloc (pass->saltlen); + if (!ptro) + { + grub_free (pass); + return grub_errno; + } + while (ptr < ptr2) + { + int hex1, hex2; + hex1 = hex2val (*ptr); + ptr++; + hex2 = hex2val (*ptr); + ptr++; + if (hex1 < 0 || hex2 < 0) + { + grub_free (pass->salt); + grub_free (pass); + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "Incorrect PBKDF2 password."); + } + + *ptro = (hex1 << 4) | hex2; + ptro++; + } + + ptro = pass->expected = grub_malloc (pass->buflen); + if (!ptro) + { + grub_free (pass->salt); + grub_free (pass); + return grub_errno; + } + ptr = ptr2 + 1; + ptr2 += grub_strlen (ptr2); + while (ptr < ptr2) + { + int hex1, hex2; + hex1 = hex2val (*ptr); + ptr++; + hex2 = hex2val (*ptr); + ptr++; + if (hex1 < 0 || hex2 < 0) + { + grub_free (pass->expected); + grub_free (pass->salt); + grub_free (pass); + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "Incorrect PBKDF2 password."); + } + + *ptro = (hex1 << 4) | hex2; + ptro++; + } + + 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_pbkdf2) +{ + my_mod = mod; + cmd = grub_register_command ("password_pbkdf2", grub_cmd_password, + "password_pbkdf2 USER PBKDF2_PASSWORD", + "Set user password (PBKDF2). "); +} + +GRUB_MOD_FINI(password_pbkdf2) +{ + grub_unregister_command (cmd); +} diff --git a/conf/common.rmk b/conf/common.rmk index 3356c556b..eae37acde 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -629,4 +629,13 @@ pbkdf2_mod_SOURCES = lib/pbkdf2.c pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS) pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For password_pbkdf2.mod. +pkglib_MODULES += password_pbkdf2.mod +password_pbkdf2_mod_SOURCES = commands/password_pbkdf2.c +password_pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS) +password_pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS) + +bin_UTILITIES += grub-pbkdf2 +grub_pbkdf2_SOURCES = util/grub-pbkdf2.c lib/crypto.c gcry/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c + include $(srcdir)/conf/gcry.mk diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index 5645395b8..83a49d398 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -130,7 +130,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/auth.c normal/autofs.c \ + normal/handler.c normal/auth.c lib/crypto.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 99ab06f64..6c9e8862f 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -57,7 +57,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/auth.c normal/autofs.c \ + normal/auth.c lib/crypto.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 4b640de49..6042676ea 100644 --- a/conf/i386-ieee1275.rmk +++ b/conf/i386-ieee1275.rmk @@ -85,7 +85,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/auth.c normal/autofs.c \ + normal/handler.c normal/auth.c lib/crypto.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 ac9337e41..0372b529d 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -137,7 +137,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/auth.c normal/autofs.c \ + normal/handler.c normal/auth.c lib/crypto.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 ee7f9ec27..344aa17ac 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -65,7 +65,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/auth.c normal/autofs.c normal/main.c \ + normal/handler.c normal/auth.c lib/crypto.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 62e951a5e..de67a131a 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -123,7 +123,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/auth.c normal/autofs.c normal/main.c \ + normal/handler.c normal/auth.c lib/crypto.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 5be1b404f..d671f152b 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -53,7 +53,7 @@ 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/auth.c \ + lib/arg.c normal/cmdline.c normal/misc.c normal/auth.c lib/crypto.c \ normal/autofs.c \ normal/completion.c normal/datetime.c normal/context.c \ normal/main.c \ diff --git a/include/grub/crypto.h b/include/grub/crypto.h index 4d8ce88b8..eb1898fe4 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -244,9 +244,11 @@ grub_crypto_hmac_buffer (const struct gcry_md_spec *md, extern gcry_md_spec_t _gcry_digest_spec_md5; extern gcry_md_spec_t _gcry_digest_spec_sha1; extern gcry_md_spec_t _gcry_digest_spec_sha256; +extern gcry_md_spec_t _gcry_digest_spec_sha512; #define GRUB_MD_MD5 ((const gcry_md_spec_t *) &_gcry_digest_spec_md5) #define GRUB_MD_SHA1 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha1) #define GRUB_MD_SHA256 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha256) +#define GRUB_MD_SHA512 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha512) /* Implement PKCS#5 PBKDF2 as per RFC 2898. The PRF to use is HMAC variant of digest supplied by MD. Inputs are the password P of length PLEN, diff --git a/util/grub-pbkdf2.c b/util/grub-pbkdf2.c new file mode 100644 index 000000000..a05fa62b1 --- /dev/null +++ b/util/grub-pbkdf2.c @@ -0,0 +1,337 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1992-1999,2001,2003,2004,2005,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 +#include +#include + + +/* Few functions to make crypto happy. */ +void * +grub_memmove (void *dest, const void *src, grub_size_t n) +{ + return memmove (dest, src, n); +} + +void * +grub_memset (void *s, int c, grub_size_t n) +{ + return memset (s, c, n); +} + +int +grub_vprintf (const char *fmt, va_list args) +{ + return vprintf (fmt, args); +} + +int +grub_vsprintf (char *str, const char *fmt, va_list args) +{ + return vsprintf (str, fmt, args); +} + +void +grub_abort (void) +{ + abort (); +} + +static struct option options[] = + { + {"iteration_count", required_argument, 0, 'c'}, + {"buflen", required_argument, 0, 'l'}, + {"saltlen", required_argument, 0, 's'}, + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'V'}, + }; + +static void +usage (int status) +{ + if (status) + fprintf (stderr, "Try ``grub-scrypt --help'' for more information.\n"); + else + printf ("\ +Usage: grub-scrypt [OPTIONS]\n\ +\nOptions:\n\ + -c number, --iteration-count=number Number of PBKDF2 iterations\n\ + -l number, --buflen=number Length of generated hash\n\ + -s number, --salt=number Length of salt\n\ +\n\ +Report bugs to <%s>.\n", PACKAGE_BUGREPORT); + + exit (status); +} + +static void +hexify (char *hex, grub_uint8_t *bin, grub_size_t n) +{ + while (n--) + { + if (((*bin & 0xf0) >> 4) < 10) + *hex = ((*bin & 0xf0) >> 4) + '0'; + else + *hex = ((*bin & 0xf0) >> 4) + 'A' - 10; + hex++; + + if ((*bin & 0xf) < 10) + *hex = (*bin & 0xf) + '0'; + else + *hex = (*bin & 0xf) + 'A' - 10; + hex++; + bin++; + } + *hex = 0; +} + +int +main (int argc, char *argv[]) +{ + unsigned int c = 10000, buflen = 64, saltlen = 64; + char *pass1, *pass2; + char *bufhex, *salthex; + gcry_err_code_t gcry_err; + grub_uint8_t *buf, *salt; + ssize_t nr; + FILE *in, *out; + struct termios s, t; + int tty_changed; + + progname = "grub-pbkdf2"; + + /* Check for options. */ + while (1) + { + int c = getopt_long (argc, argv, "c:l:s:hvV", options, 0); + + if (c == -1) + break; + + switch (c) + { + case 'c': + c = strtoul (optarg, NULL, 0); + break; + + case 'l': + buflen = strtoul (optarg, NULL, 0); + break; + + case 's': + saltlen = strtoul (optarg, NULL, 0); + break; + + case 'h': + usage (0); + return 0; + + case 'V': + printf ("%s (%s) %s\n", progname, + PACKAGE_NAME, PACKAGE_VERSION); + return 0; + + default: + usage (1); + return 1; + } + } + + bufhex = malloc (buflen * 2 + 1); + if (!bufhex) + grub_util_error ("Out of memory"); + buf = malloc (buflen); + if (!buf) + { + free (bufhex); + grub_util_error ("Out of memory"); + } + + salt = malloc (saltlen); + if (!salt) + { + free (bufhex); + free (buf); + grub_util_error ("Out of memory"); + } + salthex = malloc (saltlen * 2 + 1); + if (!salthex) + { + free (salt); + free (bufhex); + free (buf); + grub_util_error ("Out of memory"); + } + + /* Disable echoing. Based on glibc. */ + in = fopen ("/dev/tty", "w+c"); + if (in == NULL) + { + in = stdin; + out = stderr; + } + else + out = in; + + if (tcgetattr (fileno (in), &t) == 0) + { + /* Save the old one. */ + s = t; + /* Tricky, tricky. */ + t.c_lflag &= ~(ECHO|ISIG); + tty_changed = (tcsetattr (fileno (in), TCSAFLUSH, &t) == 0); + } + else + tty_changed = 0; + + printf ("Enter password: "); + pass1 = NULL; + { + grub_size_t n; + nr = getline (&pass1, &n, stdin); + } + if (nr < 0 || !pass1) + { + free (buf); + free (bufhex); + free (salthex); + free (salt); + /* Restore the original setting. */ + if (tty_changed) + (void) tcsetattr (fileno (in), TCSAFLUSH, &s); + grub_util_error ("Failure to read password"); + } + if (nr >= 1 && pass1[nr-1] == '\n') + pass1[nr-1] = 0; + + printf ("\nReenter password: "); + pass2 = NULL; + { + grub_size_t n; + nr = getline (&pass2, &n, stdin); + } + /* Restore the original setting. */ + if (tty_changed) + (void) tcsetattr (fileno (in), TCSAFLUSH, &s); + printf ("\n"); + + if (nr < 0 || !pass2) + { + memset (pass1, 0, strlen (pass1)); + free (pass1); + free (buf); + free (bufhex); + free (salthex); + free (salt); + grub_util_error ("Failure to read password"); + } + if (nr >= 1 && pass2[nr-1] == '\n') + pass2[nr-1] = 0; + + if (strcmp (pass1, pass2) != 0) + { + memset (pass1, 0, strlen (pass1)); + memset (pass2, 0, strlen (pass2)); + free (pass1); + free (pass2); + free (buf); + free (bufhex); + free (salthex); + free (salt); + grub_util_error ("Passwords don't match"); + } + memset (pass2, 0, strlen (pass2)); + free (pass2); + +#if ! defined (__linux__) && ! defined (__FreeBSD__) + printf ("WARNING: your random generator isn't known to be secure\n"); +#endif + + { + FILE *f; + size_t rd; + f = fopen ("/dev/random", "rb"); + if (!f) + { + memset (pass1, 0, strlen (pass1)); + free (pass1); + free (buf); + free (bufhex); + free (salthex); + free (salt); + fclose (f); + grub_util_error ("Couldn't retrieve random data for salt"); + } + rd = fread (salt, 1, saltlen, f); + if (rd != saltlen) + { + fclose (f); + memset (pass1, 0, strlen (pass1)); + free (pass1); + free (buf); + free (bufhex); + free (salthex); + free (salt); + fclose (f); + grub_util_error ("Couldn't retrieve random data for salt"); + } + fclose (f); + } + + gcry_err = grub_crypto_pbkdf2 (GRUB_MD_SHA512, + (grub_uint8_t *) pass1, strlen (pass1), + salt, saltlen, + c, buf, buflen); + memset (pass1, 0, strlen (pass1)); + free (pass1); + + if (gcry_err) + { + memset (buf, 0, buflen); + memset (bufhex, 0, 2 * buflen); + free (buf); + free (bufhex); + memset (salt, 0, saltlen); + memset (salthex, 0, 2 * saltlen); + free (salt); + free (salthex); + grub_util_error ("Cryptographic error number %d", gcry_err); + } + + hexify (bufhex, buf, buflen); + hexify (salthex, salt, saltlen); + + printf ("Your PBKDF2 is grub.pbkdf2.sha512.%d.%s.%s\n", c, salthex, bufhex); + memset (buf, 0, buflen); + memset (bufhex, 0, 2 * buflen); + free (buf); + free (bufhex); + memset (salt, 0, saltlen); + memset (salthex, 0, 2 * saltlen); + free (salt); + free (salthex); + + return 0; +} From 5edd456216b1d6f648f405ba8a065235f015997a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 16 Nov 2009 14:33:44 +0100 Subject: [PATCH 026/208] Remove leftover kern/crypto.c --- kern/crypto.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 kern/crypto.c diff --git a/kern/crypto.c b/kern/crypto.c deleted file mode 100644 index d097e1668..000000000 --- a/kern/crypto.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999, 2001, 2002, 2003, 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 - * 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 - -gcry_cipher_spec_t *grub_ciphers = NULL; -gcry_md_spec_t *grub_digests = NULL; - -/* Based on libgcrypt-1.4.4/src/misc.c. */ -void -grub_burn_stack (grub_size_t size) -{ - char buf[64]; - - grub_memset (buf, 0, sizeof (buf)); - if (size > sizeof (buf)) - grub_burn_stack (size - sizeof (buf)); -} From 024478a2d8fba8fc6d26f61480058fc64de353fc Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 18 Nov 2009 18:54:23 +0100 Subject: [PATCH 027/208] Fixed bug which causes some commands to be masked --- normal/dyncmd.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/normal/dyncmd.c b/normal/dyncmd.c index 6e5028906..edaf614b8 100644 --- a/normal/dyncmd.c +++ b/normal/dyncmd.c @@ -78,14 +78,22 @@ read_command_list (void) if (file) { char *buf = NULL; + grub_command_t ptr, last = 0, next; /* Override previous commands.lst. */ - while (grub_command_list) + for (ptr = grub_command_list; ptr; ptr = next) { - grub_command_t tmp; - tmp = grub_command_list->next; - grub_free (grub_command_list); - grub_command_list = tmp; + next = ptr->next; + if (ptr->func == grub_dyncmd_dispatcher) + { + if (last) + last->next = ptr->next; + else + grub_command_list = ptr->next; + grub_free (ptr); + } + else + last = ptr; } for (;; grub_free (buf)) From f78821e5bc473ce99b2bba9b9ce38e17f9149e3d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 19 Nov 2009 23:10:40 +0100 Subject: [PATCH 028/208] Removed extraneous copyright line --- commands/password_pbkdf2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/commands/password_pbkdf2.c b/commands/password_pbkdf2.c index 44da0101e..38481f362 100644 --- a/commands/password_pbkdf2.c +++ b/commands/password_pbkdf2.c @@ -1,7 +1,6 @@ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 2009 Free Software Foundation, Inc. - * Copyright (C) 2009 Vladimir 'phcoder' Serbineko * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 242f0731c7805a94d79eade8cb0cf928a526839c Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 20 Nov 2009 09:41:20 +0100 Subject: [PATCH 029/208] reimported savedefault by cjwatson and myself Also-By: Vladimir 'phcoder' Serbinenko --- ChangeLog.savedefault | 29 +++++++ conf/common.rmk | 14 ++++ normal/menu.c | 2 + normal/menu_text.c | 26 ++++++- util/grub-install.in | 5 ++ util/grub-mkconfig_lib.in | 8 ++ util/grub-reboot.in | 104 ++++++++++++++++++++++++++ util/grub-set-default.in | 99 ++++++++++++++++++++++++ util/grub.d/00_header.in | 8 ++ util/grub.d/10_hurd.in | 1 + util/grub.d/10_kfreebsd.in | 1 + util/grub.d/10_linux.in | 1 + util/grub.d/10_windows.in | 1 + util/grub.d/30_os-prober.in | 3 + util/i386/efi/grub-install.in | 5 ++ util/ieee1275/grub-install.in | 5 ++ util/sparc64/ieee1275/grub-install.in | 5 ++ 17 files changed, 315 insertions(+), 2 deletions(-) create mode 100644 ChangeLog.savedefault create mode 100644 util/grub-reboot.in create mode 100644 util/grub-set-default.in diff --git a/ChangeLog.savedefault b/ChangeLog.savedefault new file mode 100644 index 000000000..c18106bd5 --- /dev/null +++ b/ChangeLog.savedefault @@ -0,0 +1,29 @@ +2009-10-25 Vladimir Serbinenko +2009-10-25 Colin Watson + + * normal/menu.c (grub_menu_execute_entry): Save selected entry title + in `chosen' environment variable. + * normal/menu_text.c (get_entry_number): Check if the variable + matches the title of a menu entry. + (run_menu): Pass menu to get_entry_number. + + * util/grub-reboot.in: New file. + * util/grub-set-default.in: New file. + * conf/common.rmk (grub-reboot): New utility. + (grub-set-default): New utility. + + * util/grub-mkconfig_lib.in (save_default_entry): New function. + * util/grub.d/00_header.in: If GRUB_DEFAULT is `saved', set + default to `${saved_entry}'. If `${prev_saved_entry}' is non-empty, + move it to `saved_entry' for the next boot. Load environment on + initialisation. + * util/grub.d/10_kfreebsd.in: Call save_default_entry. + * util/grub.d/10_hurd.in: Likewise. + * util/grub.d/10_linux.in (linux_entry): Likewise. + * util/grub.d/10_windows.in: Likewise. + * util/grub.d/30_os-prober.in: Likewise. + + * util/grub-install.in: Create environment block. + * util/i386/efi/grub-install.in: Likewise. + * util/ieee1275/grub-install.in: Likewise. + * util/sparc64/ieee1275/grub-install.in: Likewise. diff --git a/conf/common.rmk b/conf/common.rmk index 173f24b62..881c72795 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -175,6 +175,20 @@ CLEANFILES += $(grub-mkconfig_SCRIPTS) grub-mkconfig_DATA += util/grub.d/README +# For grub-set-default. +grub-set-default: util/grub-set-default.in config.status + ./config.status --file=$@:$< + chmod +x $@ +sbin_SCRIPTS += grub-set-default +CLEANFILES += grub-set-default + +# For grub-reboot. +grub-reboot: util/grub-reboot.in config.status + ./config.status --file=$@:$< + chmod +x $@ +sbin_SCRIPTS += grub-reboot +CLEANFILES += grub-reboot + # Filing systems. 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 \ diff --git a/normal/menu.c b/normal/menu.c index 8ee7d1c22..b9f74b7d7 100644 --- a/normal/menu.c +++ b/normal/menu.c @@ -137,6 +137,8 @@ grub_menu_execute_entry(grub_menu_entry_t entry) return; } + grub_env_set ("chosen", entry->title); + grub_parser_execute ((char *) entry->sourcecode); if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ()) diff --git a/normal/menu_text.c b/normal/menu_text.c index e0d96c47f..19f9cf756 100644 --- a/normal/menu_text.c +++ b/normal/menu_text.c @@ -237,7 +237,7 @@ grub_menu_init_page (int nested, int edit) /* Get the entry number from the variable NAME. */ static int -get_entry_number (const char *name) +get_entry_number (grub_menu_t menu, const char *name) { char *val; int entry; @@ -250,6 +250,28 @@ get_entry_number (const char *name) entry = (int) grub_strtoul (val, 0, 0); + if (grub_errno == GRUB_ERR_BAD_NUMBER) + { + /* See if the variable matches the title of a menu entry. */ + grub_menu_entry_t e = menu->entry_list; + int i; + + grub_errno = GRUB_ERR_NONE; + + for (i = 0; e; i++) + { + if (grub_strcmp (e->title, val) == 0) + { + entry = i; + break; + } + e = e->next; + } + + if (! e) + entry = -1; + } + if (grub_errno != GRUB_ERR_NONE) { grub_errno = GRUB_ERR_NONE; @@ -291,7 +313,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) first = 0; - default_entry = get_entry_number ("default"); + default_entry = get_entry_number (menu, "default"); /* If DEFAULT_ENTRY is not within the menu entries, fall back to the first entry. */ diff --git a/util/grub-install.in b/util/grub-install.in index 356e161e7..1cf7135fd 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -39,6 +39,7 @@ else fi grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` +grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` rootdir= grub_prefix=`echo /boot/grub | sed ${transform}` modules= @@ -250,6 +251,10 @@ fi # Write device to a variable so we don't have to traverse /dev every time. grub_device=`$grub_probe --target=device ${grubdir}` +if ! test -f ${grubdir}/grubenv; then + $grub_editenv ${grubdir}/grubenv create +fi + # Create the core image. First, auto-detect the filesystem module. fs_module=`$grub_probe --target=fs --device ${grub_device}` if test "x$fs_module" = x -a "x$modules" = x; then diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index bb30cc475..8cdd1d470 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -130,6 +130,14 @@ convert_system_path_to_grub_path () echo ${drive}${relative_path} } +save_default_entry () +{ + if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then + echo 'saved_entry=${chosen}' + echo 'save_env saved_entry' + fi +} + prepare_grub_to_access_device () { device=$1 diff --git a/util/grub-reboot.in b/util/grub-reboot.in new file mode 100644 index 000000000..886d61770 --- /dev/null +++ b/util/grub-reboot.in @@ -0,0 +1,104 @@ +#! /bin/sh +# +# Set a default boot entry for GRUB, for the next boot only. +# Copyright (C) 2004,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 . + +# Initialize some variables. +transform="@program_transform_name@" + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ + +grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` +rootdir= + +# Usage: usage +# Print the usage. +usage () { + cat <. +EOF +} + +# Check the arguments. +for option in "$@"; do + case "$option" in + -h | --help) + usage + exit 0 ;; + -v | --version) + echo "grub-install (GNU GRUB ${PACKAGE_VERSION})" + exit 0 ;; + --root-directory=*) + rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; + -*) + echo "Unrecognized option \`$option'" 1>&2 + usage + exit 1 + ;; + *) + if test "x$entry" != x; then + echo "More than one entry?" 1>&2 + usage + exit 1 + fi + entry="${option}" ;; + esac +done + +if test "x$entry" = x; then + echo "entry not specified." 1>&2 + usage + exit 1 +fi + +# Initialize these directories here, since ROOTDIR was initialized. +case "$host_os" in +netbsd* | openbsd*) + # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub + # instead of /boot/grub. + grub_prefix=`echo /grub | sed ${transform}` + bootdir=${rootdir} + ;; +*) + # Use /boot/grub by default. + bootdir=${rootdir}/boot + ;; +esac + +grubdir=${bootdir}/`echo grub | sed ${transform}` + +prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'` +if [ "$prev_saved_entry" ]; then + $grub_editenv ${grubdir}/grubenv set prev_saved_entry="$prev_saved_entry" +else + $grub_editenv ${grubdir}/grubenv unset prev_saved_entry +fi +$grub_editenv ${grubdir}/grubenv set saved_entry="$entry" + +# Bye. +exit 0 diff --git a/util/grub-set-default.in b/util/grub-set-default.in new file mode 100644 index 000000000..6663d3fbd --- /dev/null +++ b/util/grub-set-default.in @@ -0,0 +1,99 @@ +#! /bin/sh +# +# Set a default boot entry for GRUB. +# Copyright (C) 2004,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 . + +# Initialize some variables. +transform="@program_transform_name@" + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ + +grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` +rootdir= + +# Usage: usage +# Print the usage. +usage () { + cat <. +EOF +} + +# Check the arguments. +for option in "$@"; do + case "$option" in + -h | --help) + usage + exit 0 ;; + -v | --version) + echo "grub-install (GNU GRUB ${PACKAGE_VERSION})" + exit 0 ;; + --root-directory=*) + rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; + -*) + echo "Unrecognized option \`$option'" 1>&2 + usage + exit 1 + ;; + *) + if test "x$entry" != x; then + echo "More than one entry?" 1>&2 + usage + exit 1 + fi + entry="${option}" ;; + esac +done + +if test "x$entry" = x; then + echo "entry not specified." 1>&2 + usage + exit 1 +fi + +# Initialize these directories here, since ROOTDIR was initialized. +case "$host_os" in +netbsd* | openbsd*) + # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub + # instead of /boot/grub. + grub_prefix=`echo /grub | sed ${transform}` + bootdir=${rootdir} + ;; +*) + # Use /boot/grub by default. + bootdir=${rootdir}/boot + ;; +esac + +grubdir=${bootdir}/`echo grub | sed ${transform}` + +$grub_editenv ${grubdir}/grubenv unset prev_saved_entry +$grub_editenv ${grubdir}/grubenv set saved_entry="$entry" + +# Bye. +exit 0 diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 9f421dc1c..7279469b7 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -32,11 +32,19 @@ for i in ${GRUB_PRELOAD_MODULES} ; do done if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi +if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi cat << EOF +load_env set default=${GRUB_DEFAULT} +if [ \${prev_saved_entry} ]; then + saved_entry=\${prev_saved_entry} + save_env saved_entry + prev_saved_entry= + save_env prev_saved_entry +fi EOF case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index e693c7dfa..c1871e07a 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -75,6 +75,7 @@ prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/" cat << EOF multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} EOF +save_default_entry | sed -e "s/^/\t/" prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/" cat << EOF module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\ diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index c6712e32f..026f1d7ac 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -39,6 +39,7 @@ kfreebsd_entry () args="$4" # not used yet title="$(gettext "%s, with kFreeBSD %s")" printf "menuentry \"${title}\" {" ${os} ${version} + save_default_entry | sed -e "s/^/\t/" if [ -z "${prepare_boot_cache}" ]; then prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" fi diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 8803055cf..dc9696ec8 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -59,6 +59,7 @@ linux_entry () title="$(gettext "%s, with Linux %s")" fi printf "menuentry \"${title}\" {" ${os} ${version} + save_default_entry | sed -e "s/^/\t/" if [ -z "${prepare_boot_cache}" ]; then prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" fi diff --git a/util/grub.d/10_windows.in b/util/grub.d/10_windows.in index 055258e29..35dd4a4cc 100644 --- a/util/grub.d/10_windows.in +++ b/util/grub.d/10_windows.in @@ -73,6 +73,7 @@ for dir in $dirlist ; do menuentry "$OS" { EOF + save_default_entry | sed -e 's,^,\t,' prepare_grub_to_access_device "$dev" | sed 's,^,\t,' cat << EOF diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index c5728866c..103785ed9 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -55,6 +55,7 @@ for OS in ${OSPROBED} ; do cat << EOF menuentry "${LONGNAME} (on ${DEVICE})" { EOF + save_default_entry | sed -e "s/^/\t/" prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" case ${LONGNAME} in @@ -113,6 +114,8 @@ EOF cat << EOF menuentry "${LONGNAME} (on ${DEVICE})" { EOF + save_default_entry | sed -e "s/^/\t/" + save_default_entry | sed -e "s/^/\t/" prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" cat << EOF insmod vbe diff --git a/util/i386/efi/grub-install.in b/util/i386/efi/grub-install.in index a5f97e346..e597c4eee 100644 --- a/util/i386/efi/grub-install.in +++ b/util/i386/efi/grub-install.in @@ -34,6 +34,7 @@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${t grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` +grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` rootdir= grub_prefix=`echo /boot/grub | sed ${transform}` modules= @@ -178,6 +179,10 @@ for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do cp -f $file ${grubdir} || exit 1 done +if ! test -f ${grubdir}/grubenv; then + $grub_editenv ${grubdir}/grubenv create +fi + # Create the core image. First, auto-detect the filesystem module. fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}` if test "x$fs_module" = xfat; then :; else diff --git a/util/ieee1275/grub-install.in b/util/ieee1275/grub-install.in index 710ed125b..9a26b0dca 100644 --- a/util/ieee1275/grub-install.in +++ b/util/ieee1275/grub-install.in @@ -37,6 +37,7 @@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${t grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}` grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` +grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` rootdir= grub_prefix=`echo /boot/grub | sed ${transform}` modules= @@ -163,6 +164,10 @@ for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst ; do cp -f $file ${grubdir} || exit 1 done +if ! test -f ${grubdir}/grubenv; then + $grub_editenv ${grubdir}/grubenv create +fi + # Create the core image. First, auto-detect the filesystem module. fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}` if test "x$fs_module" = x -a "x$modules" = x; then diff --git a/util/sparc64/ieee1275/grub-install.in b/util/sparc64/ieee1275/grub-install.in index a03869cb3..f49157acd 100644 --- a/util/sparc64/ieee1275/grub-install.in +++ b/util/sparc64/ieee1275/grub-install.in @@ -38,6 +38,7 @@ grub_setup=${sbindir}/`echo grub-setup | sed ${transform}` grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` +grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` rootdir= grub_prefix=`echo /boot/grub | sed ${transform}` modules= @@ -206,6 +207,10 @@ for file in ${pkglibdir}/*.img; do cp -f $file ${grubdir} || exit 1 done +if ! test -f ${grubdir}/grubenv; then + $grub_editenv ${grubdir}/grubenv create +fi + # Write device to a variable so we don't have to traverse /dev every time. grub_device=`$grub_probe --target=device ${grubdir}` From 7f4f3f581ce36c66644df68e7107466540e690ab Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 22 Nov 2009 12:22:19 +0100 Subject: [PATCH 030/208] Unify grub-install.in for sparc64 with i386-ieee1275 --- util/grub-install.in | 10 +- util/sparc64/ieee1275/grub-install.in | 276 -------------------------- 2 files changed, 6 insertions(+), 280 deletions(-) delete mode 100644 util/sparc64/ieee1275/grub-install.in diff --git a/util/grub-install.in b/util/grub-install.in index a004b2d11..a18a530a1 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -32,7 +32,7 @@ platform=@platform@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` grub_setup=${sbindir}/`echo grub-setup | sed ${transform}` -if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then +if [ "${target_cpu}-${platform}" = "i386-pc" || "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` else grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}` @@ -51,6 +51,8 @@ debug=no if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then disk_module=biosdisk +elif [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then + disk_module= else disk_module=ata fi @@ -177,7 +179,7 @@ device_map=${grubdir}/device.map grub_probe="${grub_probe} --device-map=${device_map}" # Check if GRUB is installed. -if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then +if [ "${target_cpu}-${platform}" = "i386-pc" || "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then set $grub_setup dummy if test -f "$1"; then : @@ -239,7 +241,7 @@ done for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do cp -f $file ${grubdir} || exit 1 done -if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then +if [ "${target_cpu}-${platform}" = "i386-pc" || "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then for file in ${pkglibdir}/*.img ${pkglibdir}/efiemu??.o; do if test -f $file; then cp -f $file ${grubdir} || exit 1 @@ -316,7 +318,7 @@ if [ x$config != x ]; then config_opt="-c $config " fi -if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then +if [ "${target_cpu}-${platform}" = "i386-pc" || "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then $grub_mkimage ${config_opt} --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1 # Now perform the installation. diff --git a/util/sparc64/ieee1275/grub-install.in b/util/sparc64/ieee1275/grub-install.in deleted file mode 100644 index a03869cb3..000000000 --- a/util/sparc64/ieee1275/grub-install.in +++ /dev/null @@ -1,276 +0,0 @@ -#! /bin/sh - -# Install GRUB on your drive. -# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,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 -# 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 . - -# Initialize some variables. -transform="@program_transform_name@" - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -sbindir=@sbindir@ -bindir=@bindir@ -libdir=@libdir@ -PACKAGE_NAME=@PACKAGE_NAME@ -PACKAGE_TARNAME=@PACKAGE_TARNAME@ -PACKAGE_VERSION=@PACKAGE_VERSION@ -target_cpu=@target_cpu@ -platform=@platform@ -pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` - -# for make_system_path_relative_to_its_root() -. ${libdir}/grub/grub-mkconfig_lib - -grub_setup=${sbindir}/`echo grub-setup | sed ${transform}` -grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` -grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` -grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` -rootdir= -grub_prefix=`echo /boot/grub | sed ${transform}` -modules= - -install_device= -no_floppy= -force_lba= -recheck=no -debug=no - -# Usage: usage -# Print the usage. -usage () { - cat <. -EOF -} - -# Check the arguments. -for option in "$@"; do - case "$option" in - -h | --help) - usage - exit 0 ;; - -v | --version) - echo "grub-install (GNU GRUB ${PACKAGE_VERSION})" - exit 0 ;; - --modules=*) - modules=`echo "$option" | sed 's/--modules=//'` ;; - --root-directory=*) - rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; - --grub-setup=*) - grub_setup=`echo "$option" | sed 's/--grub-setup=//'` ;; - --grub-mkimage=*) - grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;; - --grub-mkdevicemap=*) - grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;; - --grub-probe=*) - grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;; - --no-floppy) - no_floppy="--no-floppy" ;; - --recheck) - recheck=yes ;; - # This is an undocumented feature... - --debug) - debug=yes ;; - -*) - echo "Unrecognized option \`$option'" 1>&2 - usage - exit 1 - ;; - *) - if test "x$install_device" != x; then - echo "More than one install_devices?" 1>&2 - usage - exit 1 - fi - install_device="${option}" ;; - esac -done - -if test "x$install_device" = x; then - echo "install_device not specified." 1>&2 - usage - exit 1 -fi - -# If the debugging feature is enabled, print commands. -setup_verbose= -if test $debug = yes; then - set -x - setup_verbose="--verbose" -fi - -# Initialize these directories here, since ROOTDIR was initialized. -bootdir=${rootdir}/boot -grubdir=${bootdir}/`echo grub | sed ${transform}` -device_map=${grubdir}/device.map - -grub_probe="${grub_probe} --device-map=${device_map}" - -# Check if GRUB is installed. -set $grub_setup dummy -if test -f "$1"; then - : -else - echo "$1: Not found." 1>&2 - exit 1 -fi - -set $grub_mkimage dummy -if test -f "$1"; then - : -else - echo "$1: Not found." 1>&2 - exit 1 -fi - -set $grub_mkdevicemap dummy -if test -f "$1"; then - : -else - echo "$1: Not found." 1>&2 - exit 1 -fi - -# Create the GRUB directory if it is not present. -test -d "$bootdir" || mkdir "$bootdir" || exit 1 -test -d "$grubdir" || mkdir "$grubdir" || exit 1 - -# If --recheck is specified, remove the device map, if present. -if test $recheck = yes; then - rm -f $device_map -fi - -# Create the device map file if it is not present. -if test -f "$device_map"; then - : -else - # Create a safe temporary file. - test -n "$mklog" && log_file=`$mklog` - - $grub_mkdevicemap --device-map=$device_map $no_floppy || exit 1 -fi - -# Make sure that there is no duplicated entry. -tmp=`sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' $device_map \ - | sort | uniq -d | sed -n 1p` -if test -n "$tmp"; then - echo "The drive $tmp is defined multiple times in the device map $device_map" 1>&2 - exit 1 -fi - -# Copy the GRUB images to the GRUB directory. -for file in ${grubdir}/*.mod ${grubdir}/*.lst ${grubdir}/*.img; do - if test -f $file && [ "`basename $file`" != menu.lst ]; then - rm -f $file || exit 1 - fi -done -for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do - cp -f $file ${grubdir} || exit 1 -done - -for file in ${pkglibdir}/*.img; do - cp -f $file ${grubdir} || exit 1 -done - -# Write device to a variable so we don't have to traverse /dev every time. -grub_device=`$grub_probe --target=device ${grubdir}` - -# Create the core image. First, auto-detect the filesystem module. -fs_module=`$grub_probe --target=fs --device ${grub_device}` -if test "x$fs_module" = x -a "x$modules" = x; then - echo "Auto-detection of a filesystem module failed." 1>&2 - echo "Please specify the module with the option \`--modules' explicitly." 1>&2 - exit 1 -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` - -# Device abstraction module, if any (lvm, raid). -devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}` - -modules="$modules $fs_module $partmap_module $devabstraction_module" - -prefix_drive= -if [ "x${devabstraction_module}" = "x" ] ; then - if echo "${install_device}" | grep -qx "(.*)" ; then - install_drive="${install_device}" - else - install_drive="`$grub_probe --target=drive --device ${install_device}`" - fi - grub_drive="`$grub_probe --target=drive --device ${grub_device}`" - - # Strip partition number - install_drive="`echo ${install_drive} | sed -e 's/\([^\]\),[0-9]*/\1/g'`" - grub_drive="`echo ${grub_drive} | sed -e 's/\([^\]\),[0-9]*/\1/g'`" - if [ "x${grub_drive}" != "x${install_drive}" ] ; then - uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`" - if [ "x${uuid}" = "x" ] ; then - echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 - exit 1 - fi - prefix_drive="(UUID=${uuid})" - modules="$modules fs_uuid" - fi -else - prefix_drive=`$grub_probe --target=drive --device ${grub_device}` -fi - -relative_grubdir=`make_system_path_relative_to_its_root ${grubdir}` || exit 1 -if [ "x${relative_grubdir}" = "x" ] ; then - relative_grubdir=/ -fi - -$grub_mkimage --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1 - -# Now perform the installation. -$grub_setup ${setup_verbose} --directory=${grubdir} --device-map=${device_map} \ - ${install_device} || exit 1 - -# Prompt the user to check if the device map is correct. -echo "Installation finished. No error reported." -echo "This is the contents of the device map $device_map." -echo "Check if this is correct or not. If any of the lines is incorrect," -echo "fix it and re-run the script \`grub-install'." -echo - -cat $device_map - -# Bye. -exit 0 From 937d332db3d491b2d1018519a84d54dec454a8f3 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 22 Nov 2009 13:15:49 +0100 Subject: [PATCH 031/208] compile and configuration fixes --- commands/search.c | 2 +- commands/search_wrap.c | 12 ++++++++++++ conf/common.rmk | 17 +++++++++-------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/commands/search.c b/commands/search.c index 60b5bbf04..e885391cf 100644 --- a/commands/search.c +++ b/commands/search.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include void FUNC_NAME (const char *key, const char *var, int no_floppy) diff --git a/commands/search_wrap.c b/commands/search_wrap.c index 35cce3f5e..d28bb744e 100644 --- a/commands/search_wrap.c +++ b/commands/search_wrap.c @@ -17,6 +17,14 @@ * along with GRUB. If not, see . */ +#include +#include +#include +#include +#include +#include +#include + static const struct grub_arg_option options[] = { {"file", 'f', 0, "search devices by a file", 0, 0}, @@ -36,6 +44,10 @@ enum options SEARCH_NO_FLOPPY, }; +void grub_search_fs_file (const char *key, const char *var, int no_floppy); +void grub_search_fs_uuid (const char *key, const char *var, int no_floppy); +void grub_search_label (const char *key, const char *var, int no_floppy); + static grub_err_t grub_cmd_search (grub_extcmd_t cmd, int argc, char **args) { diff --git a/conf/common.rmk b/conf/common.rmk index 00830e54d..f27c837b8 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -370,8 +370,7 @@ scsi_mod_LDFLAGS = $(COMMON_LDFLAGS) # Commands. pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \ - ls.mod cmp.mod cat.mod help.mod search_file.mod \ - search_fs_uuid.mod search_fs_label.mod search.mod loopback.mod \ + ls.mod cmp.mod cat.mod help.mod search.mod loopback.mod \ configfile.mod echo.mod \ terminfo.mod test.mod blocklist.mod hexdump.mod \ read.mod sleep.mod loadenv.mod crc.mod parttool.mod \ @@ -449,10 +448,12 @@ search_mod_SOURCES = commands/search_wrap.c search_mod_CFLAGS = $(COMMON_CFLAGS) search_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += search_fs_file.mod search_fs_uuid.mod search_label.mod + # For search.mod. -search_file_mod_SOURCES = commands/search_file.c -search_file_mod_CFLAGS = $(COMMON_CFLAGS) -search_file_mod_LDFLAGS = $(COMMON_LDFLAGS) +search_fs_file_mod_SOURCES = commands/search_file.c +search_fs_file_mod_CFLAGS = $(COMMON_CFLAGS) +search_fs_file_mod_LDFLAGS = $(COMMON_LDFLAGS) # For search.mod. search_label_mod_SOURCES = commands/search_label.c @@ -460,9 +461,9 @@ search_label_mod_CFLAGS = $(COMMON_CFLAGS) search_label_mod_LDFLAGS = $(COMMON_LDFLAGS) # For search.mod. -search_uuid_mod_SOURCES = commands/search_uuid.c -search_uuid_mod_CFLAGS = $(COMMON_CFLAGS) -search_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS) +search_fs_uuid_mod_SOURCES = commands/search_uuid.c +search_fs_uuid_mod_CFLAGS = $(COMMON_CFLAGS) +search_fs_uuid_mod_LDFLAGS = $(COMMON_LDFLAGS) # For test.mod. test_mod_SOURCES = commands/test.c From 4996893238fd3a2314aac73c856381cc09cacf5d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 23 Nov 2009 21:15:44 +0100 Subject: [PATCH 032/208] definition fixes --- commands/search.c | 9 ++--- commands/search_wrap.c | 5 +-- include/grub/search.h | 26 ++++++++++++++ po/ca.po | 81 +----------------------------------------- 4 files changed, 33 insertions(+), 88 deletions(-) create mode 100644 include/grub/search.h diff --git a/commands/search.c b/commands/search.c index e885391cf..fc73b550e 100644 --- a/commands/search.c +++ b/commands/search.c @@ -26,6 +26,7 @@ #include #include #include +#include void FUNC_NAME (const char *key, const char *var, int no_floppy) @@ -153,9 +154,9 @@ grub_cmd_do_search (grub_command_t cmd __attribute__ ((unused)), int argc, static grub_command_t cmd; -#ifdef SEARCH_FILE +#ifdef DO_SEARCH_FILE GRUB_MOD_INIT(search_file) -#elif defined (SEARCH_FS_UUID) +#elif defined (DO_SEARCH_FS_UUID) GRUB_MOD_INIT(search_fs_uuid) #else GRUB_MOD_INIT(search_fs_label) @@ -169,9 +170,9 @@ GRUB_MOD_INIT(search_fs_label) " set to a variable."); } -#ifdef SEARCH_FILE +#ifdef DO_SEARCH_FILE GRUB_MOD_FINI(search_file) -#elif defined (SEARCH_FS_UUID) +#elif defined (DO_SEARCH_FS_UUID) GRUB_MOD_FINI(search_fs_uuid) #else GRUB_MOD_FINI(search_fs_label) diff --git a/commands/search_wrap.c b/commands/search_wrap.c index d28bb744e..8bb26cd0c 100644 --- a/commands/search_wrap.c +++ b/commands/search_wrap.c @@ -24,6 +24,7 @@ #include #include #include +#include static const struct grub_arg_option options[] = { @@ -44,10 +45,6 @@ enum options SEARCH_NO_FLOPPY, }; -void grub_search_fs_file (const char *key, const char *var, int no_floppy); -void grub_search_fs_uuid (const char *key, const char *var, int no_floppy); -void grub_search_label (const char *key, const char *var, int no_floppy); - static grub_err_t grub_cmd_search (grub_extcmd_t cmd, int argc, char **args) { diff --git a/include/grub/search.h b/include/grub/search.h new file mode 100644 index 000000000..e8f9db285 --- /dev/null +++ b/include/grub/search.h @@ -0,0 +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_SEARCH_HEADER +#define GRUB_SEARCH_HEADER 1 + +void grub_search_fs_file (const char *key, const char *var, int no_floppy); +void grub_search_fs_uuid (const char *key, const char *var, int no_floppy); +void grub_search_label (const char *key, const char *var, int no_floppy); + +#endif diff --git a/po/ca.po b/po/ca.po index 3f9b0ac32..7c1025fdc 100644 --- a/po/ca.po +++ b/po/ca.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: GNU GRUB\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-11-19 00:16+0100\n" +"POT-Creation-Date: 2009-11-23 21:07+0100\n" "PO-Revision-Date: 2009-11-17 12:26+0100\n" "Last-Translator: Robert Millan \n" "Language-Team: None \n" @@ -22,30 +22,10 @@ msgstr "" msgid "cannot compress the kernel image" msgstr "" -#: util/i386/pc/grub-mkimage.c:117 -#, c-format -msgid "the size of memory disk is 0x%x" -msgstr "" - -#: util/i386/pc/grub-mkimage.c:124 -#, c-format -msgid "the size of config file is 0x%x" -msgstr "" - -#: util/i386/pc/grub-mkimage.c:132 -#, c-format -msgid "the total module size is 0x%x" -msgstr "" - #: util/i386/pc/grub-mkimage.c:138 msgid "prefix is too long" msgstr "" -#: util/i386/pc/grub-mkimage.c:199 -#, c-format -msgid "the core size is 0x%x" -msgstr "" - #: util/i386/pc/grub-mkimage.c:206 msgid "the core image is too big" msgstr "" @@ -89,20 +69,10 @@ msgstr "" msgid "cannot open %s" msgstr "" -#: util/i386/pc/grub-setup.c:162 -#, c-format -msgid "the first sector is <%llu,%u,%u>" -msgstr "" - #: util/i386/pc/grub-setup.c:166 msgid "The first sector of the core file is not sector-aligned" msgstr "" -#: util/i386/pc/grub-setup.c:176 -#, c-format -msgid "saving <%llu,%u,%u> with the segment 0x%x" -msgstr "" - #: util/i386/pc/grub-setup.c:180 msgid "Non-sector-aligned data is found in the core file" msgstr "" @@ -126,11 +96,6 @@ msgstr "" msgid "The size of `%s' is too large" msgstr "" -#: util/i386/pc/grub-setup.c:247 -#, c-format -msgid "setting the root device to `%s'" -msgstr "" - #: util/i386/pc/grub-setup.c:261 #, c-format msgid "Unable to identify a filesystem in %s; safety check can't be performed" @@ -149,11 +114,6 @@ msgstr "" msgid "No DOS-style partitions found" msgstr "" -#: util/i386/pc/grub-setup.c:325 -#, c-format -msgid "dos partition is %d, bsd partition is %d" -msgstr "" - #: util/i386/pc/grub-setup.c:330 util/i386/pc/grub-setup.c:355 msgid "" "Attempting to install GRUB to a partitionless disk. This is a BAD idea." @@ -185,11 +145,6 @@ msgstr "" msgid "Your embedding area is unusually small. core.img won't fit in it." msgstr "" -#: util/i386/pc/grub-setup.c:381 -#, c-format -msgid "the core image will be embedded at sector 0x%llx" -msgstr "" - #: util/i386/pc/grub-setup.c:418 msgid "" "Embedding is not possible, but this is required when the root device is on a " @@ -217,30 +172,6 @@ msgstr "" msgid "attempting to read the core image `%s' from GRUB again" msgstr "" -#: util/i386/pc/grub-setup.c:449 -#, c-format -msgid "" -"succeeded in opening the core image but the size is different (%d != %d)" -msgstr "" - -#: util/i386/pc/grub-setup.c:453 -#, c-format -msgid "succeeded in opening the core image but cannot read %d bytes" -msgstr "" - -#: util/i386/pc/grub-setup.c:476 -msgid "succeeded in opening the core image but the data is different" -msgstr "" - -#: util/i386/pc/grub-setup.c:487 -msgid "couldn't open the core image" -msgstr "" - -#: util/i386/pc/grub-setup.c:490 -#, c-format -msgid "error message = %s" -msgstr "" - #: util/i386/pc/grub-setup.c:498 #, c-format msgid "Cannot read `%s' correctly" @@ -258,11 +189,6 @@ msgstr "" msgid "Failed to read the rest sectors of the core image" msgstr "" -#: util/i386/pc/grub-setup.c:544 -#, c-format -msgid "opening the core image `%s'" -msgstr "" - #: util/i386/pc/grub-setup.c:547 #, c-format msgid "Cannot open `%s'" @@ -310,11 +236,6 @@ msgstr "" msgid "Invalid root device `%s'" msgstr "" -#: util/i386/pc/grub-setup.c:766 -#, c-format -msgid "guessing the root device failed, because of `%s'" -msgstr "" - #: util/i386/pc/grub-setup.c:768 msgid "Cannot guess the root device. Specify the option ``--root-device''." msgstr "" From 20f1afd41afa3db3b00c7c9398a4cdcd67cfde75 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 25 Nov 2009 22:34:35 +0100 Subject: [PATCH 033/208] Fixed various script issues. Thanks fezie for testing. --- util/grub-install.in | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/util/grub-install.in b/util/grub-install.in index a18a530a1..5118e6e56 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -32,7 +32,7 @@ platform=@platform@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` grub_setup=${sbindir}/`echo grub-setup | sed ${transform}` -if [ "${target_cpu}-${platform}" = "i386-pc" || "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then +if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` else grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}` @@ -179,7 +179,7 @@ device_map=${grubdir}/device.map grub_probe="${grub_probe} --device-map=${device_map}" # Check if GRUB is installed. -if [ "${target_cpu}-${platform}" = "i386-pc" || "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then +if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then set $grub_setup dummy if test -f "$1"; then : @@ -241,7 +241,7 @@ done for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do cp -f $file ${grubdir} || exit 1 done -if [ "${target_cpu}-${platform}" = "i386-pc" || "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then +if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then for file in ${pkglibdir}/*.img ${pkglibdir}/efiemu??.o; do if test -f $file; then cp -f $file ${grubdir} || exit 1 @@ -272,8 +272,14 @@ devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}` modules="$modules $disk_module" modules="$modules $fs_module $partmap_module $devabstraction_module" +relative_grubdir=`make_system_path_relative_to_its_root ${grubdir}` || exit 1 +if [ "x${relative_grubdir}" = "x" ] ; then + relative_grubdir=/ +fi + prefix_drive= -config= +config_opt= + if [ "x${devabstraction_module}" = "x" ] ; then if echo "${install_device}" | grep -qx "(.*)" ; then install_drive="${install_device}" @@ -292,7 +298,9 @@ if [ "x${devabstraction_module}" = "x" ] ; then echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 exit 1 fi - config="search_fs_uuid ${uuid} root" + echo "search.fs_uuid ${uuid} root " > ${grubdir}/load.cfg + echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg + config_opt="-c ${grubdir}/load.cfg " modules="$modules search_fs_uuid" elif [ "x${grub_drive}" != "x${install_drive}" ] ; then uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`" @@ -300,25 +308,16 @@ if [ "x${devabstraction_module}" = "x" ] ; then echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 exit 1 fi - config="search_fs_uuid ${uuid} root" + echo "search.fs_uuid ${uuid} root " > ${grubdir}/load.cfg + echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg + config_opt="-c ${grubdir}/load.cfg " modules="$modules search_fs_uuid" fi else prefix_drive=`$grub_probe --target=drive --device ${grub_device}` fi -relative_grubdir=`make_system_path_relative_to_its_root ${grubdir}` || exit 1 -if [ "x${relative_grubdir}" = "x" ] ; then - relative_grubdir=/ -fi - -config_opt= -echo $config > ${grubdir}/load.cfg -if [ x$config != x ]; then - config_opt="-c $config " -fi - -if [ "${target_cpu}-${platform}" = "i386-pc" || "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then +if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then $grub_mkimage ${config_opt} --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1 # Now perform the installation. From a261f807286581cbc86b08fa8141cc617bc6b842 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 26 Nov 2009 17:14:39 +0100 Subject: [PATCH 034/208] Added origin notice to lib/pbkdf2.c --- lib/pbkdf2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pbkdf2.c b/lib/pbkdf2.c index f2d3ca97f..083446ab9 100644 --- a/lib/pbkdf2.c +++ b/lib/pbkdf2.c @@ -16,6 +16,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Written by Simon Josefsson. */ +/* Imported from gnulib. */ #include #include From 84c6b0863ff40de102f9f0845136d1964ad94f43 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 26 Nov 2009 17:34:22 +0100 Subject: [PATCH 035/208] renamed grub-pbkdf2 into grub-mkpasswd-pbkdf2 --- conf/common.rmk | 4 ++-- util/{grub-pbkdf2.c => grub-mkpasswd-pbkdf2.c} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename util/{grub-pbkdf2.c => grub-mkpasswd-pbkdf2.c} (99%) diff --git a/conf/common.rmk b/conf/common.rmk index 58b1d8a31..f680655ed 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -638,7 +638,7 @@ password_pbkdf2_mod_SOURCES = commands/password_pbkdf2.c password_pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS) password_pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS) -bin_UTILITIES += grub-pbkdf2 -grub_pbkdf2_SOURCES = util/grub-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c +bin_UTILITIES += grub-mkpasswd-pbkdf2 +grub_mkpasswd_pbkdf2_SOURCES = util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c include $(srcdir)/conf/gcry.mk diff --git a/util/grub-pbkdf2.c b/util/grub-mkpasswd-pbkdf2.c similarity index 99% rename from util/grub-pbkdf2.c rename to util/grub-mkpasswd-pbkdf2.c index a05fa62b1..ad52aae91 100644 --- a/util/grub-pbkdf2.c +++ b/util/grub-mkpasswd-pbkdf2.c @@ -120,7 +120,7 @@ main (int argc, char *argv[]) struct termios s, t; int tty_changed; - progname = "grub-pbkdf2"; + progname = "grub-mkpasswd-pbkdf2"; /* Check for options. */ while (1) From 6ee8daeead5859a956dc9f919b4bb612627eb072 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 27 Nov 2009 13:38:01 +0100 Subject: [PATCH 036/208] Second part of the LBA fix --- ChangeLog.lbafix | 1 + kern/i386/pc/startup.S | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog.lbafix b/ChangeLog.lbafix index add35fb83..ec9737e9c 100644 --- a/ChangeLog.lbafix +++ b/ChangeLog.lbafix @@ -2,4 +2,5 @@ * kern/i386/pc/startup.S (grub_biosdisk_get_diskinfo_int13_extensions): Ignore return status if CF is cleared. + (grub_biosdisk_get_diskinfo_standard): Likewise. diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S index 83f0b4ef8..a81795b22 100644 --- a/kern/i386/pc/startup.S +++ b/kern/i386/pc/startup.S @@ -824,6 +824,11 @@ FUNCTION(grub_biosdisk_get_diskinfo_standard) .code16 movb $0x8, %ah int $0x13 /* do the operation */ + jc noclean2 + /* Clean return value if carry isn't set to workaround + some buggy BIOSes. */ + xor %ax, %ax +noclean2: /* check if successful */ testb %ah, %ah jnz 1f From 9d1fafb96e554d6246ae14b42887f3d9774458b5 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 5 Dec 2009 16:33:39 +0100 Subject: [PATCH 037/208] Move include/grub/cipher_wrap.h to lib/libgcrypt_wrap/cipher_wrap.h --- conf/common.rmk | 1 + .../grub => lib/libgcrypt_wrap}/cipher_wrap.h | 0 util/import_gcry.py | 23 +++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) rename {include/grub => lib/libgcrypt_wrap}/cipher_wrap.h (100%) diff --git a/conf/common.rmk b/conf/common.rmk index f680655ed..376700be2 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -640,5 +640,6 @@ password_pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS) bin_UTILITIES += grub-mkpasswd-pbkdf2 grub_mkpasswd_pbkdf2_SOURCES = util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c +grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap include $(srcdir)/conf/gcry.mk diff --git a/include/grub/cipher_wrap.h b/lib/libgcrypt_wrap/cipher_wrap.h similarity index 100% rename from include/grub/cipher_wrap.h rename to lib/libgcrypt_wrap/cipher_wrap.h diff --git a/util/import_gcry.py b/util/import_gcry.py index b66de90cc..fe68c85a4 100644 --- a/util/import_gcry.py +++ b/util/import_gcry.py @@ -67,6 +67,12 @@ for cipher_file in cipher_files: if cipher_file == "ChangeLog": continue chlognew = " * %s" % cipher_file + if re.match ("(Manifest|Makefile\.am|ac\.c|cipher\.c|hash-common\.c|hmac-tests\.c|md\.c|pubkey\.c)$", cipher_file): + chlog = "%s%s: Removed\n" % (chlog, chlognew) + continue + # Autogenerated files. Not even worth mentionning in ChangeLog + if re.match ("Makefile\.in$", cipher_file): + continue nch = False if re.match (".*\.[ch]$", cipher_file): isc = re.match (".*\.c$", cipher_file) @@ -220,7 +226,7 @@ for cipher_file in cipher_files: conf.write ("pkglib_MODULES += %s.mod\n" % modname) conf.write ("%s_mod_SOURCES = %s\n" %\ (modname, modfiles)) - conf.write ("%s_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-missing-field-initializers -Wno-error\n" % modname) + conf.write ("%s_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap\n" % modname) conf.write ("%s_mod_LDFLAGS = $(COMMON_LDFLAGS)\n\n" % modname) elif isc and cipher_file != "camellia.c": print ("WARNING: C file isn't a module: %s" % cipher_file) @@ -229,26 +235,19 @@ for cipher_file in cipher_files: if nch: chlog = "%s%s\n" % (chlog, chlognew) continue - if re.match ("(Manifest|Makefile\.am)$", cipher_file): - chlog = "%s%sRemoved\n" % (chlog, chlognew) - continue - # Autogenerated files. Not even worth mentionning in ChangeLog - if re.match ("Makefile\.in$", cipher_file): - chlog = "%s%sRemoved\n" % (chlog, chlognew) - continue chlog = "%s%sSkipped unknown file\n" % (chlog, chlognew) print ("WARNING: unknown file %s" % cipher_file) outfile = os.path.join (cipher_dir_out, "types.h") fw=open (outfile, "w") fw.write ("#include \n") -fw.write ("#include \n") +fw.write ("#include \n") chlog = "%s * types.h: New file.\n" % chlog fw.close () outfile = os.path.join (cipher_dir_out, "memory.h") fw=open (outfile, "w") -fw.write ("#include \n") +fw.write ("#include \n") chlog = "%s * memory.h: New file.\n" % chlog fw.close () @@ -256,13 +255,13 @@ fw.close () outfile = os.path.join (cipher_dir_out, "cipher.h") fw=open (outfile, "w") fw.write ("#include \n") -fw.write ("#include \n") +fw.write ("#include \n") chlog = "%s * cipher.h: Likewise.\n" % chlog fw.close () outfile = os.path.join (cipher_dir_out, "g10lib.h") fw=open (outfile, "w") -fw.write ("#include \n") +fw.write ("#include \n") chlog = "%s * g10lib.h: Likewise.\n" % chlog fw.close () From fd39f820fdbd4fdb9d82cdc6befecdd25904709a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 5 Dec 2009 18:59:36 +0100 Subject: [PATCH 038/208] fix mismerge with trunk (progname) --- conf/common.rmk | 2 +- util/grub-mkpasswd-pbkdf2.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/conf/common.rmk b/conf/common.rmk index 395d6b17b..0c6fb0cae 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -650,7 +650,7 @@ password_pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS) password_pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS) bin_UTILITIES += grub-mkpasswd-pbkdf2 -grub_mkpasswd_pbkdf2_SOURCES = util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c +grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap include $(srcdir)/conf/gcry.mk diff --git a/util/grub-mkpasswd-pbkdf2.c b/util/grub-mkpasswd-pbkdf2.c index ad52aae91..2f7c5efaa 100644 --- a/util/grub-mkpasswd-pbkdf2.c +++ b/util/grub-mkpasswd-pbkdf2.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -27,6 +28,7 @@ #include #include +#include "progname.h" /* Few functions to make crypto happy. */ void * @@ -120,7 +122,10 @@ main (int argc, char *argv[]) struct termios s, t; int tty_changed; - progname = "grub-mkpasswd-pbkdf2"; + set_program_name (argv[0]); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); /* Check for options. */ while (1) @@ -149,7 +154,7 @@ main (int argc, char *argv[]) return 0; case 'V': - printf ("%s (%s) %s\n", progname, + printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION); return 0; From c0a6bd447e6d551df5dc27128ad539f00abf7e39 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 5 Dec 2009 20:45:32 +0100 Subject: [PATCH 039/208] fix *-emu build --- conf/any-emu.rmk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index 9038b07df..cf13d2b67 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -45,7 +45,10 @@ 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/msdospart.c \ + lib/libgcrypt-grub/cipher/md5.c \ grub_emu_init.c gnulib/progname.c +grub_emu_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap + ifeq ($(target_cpu), i386) grub_emu_SOURCES += commands/i386/cpuid.c From b391bdb2f2c5ccf29da66cecdbfb7566656a704d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 6 Dec 2009 20:11:50 +0100 Subject: [PATCH 040/208] Use dedicated simple password retriever for size of future crypto disks modules and simplify entering passwords routines --- commands/password.c | 19 +++++----------- commands/password_pbkdf2.c | 11 +++------ conf/common.rmk | 2 +- include/grub/auth.h | 9 +++----- include/grub/crypto.h | 10 ++++++--- lib/crypto.c | 46 ++++++++++++++++++++++++++++++++++++-- normal/auth.c | 20 +++++++---------- 7 files changed, 71 insertions(+), 46 deletions(-) diff --git a/commands/password.c b/commands/password.c index 99b993839..7bb2f0ae5 100644 --- a/commands/password.c +++ b/commands/password.c @@ -27,20 +27,11 @@ static grub_dl_t my_mod; -#define MAX_PASSLEN 1024 - static grub_err_t -check_password (const char *user, +check_password (const char *user, const char *entered, void *password) { - char entered[MAX_PASSLEN]; - - grub_memset (entered, 0, sizeof (entered)); - - if (!GRUB_GET_PASSWORD (entered, sizeof (entered) - 1)) - return GRUB_ACCESS_DENIED; - - if (grub_crypto_memcmp (entered, password, MAX_PASSLEN) != 0) + if (grub_crypto_memcmp (entered, password, GRUB_AUTH_MAX_PASSLEN) != 0) return GRUB_ACCESS_DENIED; grub_auth_authenticate (user); @@ -59,12 +50,12 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)), if (argc != 2) return grub_error (GRUB_ERR_BAD_ARGUMENT, "Two arguments expected."); - pass = grub_zalloc (MAX_PASSLEN); + pass = grub_zalloc (GRUB_AUTH_MAX_PASSLEN); if (!pass) return grub_errno; copylen = grub_strlen (args[1]); - if (copylen >= MAX_PASSLEN) - copylen = MAX_PASSLEN - 1; + if (copylen >= GRUB_AUTH_MAX_PASSLEN) + copylen = GRUB_AUTH_MAX_PASSLEN - 1; grub_memcpy (pass, args[1], copylen); err = grub_auth_register_authentication (args[0], check_password, pass); diff --git a/commands/password_pbkdf2.c b/commands/password_pbkdf2.c index 38481f362..51c8ea794 100644 --- a/commands/password_pbkdf2.c +++ b/commands/password_pbkdf2.c @@ -16,6 +16,7 @@ * along with GRUB. If not, see . */ +#include #include #include #include @@ -36,23 +37,17 @@ struct pbkdf2_password }; static grub_err_t -check_password (const char *user, void *pin) +check_password (const char *user, const char *entered, void *pin) { - char entered[1024]; grub_uint8_t *buf; struct pbkdf2_password *pass = pin; gcry_err_code_t err; - grub_memset (entered, 0, sizeof (entered)); - - if (!GRUB_GET_PASSWORD (entered, sizeof (entered) - 1)) - return GRUB_ACCESS_DENIED; - buf = grub_malloc (pass->buflen); if (!buf) return grub_crypto_gcry_error (GPG_ERR_OUT_OF_MEMORY); - err = grub_crypto_pbkdf2 (GRUB_MD_SHA512, (grub_uint8_t *) &entered, + err = grub_crypto_pbkdf2 (GRUB_MD_SHA512, (grub_uint8_t *) entered, grub_strlen (entered), pass->salt, pass->saltlen, pass->c, buf, pass->buflen); diff --git a/conf/common.rmk b/conf/common.rmk index 0c6fb0cae..ad0e4942c 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -651,6 +651,6 @@ password_pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS) bin_UTILITIES += grub-mkpasswd-pbkdf2 grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c -grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap +grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1 include $(srcdir)/conf/gcry.mk diff --git a/include/grub/auth.h b/include/grub/auth.h index e72d984ae..747334451 100644 --- a/include/grub/auth.h +++ b/include/grub/auth.h @@ -19,14 +19,11 @@ #define GRUB_AUTH_HEADER 1 #include +#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) +#define GRUB_AUTH_MAX_PASSLEN 1024 -typedef grub_err_t (*grub_auth_callback_t) (const char*, void *); +typedef grub_err_t (*grub_auth_callback_t) (const char *, const char *, void *); grub_err_t grub_auth_register_authentication (const char *user, grub_auth_callback_t callback, diff --git a/include/grub/crypto.h b/include/grub/crypto.h index eb1898fe4..3129131cb 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -26,8 +26,6 @@ #include #include #include -/* For GRUB_ACCESS_DENIED. */ -#include typedef enum { @@ -264,6 +262,12 @@ grub_crypto_pbkdf2 (const struct gcry_md_spec *md, grub_uint8_t *DK, grub_size_t dkLen); int -grub_crypto_memcmp (void *a, void *b, grub_size_t n); +grub_crypto_memcmp (const void *a, const void *b, grub_size_t n); + +int +grub_password_get (char buf[], unsigned buf_size); + +/* For indistinguishibility. */ +#define GRUB_ACCESS_DENIED grub_error (GRUB_ERR_ACCESS_DENIED, "Access denied.") #endif diff --git a/lib/crypto.c b/lib/crypto.c index 4b36dde6f..06104bd4d 100644 --- a/lib/crypto.c +++ b/lib/crypto.c @@ -20,6 +20,7 @@ #include #include #include +#include struct grub_crypto_hmac_handle { @@ -372,10 +373,10 @@ grub_crypto_gcry_error (gcry_err_code_t in) } int -grub_crypto_memcmp (void *a, void *b, grub_size_t n) +grub_crypto_memcmp (const void *a, const void *b, grub_size_t n) { register grub_size_t counter = 0; - grub_uint8_t *pa, *pb; + const grub_uint8_t *pa, *pb; for (pa = a, pb = b; n; pa++, pb++, n--) { @@ -385,3 +386,44 @@ grub_crypto_memcmp (void *a, void *b, grub_size_t n) return !!counter; } + +#ifndef GRUB_MKPASSWD +int +grub_password_get (char buf[], unsigned buf_size) +{ + unsigned cur_len = 0; + int key; + + while (1) + { + key = GRUB_TERM_ASCII_CHAR (grub_getkey ()); + if (key == '\n' || key == '\r') + break; + + if (key == '\e') + { + cur_len = 0; + break; + } + + if (key == '\b') + { + cur_len--; + continue; + } + + if (!grub_isprint (key)) + continue; + + if (cur_len + 2 < buf_size) + buf[cur_len++] = key; + } + + grub_memset (buf + cur_len, 0, buf_size - cur_len); + + grub_putchar ('\n'); + grub_refresh (); + + return (key != '\e'); +} +#endif diff --git a/normal/auth.c b/normal/auth.c index 0a8b5bc82..d679fcc35 100644 --- a/normal/auth.c +++ b/normal/auth.c @@ -160,6 +160,7 @@ grub_auth_check_authentication (const char *userlist) struct grub_auth_user *cur = NULL; grub_err_t err; static unsigned long punishment_delay = 1; + char entered[GRUB_AUTH_MAX_PASSLEN]; auto int hook (grub_list_t item); int hook (grub_list_t item) @@ -189,22 +190,17 @@ grub_auth_check_authentication (const char *userlist) 0, 0, 0)) goto access_denied; + grub_printf ("Enter password: "); + + if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN)) + goto access_denied; + grub_list_iterate (GRUB_AS_LIST (users), hook); if (!cur || ! cur->callback) - { - grub_list_iterate (GRUB_AS_LIST (users), hook_any); + goto access_denied; - /* No users present at all. */ - if (!cur) - goto access_denied; - - /* Display any of available authentication schemes. */ - err = cur->callback (login, 0); - - goto access_denied; - } - err = cur->callback (login, cur->arg); + err = cur->callback (login, entered, cur->arg); if (is_authenticated (userlist)) { punishment_delay = 1; From b824145a8f2f6435a62b6d127536078f6d3e136c Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 8 Dec 2009 00:56:39 +0000 Subject: [PATCH 041/208] 2009-12-08 Colin Watson * util/grub.d/30_os-prober.in: Fix merge error that moved a `save_default_entry' call from the macosx case to the linux case. --- ChangeLog.savedefault | 5 +++++ util/grub.d/30_os-prober.in | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog.savedefault b/ChangeLog.savedefault index c18106bd5..0810274a3 100644 --- a/ChangeLog.savedefault +++ b/ChangeLog.savedefault @@ -1,3 +1,8 @@ +2009-12-08 Colin Watson + + * util/grub.d/30_os-prober.in: Fix merge error that moved a + `save_default_entry' call from the macosx case to the linux case. + 2009-10-25 Vladimir Serbinenko 2009-10-25 Colin Watson diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 0e71096d1..f4a37d5f5 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -97,6 +97,7 @@ EOF cat << EOF menuentry "${LLABEL} (on ${DEVICE})" { EOF + save_default_entry | sed -e "s/^/\t/" if [ -z "${prepare_boot_cache}" ]; then prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/")" fi @@ -119,7 +120,6 @@ EOF cat << EOF menuentry "${LONGNAME} (on ${DEVICE})" { EOF - save_default_entry | sed -e "s/^/\t/" save_default_entry | sed -e "s/^/\t/" prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" cat << EOF From 36cd6dd151db7b033fb3d0fd055f8c7d83feb928 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 8 Dec 2009 00:57:46 +0000 Subject: [PATCH 042/208] 2009-12-08 Colin Watson * util/grub.d/00_header.in: Quote the value assigned to `default', in case it contains spaces. --- ChangeLog.savedefault | 5 +++++ util/grub.d/00_header.in | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog.savedefault b/ChangeLog.savedefault index 0810274a3..6f885a73f 100644 --- a/ChangeLog.savedefault +++ b/ChangeLog.savedefault @@ -1,3 +1,8 @@ +2009-12-08 Colin Watson + + * util/grub.d/00_header.in: Quote the value assigned to `default', + in case it contains spaces. + 2009-12-08 Colin Watson * util/grub.d/30_os-prober.in: Fix merge error that moved a diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 577a12722..e8c3a14c4 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -40,7 +40,7 @@ if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi cat << EOF load_env -set default=${GRUB_DEFAULT} +set default="${GRUB_DEFAULT}" if [ \${prev_saved_entry} ]; then saved_entry=\${prev_saved_entry} save_env saved_entry From 42356b4d5e1ee06d9189b4b4001215585c62dc8a Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 8 Dec 2009 00:59:26 +0000 Subject: [PATCH 043/208] 2009-12-08 Colin Watson * util/grub.d/00_header.in: Silently ignore zero-sized environment blocks. --- ChangeLog.savedefault | 5 +++++ util/grub.d/00_header.in | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog.savedefault b/ChangeLog.savedefault index 6f885a73f..cdeb05a87 100644 --- a/ChangeLog.savedefault +++ b/ChangeLog.savedefault @@ -1,3 +1,8 @@ +2009-12-08 Colin Watson + + * util/grub.d/00_header.in: Silently ignore zero-sized environment + blocks. + 2009-12-08 Colin Watson * util/grub.d/00_header.in: Quote the value assigned to `default', diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index e8c3a14c4..2bcfe1d25 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -39,7 +39,9 @@ if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi cat << EOF -load_env +if [ -s \$prefix/grubenv ]; then + load_env +fi set default="${GRUB_DEFAULT}" if [ \${prev_saved_entry} ]; then saved_entry=\${prev_saved_entry} From 47075ea3c749f0d4ed082f7748387abc7f8a0717 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 8 Dec 2009 01:00:26 +0000 Subject: [PATCH 044/208] 2009-12-08 Colin Watson * util/grub-reboot.in: Fix --version output. * util/grub-set-default.in: Likewise. --- ChangeLog.savedefault | 5 +++++ util/grub-reboot.in | 2 +- util/grub-set-default.in | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog.savedefault b/ChangeLog.savedefault index cdeb05a87..55500a67c 100644 --- a/ChangeLog.savedefault +++ b/ChangeLog.savedefault @@ -1,3 +1,8 @@ +2009-12-08 Colin Watson + + * util/grub-reboot.in: Fix --version output. + * util/grub-set-default.in: Likewise. + 2009-12-08 Colin Watson * util/grub.d/00_header.in: Silently ignore zero-sized environment diff --git a/util/grub-reboot.in b/util/grub-reboot.in index 886d61770..16abdf6f4 100644 --- a/util/grub-reboot.in +++ b/util/grub-reboot.in @@ -51,7 +51,7 @@ for option in "$@"; do usage exit 0 ;; -v | --version) - echo "grub-install (GNU GRUB ${PACKAGE_VERSION})" + echo "grub-reboot (GNU GRUB ${PACKAGE_VERSION})" exit 0 ;; --root-directory=*) rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; diff --git a/util/grub-set-default.in b/util/grub-set-default.in index 6663d3fbd..4d7c10e8e 100644 --- a/util/grub-set-default.in +++ b/util/grub-set-default.in @@ -51,7 +51,7 @@ for option in "$@"; do usage exit 0 ;; -v | --version) - echo "grub-install (GNU GRUB ${PACKAGE_VERSION})" + echo "grub-set-default (GNU GRUB ${PACKAGE_VERSION})" exit 0 ;; --root-directory=*) rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; From b967a04d5b398fcbe5e3a157432f8559ca41b087 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 8 Dec 2009 01:01:21 +0000 Subject: [PATCH 045/208] 2009-12-08 Colin Watson * util/grub.d/00_header.in: Use `set var=val' rather than plain `var=val'. * util/grub-mkconfig_lib.in (save_default_entry): Likewise. --- ChangeLog.savedefault | 6 ++++++ util/grub-mkconfig_lib.in | 2 +- util/grub.d/00_header.in | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog.savedefault b/ChangeLog.savedefault index 55500a67c..25811c79b 100644 --- a/ChangeLog.savedefault +++ b/ChangeLog.savedefault @@ -1,3 +1,9 @@ +2009-12-08 Colin Watson + + * util/grub.d/00_header.in: Use `set var=val' rather than plain + `var=val'. + * util/grub-mkconfig_lib.in (save_default_entry): Likewise. + 2009-12-08 Colin Watson * util/grub-reboot.in: Fix --version output. diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index d18002ce4..95fd02ad9 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -93,7 +93,7 @@ convert_system_path_to_grub_path () save_default_entry () { if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then - echo 'saved_entry=${chosen}' + echo 'set saved_entry=${chosen}' echo 'save_env saved_entry' fi } diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 2bcfe1d25..4cd8fd30c 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -44,9 +44,9 @@ if [ -s \$prefix/grubenv ]; then fi set default="${GRUB_DEFAULT}" if [ \${prev_saved_entry} ]; then - saved_entry=\${prev_saved_entry} + set saved_entry=\${prev_saved_entry} save_env saved_entry - prev_saved_entry= + set prev_saved_entry= save_env prev_saved_entry fi EOF From 6c1f8c1215b57cf404d103003d0becc74dbeed10 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 8 Dec 2009 01:02:08 +0000 Subject: [PATCH 046/208] 2009-12-08 Colin Watson * util/grub.d/30_os-prober.in: Call save_default_entry for hurd. --- ChangeLog.savedefault | 4 ++++ util/grub.d/30_os-prober.in | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog.savedefault b/ChangeLog.savedefault index 25811c79b..7457c3f71 100644 --- a/ChangeLog.savedefault +++ b/ChangeLog.savedefault @@ -1,3 +1,7 @@ +2009-12-08 Colin Watson + + * util/grub.d/30_os-prober.in: Call save_default_entry for hurd. + 2009-12-08 Colin Watson * util/grub.d/00_header.in: Use `set var=val' rather than plain diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index f4a37d5f5..b91838782 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -170,6 +170,7 @@ EOF cat << EOF menuentry "${LONGNAME} (on ${DEVICE})" { EOF + save_default_entry | sed -e "s/^/\t/" prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" grub_device="`${grub_probe} --device ${DEVICE} --target=drive`" mach_device="`echo "${grub_device}" | tr -d '()' | tr , s`" From 03157a273d846d04d724857eee0b538f0ef191ca Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sat, 12 Dec 2009 00:10:38 +0000 Subject: [PATCH 047/208] util/sparc64/ieee1275/grub-install.in was meant to be removed --- conf/sparc64-ieee1275.rmk | 2 +- util/sparc64/ieee1275/grub-install.in | 276 -------------------------- 2 files changed, 1 insertion(+), 277 deletions(-) delete mode 100644 util/sparc64/ieee1275/grub-install.in diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index d19e927a5..32723b635 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -93,7 +93,7 @@ grub_ofpathname_SOURCES = util/sparc64/ieee1275/grub-ofpathname.c \ sbin_SCRIPTS = grub-install # For grub-install. -grub_install_SOURCES = util/sparc64/ieee1275/grub-install.in +grub_install_SOURCES = util/grub-install.in # Modules. pkglib_MODULES = halt.mod \ diff --git a/util/sparc64/ieee1275/grub-install.in b/util/sparc64/ieee1275/grub-install.in deleted file mode 100644 index 5cfb858d7..000000000 --- a/util/sparc64/ieee1275/grub-install.in +++ /dev/null @@ -1,276 +0,0 @@ -#! /bin/sh - -# Install GRUB on your drive. -# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,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 -# 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 . - -# Initialize some variables. -transform="@program_transform_name@" - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -sbindir=@sbindir@ -bindir=@bindir@ -libdir=@libdir@ -PACKAGE_NAME=@PACKAGE_NAME@ -PACKAGE_TARNAME=@PACKAGE_TARNAME@ -PACKAGE_VERSION=@PACKAGE_VERSION@ -target_cpu=@target_cpu@ -platform=@platform@ -pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` - -grub_setup=${sbindir}/`echo grub-setup | sed ${transform}` -grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` -grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` -grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` -rootdir= -grub_prefix=`echo /boot/grub | sed ${transform}` -modules= - -install_device= -no_floppy= -force_lba= -recheck=no -debug=no - -# Usage: usage -# Print the usage. -usage () { - cat <. -EOF -} - -# Check the arguments. -for option in "$@"; do - case "$option" in - -h | --help) - usage - exit 0 ;; - -v | --version) - echo "grub-install (GNU GRUB ${PACKAGE_VERSION})" - exit 0 ;; - --modules=*) - modules=`echo "$option" | sed 's/--modules=//'` ;; - --root-directory=*) - rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; - --grub-setup=*) - grub_setup=`echo "$option" | sed 's/--grub-setup=//'` ;; - --grub-mkimage=*) - grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;; - --grub-mkdevicemap=*) - grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;; - --grub-probe=*) - grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;; - --no-floppy) - no_floppy="--no-floppy" ;; - --recheck) - recheck=yes ;; - # This is an undocumented feature... - --debug) - debug=yes ;; - -*) - echo "Unrecognized option \`$option'" 1>&2 - usage - exit 1 - ;; - *) - if test "x$install_device" != x; then - echo "More than one install_devices?" 1>&2 - usage - exit 1 - fi - install_device="${option}" ;; - esac -done - -# for make_system_path_relative_to_its_root() -. ${libdir}/grub/grub-mkconfig_lib - -if test "x$install_device" = x; then - echo "install_device not specified." 1>&2 - usage - exit 1 -fi - -# If the debugging feature is enabled, print commands. -setup_verbose= -if test $debug = yes; then - set -x - setup_verbose="--verbose" -fi - -# Initialize these directories here, since ROOTDIR was initialized. -bootdir=${rootdir}/boot -grubdir=${bootdir}/`echo grub | sed ${transform}` -device_map=${grubdir}/device.map - -grub_probe="${grub_probe} --device-map=${device_map}" - -# Check if GRUB is installed. -set $grub_setup dummy -if test -f "$1"; then - : -else - echo "$1: Not found." 1>&2 - exit 1 -fi - -set $grub_mkimage dummy -if test -f "$1"; then - : -else - echo "$1: Not found." 1>&2 - exit 1 -fi - -set $grub_mkdevicemap dummy -if test -f "$1"; then - : -else - echo "$1: Not found." 1>&2 - exit 1 -fi - -# Create the GRUB directory if it is not present. -test -d "$bootdir" || mkdir "$bootdir" || exit 1 -test -d "$grubdir" || mkdir "$grubdir" || exit 1 - -# If --recheck is specified, remove the device map, if present. -if test $recheck = yes; then - rm -f $device_map -fi - -# Create the device map file if it is not present. -if test -f "$device_map"; then - : -else - # Create a safe temporary file. - test -n "$mklog" && log_file=`$mklog` - - $grub_mkdevicemap --device-map=$device_map $no_floppy || exit 1 -fi - -# Make sure that there is no duplicated entry. -tmp=`sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' $device_map \ - | sort | uniq -d | sed -n 1p` -if test -n "$tmp"; then - echo "The drive $tmp is defined multiple times in the device map $device_map" 1>&2 - exit 1 -fi - -# Copy the GRUB images to the GRUB directory. -for file in ${grubdir}/*.mod ${grubdir}/*.lst ${grubdir}/*.img; do - if test -f $file && [ "`basename $file`" != menu.lst ]; then - rm -f $file || exit 1 - fi -done -for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do - cp -f $file ${grubdir} || exit 1 -done - -for file in ${pkglibdir}/*.img; do - cp -f $file ${grubdir} || exit 1 -done - -# Write device to a variable so we don't have to traverse /dev every time. -grub_device=`$grub_probe --target=device ${grubdir}` - -# Create the core image. First, auto-detect the filesystem module. -fs_module=`$grub_probe --target=fs --device ${grub_device}` -if test "x$fs_module" = x -a "x$modules" = x; then - echo "Auto-detection of a filesystem module failed." 1>&2 - echo "Please specify the module with the option \`--modules' explicitly." 1>&2 - exit 1 -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` - -# Device abstraction module, if any (lvm, raid). -devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}` - -modules="$modules $fs_module $partmap_module $devabstraction_module" - -prefix_drive= -if [ "x${devabstraction_module}" = "x" ] ; then - if echo "${install_device}" | grep -qx "(.*)" ; then - install_drive="${install_device}" - else - install_drive="`$grub_probe --target=drive --device ${install_device}`" - fi - grub_drive="`$grub_probe --target=drive --device ${grub_device}`" - - # Strip partition number - install_drive="`echo ${install_drive} | sed -e 's/\([^\]\),[0-9]*/\1/g'`" - grub_drive="`echo ${grub_drive} | sed -e 's/\([^\]\),[0-9]*/\1/g'`" - if [ "x${grub_drive}" != "x${install_drive}" ] ; then - uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`" - if [ "x${uuid}" = "x" ] ; then - echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 - exit 1 - fi - prefix_drive="(UUID=${uuid})" - modules="$modules fs_uuid" - fi -else - prefix_drive=`$grub_probe --target=drive --device ${grub_device}` -fi - -relative_grubdir=`make_system_path_relative_to_its_root ${grubdir}` || exit 1 -if [ "x${relative_grubdir}" = "x" ] ; then - relative_grubdir=/ -fi - -$grub_mkimage --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1 - -# Now perform the installation. -$grub_setup ${setup_verbose} --directory=${grubdir} --device-map=${device_map} \ - ${install_device} || exit 1 - -# Prompt the user to check if the device map is correct. -echo "Installation finished. No error reported." -echo "This is the contents of the device map $device_map." -echo "Check if this is correct or not. If any of the lines is incorrect," -echo "fix it and re-run the script \`grub-install'." -echo - -cat $device_map - -# Bye. -exit 0 From 8140d50bdc4d25df56ab8d254694ce77cc7f7935 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 20 Dec 2009 20:05:53 +0100 Subject: [PATCH 048/208] PXE environment variables --- commands/i386/pc/pxecmd.c | 70 ++------- fs/i386/pc/pxe.c | 300 ++++++++++++++++++++++++++++++++++--- include/grub/i386/pc/pxe.h | 8 +- 3 files changed, 296 insertions(+), 82 deletions(-) diff --git a/commands/i386/pc/pxecmd.c b/commands/i386/pc/pxecmd.c index df538704c..b2c99c4e2 100644 --- a/commands/i386/pc/pxecmd.c +++ b/commands/i386/pc/pxecmd.c @@ -1,7 +1,7 @@ /* pxe.c - command to control the pxe driver */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 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 @@ -21,79 +21,31 @@ #include #include #include -#include - -static const struct grub_arg_option options[] = -{ - {"info", 'i', 0, "show PXE information.", 0, 0}, - {"bsize", 'b', 0, "set PXE block size", 0, ARG_TYPE_INT}, - {"unload", 'u', 0, "unload PXE stack.", 0, 0}, - {0, 0, 0, 0, 0, 0} - }; - -static void -print_ip (grub_uint32_t ip) -{ - int i; - - for (i = 0; i < 3; i++) - { - grub_printf ("%d.", ip & 0xFF); - ip >>= 8; - } - grub_printf ("%d", ip); -} +#include static grub_err_t -grub_cmd_pxe (grub_extcmd_t cmd, int argc __attribute__ ((unused)), - char **args __attribute__ ((unused))) +grub_cmd_pxe_unload (grub_command_t cmd __attribute__ ((unused)), + int argc __attribute__ ((unused)), + char **args __attribute__ ((unused))) { - struct grub_arg_list *state = cmd->state; - if (! grub_pxe_pxenv) return grub_error (GRUB_ERR_FILE_NOT_FOUND, "no pxe environment"); - if (state[1].set) - { - int size; - - size = grub_strtoul (state[1].arg, 0, 0); - if (size < GRUB_PXE_MIN_BLKSIZE) - size = GRUB_PXE_MIN_BLKSIZE; - else if (size > GRUB_PXE_MAX_BLKSIZE) - size = GRUB_PXE_MAX_BLKSIZE; - - grub_pxe_blksize = size; - } - - if (state[0].set) - { - grub_printf ("blksize : %d\n", grub_pxe_blksize); - grub_printf ("client ip : "); - print_ip (grub_pxe_your_ip); - grub_printf ("\nserver ip : "); - print_ip (grub_pxe_server_ip); - grub_printf ("\ngateway ip : "); - print_ip (grub_pxe_gateway_ip); - grub_printf ("\n"); - } - - if (state[2].set) - grub_pxe_unload (); + grub_pxe_unload (); return 0; } -static grub_extcmd_t cmd; +static grub_command_t cmd; GRUB_MOD_INIT(pxecmd) { - cmd = grub_register_extcmd ("pxe", grub_cmd_pxe, GRUB_COMMAND_FLAG_BOTH, - "pxe [-i|-b|-u]", - "Command to control the PXE device.", options); + cmd = grub_register_command ("pxe_unload", grub_cmd_pxe_unload, + "pxe_unload", + "Unload PXE environment."); } GRUB_MOD_FINI(pxecmd) { - grub_unregister_extcmd (cmd); + grub_unregister_command (cmd); } diff --git a/fs/i386/pc/pxe.c b/fs/i386/pc/pxe.c index dec3b91bf..f7ad95f81 100644 --- a/fs/i386/pc/pxe.c +++ b/fs/i386/pc/pxe.c @@ -1,7 +1,7 @@ /* pxe.c - Driver to provide access to the pxe filesystem */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 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 @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -33,11 +34,17 @@ #define SEGOFS(x) ((SEGMENT(x) << 16) + OFFSET(x)) #define LINEAR(x) (void *) (((x >> 16) <<4) + (x & 0xFFFF)) +struct grub_pxe_disk_data +{ + grub_uint32_t server_ip; + grub_uint32_t gateway_ip; +}; + struct grub_pxenv *grub_pxe_pxenv; -grub_uint32_t grub_pxe_your_ip; -grub_uint32_t grub_pxe_server_ip; -grub_uint32_t grub_pxe_gateway_ip; -int grub_pxe_blksize = GRUB_PXE_MIN_BLKSIZE; +static grub_uint32_t grub_pxe_your_ip; +static grub_uint32_t grub_pxe_default_server_ip; +static grub_uint32_t grub_pxe_default_gateway_ip; +static unsigned grub_pxe_blksize = GRUB_PXE_MIN_BLKSIZE; static grub_file_t curr_file = 0; @@ -56,24 +63,83 @@ grub_pxe_iterate (int (*hook) (const char *name)) return 0; } +static grub_err_t +parse_ip (const char *val, grub_uint32_t *ip, const char **rest) +{ + grub_uint32_t newip = 0; + unsigned long t; + int i; + const char *ptr = val; + + for (i = 0; i < 4; i++) + { + t = grub_strtoul (ptr, (char **) &ptr, 0); + if (grub_errno) + return grub_errno; + if (t & ~0xff) + return grub_error (GRUB_ERR_OUT_OF_RANGE, "Invalid IP."); + newip >>= 8; + newip |= (t << 24); + if (i != 3 && *ptr != '.') + return grub_error (GRUB_ERR_OUT_OF_RANGE, "Invalid IP."); + ptr++; + } + *ip = newip; + if (rest) + *rest = ptr - 1; + return 0; +} + static grub_err_t grub_pxe_open (const char *name, grub_disk_t disk) { - if (grub_strcmp (name, "pxe")) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a pxe disk"); + struct grub_pxe_disk_data *data; + + if (grub_strcmp (name, "pxe") != 0 + && grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) != 0) + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a pxe disk"); + + data = grub_malloc (sizeof (*data)); + if (!data) + return grub_errno; + + if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0) + { + const char *ptr; + grub_err_t err; + + ptr = name + sizeof ("pxe:") - 1; + err = parse_ip (ptr, &(data->server_ip), &ptr); + if (err) + return err; + if (*ptr == ':') + { + err = parse_ip (ptr + 1, &(data->server_ip), 0); + if (err) + return err; + } + else + data->gateway_ip = grub_pxe_default_gateway_ip; + } + else + { + data->server_ip = grub_pxe_default_server_ip; + data->gateway_ip = grub_pxe_default_gateway_ip; + } disk->total_sectors = 0; - disk->id = (unsigned long) "pxe"; + disk->id = (unsigned long) data; disk->has_partitions = 0; - disk->data = 0; + disk->data = data; return GRUB_ERR_NONE; } static void -grub_pxe_close (grub_disk_t disk __attribute((unused))) +grub_pxe_close (grub_disk_t disk) { + grub_free (disk->data); } static grub_err_t @@ -125,6 +191,7 @@ grub_pxefs_open (struct grub_file *file, const char *name) struct grub_pxenv_tftp_open c2; } c; struct grub_pxe_data *data; + struct grub_pxe_disk_data *disk_data = file->device->disk->data; grub_file_t file_int, bufio; if (curr_file != 0) @@ -133,8 +200,8 @@ grub_pxefs_open (struct grub_file *file, const char *name) curr_file = 0; } - c.c1.server_ip = grub_pxe_server_ip; - c.c1.gateway_ip = grub_pxe_gateway_ip; + c.c1.server_ip = disk_data->server_ip; + c.c1.gateway_ip = disk_data->gateway_ip; grub_strcpy ((char *)&c.c1.filename[0], name); grub_pxe_call (GRUB_PXENV_TFTP_GET_FSIZE, &c.c1); if (c.c1.status) @@ -184,6 +251,7 @@ grub_pxefs_read (grub_file_t file, char *buf, grub_size_t len) { struct grub_pxenv_tftp_read c; struct grub_pxe_data *data; + struct grub_pxe_disk_data *disk_data = file->device->disk->data; grub_uint32_t pn, r; data = file->data; @@ -203,8 +271,8 @@ grub_pxefs_read (grub_file_t file, char *buf, grub_size_t len) if (curr_file != 0) grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &o); - o.server_ip = grub_pxe_server_ip; - o.gateway_ip = grub_pxe_gateway_ip; + o.server_ip = disk_data->server_ip; + o.gateway_ip = disk_data->gateway_ip; grub_strcpy ((char *)&o.filename[0], data->filename); o.tftp_port = grub_cpu_to_be16 (GRUB_PXE_TFTP_PORT); o.packet_size = grub_pxe_blksize; @@ -272,6 +340,99 @@ static struct grub_fs grub_pxefs_fs = .next = 0 }; +static char * +grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)), + const char *val __attribute__ ((unused))) +{ + return NULL; +} + +static void +set_mac_env (grub_uint8_t *mac_addr, grub_size_t mac_len) +{ + char buf[(sizeof ("XX:") - 1) * mac_len + 1]; + char *ptr = buf; + unsigned i; + + for (i = 0; i < mac_len; i++) + { + grub_sprintf (ptr, "%02x:", mac_addr[i] & 0xff); + ptr += (sizeof ("XX:") - 1); + } + if (mac_len) + *(ptr - 1) = 0; + else + buf[0] = 0; + + grub_env_set ("net_pxe_mac", buf); + /* XXX: Is it possible to change MAC in PXE? */ + grub_register_variable_hook ("net_pxe_mac", 0, grub_env_write_readonly); +} + +static void +set_env_limn_ro (const char *varname, char *value, grub_size_t len) +{ + char c; + c = value[len]; + value[len] = 0; + grub_env_set (varname, value); + value[len] = c; + grub_register_variable_hook (varname, 0, grub_env_write_readonly); +} + +static void +parse_dhcp_vendor (void *vend, int limit) +{ + grub_uint8_t *ptr, *ptr0; + + ptr = ptr0 = vend; + + if (grub_be_to_cpu32 (*(grub_uint32_t *) ptr) != 0x63825363) + return; + ptr = ptr + sizeof (grub_uint32_t); + while (ptr - ptr0 < limit) + { + grub_uint8_t tagtype; + grub_uint8_t taglength; + + tagtype = *ptr++; + + /* Pad tag. */ + if (tagtype == 0) + continue; + + /* End tag. */ + if (tagtype == 0xff) + return; + + taglength = *ptr++; + + switch (tagtype) + { + case 12: + set_env_limn_ro ("net_pxe_hostname", (char *) ptr, taglength); + break; + + case 15: + set_env_limn_ro ("net_pxe_domain", (char *) ptr, taglength); + break; + + case 17: + set_env_limn_ro ("net_pxe_rootpath", (char *) ptr, taglength); + break; + + case 18: + set_env_limn_ro ("net_pxe_extensionspath", (char *) ptr, taglength); + break; + + /* If you need any other options please contact GRUB + developpement team. */ + } + + ptr += taglength; + } +} + static void grub_pxe_detect (void) { @@ -293,9 +454,15 @@ grub_pxe_detect (void) bp = LINEAR (ci.buffer); grub_pxe_your_ip = bp->your_ip; - grub_pxe_server_ip = bp->server_ip; - grub_pxe_gateway_ip = bp->gateway_ip; - + grub_pxe_default_server_ip = bp->server_ip; + grub_pxe_default_gateway_ip = bp->gateway_ip; + set_mac_env (bp->mac_addr, bp->hw_len < sizeof (bp->mac_addr) ? bp->hw_len + : sizeof (bp->mac_addr)); + set_env_limn_ro ("net_pxe_boot_file", (char *) bp->boot_file, + sizeof (bp->boot_file)); + set_env_limn_ro ("net_pxe_dhcp_server_name", (char *) bp->server_name, + sizeof (bp->server_name)); + parse_dhcp_vendor (&bp->vendor, sizeof (bp->vendor)); grub_pxe_pxenv = pxenv; } @@ -311,11 +478,110 @@ grub_pxe_unload (void) } } +static void +set_ip_env (char *varname, grub_uint32_t ip) +{ + char buf[sizeof ("XXX.XXX.XXX.XXX")]; + + grub_sprintf (buf, "%d.%d.%d.%d", (ip & 0xff), + (ip >> 8) & 0xff, (ip >> 16) & 0xff, (ip >> 24) & 0xff); + grub_env_set (varname, buf); +} + +static char * +write_ip_env (grub_uint32_t *ip, const char *val) +{ + char *buf; + grub_err_t err; + grub_uint32_t newip; + + err = parse_ip (val, &newip, 0); + if (err) + return 0; + + /* Normalize the IP. */ + buf = grub_malloc (sizeof ("XXX.XXX.XXX.XXX")); + if (!buf) + return 0; + + *ip = newip; + + grub_sprintf (buf, "%d.%d.%d.%d", (newip & 0xff), (newip >> 8) & 0xff, + (newip >> 16) & 0xff, (newip >> 24) & 0xff); + + return buf; +} + +static char * +grub_env_write_pxe_default_server (struct grub_env_var *var + __attribute__ ((unused)), + const char *val) +{ + return write_ip_env (&grub_pxe_default_server_ip, val); +} + +static char * +grub_env_write_pxe_default_gateway (struct grub_env_var *var + __attribute__ ((unused)), + const char *val) +{ + return write_ip_env (&grub_pxe_default_gateway_ip, val); +} + +static char * +grub_env_write_pxe_blocksize (struct grub_env_var *var __attribute__ ((unused)), + const char *val) +{ + unsigned size; + char *buf; + + size = grub_strtoul (val, 0, 0); + if (grub_errno) + return 0; + + if (size < GRUB_PXE_MIN_BLKSIZE) + size = GRUB_PXE_MIN_BLKSIZE; + else if (size > GRUB_PXE_MAX_BLKSIZE) + size = GRUB_PXE_MAX_BLKSIZE; + + buf = grub_malloc (sizeof ("XXXXXX XXXXXX")); + if (!buf) + return 0; + + grub_sprintf (buf, "%d", size); + grub_pxe_blksize = size; + + return buf; +} + + GRUB_MOD_INIT(pxe) { grub_pxe_detect (); if (grub_pxe_pxenv) { + char *buf; + + buf = grub_malloc (sizeof ("XXXXXX XXXXXX")); + if (buf) + { + grub_sprintf (buf, "%d", grub_pxe_blksize); + grub_env_set ("net_pxe_blksize", buf); + } + + set_ip_env ("pxe_default_server", grub_pxe_default_server_ip); + set_ip_env ("pxe_default_gateway", grub_pxe_default_gateway_ip); + set_ip_env ("net_pxe_ip", grub_pxe_your_ip); + grub_register_variable_hook ("net_pxe_default_server", 0, + grub_env_write_pxe_default_server); + grub_register_variable_hook ("net_pxe_default_gateway", 0, + grub_env_write_pxe_default_gateway); + + /* XXX: Is it possible to change IP in PXE? */ + grub_register_variable_hook ("net_pxe_ip", 0, + grub_env_write_readonly); + grub_register_variable_hook ("net_pxe_blksize", 0, + grub_env_write_pxe_blocksize); grub_disk_dev_register (&grub_pxe_dev); grub_fs_register (&grub_pxefs_fs); } diff --git a/include/grub/i386/pc/pxe.h b/include/grub/i386/pc/pxe.h index 482132896..39f356c83 100644 --- a/include/grub/i386/pc/pxe.h +++ b/include/grub/i386/pc/pxe.h @@ -201,7 +201,7 @@ struct grub_pxenv_get_cached_info #define GRUB_PXE_MAC_ADDR_LEN 16 -typedef grub_uint8_t grub_pxe_mac_addr[GRUB_PXE_MAC_ADDR_LEN]; +typedef grub_uint8_t grub_pxe_mac_addr_t[GRUB_PXE_MAC_ADDR_LEN]; struct grub_pxenv_boot_player { @@ -216,7 +216,7 @@ struct grub_pxenv_boot_player grub_uint32_t your_ip; grub_uint32_t server_ip; grub_uint32_t gateway_ip; - grub_pxe_mac_addr mac_addr; + grub_pxe_mac_addr_t mac_addr; grub_uint8_t server_name[64]; grub_uint8_t boot_file[128]; union @@ -306,10 +306,6 @@ struct grub_pxenv * EXPORT_FUNC(grub_pxe_scan) (void); int EXPORT_FUNC(grub_pxe_call) (int func, void * data); extern struct grub_pxenv *grub_pxe_pxenv; -extern grub_uint32_t grub_pxe_your_ip; -extern grub_uint32_t grub_pxe_server_ip; -extern grub_uint32_t grub_pxe_gateway_ip; -extern int grub_pxe_blksize; void grub_pxe_unload (void); From 3c9296a029c3ef82f56914db17f7452d67fee054 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 20 Dec 2009 20:23:11 +0100 Subject: [PATCH 049/208] ChangeLog --- ChangeLog.pxeenv | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ChangeLog.pxeenv diff --git a/ChangeLog.pxeenv b/ChangeLog.pxeenv new file mode 100644 index 000000000..02b967edf --- /dev/null +++ b/ChangeLog.pxeenv @@ -0,0 +1,36 @@ +2009-12-19 Vladimir Serbinenko + + Support for (pxe[:server[:gateway]]) syntax and + use environment variable for PXE. + + * commands/i386/pc/pxecmd.c (options): Removed. + (print_ip): Removed. + (grub_cmd_pxe): Removed + (grub_cmd_pxe_unload): New function. + * fs/i386/pc/pxe.c (grub_pxe_disk_data): New structure. + (grub_pxe_your_ip): Made static. + (grub_pxe_default_server_ip): Likewise. + (grub_pxe_default_gateway_ip): Likewise. + (grub_pxe_blksize): Likewise. + (parse_ip): New function. + (grub_pxe_open): Support server and gateway specification. + (grub_pxe_close): Free disk->data. + (grub_pxefs_open): Use disk->data. + (grub_pxefs_read): Likewise. + (grub_env_write_readonly): New function. + (set_mac_env): Likewise. + (set_env_limn_ro): Likewise. + (parse_dhcp_vendor): Likewise. + (grub_pxe_detect): Set the environment variables. + (set_ip_env): New function. + (write_ip_env): Likewise. + (grub_env_write_pxe_default_server): Likewise. + (grub_env_write_pxe_default_gateway): Likewise. + (grub_env_write_pxe_blocksize): Likewise. + (GRUB_MOD_INIT(pxe)): Set environment variables. + * include/grub/i386/pc/pxe.h (grub_pxe_mac_addr): Rename to ... + (grub_pxe_mac_addr_t): ... this. All users updated. + (grub_pxe_your_ip): Removed. + (grub_pxe_server_ip): Likewise. + (grub_pxe_gateway_ip): Likewise. + (grub_pxe_blksize): Likewise. From 7e70dfffc1c8614208cc6db583db7738db6a1402 Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Tue, 22 Dec 2009 12:02:57 +0100 Subject: [PATCH 050/208] 2009-12-22 Felix Zielcke * util/grub.d/30_os-prober.in (osx_entry): Add round brackets after function name. Noticed by Rene Engelhard . --- ChangeLog | 6 ++++++ util/grub.d/30_os-prober.in | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c041a685c..e0464e965 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-12-22 Felix Zielcke + + * util/grub.d/30_os-prober.in (osx_entry): Add round brackets + after function name. + Noticed by Rene Engelhard . + 2009-12-22 Vladimir Serbinenko * commands/lspci.c (grub_pci_classes): Add "USB Controller". diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 0ab54bbaa..38c96f9f8 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -37,7 +37,7 @@ if [ -z "${OSPROBED}" ] ; then exit 0 fi -osx_entry { +osx_entry() { cat << EOF menuentry "${LONGNAME} (${2}-bit) (on ${DEVICE})" { EOF From 10a8879783af11894dda453e4843317e43788e2a Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Tue, 22 Dec 2009 12:12:51 +0100 Subject: [PATCH 051/208] 2009-12-22 Felix Zielcke * genmk.rb (class SCRIPT): Use sed to substitute @pkglib_DATA@ with the actual contents of the correspondending make variable. * util/grub-mkrescue.in (pkglib_DATA): New variable. (process_input_dir): Copy all $pkglib_DATA files instead of explicitly specifying `*.lst' and `efiemu??.o' --- ChangeLog | 8 ++++++++ genmk.rb | 1 + util/grub-mkrescue.in | 9 +++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0464e965..11414095d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-12-22 Felix Zielcke + + * genmk.rb (class SCRIPT): Use sed to substitute @pkglib_DATA@ + with the actual contents of the correspondending make variable. + * util/grub-mkrescue.in (pkglib_DATA): New variable. + (process_input_dir): Copy all $pkglib_DATA files instead of explicitly + specifying `*.lst' and `efiemu??.o' + 2009-12-22 Felix Zielcke * util/grub.d/30_os-prober.in (osx_entry): Add round brackets diff --git a/genmk.rb b/genmk.rb index 127b8096b..91a20b7e4 100644 --- a/genmk.rb +++ b/genmk.rb @@ -363,6 +363,7 @@ class Script "CLEANFILES += #{@name} #{@name}: #{src} $(#{src}_DEPENDENCIES) config.status + sed -i -e 's,@pkglib_DATA@,$(pkglib_DATA),g' #{src} ./config.status --file=#{name}:#{src} chmod +x $@ diff --git a/util/grub-mkrescue.in b/util/grub-mkrescue.in index fd3a86c95..c56525c10 100644 --- a/util/grub-mkrescue.in +++ b/util/grub-mkrescue.in @@ -28,6 +28,7 @@ PACKAGE_TARNAME=@PACKAGE_TARNAME@ PACKAGE_VERSION=@PACKAGE_VERSION@ target_cpu=@target_cpu@ native_platform=@platform@ +pkglib_DATA="efiemu32.o efiemu64.o moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst" coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc @@ -93,12 +94,16 @@ process_input_dir () input_dir="$1" platform="$2" mkdir -p ${iso9660_dir}/boot/grub/${target_cpu}-${platform} - for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \ - ${input_dir}/*.lst; do + for file in ${input_dir}/*.mod; do if test -f "$file"; then cp -f "$file" ${iso9660_dir}/boot/grub/${target_cpu}-${platform}/ fi done + for file in ${pkglib_DATA}; do + if test -f "${input_dir}/${file}"; then + cp -f "${input_dir}/${file}" ${iso9660_dir}/boot/grub/${target_cpu}-${platform}/ + fi + done mkdir -p ${iso9660_dir}/boot/grub/locale for file in ${input_dir}/po/*.mo; do From 67618ea6a0269d5c2adf245ea679c34d659d4158 Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Tue, 22 Dec 2009 12:41:31 +0100 Subject: [PATCH 052/208] 2009-12-22 Felix Zielcke * genmk.rb (class SCRIPT): Prepend #{src} path with $(srcdir). --- ChangeLog | 4 ++++ genmk.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 11414095d..56c660494 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-12-22 Felix Zielcke + + * genmk.rb (class SCRIPT): Prepend #{src} path with $(srcdir). + 2009-12-22 Felix Zielcke * genmk.rb (class SCRIPT): Use sed to substitute @pkglib_DATA@ diff --git a/genmk.rb b/genmk.rb index 91a20b7e4..5381aebf5 100644 --- a/genmk.rb +++ b/genmk.rb @@ -363,7 +363,7 @@ class Script "CLEANFILES += #{@name} #{@name}: #{src} $(#{src}_DEPENDENCIES) config.status - sed -i -e 's,@pkglib_DATA@,$(pkglib_DATA),g' #{src} + sed -i -e 's,@pkglib_DATA@,$(pkglib_DATA),g' $(srcdir)/#{src} ./config.status --file=#{name}:#{src} chmod +x $@ From a34f5c705af99f4e24e66a200d2476cbd14589cf Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 22 Dec 2009 16:36:50 +0100 Subject: [PATCH 053/208] 2009-12-22 Vladimir Serbinenko * commands/memrw.c (cmd_read_byte, cmd_read_word, cmd_read_dword): Use grub_extcmd_t. All users updated. (options): New variable. (grub_cmd_read): Restructure for readability. Support "-v" option. (grub_cmd_write): Restructure for readability. --- ChangeLog | 8 +++++ commands/memrw.c | 84 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 66 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 56c660494..0e2320e29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-12-22 Vladimir Serbinenko + + * commands/memrw.c (cmd_read_byte, cmd_read_word, cmd_read_dword): + Use grub_extcmd_t. All users updated. + (options): New variable. + (grub_cmd_read): Restructure for readability. Support "-v" option. + (grub_cmd_write): Restructure for readability. + 2009-12-22 Felix Zielcke * genmk.rb (class SCRIPT): Prepend #{src} path with $(srcdir). diff --git a/commands/memrw.c b/commands/memrw.c index f43380f04..8543cadfa 100644 --- a/commands/memrw.c +++ b/commands/memrw.c @@ -19,29 +19,53 @@ #include #include -#include +#include +#include -static grub_command_t cmd_read_byte, cmd_read_word, cmd_read_dword; +static grub_extcmd_t cmd_read_byte, cmd_read_word, cmd_read_dword; static grub_command_t cmd_write_byte, cmd_write_word, cmd_write_dword; +static const struct grub_arg_option options[] = + { + {0, 'v', 0, "Save read value into variable VARNAME.", + "VARNAME", ARG_TYPE_STRING}, + {0, 0, 0, 0, 0, 0} + }; + + static grub_err_t -grub_cmd_read (grub_command_t cmd, int argc, char **argv) +grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv) { grub_target_addr_t addr; - grub_uint32_t value; + grub_uint32_t value = 0; + char buf[sizeof ("XXXXXXXX")]; if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments"); addr = grub_strtoul (argv[0], 0, 0); - if (cmd->name[5] == 'd') - value = *((grub_uint32_t *) addr); - else if (cmd->name[5] == 'w') - value = *((grub_uint16_t *) addr); - else - value = *((grub_uint8_t *) addr); + switch (cmd->cmd->name[sizeof ("read_") - 1]) + { + case 'd': + value = *((volatile grub_uint32_t *) addr); + break; - grub_printf ("0x%x\n", value); + case 'w': + value = *((volatile grub_uint16_t *) addr); + break; + + case 'b': + value = *((volatile grub_uint8_t *) addr); + break; + } + + if (cmd->state[0].set) + { + grub_sprintf (buf, "%x", value); + grub_env_set (cmd->state[0].arg, buf); + } + else + grub_printf ("0x%x\n", value); return 0; } @@ -57,12 +81,20 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) addr = grub_strtoul (argv[0], 0, 0); value = grub_strtoul (argv[1], 0, 0); - if (cmd->name[6] == 'd') - *((grub_uint32_t *) addr) = value; - else if (cmd->name[6] == 'w') - *((grub_uint16_t *) addr) = (grub_uint16_t) value; - else - *((grub_uint8_t *) addr) = (grub_uint8_t) value; + switch (cmd->name[sizeof ("write_") - 1]) + { + case 'd': + *((volatile grub_uint32_t *) addr) = value; + break; + + case 'w': + *((volatile grub_uint16_t *) addr) = (grub_uint16_t) value; + break; + + case 'b': + *((volatile grub_uint8_t *) addr) = (grub_uint8_t) value; + break; + } return 0; } @@ -70,14 +102,14 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) GRUB_MOD_INIT(memrw) { cmd_read_byte = - grub_register_command ("read_byte", grub_cmd_read, - "read_byte ADDR", "Read byte from ADDR."); + grub_register_extcmd ("read_byte", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, + "read_byte ADDR", "Read byte from ADDR.", options); cmd_read_word = - grub_register_command ("read_word", grub_cmd_read, - "read_word ADDR", "Read word from ADDR."); + grub_register_extcmd ("read_word", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, + "read_word ADDR", "Read word from ADDR.", options); cmd_read_dword = - grub_register_command ("read_dword", grub_cmd_read, - "read_dword ADDR", "Read dword from ADDR."); + grub_register_extcmd ("read_dword", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, + "read_dword ADDR", "Read dword from ADDR.", options); cmd_write_byte = grub_register_command ("write_byte", grub_cmd_write, "write_byte ADDR VALUE", "Write byte VALUE to ADDR."); @@ -91,9 +123,9 @@ GRUB_MOD_INIT(memrw) GRUB_MOD_FINI(memrw) { - grub_unregister_command (cmd_read_byte); - grub_unregister_command (cmd_read_word); - grub_unregister_command (cmd_read_dword); + grub_unregister_extcmd (cmd_read_byte); + grub_unregister_extcmd (cmd_read_word); + grub_unregister_extcmd (cmd_read_dword); grub_unregister_command (cmd_write_byte); grub_unregister_command (cmd_write_word); grub_unregister_command (cmd_write_dword); From d3d30ea08eaabc158107f974ca7edbcc2623f8d7 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 22 Dec 2009 17:00:28 +0100 Subject: [PATCH 054/208] 2009-12-22 Vladimir Serbinenko * commands/memrw.c (grub_cmd_write): Support for mask parameter. (GRUB_MOD_INIT(memrw)): Update help line. --- ChangeLog | 5 +++++ commands/memrw.c | 30 +++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e2320e29..c0c978dac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-22 Vladimir Serbinenko + + * commands/memrw.c (grub_cmd_write): Support for mask parameter. + (GRUB_MOD_INIT(memrw)): Update help line. + 2009-12-22 Vladimir Serbinenko * commands/memrw.c (cmd_read_byte, cmd_read_word, cmd_read_dword): diff --git a/commands/memrw.c b/commands/memrw.c index 8543cadfa..eada1d232 100644 --- a/commands/memrw.c +++ b/commands/memrw.c @@ -75,24 +75,40 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) { grub_target_addr_t addr; grub_uint32_t value; + grub_uint32_t mask = 0xffffffff; - if (argc != 2) + if (argc != 2 && argc != 3) return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments"); addr = grub_strtoul (argv[0], 0, 0); value = grub_strtoul (argv[1], 0, 0); + if (argc == 3) + mask = grub_strtoul (argv[2], 0, 0); + value &= mask; switch (cmd->name[sizeof ("write_") - 1]) { case 'd': - *((volatile grub_uint32_t *) addr) = value; + if (mask != 0xffffffff) + *((volatile grub_uint32_t *) addr) + = (*((volatile grub_uint32_t *) addr) & ~mask) | value; + else + *((volatile grub_uint32_t *) addr) = value; break; case 'w': - *((volatile grub_uint16_t *) addr) = (grub_uint16_t) value; + if ((mask & 0xffff) != 0xffff) + *((volatile grub_uint16_t *) addr) + = (*((volatile grub_uint16_t *) addr) & ~mask) | value; + else + *((volatile grub_uint16_t *) addr) = value; break; case 'b': - *((volatile grub_uint8_t *) addr) = (grub_uint8_t) value; + if ((mask & 0xff) != 0xff) + *((volatile grub_uint8_t *) addr) + = (*((volatile grub_uint8_t *) addr) & ~mask) | value; + else + *((volatile grub_uint8_t *) addr) = value; break; } @@ -112,13 +128,13 @@ GRUB_MOD_INIT(memrw) "read_dword ADDR", "Read dword from ADDR.", options); cmd_write_byte = grub_register_command ("write_byte", grub_cmd_write, - "write_byte ADDR VALUE", "Write byte VALUE to ADDR."); + "write_byte ADDR VALUE [MASK]", "Write byte VALUE to ADDR."); cmd_write_word = grub_register_command ("write_word", grub_cmd_write, - "write_word ADDR VALUE", "Write word VALUE to ADDR."); + "write_word ADDR VALUE [MASK]", "Write word VALUE to ADDR."); cmd_write_dword = grub_register_command ("write_dword", grub_cmd_write, - "write_dword ADDR VALUE", "Write dword VALUE to ADDR."); + "write_dword ADDR VALUE [MASK]", "Write dword VALUE to ADDR."); } GRUB_MOD_FINI(memrw) From 990f35486efc40eec3c8b7708f3bb56d7e1ecebb Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Tue, 22 Dec 2009 18:20:27 +0100 Subject: [PATCH 055/208] 2009-12-22 Felix Zielcke * util/grub-mkrescue.in (pkglib_DATA): Set to @pkglib_DATA@. * genmk.rb (class SCRIPT): Modify the target file instead of source. --- ChangeLog | 5 +++++ genmk.rb | 2 +- util/grub-mkrescue.in | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c0c978dac..34de0864b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-22 Felix Zielcke + + * util/grub-mkrescue.in (pkglib_DATA): Set to @pkglib_DATA@. + * genmk.rb (class SCRIPT): Modify the target file instead of source. + 2009-12-22 Vladimir Serbinenko * commands/memrw.c (grub_cmd_write): Support for mask parameter. diff --git a/genmk.rb b/genmk.rb index 5381aebf5..b3dbe8678 100644 --- a/genmk.rb +++ b/genmk.rb @@ -363,8 +363,8 @@ class Script "CLEANFILES += #{@name} #{@name}: #{src} $(#{src}_DEPENDENCIES) config.status - sed -i -e 's,@pkglib_DATA@,$(pkglib_DATA),g' $(srcdir)/#{src} ./config.status --file=#{name}:#{src} + sed -i -e 's,@pkglib_DATA@,$(pkglib_DATA),g' $@ chmod +x $@ " diff --git a/util/grub-mkrescue.in b/util/grub-mkrescue.in index c56525c10..6b3c9ecb8 100644 --- a/util/grub-mkrescue.in +++ b/util/grub-mkrescue.in @@ -28,7 +28,7 @@ PACKAGE_TARNAME=@PACKAGE_TARNAME@ PACKAGE_VERSION=@PACKAGE_VERSION@ target_cpu=@target_cpu@ native_platform=@platform@ -pkglib_DATA="efiemu32.o efiemu64.o moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst" +pkglib_DATA="@pkglib_DATA@" coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc From 009ec74317d4f93634e2db340849e9d666fae837 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Dec 2009 14:48:55 +0100 Subject: [PATCH 056/208] 2009-12-23 Vladimir Serbinenko * video/efi_gop.c (grub_video_gop_get_bitmask): Fix off-by-one in mask size counting. --- ChangeLog | 5 +++++ video/efi_gop.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 34de0864b..a932abb07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-23 Vladimir Serbinenko + + * video/efi_gop.c (grub_video_gop_get_bitmask): Fix off-by-one in mask + size counting. + 2009-12-22 Felix Zielcke * util/grub-mkrescue.in (pkglib_DATA): Set to @pkglib_DATA@. diff --git a/video/efi_gop.c b/video/efi_gop.c index e2eb2f7ae..9e019ad53 100644 --- a/video/efi_gop.c +++ b/video/efi_gop.c @@ -123,7 +123,7 @@ grub_video_gop_get_bitmask (grub_uint32_t mask, unsigned int *mask_size, if (!(mask & (1 << i))) break; *field_pos = i + 1; - *mask_size = last_p - *field_pos; + *mask_size = last_p - *field_pos + 1; } static grub_err_t From 7316783f35a1c210007951d74f959e003088da8e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Dec 2009 17:33:35 +0100 Subject: [PATCH 057/208] Crypto module autoloading --- Makefile.in | 5 +- conf/any-emu.rmk | 2 +- conf/common.rmk | 2 +- include/grub/crypto.h | 2 + include/grub/normal.h | 2 + lib/crypto.c | 46 +++++++++---- normal/crypto.c | 153 ++++++++++++++++++++++++++++++++++++++++++ normal/main.c | 1 + util/import_gcry.py | 38 +++++++++-- 9 files changed, 230 insertions(+), 21 deletions(-) create mode 100644 normal/crypto.c diff --git a/Makefile.in b/Makefile.in index 46b380cd5..b28b660da 100644 --- a/Makefile.in +++ b/Makefile.in @@ -169,7 +169,7 @@ endif ### General targets. CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo -pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst +pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk cat $(DEFSYMFILES) /dev/null \ | $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \ @@ -193,6 +193,9 @@ parttool.lst: $(PARTTOOLFILES) video.lst: $(VIDEOFILES) cat $^ /dev/null | sort | uniq > $@ +crypto.lst: lib/libgcrypt-grub/cipher/crypto.lst + cp $^ $@ + ifneq (true, $(MAKEINFO)) info_INFOS += docs/grub.info endif diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index 451ab3393..a3b3c84d9 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -27,7 +27,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ normal/handler.c normal/auth.c lib/crypto.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 \ + normal/menu_text.c normal/crypto.c \ script/main.c script/execute.c script/function.c \ script/lexer.c script/script.c grub_script.tab.c \ partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \ diff --git a/conf/common.rmk b/conf/common.rmk index 81372d20c..64be988b9 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -543,7 +543,7 @@ normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.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 + normal/misc.c normal/crypto.c normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/include/grub/crypto.h b/include/grub/crypto.h index 3129131cb..48b52ee65 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -270,4 +270,6 @@ grub_password_get (char buf[], unsigned buf_size); /* For indistinguishibility. */ #define GRUB_ACCESS_DENIED grub_error (GRUB_ERR_ACCESS_DENIED, "Access denied.") +extern void (*grub_crypto_autoload_hook) (const char *name); + #endif diff --git a/include/grub/normal.h b/include/grub/normal.h index e55553de5..66b427bcb 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -95,6 +95,8 @@ void read_command_list (void); /* Defined in `autofs.c'. */ void read_fs_list (void); +void read_crypto_list (void); + #ifdef GRUB_UTIL void grub_normal_init (void); diff --git a/lib/crypto.c b/lib/crypto.c index 06104bd4d..021560d6c 100644 --- a/lib/crypto.c +++ b/lib/crypto.c @@ -32,6 +32,8 @@ struct grub_crypto_hmac_handle static gcry_cipher_spec_t *grub_ciphers = NULL; static gcry_md_spec_t *grub_digests = NULL; +void (*grub_crypto_autoload_hook) (const char *name) = NULL; + /* Based on libgcrypt-1.4.4/src/misc.c. */ void grub_burn_stack (grub_size_t size) @@ -91,28 +93,44 @@ const gcry_md_spec_t * grub_crypto_lookup_md_by_name (const char *name) { const gcry_md_spec_t *md; - for (md = grub_digests; md; md = md->next) - if (grub_strcasecmp (name, md->name) == 0) - return md; - return NULL; + int first = 1; + while (1) + { + for (md = grub_digests; md; md = md->next) + if (grub_strcasecmp (name, md->name) == 0) + return md; + if (grub_crypto_autoload_hook && first) + grub_crypto_autoload_hook (name); + else + return NULL; + first = 0; + } } const gcry_cipher_spec_t * grub_crypto_lookup_cipher_by_name (const char *name) { const gcry_cipher_spec_t *ciph; - for (ciph = grub_ciphers; ciph; ciph = ciph->next) + int first = 1; + while (1) { - const char **alias; - if (grub_strcasecmp (name, ciph->name) == 0) - return ciph; - if (!ciph->aliases) - continue; - for (alias = ciph->aliases; *alias; alias++) - if (grub_strcasecmp (name, *alias) == 0) - return ciph; + for (ciph = grub_ciphers; ciph; ciph = ciph->next) + { + const char **alias; + if (grub_strcasecmp (name, ciph->name) == 0) + return ciph; + if (!ciph->aliases) + continue; + for (alias = ciph->aliases; *alias; alias++) + if (grub_strcasecmp (name, *alias) == 0) + return ciph; + } + if (grub_crypto_autoload_hook && first) + grub_crypto_autoload_hook (name); + else + return NULL; + first = 0; } - return NULL; } diff --git a/normal/crypto.c b/normal/crypto.c new file mode 100644 index 000000000..67330272a --- /dev/null +++ b/normal/crypto.c @@ -0,0 +1,153 @@ +/* crypto.c - support crypto autoload */ +/* + * 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 load_spec +{ + struct load_spec *next; + char *name; + char *modname; +}; + +struct load_spec *crypto_specs = NULL; + +static void +grub_crypto_autoload (const char *name) +{ + struct load_spec *cur; + grub_dl_t mod; + + for (cur = crypto_specs; cur; cur = cur->next) + if (grub_strcasecmp (name, cur->name) == 0) + { + mod = grub_dl_load (cur->modname); + if (mod) + grub_dl_ref (mod); + grub_errno = GRUB_ERR_NONE; + } +} + +static void +grub_crypto_spec_free (void) +{ + struct load_spec *cur, *next; + for (cur = crypto_specs; cur; cur = next) + { + next = cur->next; + grub_free (cur->name); + grub_free (cur->modname); + grub_free (cur); + } + crypto_specs = NULL; +} + + +/* Read the file crypto.lst for auto-loading. */ +void +read_crypto_list (void) +{ + const char *prefix; + char *filename; + grub_file_t file; + char *buf = NULL; + + prefix = grub_env_get ("prefix"); + if (!prefix) + { + grub_errno = GRUB_ERR_NONE; + return; + } + + filename = grub_malloc (grub_strlen (prefix) + sizeof ("/crypto.lst")); + if (!filename) + { + grub_errno = GRUB_ERR_NONE; + return; + } + + grub_sprintf (filename, "%s/crypto.lst", prefix); + file = grub_file_open (filename); + if (!file) + { + grub_errno = GRUB_ERR_NONE; + return; + } + + /* Override previous commands.lst. */ + grub_crypto_spec_free (); + + for (;; grub_free (buf)) + { + char *p, *name; + struct load_spec *cur; + + buf = grub_file_getline (file); + + if (! buf) + break; + + name = buf; + + p = grub_strchr (name, ':'); + if (! p) + continue; + + *p = '\0'; + while (*++p == ' ') + ; + + cur = grub_malloc (sizeof (*cur)); + if (!cur) + { + grub_errno = GRUB_ERR_NONE; + continue; + } + + cur->name = grub_strdup (name); + if (! name) + { + grub_errno = GRUB_ERR_NONE; + grub_free (cur); + continue; + } + + cur->modname = grub_strdup (p); + if (! cur->modname) + { + grub_errno = GRUB_ERR_NONE; + grub_free (cur); + grub_free (cur->name); + continue; + } + cur->next = crypto_specs; + crypto_specs = cur; + } + + grub_file_close (file); + + grub_errno = GRUB_ERR_NONE; + + grub_crypto_autoload_hook = grub_crypto_autoload; +} diff --git a/normal/main.c b/normal/main.c index 3166ea146..189244aa0 100644 --- a/normal/main.c +++ b/normal/main.c @@ -428,6 +428,7 @@ grub_normal_execute (const char *config, int nested, int batch) read_command_list (); read_fs_list (); read_handler_list (); + read_crypto_list (); grub_command_execute ("parser.grub", 0, 0); reader_nested = nested; diff --git a/util/import_gcry.py b/util/import_gcry.py index fe68c85a4..93bf5982f 100644 --- a/util/import_gcry.py +++ b/util/import_gcry.py @@ -61,6 +61,18 @@ mdblocksizes = {"_gcry_digest_spec_crc32" : 64, "_gcry_digest_spec_tiger" : 64, "_gcry_digest_spec_whirlpool" : 64} +cryptolist = open (os.path.join (cipher_dir_out, "crypto.lst"), "w") + +# rijndael is the only cipher using aliases. So no need for mangling, just +# hardcode it +cryptolist.write ("RIJNDAEL: gcry_rijndael\n"); +cryptolist.write ("RIJNDAEL192: gcry_rijndael\n"); +cryptolist.write ("RIJNDAEL256: gcry_rijndael\n"); +cryptolist.write ("AES128: gcry_rijndael\n"); +cryptolist.write ("AES-128: gcry_rijndael\n"); +cryptolist.write ("AES-192: gcry_rijndael\n"); +cryptolist.write ("AES-256: gcry_rijndael\n"); + for cipher_file in cipher_files: infile = os.path.join (cipher_dir_in, cipher_file) outfile = os.path.join (cipher_dir_out, cipher_file) @@ -86,7 +98,15 @@ for cipher_file in cipher_files: skip = False skip2 = False ismd = False + iscryptostart = False iscomma = False + isglue = False + if isc: + modname = cipher_file [0:len(cipher_file) - 2] + if re.match (".*-glue$", modname): + modname = modname.replace ("-glue", "") + isglue = True + modname = "gcry_%s" % modname for line in f: if skip: if line[0] == "}": @@ -96,6 +116,12 @@ for cipher_file in cipher_files: if not re.search (" *};", line) is None: skip2 = False continue + if iscryptostart: + s = re.search (" *\"([A-Z0-9_a-z]*)\"", line) + if not s is None: + sg = s.groups()[0] + cryptolist.write (("%s: %s\n") % (sg, modname)) + iscryptostart = False if ismd: if not re.search (" *};", line) is None: if not mdblocksizes.has_key (mdname): @@ -133,16 +159,20 @@ for cipher_file in cipher_files: continue m = re.match ("gcry_cipher_spec_t", line) if isc and not m is None: + assert (not iscryptostart) ciphername = line [len ("gcry_cipher_spec_t"):].strip () ciphername = re.match("[a-zA-Z0-9_]*",ciphername).group () ciphernames.append (ciphername) + iscryptostart = True m = re.match ("gcry_md_spec_t", line) if isc and not m is None: assert (not ismd) + assert (not iscryptostart) mdname = line [len ("gcry_md_spec_t"):].strip () mdname = re.match("[a-zA-Z0-9_]*",mdname).group () mdnames.append (mdname) ismd = True + iscryptostart = True m = re.match ("static const char \*selftest.*;$", line) if not m is None: fname = line[len ("static const char \*"):] @@ -185,14 +215,11 @@ for cipher_file in cipher_files: continue fw.write (line) if len (ciphernames) > 0 or len (mdnames) > 0: - modname = cipher_file [0:len(cipher_file) - 2] - if re.match (".*-glue$", modname): + if isglue: modfiles = "lib/libgcrypt-grub/cipher/%s lib/libgcrypt-grub/cipher/%s" \ % (cipher_file, cipher_file.replace ("-glue.c", ".c")) - modname = modname.replace ("-glue", "") else: modfiles = "lib/libgcrypt-grub/cipher/%s" % cipher_file - modname = "gcry_%s" % modname chmsg = "(GRUB_MOD_INIT(%s)): New function\n" % modname if nch: chlognew = "%s\n %s" % (chlognew, chmsg) @@ -238,6 +265,9 @@ for cipher_file in cipher_files: chlog = "%s%sSkipped unknown file\n" % (chlog, chlognew) print ("WARNING: unknown file %s" % cipher_file) +cryptolist.close () +chlog = "%s * crypto.lst: New file.\n" % chlog + outfile = os.path.join (cipher_dir_out, "types.h") fw=open (outfile, "w") fw.write ("#include \n") From a2c1332b709efa6de30c376a29b09d3052aced5e Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Wed, 23 Dec 2009 17:41:32 +0100 Subject: [PATCH 058/208] 2009-12-23 Felix Zielcke * commands/i386/pc/drivemap.c: Remove all trailing whitespace. * commands/lspci.c: Likewise. * commands/probe.c: Likewise. * commands/xnu_uuid.c: Likewise. * conf/i386-coreboot.rmk: Likewise. * conf/i386-efi.rmk: Likewise. * conf/i386-ieee1275.rmk: Likewise. * conf/i386-pc.rmk: Likewise. * conf/powerpc-ieee1275.rmk: Likewise. * conf/sparc64-ieee1275.rmk: Likewise. * conf/x86_64-efi.rmk: Likewise. * fs/i386/pc/pxe.c: Likewise. * gettext/gettext.c: Likewise. * include/grub/efi/graphics_output.h: Likewise. * include/grub/i386/pc/memory.h: Likewise. * kern/env.c: Likewise. * kern/i386/qemu/startup.S: Likewise. * lib/i386/pc/biosnum.c: Likewise. * lib/i386/relocator.c: Likewise. * lib/i386/relocator_asm.S: Likewise. * lib/relocator.c: Likewise. * loader/i386/bsd.c: Likewise. * loader/i386/multiboot.c: Likewise. * loader/i386/pc/chainloader.c: Likewise. * loader/i386/xnu.c: Likewise. * loader/xnu.c: Likewise. * normal/main.c: Likewise. * normal/menu_text.c: Likewise. * util/getroot.c: Likewise. * util/grub-mkconfig_lib.in: Likewise. * util/grub.d/00_header.in: Likewise. * util/i386/pc/grub-mkimage.c: Likewise. * util/mkisofs/eltorito.c: Likewise. * util/mkisofs/exclude.h: Likewise. * util/mkisofs/hash.c: Likewise. * util/mkisofs/iso9660.h: Likewise. * util/mkisofs/joliet.c: Likewise. * util/mkisofs/mkisofs.c: Likewise. * util/mkisofs/mkisofs.h: Likewise. * util/mkisofs/multi.c: Likewise. * util/mkisofs/name.c: Likewise. * util/mkisofs/rock.c: Likewise. * util/mkisofs/tree.c: Likewise. * util/mkisofs/write.c: Likewise. * video/efi_gop.c: Likewise. --- ChangeLog | 54 +++- commands/i386/pc/drivemap.c | 2 +- commands/lspci.c | 10 +- commands/probe.c | 2 +- commands/xnu_uuid.c | 10 +- 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 +- fs/i386/pc/pxe.c | 2 +- gettext/gettext.c | 4 +- include/grub/efi/graphics_output.h | 2 +- include/grub/i386/pc/memory.h | 2 +- kern/env.c | 4 +- kern/i386/qemu/startup.S | 2 +- lib/i386/pc/biosnum.c | 2 +- lib/i386/relocator.c | 4 +- lib/i386/relocator_asm.S | 14 +- lib/relocator.c | 4 +- loader/i386/bsd.c | 2 +- loader/i386/multiboot.c | 2 +- loader/i386/pc/chainloader.c | 2 +- loader/i386/xnu.c | 2 +- loader/xnu.c | 10 +- normal/main.c | 12 +- normal/menu_text.c | 6 +- util/getroot.c | 2 +- util/grub-mkconfig_lib.in | 2 +- util/grub.d/00_header.in | 4 +- util/i386/pc/grub-mkimage.c | 8 +- util/mkisofs/eltorito.c | 122 ++++----- util/mkisofs/exclude.h | 2 +- util/mkisofs/hash.c | 12 +- util/mkisofs/iso9660.h | 2 +- util/mkisofs/joliet.c | 212 +++++++-------- util/mkisofs/mkisofs.c | 32 +-- util/mkisofs/mkisofs.h | 26 +- util/mkisofs/multi.c | 68 ++--- util/mkisofs/name.c | 90 +++---- util/mkisofs/rock.c | 46 ++-- util/mkisofs/tree.c | 408 ++++++++++++++--------------- util/mkisofs/write.c | 334 +++++++++++------------ video/efi_gop.c | 20 +- 46 files changed, 803 insertions(+), 755 deletions(-) diff --git a/ChangeLog b/ChangeLog index a932abb07..e594931e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,51 @@ +2009-12-23 Felix Zielcke + + * commands/i386/pc/drivemap.c: Remove all trailing whitespace. + * commands/lspci.c: Likewise. + * commands/probe.c: Likewise. + * commands/xnu_uuid.c: Likewise. + * conf/i386-coreboot.rmk: Likewise. + * conf/i386-efi.rmk: Likewise. + * conf/i386-ieee1275.rmk: Likewise. + * conf/i386-pc.rmk: Likewise. + * conf/powerpc-ieee1275.rmk: Likewise. + * conf/sparc64-ieee1275.rmk: Likewise. + * conf/x86_64-efi.rmk: Likewise. + * fs/i386/pc/pxe.c: Likewise. + * gettext/gettext.c: Likewise. + * include/grub/efi/graphics_output.h: Likewise. + * include/grub/i386/pc/memory.h: Likewise. + * kern/env.c: Likewise. + * kern/i386/qemu/startup.S: Likewise. + * lib/i386/pc/biosnum.c: Likewise. + * lib/i386/relocator.c: Likewise. + * lib/i386/relocator_asm.S: Likewise. + * lib/relocator.c: Likewise. + * loader/i386/bsd.c: Likewise. + * loader/i386/multiboot.c: Likewise. + * loader/i386/pc/chainloader.c: Likewise. + * loader/i386/xnu.c: Likewise. + * loader/xnu.c: Likewise. + * normal/main.c: Likewise. + * normal/menu_text.c: Likewise. + * util/getroot.c: Likewise. + * util/grub-mkconfig_lib.in: Likewise. + * util/grub.d/00_header.in: Likewise. + * util/i386/pc/grub-mkimage.c: Likewise. + * util/mkisofs/eltorito.c: Likewise. + * util/mkisofs/exclude.h: Likewise. + * util/mkisofs/hash.c: Likewise. + * util/mkisofs/iso9660.h: Likewise. + * util/mkisofs/joliet.c: Likewise. + * util/mkisofs/mkisofs.c: Likewise. + * util/mkisofs/mkisofs.h: Likewise. + * util/mkisofs/multi.c: Likewise. + * util/mkisofs/name.c: Likewise. + * util/mkisofs/rock.c: Likewise. + * util/mkisofs/tree.c: Likewise. + * util/mkisofs/write.c: Likewise. + * video/efi_gop.c: Likewise. + 2009-12-23 Vladimir Serbinenko * video/efi_gop.c (grub_video_gop_get_bitmask): Fix off-by-one in mask @@ -695,7 +743,7 @@ grub_gettext_msg_list. (grub_gettext_gettranslation_from_position): Return const char * and not char *. - (grub_gettext_translate): Add the translated strings into a list, + (grub_gettext_translate): Add the translated strings into a list, returns from the list if existing there. (grub_gettext_init_ext): Add \n at the end of grub_dprintf string. (grub_gettext_delete_list): Delete the list. @@ -736,7 +784,7 @@ (run_menu): Replaces grub_printf by print_spaces and dynamic terminal width. (get_entry_number): Gettextize and uses dynamic terminal width. - (notify_booting, notify_fallback, notify_execution_failure): + (notify_booting, notify_fallback, notify_execution_failure): Gettextize. * normal/menu_entry.c (store_completion): Cleanup the gettextized string. @@ -1007,7 +1055,7 @@ * include/grub/i18n.h: ... to here * include/grub/i18n.h: ... to here. * kern/misc.c: Include - (grub_gettext_dummy): Move above user. + (grub_gettext_dummy): Move above user. 2009-11-24 Felix Zielcke diff --git a/commands/i386/pc/drivemap.c b/commands/i386/pc/drivemap.c index 991634df0..7d1420eea 100644 --- a/commands/i386/pc/drivemap.c +++ b/commands/i386/pc/drivemap.c @@ -370,7 +370,7 @@ grub_get_root_biosnumber_drivemap (void) return grub_strtoul (biosnum, 0, 0); dev = grub_device_open (0); - if (dev && dev->disk && dev->disk->dev + if (dev && dev->disk && dev->disk->dev && dev->disk->dev->id == GRUB_DISK_DEVICE_BIOSDISK_ID) { drivemap_node_t *curnode = map_head; diff --git a/commands/lspci.c b/commands/lspci.c index 559bb8242..fbade98c1 100644 --- a/commands/lspci.c +++ b/commands/lspci.c @@ -163,10 +163,10 @@ grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid) space = grub_pci_read (addr); reg++; - + if (space == 0) continue; - + switch (space & GRUB_PCI_ADDR_SPACE_MASK) { case GRUB_PCI_ADDR_SPACE_IO: @@ -175,7 +175,7 @@ grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid) (space & GRUB_PCI_ADDR_IO_MASK)); break; case GRUB_PCI_ADDR_SPACE_MEMORY: - if ((space & GRUB_PCI_ADDR_MEM_TYPE_MASK) + if ((space & GRUB_PCI_ADDR_MEM_TYPE_MASK) == GRUB_PCI_ADDR_MEM_TYPE_64) { addr = grub_pci_make_address (dev, reg); @@ -186,11 +186,11 @@ grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid) (space & GRUB_PCI_ADDR_MEM_MASK), space & GRUB_PCI_ADDR_MEM_PREFETCH ? "prefetchable" : "non-prefetchable"); - + } else grub_printf ("\t32-bit memory space %d at 0x%016llx [%s]\n", - (reg - 1) - 4, (unsigned long long) + (reg - 1) - 4, (unsigned long long) (space & GRUB_PCI_ADDR_MEM_MASK), space & GRUB_PCI_ADDR_MEM_PREFETCH ? "prefetchable" : "non-prefetchable"); diff --git a/commands/probe.c b/commands/probe.c index 0acbf30f4..fb196275f 100644 --- a/commands/probe.c +++ b/commands/probe.c @@ -31,7 +31,7 @@ #include #include -static const struct grub_arg_option options[] = +static const struct grub_arg_option options[] = { {"set", 's', GRUB_ARG_OPTION_OPTIONAL, "Set a variable to return value.", "VAR", ARG_TYPE_STRING}, diff --git a/commands/xnu_uuid.c b/commands/xnu_uuid.c index 06e88e560..85c0e9ce4 100644 --- a/commands/xnu_uuid.c +++ b/commands/xnu_uuid.c @@ -1,4 +1,4 @@ -/* xnu_uuid.c - transform 64-bit serial number +/* xnu_uuid.c - transform 64-bit serial number to 128-bit uuid suitable for xnu. */ /* * GRUB -- GRand Unified Bootloader @@ -38,10 +38,10 @@ struct tohash grub_uint64_t serial; } __attribute__ ((packed)); -/* This prefix is used by xnu and boot-132 to hash +/* This prefix is used by xnu and boot-132 to hash together with volume serial. */ -static grub_uint8_t hash_prefix[16] - = {0xB3, 0xE2, 0x0F, 0x39, 0xF2, 0x92, 0x11, 0xD6, +static grub_uint8_t hash_prefix[16] + = {0xB3, 0xE2, 0x0F, 0x39, 0xF2, 0x92, 0x11, 0xD6, 0x97, 0xA4, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC}; #define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) ) @@ -237,7 +237,7 @@ md5_write( void *context, const void *inbuf_arg , grub_size_t inlen) } // _gcry_burn_stack (80+6*sizeof(void*)); - while( inlen >= 64 ) + while( inlen >= 64 ) { transform( hd, inbuf ); hd->count = 0; diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index e597328e7..8b69f7796 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -109,7 +109,7 @@ pkglib_MODULES = linux.mod multiboot.mod \ lsmmap.mod mmap.mod # For boot.mod. -pkglib_MODULES += boot.mod +pkglib_MODULES += boot.mod boot_mod_SOURCES = commands/boot.c boot_mod_CFLAGS = $(COMMON_CFLAGS) boot_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index 261fe4092..3a219e71b 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -67,7 +67,7 @@ kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genke /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) # For boot.mod. -pkglib_MODULES += boot.mod +pkglib_MODULES += boot.mod boot_mod_SOURCES = commands/boot.c boot_mod_CFLAGS = $(COMMON_CFLAGS) boot_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk index 8d9577844..2a90fd2be 100644 --- a/conf/i386-ieee1275.rmk +++ b/conf/i386-ieee1275.rmk @@ -60,7 +60,7 @@ pkglib_MODULES = halt.mod reboot.mod suspend.mod \ date.mod datehook.mod lsmmap.mod mmap.mod # For boot.mod. -pkglib_MODULES += boot.mod +pkglib_MODULES += boot.mod boot_mod_SOURCES = commands/boot.c boot_mod_CFLAGS = $(COMMON_CFLAGS) boot_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 046c71641..4ae753776 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -128,7 +128,7 @@ pkglib_MODULES = biosdisk.mod chain.mod \ efiemu.mod mmap.mod acpi.mod drivemap.mod # For boot.mod. -pkglib_MODULES += boot.mod +pkglib_MODULES += boot.mod boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c boot_mod_CFLAGS = $(COMMON_CFLAGS) boot_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index 85b1fa211..122455280 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -66,7 +66,7 @@ pkglib_MODULES = halt.mod \ lsmmap.mod # For boot.mod. -pkglib_MODULES += boot.mod +pkglib_MODULES += boot.mod boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c boot_mod_CFLAGS = $(COMMON_CFLAGS) boot_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index d19e927a5..4e90a4d35 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -103,7 +103,7 @@ pkglib_MODULES = halt.mod \ lsmmap.mod # For boot.mod. -pkglib_MODULES += boot.mod +pkglib_MODULES += boot.mod boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c boot_mod_CFLAGS = $(COMMON_CFLAGS) boot_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index 0d1289c6f..a82b35222 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -67,7 +67,7 @@ kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genke /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) # For boot.mod. -pkglib_MODULES += boot.mod +pkglib_MODULES += boot.mod boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c boot_mod_CFLAGS = $(COMMON_CFLAGS) boot_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/fs/i386/pc/pxe.c b/fs/i386/pc/pxe.c index dec3b91bf..4bab45d35 100644 --- a/fs/i386/pc/pxe.c +++ b/fs/i386/pc/pxe.c @@ -110,7 +110,7 @@ static grub_err_t grub_pxefs_dir (grub_device_t device __attribute__ ((unused)), const char *path __attribute__ ((unused)), int (*hook) (const char *filename, - const struct grub_dirhook_info *info) + const struct grub_dirhook_info *info) __attribute__ ((unused))) { return GRUB_ERR_NONE; diff --git a/gettext/gettext.c b/gettext/gettext.c index 65db73a78..fe14dab2e 100644 --- a/gettext/gettext.c +++ b/gettext/gettext.c @@ -29,8 +29,8 @@ #include #include -/* - .mo file information from: +/* + .mo file information from: http://www.gnu.org/software/autoconf/manual/gettext/MO-Files.html . */ diff --git a/include/grub/efi/graphics_output.h b/include/grub/efi/graphics_output.h index a55869dc7..a29221919 100644 --- a/include/grub/efi/graphics_output.h +++ b/include/grub/efi/graphics_output.h @@ -24,7 +24,7 @@ #define GRUB_EFI_GOP_GUID \ { 0x9042a9de, 0x23dc, 0x4a38, { 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a }} -typedef enum +typedef enum { GRUB_EFI_GOT_RGBA8, GRUB_EFI_GOT_BGRA8, diff --git a/include/grub/i386/pc/memory.h b/include/grub/i386/pc/memory.h index 1b470f8c2..e14cc3e96 100644 --- a/include/grub/i386/pc/memory.h +++ b/include/grub/i386/pc/memory.h @@ -85,7 +85,7 @@ struct grub_machine_bios_data_area { grub_uint8_t unused1[0x17]; - grub_uint8_t keyboard_flag_lower; /* 0x17 */ + grub_uint8_t keyboard_flag_lower; /* 0x17 */ grub_uint8_t unused2[0xf0 - 0x18]; }; diff --git a/kern/env.c b/kern/env.c index 73a2b927a..969227dec 100644 --- a/kern/env.c +++ b/kern/env.c @@ -174,12 +174,12 @@ grub_env_export (const char *name) if (! var) { grub_err_t err; - + err = grub_env_set (name, ""); if (err) return err; var = grub_env_find (name); - } + } var->type = GRUB_ENV_VAR_GLOBAL; return GRUB_ERR_NONE; diff --git a/kern/i386/qemu/startup.S b/kern/i386/qemu/startup.S index 7d3cb1b5e..7484650b2 100644 --- a/kern/i386/qemu/startup.S +++ b/kern/i386/qemu/startup.S @@ -81,7 +81,7 @@ codestart: movl $END_SYMBOL, %ecx subl %edi, %ecx #endif - + /* clean out */ xorl %eax, %eax cld diff --git a/lib/i386/pc/biosnum.c b/lib/i386/pc/biosnum.c index 1f9b5f3fc..058c9d331 100644 --- a/lib/i386/pc/biosnum.c +++ b/lib/i386/pc/biosnum.c @@ -33,7 +33,7 @@ grub_get_root_biosnumber_default (void) return grub_strtoul (biosnum, 0, 0); dev = grub_device_open (0); - if (dev && dev->disk && dev->disk->dev + if (dev && dev->disk && dev->disk->dev && dev->disk->dev->id == GRUB_DISK_DEVICE_BIOSDISK_ID) ret = (int) dev->disk->id; diff --git a/lib/i386/relocator.c b/lib/i386/relocator.c index ae7caf28b..453f73fdd 100644 --- a/lib/i386/relocator.c +++ b/lib/i386/relocator.c @@ -85,14 +85,14 @@ write_call_relocator_fw (void *ptr, void *src, grub_uint32_t dest, grub_relocator32_forward_dest = dest; grub_relocator32_forward_src = PTR_TO_UINT64 (src); grub_relocator32_forward_size = size; - + grub_relocator32_forward_eax = state.eax; grub_relocator32_forward_ebx = state.ebx; grub_relocator32_forward_ecx = state.ecx; grub_relocator32_forward_edx = state.edx; grub_relocator32_forward_eip = state.eip; grub_relocator32_forward_esp = state.esp; - + grub_memmove (ptr, &grub_relocator32_forward_start, RELOCATOR_SIZEOF (forward)); diff --git a/lib/i386/relocator_asm.S b/lib/i386/relocator_asm.S index d39732987..6b803db13 100644 --- a/lib/i386/relocator_asm.S +++ b/lib/i386/relocator_asm.S @@ -32,8 +32,8 @@ #else #define RAX %eax #define RCX %ecx -#define RDI %edi -#define RSI %esi +#define RDI %edi +#define RSI %esi #endif /* The code segment of the protected mode. */ @@ -41,7 +41,7 @@ /* The data segment of the protected mode. */ #define DATA_SEGMENT 0x18 - + .p2align 4 /* force 16-byte alignment */ RELOCATOR_VARIABLE(start) @@ -92,7 +92,7 @@ RELOCATOR_VARIABLE(size) #endif mov RDI, RAX - + #ifdef BACKWARD add RCX, RSI add RCX, RDI @@ -104,7 +104,7 @@ RELOCATOR_VARIABLE(size) add $0x3, RCX shr $2, RCX - + #ifdef BACKWARD /* Backward movsl is implicitly off-by-four. compensate that. */ sub $4, RSI @@ -213,7 +213,7 @@ RELOCATOR_VARIABLE (eip) LOCAL(gdt): /* NULL. */ .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - + /* Reserved. */ .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -234,7 +234,7 @@ LOCAL(gdt_addr): /* Filled by the code. */ .long 0 #endif - + .p2align 4 LOCAL(jump_vector): /* Jump location. Is filled by the code */ diff --git a/lib/relocator.c b/lib/relocator.c index d10af34d4..6a5acc548 100644 --- a/lib/relocator.c +++ b/lib/relocator.c @@ -79,7 +79,7 @@ PREFIX (boot) (void *relocator, grub_uint32_t dest, /* Very unlikely condition: Relocator may risk overwrite itself. Just move it a bit up. */ if ((grub_addr_t) dest < (grub_addr_t) relocator - + (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN) + + (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN) && (grub_addr_t) dest + (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN) > (grub_addr_t) relocator) { @@ -105,7 +105,7 @@ PREFIX (boot) (void *relocator, grub_uint32_t dest, "Backward relocator: code %p, source: %p, " "destination: 0x%x, size: 0x%lx\n", (char *) relocator - overhead, - (char *) relocator - overhead, + (char *) relocator - overhead, (unsigned) dest - overhead, (unsigned long) size + overhead); diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 6f2202a67..84eb13d74 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -140,7 +140,7 @@ grub_bsd_get_device (grub_uint32_t * biosdev, grub_uint32_t * slice, grub_uint32_t * part) { char *p; - grub_device_t dev; + grub_device_t dev; #ifdef GRUB_MACHINE_PCBIOS *biosdev = grub_get_root_biosnumber () & 0xff; diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index f5036a2ae..be824e2f4 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -201,7 +201,7 @@ grub_multiboot_get_bootdev (grub_uint32_t *bootdev) if (dev) grub_device_close (dev); - *bootdev = ((biosdev & 0xff) << 24) | ((slice & 0xff) << 16) + *bootdev = ((biosdev & 0xff) << 24) | ((slice & 0xff) << 16) | ((part & 0xff) << 8) | 0xff; return (biosdev != ~0UL); #else diff --git a/loader/i386/pc/chainloader.c b/loader/i386/pc/chainloader.c index caf1450e4..2e3b24fee 100644 --- a/loader/i386/pc/chainloader.c +++ b/loader/i386/pc/chainloader.c @@ -102,7 +102,7 @@ grub_chainloader_cmd (const char *filename, grub_chainloader_flags_t flags) if (dev) grub_device_close (dev); - + /* Ignore errors. Perhaps it's not fatal. */ grub_errno = GRUB_ERR_NONE; diff --git a/loader/i386/xnu.c b/loader/i386/xnu.c index b1509cdc8..4786bfd39 100644 --- a/loader/i386/xnu.c +++ b/loader/i386/xnu.c @@ -832,7 +832,7 @@ grub_xnu_boot_resume (void) state.eax = grub_xnu_arg1; return grub_relocator32_boot (grub_xnu_heap_start, grub_xnu_heap_will_be_at, - state); + state); } /* Boot xnu. */ diff --git a/loader/xnu.c b/loader/xnu.c index 7d33f8ea4..37239e23c 100644 --- a/loader/xnu.c +++ b/loader/xnu.c @@ -67,7 +67,7 @@ grub_xnu_heap_malloc (int size) advanced mm is ready. */ grub_xnu_heap_start = XNU_RELOCATOR (realloc) (grub_xnu_heap_start, - newblknum + newblknum * GRUB_XNU_HEAP_ALLOC_BLOCK); if (!grub_xnu_heap_start) return NULL; @@ -1326,20 +1326,20 @@ grub_xnu_fill_devicetree (void) nextdot = curdot + grub_strlen (curdot) + 1; name = grub_realloc (name, nextdot - curdot + 1); - + if (!name) return 1; - + unescape (name, curdot, nextdot, &len); name[len] = 0; curvalue = grub_xnu_create_value (curkey, name); grub_free (name); - + data = grub_malloc (grub_strlen (var->value) + 1); if (!data) return 1; - + unescape (data, var->value, var->value + grub_strlen (var->value), &len); curvalue->datasize = len; diff --git a/normal/main.c b/normal/main.c index 3166ea146..e8dfb182b 100644 --- a/normal/main.c +++ b/normal/main.c @@ -391,17 +391,17 @@ grub_normal_init_page (void) char *msg_formatted = grub_malloc (grub_strlen(msg) + grub_strlen(PACKAGE_VERSION)); - + grub_cls (); grub_sprintf (msg_formatted, msg, PACKAGE_VERSION); grub_uint32_t *unicode_msg; grub_uint32_t *last_position; - - msg_len = grub_utf8_to_ucs4_alloc (msg_formatted, + + msg_len = grub_utf8_to_ucs4_alloc (msg_formatted, &unicode_msg, &last_position); - + if (msg_len < 0) { return; @@ -528,7 +528,7 @@ grub_normal_reader_init (void) const char *msg_esc = _("ESC at any time exits."); - char *msg_formatted = grub_malloc (sizeof (char) * (grub_strlen (msg) + + char *msg_formatted = grub_malloc (sizeof (char) * (grub_strlen (msg) + grub_strlen(msg_esc) + 1)); grub_sprintf (msg_formatted, msg, reader_nested ? msg_esc : ""); @@ -536,7 +536,7 @@ grub_normal_reader_init (void) grub_puts ("\n"); grub_free (msg_formatted); - + return 0; } diff --git a/normal/menu_text.c b/normal/menu_text.c index 45cf95500..4f2dfb78e 100644 --- a/normal/menu_text.c +++ b/normal/menu_text.c @@ -71,7 +71,7 @@ grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg, grub_ssize_t msg_len = grub_strlen (msg); *unicode_msg = grub_malloc (grub_strlen (msg) * sizeof (grub_uint32_t)); - + if (!*unicode_msg) { grub_printf ("utf8_to_ucs4 ERROR1: %s", msg); @@ -133,7 +133,7 @@ grub_print_message_indented (const char *msg, int margin_left, int margin_right) { if (! first_loop) grub_putchar ('\n'); - + next_new_line = (grub_uint32_t *) last_position; while (grub_getstringwidth (current_position, next_new_line) > line_len @@ -402,7 +402,7 @@ print_timeout (int timeout, int offset) grub_sprintf (msg_translated, msg, timeout); grub_print_message_indented (msg_translated, 3, 0); - + int posx; posx = grub_getxy() >> 8; print_spaces (GRUB_TERM_WIDTH - posx - 1); diff --git a/util/getroot.c b/util/getroot.c index db772b968..22ad7e967 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -483,7 +483,7 @@ grub_util_is_dmraid (const char *os_dev) return 1; else if (! strncmp (os_dev, "/dev/mapper/sil_", 16)) return 1; - + return 0; } diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 8caf4f154..bd4b3e2c8 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -100,7 +100,7 @@ prepare_grub_to_access_device () # Abstraction modules aren't auto-loaded. abstraction="`${grub_probe} --device ${device} --target=abstraction`" - for module in ${abstraction} ; do + for module in ${abstraction} ; do echo "insmod ${module}" done diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 96352cdae..feeb69b70 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -107,12 +107,12 @@ if [ "x${LANG}" != "xC" ] ; then cat << EOF set locale_dir=${locale_dir} set lang=${grub_lang} -insmod gettext +insmod gettext EOF fi if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then - if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then + if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then verbose= else verbose=" --verbose" diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index 785ea8c71..3c2cb7549 100644 --- a/util/i386/pc/grub-mkimage.c +++ b/util/i386/pc/grub-mkimage.c @@ -204,19 +204,19 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS); if (num > 0xffff) grub_util_error (_("the core image is too big")); - + boot_path = grub_util_get_path (dir, "diskboot.img"); boot_size = grub_util_get_image_size (boot_path); if (boot_size != GRUB_DISK_SECTOR_SIZE) grub_util_error (_("diskboot.img size must be %u bytes"), GRUB_DISK_SECTOR_SIZE); - + boot_img = grub_util_read_image (boot_path); - + /* i386 is a little endian architecture. */ *((grub_uint16_t *) (boot_img + GRUB_DISK_SECTOR_SIZE - GRUB_BOOT_MACHINE_LIST_SIZE + 8)) = grub_cpu_to_le16 (num); - + grub_util_write_image (boot_img, boot_size, out); free (boot_img); free (boot_path); diff --git a/util/mkisofs/eltorito.c b/util/mkisofs/eltorito.c index 05a9040d6..a134dfc48 100644 --- a/util/mkisofs/eltorito.c +++ b/util/mkisofs/eltorito.c @@ -1,6 +1,6 @@ /* * Program eltorito.c - Handle El Torito specific extensions to iso9660. - * + * Written by Michael Fulbright (1996). @@ -53,7 +53,7 @@ static struct eltorito_boot_descriptor gboot_desc; static int tvd_write __PR((FILE * outfile)); /* - * Check for presence of boot catalog. If it does not exist then make it + * Check for presence of boot catalog. If it does not exist then make it */ void FDECL1(init_boot_catalog, const char *, path) { @@ -61,37 +61,37 @@ void FDECL1(init_boot_catalog, const char *, path) char * bootpath; /* filename of boot catalog */ char * buf; struct stat statbuf; - + bootpath = (char *) e_malloc(strlen(boot_catalog)+strlen(path)+2); strcpy(bootpath, path); - if (bootpath[strlen(bootpath)-1] != '/') + if (bootpath[strlen(bootpath)-1] != '/') { strcat(bootpath,"/"); } - + strcat(bootpath, boot_catalog); - + /* - * check for the file existing + * check for the file existing */ #ifdef DEBUG_TORITO fprintf(stderr,"Looking for boot catalog file %s\n",bootpath); #endif - - if (!stat_filter(bootpath, &statbuf)) + + if (!stat_filter(bootpath, &statbuf)) { /* - * make sure its big enough to hold what we want + * make sure its big enough to hold what we want */ - if (statbuf.st_size == 2048) + if (statbuf.st_size == 2048) { /* - * printf("Boot catalog exists, so we do nothing\n"); + * printf("Boot catalog exists, so we do nothing\n"); */ free(bootpath); return; } - else + else { fprintf (stderr, _("A boot catalog exists and appears corrupted.\n")); fprintf (stderr, _("Please check the following file: %s.\n"), bootpath); @@ -100,15 +100,15 @@ void FDECL1(init_boot_catalog, const char *, path) exit (1); } } - + /* - * file does not exist, so we create it + * file does not exist, so we create it * make it one CD sector long */ bcat = fopen (bootpath, "wb"); if (bcat == NULL) error (1, errno, _("Error creating boot catalog (%s)"), bootpath); - + buf = (char *) e_malloc( 2048 ); if (fwrite (buf, 1, 2048, bcat) != 2048) error (1, errno, _("Error writing to boot catalog (%s)"), bootpath); @@ -127,65 +127,65 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc) struct directory_entry * de2; unsigned int i; int nsectors; - + memset(boot_desc, 0, sizeof(*boot_desc)); boot_desc->id[0] = 0; memcpy(boot_desc->id2, ISO_STANDARD_ID, sizeof(ISO_STANDARD_ID)); boot_desc->version[0] = 1; - + memcpy(boot_desc->system_id, EL_TORITO_ID, sizeof(EL_TORITO_ID)); - + /* - * search from root of iso fs to find boot catalog + * search from root of iso fs to find boot catalog */ de2 = search_tree_file(root, boot_catalog); - if (!de2) + if (!de2) { fprintf (stderr, _("Boot catalog cannot be found!\n")); exit (1); } - + set_731(boot_desc->bootcat_ptr, (unsigned int) get_733(de2->isorec.extent)); - - /* + + /* * now adjust boot catalog - * lets find boot image first + * lets find boot image first */ de=search_tree_file(root, boot_image); - if (!de) + if (!de) { fprintf (stderr, _("Boot image cannot be found!\n")); exit (1); - } - - /* + } + + /* * we have the boot image, so write boot catalog information - * Next we write out the primary descriptor for the disc + * Next we write out the primary descriptor for the disc */ memset(&valid_desc, 0, sizeof(valid_desc)); valid_desc.headerid[0] = 1; valid_desc.arch[0] = EL_TORITO_ARCH_x86; - + /* * we'll shove start of publisher id into id field, may get truncated * but who really reads this stuff! */ if (publisher) memcpy_max(valid_desc.id, publisher, MIN(23, strlen(publisher))); - + valid_desc.key1[0] = 0x55; valid_desc.key2[0] = 0xAA; - + /* - * compute the checksum + * compute the checksum */ checksum=0; checksum_ptr = (unsigned char *) &valid_desc; - for (i=0; isize + 511) & ~(511))/512; - fprintf (stderr, _("\nSize of boot image is %d sectors"), nsectors); - fprintf (stderr, " -> "); + fprintf (stderr, _("\nSize of boot image is %d sectors"), nsectors); + fprintf (stderr, " -> "); if (! use_eltorito_emul_floppy) { default_desc.boot_media[0] = EL_TORITO_MEDIA_NOEMUL; fprintf (stderr, _("No emulation\n")); } - else if (nsectors == 2880 ) + else if (nsectors == 2880 ) /* - * choose size of emulated floppy based on boot image size + * choose size of emulated floppy based on boot image size */ { default_desc.boot_media[0] = EL_TORITO_MEDIA_144FLOP; fprintf (stderr, _("Emulating a 1.44 meg floppy\n")); } - else if (nsectors == 5760 ) + else if (nsectors == 5760 ) { default_desc.boot_media[0] = EL_TORITO_MEDIA_288FLOP; fprintf (stderr, _("Emulating a 2.88 meg floppy\n")); } - else if (nsectors == 2400 ) + else if (nsectors == 2400 ) { default_desc.boot_media[0] = EL_TORITO_MEDIA_12FLOP; fprintf (stderr, _("Emulating a 1.2 meg floppy\n")); } - else + else { fprintf (stderr, _("\nError - boot image is not the an allowable size.\n")); exit (1); } - - /* - * FOR NOW LOAD 1 SECTOR, JUST LIKE FLOPPY BOOT!!! + + /* + * FOR NOW LOAD 1 SECTOR, JUST LIKE FLOPPY BOOT!!! */ nsectors = 1; set_721(default_desc.nsect, (unsigned int) nsectors ); #ifdef DEBUG_TORITO fprintf(stderr,"Extent of boot images is %d\n",get_733(de->isorec.extent)); #endif - set_731(default_desc.bootoff, + set_731(default_desc.bootoff, (unsigned int) get_733(de->isorec.extent)); - + /* - * now write it to disk + * now write it to disk */ bootcat = fopen (de2->whole_name, "r+b"); - if (bootcat == NULL) + if (bootcat == NULL) error (1, errno, _("Error opening boot catalog for update")); - /* - * write out + /* + * write out */ if (fwrite (&valid_desc, 1, 32, bootcat) != 32) error (1, errno, _("Error writing to boot catalog")); @@ -332,7 +332,7 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc) static int FDECL1(tvd_write, FILE *, outfile) { /* - * Next we write out the boot volume descriptor for the disc + * Next we write out the boot volume descriptor for the disc */ get_torito_desc(&gboot_desc); xfwrite(&gboot_desc, 1, 2048, outfile); diff --git a/util/mkisofs/exclude.h b/util/mkisofs/exclude.h index 87cd6948a..ac1a561ad 100644 --- a/util/mkisofs/exclude.h +++ b/util/mkisofs/exclude.h @@ -1,6 +1,6 @@ /* * 9-Dec-93 R.-D. Marzusch, marzusch@odiehh.hanse.de: - * added 'exclude' option (-x) to specify pathnames NOT to be included in + * added 'exclude' option (-x) to specify pathnames NOT to be included in * CD image. * * $Id: exclude.h,v 1.2 1999/03/02 03:41:25 eric Exp $ diff --git a/util/mkisofs/hash.c b/util/mkisofs/hash.c index 4d26e4dba..41e76b342 100644 --- a/util/mkisofs/hash.c +++ b/util/mkisofs/hash.c @@ -33,7 +33,7 @@ void FDECL1(add_hash, struct directory_entry *, spnt){ struct file_hash * s_hash; unsigned int hash_number; - if(spnt->size == 0 || spnt->starting_block == 0) + if(spnt->size == 0 || spnt->starting_block == 0) if(spnt->size != 0 || spnt->starting_block != 0) { fprintf(stderr,"Non zero-length file assigned zero extent.\n"); exit(1); @@ -116,10 +116,10 @@ static unsigned int FDECL1(name_hash, const char *, name) { unsigned int hash = 0; const char * p; - + p = name; - - while (*p) + + while (*p) { /* * Don't hash the iso9660 version number. This way @@ -155,7 +155,7 @@ struct directory_entry * FDECL1(find_file_hash, char *, name) struct name_hash * nh; char * p1; char * p2; - + for(nh = name_hash_table[name_hash(name)]; nh; nh = nh->next) { p1 = name; @@ -220,6 +220,6 @@ void flush_file_hash(){ nh = nh1; } name_hash_table[i] = NULL; - + } } diff --git a/util/mkisofs/iso9660.h b/util/mkisofs/iso9660.h index 5818ee81c..78a05db92 100644 --- a/util/mkisofs/iso9660.h +++ b/util/mkisofs/iso9660.h @@ -138,7 +138,7 @@ struct eltorito_boot_info char pvd_addr[ISODCL (1, 4)]; /* Boot file address. */ char file_addr[ISODCL (5, 8)]; - /* Boot file length. */ + /* Boot file length. */ char file_length[ISODCL (9, 12)]; /* Boot file checksum. */ char file_checksum[ISODCL (13, 16)]; diff --git a/util/mkisofs/joliet.c b/util/mkisofs/joliet.c index 736037df9..b3c755792 100644 --- a/util/mkisofs/joliet.c +++ b/util/mkisofs/joliet.c @@ -87,13 +87,13 @@ static int DECL(joliet_sort_directory, (struct directory_entry ** sort_dir)); static void DECL(assign_joliet_directory_addresses, (struct directory * node)); static int jroot_gen __PR((void)); -/* +/* * Function: convert_to_unicode * * Purpose: Perform a 1/2 assed unicode conversion on a text * string. * - * Notes: + * Notes: */ static void FDECL3(convert_to_unicode, unsigned char *, buffer, int, size, char *, source ) { @@ -127,9 +127,9 @@ static void FDECL3(convert_to_unicode, unsigned char *, buffer, int, size, char * JS integrated from: Achim_Kaiser@t-online.de * * Let all valid unicode characters pass through (assuming ISO-8859-1). - * Others are set to '_' . - */ - if( tmpbuf[j] != 0 && + * Others are set to '_' . + */ + if( tmpbuf[j] != 0 && (tmpbuf[j] <= 0x1f || (tmpbuf[j] >= 0x7F && tmpbuf[j] <= 0xA0)) ) { buffer[i+1] = '_'; @@ -163,7 +163,7 @@ static void FDECL3(convert_to_unicode, unsigned char *, buffer, int, size, char } } -/* +/* * Function: joliet_strlen * * Purpose: Return length in bytes of string after conversion to unicode. @@ -178,7 +178,7 @@ static int FDECL1(joliet_strlen, const char *, string) rtn = strlen(string) << 1; - /* + /* * We do clamp the maximum length of a Joliet string to be the * maximum path size. This helps to ensure that we don't completely * bolix things up with very long paths. The Joliet specs say @@ -191,7 +191,7 @@ static int FDECL1(joliet_strlen, const char *, string) return rtn; } -/* +/* * Function: get_joliet_vol_desc * * Purpose: generate a Joliet compatible volume desc. @@ -212,7 +212,7 @@ static void FDECL1(get_joliet_vol_desc, struct iso_primary_descriptor *, jvol_de * "expands" 8 bit character codes to 16 bits and does nothing * special with the Unicode characters, therefore shouldn't mkisofs * really be stating that it's using UCS-2 Level 1, not Level 3 for - * the Joliet directory tree. + * the Joliet directory tree. */ strcpy(jvol_desc->escape_sequences, "%/@"); @@ -228,7 +228,7 @@ static void FDECL1(get_joliet_vol_desc, struct iso_primary_descriptor *, jvol_de /* * Set this one up. */ - memcpy(jvol_desc->root_directory_record, &jroot_record, + memcpy(jvol_desc->root_directory_record, &jroot_record, sizeof(struct iso_directory_record)); /* @@ -256,7 +256,7 @@ static void FDECL1(assign_joliet_directory_addresses, struct directory *, node) struct directory * dpnt; dpnt = node; - + while (dpnt) { if( (dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) == 0 ) @@ -275,7 +275,7 @@ static void FDECL1(assign_joliet_directory_addresses, struct directory *, node) } /* skip if hidden - but not for the rr_moved dir */ - if(dpnt->subdir && (!(dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) || dpnt == reloc_dir)) + if(dpnt->subdir && (!(dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) || dpnt == reloc_dir)) { assign_joliet_directory_addresses(dpnt->subdir); } @@ -283,13 +283,13 @@ static void FDECL1(assign_joliet_directory_addresses, struct directory *, node) } } -static +static void FDECL1(build_jpathlist, struct directory *, node) { struct directory * dpnt; - + dpnt = node; - + while (dpnt) { @@ -302,7 +302,7 @@ void FDECL1(build_jpathlist, struct directory *, node) } } /* build_jpathlist(... */ -static int FDECL2(joliet_compare_paths, void const *, r, void const *, l) +static int FDECL2(joliet_compare_paths, void const *, r, void const *, l) { struct directory const *ll = *(struct directory * const *)l; struct directory const *rr = *(struct directory * const *)r; @@ -325,13 +325,13 @@ static int FDECL2(joliet_compare_paths, void const *, r, void const *, l) return -1; } - if (rparent > lparent) + if (rparent > lparent) { return 1; } return strcmp(rr->self->name, ll->self->name); - + } /* compare_paths(... */ static int generate_joliet_path_tables() @@ -346,7 +346,7 @@ static int generate_joliet_path_tables() int tablesize; /* - * First allocate memory for the tables and initialize the memory + * First allocate memory for the tables and initialize the memory */ tablesize = jpath_blocks << 11; jpath_table_m = (char *) e_malloc(tablesize); @@ -361,10 +361,10 @@ static int generate_joliet_path_tables() exit (1); } /* - * Now start filling in the path tables. Start with root directory + * Now start filling in the path tables. Start with root directory */ jpath_table_index = 0; - jpathlist = (struct directory **) e_malloc(sizeof(struct directory *) + jpathlist = (struct directory **) e_malloc(sizeof(struct directory *) * next_jpath_index); memset(jpathlist, 0, sizeof(struct directory *) * next_jpath_index); build_jpathlist(root); @@ -373,10 +373,10 @@ static int generate_joliet_path_tables() { fix = 0; #ifdef __STDC__ - qsort(&jpathlist[1], next_jpath_index-1, sizeof(struct directory *), + qsort(&jpathlist[1], next_jpath_index-1, sizeof(struct directory *), (int (*)(const void *, const void *))joliet_compare_paths); #else - qsort(&jpathlist[1], next_jpath_index-1, sizeof(struct directory *), + qsort(&jpathlist[1], next_jpath_index-1, sizeof(struct directory *), joliet_compare_paths); #endif @@ -399,20 +399,20 @@ static int generate_joliet_path_tables() exit (1); } npnt = dpnt->de_name; - + npnt1 = strrchr(npnt, PATH_SEPARATOR); - if(npnt1) - { + if(npnt1) + { npnt = npnt1 + 1; } - + de = dpnt->self; - if(!de) + if(!de) { - fprintf (stderr, _("Fatal goof - directory has amnesia\n")); + fprintf (stderr, _("Fatal goof - directory has amnesia\n")); exit (1); } - + namelen = joliet_strlen(de->name); if( dpnt == root ) @@ -426,28 +426,28 @@ static int generate_joliet_path_tables() jpath_table_m[jpath_table_index] = namelen; } jpath_table_index += 2; - - set_731(jpath_table_l + jpath_table_index, dpnt->jextent); - set_732(jpath_table_m + jpath_table_index, dpnt->jextent); + + set_731(jpath_table_l + jpath_table_index, dpnt->jextent); + set_732(jpath_table_m + jpath_table_index, dpnt->jextent); jpath_table_index += 4; - + if( dpnt->parent != reloc_dir ) { - set_721(jpath_table_l + jpath_table_index, - dpnt->parent->jpath_index); - set_722(jpath_table_m + jpath_table_index, - dpnt->parent->jpath_index); + set_721(jpath_table_l + jpath_table_index, + dpnt->parent->jpath_index); + set_722(jpath_table_m + jpath_table_index, + dpnt->parent->jpath_index); } else { - set_721(jpath_table_l + jpath_table_index, - dpnt->self->parent_rec->filedir->jpath_index); - set_722(jpath_table_m + jpath_table_index, - dpnt->self->parent_rec->filedir->jpath_index); + set_721(jpath_table_l + jpath_table_index, + dpnt->self->parent_rec->filedir->jpath_index); + set_722(jpath_table_m + jpath_table_index, + dpnt->self->parent_rec->filedir->jpath_index); } jpath_table_index += 2; - + /* * The root directory is still represented in non-unicode fashion. */ @@ -459,19 +459,19 @@ static int generate_joliet_path_tables() } else { - convert_to_unicode((uint8_t *)jpath_table_l + jpath_table_index, + convert_to_unicode((uint8_t *)jpath_table_l + jpath_table_index, namelen, de->name); - convert_to_unicode((uint8_t *)jpath_table_m + jpath_table_index, + convert_to_unicode((uint8_t *)jpath_table_m + jpath_table_index, namelen, de->name); jpath_table_index += namelen; } - if(jpath_table_index & 1) + if(jpath_table_index & 1) { jpath_table_index++; /* For odd lengths we pad */ } } - + free(jpathlist); if(jpath_table_index != jpath_table_size) { @@ -493,20 +493,20 @@ static void FDECL2(generate_one_joliet_directory, struct directory *, dpnt, FILE unsigned int total_size; int cvt_len; struct directory * finddir; - + total_size = (dpnt->jsize + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1); directory_buffer = (char *) e_malloc(total_size); memset(directory_buffer, 0, total_size); dir_index = 0; - + s_entry = dpnt->jcontents; - while(s_entry) + while(s_entry) { if(s_entry->de_flags & INHIBIT_JOLIET_ENTRY) { s_entry = s_entry->jnext; continue; } - + /* * If this entry was a directory that was relocated, we have a bit * of trouble here. We need to dig out the real thing and put it @@ -535,43 +535,43 @@ static void FDECL2(generate_one_joliet_directory, struct directory *, dpnt, FILE { s_entry1 = s_entry; } - - /* - * We do not allow directory entries to cross sector boundaries. - * Simply pad, and then start the next entry at the next sector + + /* + * We do not allow directory entries to cross sector boundaries. + * Simply pad, and then start the next entry at the next sector */ new_reclen = s_entry1->jreclen; if( (dir_index & (SECTOR_SIZE - 1)) + new_reclen >= SECTOR_SIZE ) { - dir_index = (dir_index + (SECTOR_SIZE - 1)) & + dir_index = (dir_index + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1); } - + memcpy(&jrec, &s_entry1->isorec, sizeof(struct iso_directory_record) - sizeof(s_entry1->isorec.name)); - + cvt_len = joliet_strlen(s_entry1->name); - + /* * Fix the record length - this was the non-Joliet version we * were seeing. */ jrec.name_len[0] = cvt_len; jrec.length[0] = s_entry1->jreclen; - + /* * If this is a directory, fix the correct size and extent * number. */ if( (jrec.flags[0] & 2) != 0 ) { - if(strcmp(s_entry1->name,".") == 0) + if(strcmp(s_entry1->name,".") == 0) { jrec.name_len[0] = 1; set_733((char *) jrec.extent, dpnt->jextent); set_733((char *) jrec.size, ROUND_UP(dpnt->jsize)); } - else if(strcmp(s_entry1->name,"..") == 0) + else if(strcmp(s_entry1->name,"..") == 0) { jrec.name_len[0] = 1; if( dpnt->parent == reloc_dir ) @@ -600,7 +600,7 @@ static void FDECL2(generate_one_joliet_directory, struct directory *, dpnt, FILE { if(finddir->self == s_entry1) break; finddir = finddir->next; - if(!finddir) + if(!finddir) { fprintf (stderr, _("Fatal goof - unable to find directory location\n")); exit (1); @@ -610,25 +610,25 @@ static void FDECL2(generate_one_joliet_directory, struct directory *, dpnt, FILE set_733((char *) jrec.size, ROUND_UP(finddir->jsize)); } } - - memcpy(directory_buffer + dir_index, &jrec, + + memcpy(directory_buffer + dir_index, &jrec, sizeof(struct iso_directory_record) - sizeof(s_entry1->isorec.name)); - - - dir_index += sizeof(struct iso_directory_record) - + + + dir_index += sizeof(struct iso_directory_record) - sizeof (s_entry1->isorec.name); - + /* * Finally dump the Unicode version of the filename. * Note - . and .. are the same as with non-Joliet discs. */ - if( (jrec.flags[0] & 2) != 0 + if( (jrec.flags[0] & 2) != 0 && strcmp(s_entry1->name, ".") == 0 ) { directory_buffer[dir_index++] = 0; } - else if( (jrec.flags[0] & 2) != 0 + else if( (jrec.flags[0] & 2) != 0 && strcmp(s_entry1->name, "..") == 0 ) { directory_buffer[dir_index++] = 1; @@ -640,7 +640,7 @@ static void FDECL2(generate_one_joliet_directory, struct directory *, dpnt, FILE s_entry1->name); dir_index += cvt_len; } - + if(dir_index & 1) { directory_buffer[dir_index++] = 0; @@ -648,13 +648,13 @@ static void FDECL2(generate_one_joliet_directory, struct directory *, dpnt, FILE s_entry = s_entry->jnext; } - + if(dpnt->jsize != dir_index) { fprintf (stderr, _("Unexpected joliet directory length %d %d %s\n"), dpnt->jsize, dir_index, dpnt->de_name); } - + xfwrite(directory_buffer, 1, total_size, outfile); last_extent_written += total_size >> 11; free(directory_buffer); @@ -678,7 +678,7 @@ static int FDECL1(joliet_sort_n_finish, struct directory *, this_dir) { continue; } - + /* * First update the path table sizes for directories. * @@ -690,15 +690,15 @@ static int FDECL1(joliet_sort_n_finish, struct directory *, this_dir) */ if(s_entry->isorec.flags[0] == 2) { - if (strcmp(s_entry->name,".") && strcmp(s_entry->name,"..")) + if (strcmp(s_entry->name,".") && strcmp(s_entry->name,"..")) { jpath_table_size += joliet_strlen(s_entry->name) + sizeof(struct iso_path_table) - 1; - if (jpath_table_size & 1) + if (jpath_table_size & 1) { jpath_table_size++; } } - else + else { if (this_dir == root && strlen(s_entry->name) == 1) { @@ -708,11 +708,11 @@ static int FDECL1(joliet_sort_n_finish, struct directory *, this_dir) } } - if (strcmp(s_entry->name,".") && strcmp(s_entry->name,"..")) + if (strcmp(s_entry->name,".") && strcmp(s_entry->name,"..")) { s_entry->jreclen = sizeof(struct iso_directory_record) - sizeof(s_entry->isorec.name) - + joliet_strlen(s_entry->name) + + joliet_strlen(s_entry->name) + 1; } else @@ -737,9 +737,9 @@ static int FDECL1(joliet_sort_n_finish, struct directory *, this_dir) this_dir->jcontents = this_dir->contents; status = joliet_sort_directory(&this_dir->jcontents); - /* + /* * Now go through the directory and figure out how large this one will be. - * Do not split a directory entry across a sector boundary + * Do not split a directory entry across a sector boundary */ s_entry = this_dir->jcontents; /* @@ -756,10 +756,10 @@ static int FDECL1(joliet_sort_n_finish, struct directory *, this_dir) } jreclen = s_entry->jreclen; - + if ((this_dir->jsize & (SECTOR_SIZE - 1)) + jreclen >= SECTOR_SIZE) { - this_dir->jsize = (this_dir->jsize + (SECTOR_SIZE - 1)) & + this_dir->jsize = (this_dir->jsize + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1); } this_dir->jsize += jreclen; @@ -771,11 +771,11 @@ static int FDECL1(joliet_sort_n_finish, struct directory *, this_dir) * Similar to the iso9660 case, except here we perform a full sort based upon the * regular name of the file, not the 8.3 version. */ -static int FDECL2(joliet_compare_dirs, const void *, rr, const void *, ll) +static int FDECL2(joliet_compare_dirs, const void *, rr, const void *, ll) { char * rpnt, *lpnt; struct directory_entry ** r, **l; - + r = (struct directory_entry **) rr; l = (struct directory_entry **) ll; rpnt = (*r)->name; @@ -788,7 +788,7 @@ static int FDECL2(joliet_compare_dirs, const void *, rr, const void *, ll) { sort_goof++; } - + /* * Put the '.' and '..' entries on the head of the sorted list. * For normal ASCII, this always happens to be the case, but out of @@ -800,13 +800,13 @@ static int FDECL2(joliet_compare_dirs, const void *, rr, const void *, ll) if( strcmp(rpnt, "..") == 0 ) return -1; if( strcmp(lpnt, "..") == 0 ) return 1; - while(*rpnt && *lpnt) + while(*rpnt && *lpnt) { if(*rpnt == ';' && *lpnt != ';') return -1; if(*rpnt != ';' && *lpnt == ';') return 1; - + if(*rpnt == ';' && *lpnt == ';') return 0; - + /* * Extensions are not special here. Don't treat the dot as something that * must be bumped to the start of the list. @@ -815,7 +815,7 @@ static int FDECL2(joliet_compare_dirs, const void *, rr, const void *, ll) if(*rpnt == '.' && *lpnt != '.') return -1; if(*rpnt != '.' && *lpnt == '.') return 1; #endif - + if(*rpnt < *lpnt) return -1; if(*rpnt > *lpnt) return 1; rpnt++; lpnt++; @@ -826,7 +826,7 @@ static int FDECL2(joliet_compare_dirs, const void *, rr, const void *, ll) } -/* +/* * Function: sort_directory * * Purpose: Sort the directory in the appropriate ISO9660 @@ -840,7 +840,7 @@ static int FDECL1(joliet_sort_directory, struct directory_entry **, sort_dir) int i; struct directory_entry * s_entry; struct directory_entry ** sortlist; - + s_entry = *sort_dir; while(s_entry) { @@ -851,9 +851,9 @@ static int FDECL1(joliet_sort_directory, struct directory_entry **, sort_dir) } /* - * OK, now we know how many there are. Build a vector for sorting. + * OK, now we know how many there are. Build a vector for sorting. */ - sortlist = (struct directory_entry **) + sortlist = (struct directory_entry **) e_malloc(sizeof(struct directory_entry *) * dcount); dcount = 0; @@ -867,18 +867,18 @@ static int FDECL1(joliet_sort_directory, struct directory_entry **, sort_dir) } s_entry = s_entry->next; } - + sort_goof = 0; #ifdef __STDC__ - qsort(sortlist, dcount, sizeof(struct directory_entry *), + qsort(sortlist, dcount, sizeof(struct directory_entry *), (int (*)(const void *, const void *))joliet_compare_dirs); #else - qsort(sortlist, dcount, sizeof(struct directory_entry *), + qsort(sortlist, dcount, sizeof(struct directory_entry *), joliet_compare_dirs); #endif - - /* - * Now reassemble the linked list in the proper sorted order + + /* + * Now reassemble the linked list in the proper sorted order */ for(i=0; ijnext = NULL; *sort_dir = sortlist[0]; - + free(sortlist); return sort_goof; } @@ -934,7 +934,7 @@ static void FDECL2(generate_joliet_directories, struct directory *, node, FILE*, } } /* skip if hidden - but not for the rr_moved dir */ - if(dpnt->subdir && (!(dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) || dpnt == reloc_dir)) + if(dpnt->subdir && (!(dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) || dpnt == reloc_dir)) generate_joliet_directories(dpnt->subdir, outfile); dpnt = dpnt->next; } @@ -947,7 +947,7 @@ static void FDECL2(generate_joliet_directories, struct directory *, node, FILE*, static int FDECL1(jpathtab_write, FILE *, outfile) { /* - * Next we write the path tables + * Next we write the path tables */ xfwrite(jpath_table_l, 1, jpath_blocks << 11, outfile); xfwrite(jpath_table_m, 1, jpath_blocks << 11, outfile); @@ -995,7 +995,7 @@ static int FDECL1(jvd_write, FILE *, outfile) struct iso_primary_descriptor jvol_desc; /* - * Next we write out the boot volume descriptor for the disc + * Next we write out the boot volume descriptor for the disc */ jvol_desc = vol_desc; get_joliet_vol_desc(&jvol_desc); @@ -1013,7 +1013,7 @@ static int FDECL1(jpathtab_size, int, starting_extent) jpath_table[1] = 0; jpath_table[2] = jpath_table[0] + jpath_blocks; jpath_table[3] = 0; - + last_extent += 2*jpath_blocks; return 0; } diff --git a/util/mkisofs/mkisofs.c b/util/mkisofs/mkisofs.c index e6386fba4..8e99d5c18 100644 --- a/util/mkisofs/mkisofs.c +++ b/util/mkisofs/mkisofs.c @@ -564,8 +564,8 @@ void usage(){ } -/* - * Fill in date in the iso9660 format +/* + * Fill in date in the iso9660 format * * The standards state that the timezone offset is in multiples of 15 * minutes, and is what you add to GMT to get the localtime. The U.S. @@ -583,9 +583,9 @@ int FDECL2(iso9660_date,char *, result, time_t, crtime){ result[4] = local->tm_min; result[5] = local->tm_sec; - /* + /* * Must recalculate proper timezone offset each time, - * as some files use daylight savings time and some don't... + * as some files use daylight savings time and some don't... */ result[6] = local->tm_yday; /* save yday 'cause gmtime zaps it */ local = gmtime(&crtime); @@ -593,11 +593,11 @@ int FDECL2(iso9660_date,char *, result, time_t, crtime){ local->tm_yday -= result[6]; local->tm_hour -= result[3]; local->tm_min -= result[4]; - if (local->tm_year < 0) + if (local->tm_year < 0) { local->tm_yday = -1; } - else + else { if (local->tm_year > 0) local->tm_yday = 1; } @@ -972,7 +972,7 @@ parse_input_files: { int resource; struct rlimit rlp; - if (getrlimit(RLIMIT_DATA,&rlp) == -1) + if (getrlimit(RLIMIT_DATA,&rlp) == -1) perror (_("Warning: getrlimit")); else { rlp.rlim_cur=33554432; @@ -1092,7 +1092,7 @@ parse_input_files: merge_image); } - memcpy(&de.isorec.extent, mrootp->extent, 8); + memcpy(&de.isorec.extent, mrootp->extent, 8); } /* @@ -1175,8 +1175,8 @@ parse_input_files: break; } *pnt = '\0'; - graft_dir = find_or_create_directory(graft_dir, - graft_point, + graft_dir = find_or_create_directory(graft_dir, + graft_point, NULL, TRUE); *pnt = PATH_SEPARATOR; xpnt = pnt + 1; @@ -1262,12 +1262,12 @@ parse_input_files: if (goof) error (1, 0, _("Joliet tree sort failed.\n")); - + /* * Fix a couple of things in the root directory so that everything * is self consistent. */ - root->self = root->contents; /* Fix this up so that the path + root->self = root->contents; /* Fix this up so that the path tables get done right */ /* @@ -1344,8 +1344,8 @@ parse_input_files: outputlist_insert(&dirtree_clean); - if(extension_record) - { + if(extension_record) + { outputlist_insert(&extension_desc); } @@ -1356,7 +1356,7 @@ parse_input_files: * will always be a primary and an end volume descriptor. */ last_extent = session_start; - + /* * Calculate the size of all of the components of the disc, and assign * extent numbers. @@ -1402,7 +1402,7 @@ parse_input_files: if( verbose > 0 ) { #ifdef HAVE_SBRK - fprintf (stderr, _("Max brk space used %x\n"), + fprintf (stderr, _("Max brk space used %x\n"), (unsigned int)(((unsigned long)sbrk(0)) - mem_start)); #endif fprintf (stderr, _("%llu extents written (%llu MiB)\n"), last_extent, last_extent >> 9); diff --git a/util/mkisofs/mkisofs.h b/util/mkisofs/mkisofs.h index 1f1ef99ac..79ae50251 100644 --- a/util/mkisofs/mkisofs.h +++ b/util/mkisofs/mkisofs.h @@ -190,7 +190,7 @@ struct file_hash{ unsigned int starting_block; unsigned int size; }; - + /* * This structure is used to control the output of fragments to the cdrom @@ -243,7 +243,7 @@ extern struct output_fragment jdirtree_desc; extern struct output_fragment extension_desc; extern struct output_fragment files_desc; -/* +/* * This structure describes one complete directory. It has pointers * to other directories in the overall tree so that it is clear where * this directory lives in the tree, and it also must contain pointers @@ -326,14 +326,14 @@ extern struct directory * struct directory_entry * self, int)); extern void DECL (finish_cl_pl_entries, (void)); extern int DECL(scan_directory_tree,(struct directory * this_dir, - char * path, + char * path, struct directory_entry * self)); -extern int DECL(insert_file_entry,(struct directory *, char *, +extern int DECL(insert_file_entry,(struct directory *, char *, char *)); extern void DECL(generate_iso9660_directories,(struct directory *, FILE*)); extern void DECL(dump_tree,(struct directory * node)); -extern struct directory_entry * DECL(search_tree_file, (struct +extern struct directory_entry * DECL(search_tree_file, (struct directory * node,char * filename)); extern void DECL(update_nlink_field,(struct directory * node)); extern void DECL (init_fstatbuf, (void)); @@ -374,17 +374,17 @@ extern char *effective_date; extern FILE * in_image; extern struct iso_directory_record * - DECL(merge_isofs,(char * path)); + DECL(merge_isofs,(char * path)); extern int DECL(free_mdinfo, (struct directory_entry **, int len)); -extern struct directory_entry ** +extern struct directory_entry ** DECL(read_merging_directory,(struct iso_directory_record *, int*)); -extern void - DECL(merge_remaining_entries, (struct directory *, +extern void + DECL(merge_remaining_entries, (struct directory *, struct directory_entry **, int)); -extern int - DECL(merge_previous_session, (struct directory *, +extern int + DECL(merge_previous_session, (struct directory *, struct iso_directory_record *)); extern int DECL(get_session_start, (int *)); @@ -401,7 +401,7 @@ struct dirent * DECL(readdir_add_files, (char **, char *, DIR *)); /* */ -extern int DECL(iso9660_file_length,(const char* name, +extern int DECL(iso9660_file_length,(const char* name, struct directory_entry * sresult, int flag)); extern int DECL(iso9660_date,(char *, time_t)); extern void DECL(add_hash,(struct directory_entry *)); @@ -413,7 +413,7 @@ extern int DECL(delete_file_hash,(struct directory_entry *)); extern struct directory_entry * DECL(find_file_hash,(char *)); extern void DECL(add_file_hash,(struct directory_entry *)); extern int DECL(generate_rock_ridge_attributes,(char *, char *, - struct directory_entry *, + struct directory_entry *, struct stat *, struct stat *, int deep_flag)); extern char * DECL(generate_rr_extension_record,(char * id, char * descriptor, diff --git a/util/mkisofs/multi.c b/util/mkisofs/multi.c index 1e7f62aac..d92f14530 100644 --- a/util/mkisofs/multi.c +++ b/util/mkisofs/multi.c @@ -1,5 +1,5 @@ /* - * File multi.c - scan existing iso9660 image and merge into + * File multi.c - scan existing iso9660 image and merge into * iso9660 filesystem. Used for multisession support. * * Written by Eric Youngdale (1996). @@ -166,7 +166,7 @@ readsecs(startsecno, buffer, sectorcount) /* * Parse the RR attributes so we can find the file name. */ -static int +static int FDECL3(parse_rr, unsigned char *, pnt, int, len, struct directory_entry *,dpnt) { int cont_extent, cont_offset, cont_size; @@ -219,10 +219,10 @@ FDECL3(parse_rr, unsigned char *, pnt, int, len, struct directory_entry *,dpnt) } /* parse_rr */ -static int -FDECL4(check_rr_dates, struct directory_entry *, dpnt, - struct directory_entry *, current, - struct stat *, statbuf, +static int +FDECL4(check_rr_dates, struct directory_entry *, dpnt, + struct directory_entry *, current, + struct stat *, statbuf, struct stat *,lstatbuf) { int cont_extent, cont_offset, cont_size; @@ -233,8 +233,8 @@ FDECL4(check_rr_dates, struct directory_entry *, dpnt, int same_file_type; mode_t mode; char time_buf[7]; - - + + cont_extent = cont_offset = cont_size = 0; same_file = 1; same_file_type = 1; @@ -270,14 +270,14 @@ FDECL4(check_rr_dates, struct directory_entry *, dpnt, if( pnt[4] & TF_CREATE ) { iso9660_date((char *) time_buf, lstatbuf->st_ctime); - if(memcmp(time_buf, pnt+offset, 7) == 0) + if(memcmp(time_buf, pnt+offset, 7) == 0) same_file = 0; offset += 7; } if( pnt[4] & TF_MODIFY ) { iso9660_date((char *) time_buf, lstatbuf->st_mtime); - if(memcmp(time_buf, pnt+offset, 7) == 0) + if(memcmp(time_buf, pnt+offset, 7) == 0) same_file = 0; offset += 7; } @@ -350,7 +350,7 @@ FDECL2(read_merging_directory, struct iso_directory_record *, mrootp, while(i < len ) { idr = (struct iso_directory_record *) &dirbuff[i]; - if(idr->length[0] == 0) + if(idr->length[0] == 0) { i = (i + SECTOR_SIZE - 1) & ~(SECTOR_SIZE - 1); continue; @@ -378,7 +378,7 @@ FDECL2(read_merging_directory, struct iso_directory_record *, mrootp, while(i < len ) { idr = (struct iso_directory_record *) &dirbuff[i]; - if(idr->length[0] == 0) + if(idr->length[0] == 0) { i = (i + SECTOR_SIZE - 1) & ~(SECTOR_SIZE - 1); continue; @@ -413,16 +413,16 @@ FDECL2(read_merging_directory, struct iso_directory_record *, mrootp, */ rlen = idr->length[0] & 0xff; cpnt = (unsigned char *) idr; - + rlen -= sizeof(struct iso_directory_record); cpnt += sizeof(struct iso_directory_record); - + rlen += sizeof(idr->name); cpnt -= sizeof(idr->name); - + rlen -= idr->name_len[0]; cpnt += idr->name_len[0]; - + if((idr->name_len[0] & 1) == 0){ cpnt++; rlen--; @@ -444,7 +444,7 @@ FDECL2(read_merging_directory, struct iso_directory_record *, mrootp, memset(cpnt, 0, sizeof((*pnt)->isorec.name) - idr->name_len[0]); parse_rr((*pnt)->rr_attributes, rlen, *pnt); - + if( ((*pnt)->isorec.name_len[0] == 1) && ( ((*pnt)->isorec.name[0] == 0) || ((*pnt)->isorec.name[0] == 1)) ) @@ -485,7 +485,7 @@ FDECL2(read_merging_directory, struct iso_directory_record *, mrootp, tt_extent = isonum_733((unsigned char *)idr->extent); tt_size = isonum_733((unsigned char *)idr->size); } - + pnt++; i += idr->length[0]; } @@ -515,7 +515,7 @@ FDECL2(read_merging_directory, struct iso_directory_record *, mrootp, { rlen = isonum_711((*pnt)->isorec.name_len); if( strncmp((char *) cpnt + 2, (*pnt)->isorec.name, - rlen) == 0 + rlen) == 0 && cpnt[2+rlen] == ' ') { (*pnt)->table = e_malloc(strlen((char*)cpnt) - 33); @@ -534,7 +534,7 @@ FDECL2(read_merging_directory, struct iso_directory_record *, mrootp, cpnt = cpnt1 + 1; cpnt1 = cpnt; } - + free(tt_buf); } else if( !seen_rockridge && !warning_given ) @@ -553,14 +553,14 @@ FDECL2(read_merging_directory, struct iso_directory_record *, mrootp, { free(dirbuff); } - + return rtn; } /* read_merging_directory */ /* * Free any associated data related to the structures. */ -int +int FDECL2(free_mdinfo, struct directory_entry ** , ptr, int, len ) { int i; @@ -792,7 +792,7 @@ struct iso_directory_record * FDECL1(merge_isofs, char *, path) /* * Get the location and size of the root directory. */ - rootp = (struct iso_directory_record *) + rootp = (struct iso_directory_record *) malloc(sizeof(struct iso_directory_record)); memcpy(rootp, pri->root_directory_record, sizeof(*rootp)); @@ -820,7 +820,7 @@ void FDECL3(merge_remaining_entries, struct directory *, this_dir, { continue; } - + if( pnt[i]->name != NULL && pnt[i]->whole_name == NULL) { /* @@ -868,7 +868,7 @@ void FDECL3(merge_remaining_entries, struct directory *, this_dir, this_dir->contents = pnt[i]; pnt[i] = NULL; } - + /* * If we don't have an entry for the translation table, then @@ -945,7 +945,7 @@ void FDECL3(merge_remaining_entries, struct directory *, this_dir, * location. FIXME(eric). */ static int -FDECL2(merge_old_directory_into_tree, struct directory_entry *, dpnt, +FDECL2(merge_old_directory_into_tree, struct directory_entry *, dpnt, struct directory *, parent) { struct directory_entry **contents = NULL; @@ -997,7 +997,7 @@ FDECL2(merge_old_directory_into_tree, struct directory_entry *, dpnt, /* * We can always reuse the TRANS.TBL in this particular case. */ - contents[i]->de_flags |= SAFE_TO_REUSE_TABLE_ENTRY; + contents[i]->de_flags |= SAFE_TO_REUSE_TABLE_ENTRY; if( ((contents[i]->isorec.flags[0] & 2) != 0) && (i >= 2) ) @@ -1059,7 +1059,7 @@ FDECL2(merge_old_directory_into_tree, struct directory_entry *, dpnt, char * cdwrite_data = NULL; int -FDECL1(get_session_start, int *, file_addr) +FDECL1(get_session_start, int *, file_addr) { char * pnt; @@ -1171,14 +1171,14 @@ FDECL2(merge_previous_session,struct directory *, this_dir, { int dflag; - if (strcmp(s_entry->name,".") && strcmp(s_entry->name,"..")) + if (strcmp(s_entry->name,".") && strcmp(s_entry->name,"..")) { struct directory * child; - child = find_or_create_directory(this_dir, - s_entry->whole_name, + child = find_or_create_directory(this_dir, + s_entry->whole_name, s_entry, 1); - dflag = merge_previous_session(child, + dflag = merge_previous_session(child, &odpnt->isorec); /* If unable to scan directory, mark this as a non-directory */ if(!dflag) @@ -1188,14 +1188,14 @@ FDECL2(merge_previous_session,struct directory *, this_dir, } } } - + /* * Whatever is left over, are things which are no longer in the tree * on disk. We need to also merge these into the tree. */ merge_remaining_entries(this_dir, orig_contents, n_orig); free_mdinfo(orig_contents, n_orig); - + return 1; } diff --git a/util/mkisofs/name.c b/util/mkisofs/name.c index 13f81870a..272471e93 100644 --- a/util/mkisofs/name.c +++ b/util/mkisofs/name.c @@ -27,7 +27,7 @@ #include extern int allow_leading_dots; - + /* * Function: iso9660_file_length * @@ -43,8 +43,8 @@ extern int allow_leading_dots; * would also be nice to have. */ int FDECL3(iso9660_file_length, - const char*, name, - struct directory_entry *, sresult, + const char*, name, + struct directory_entry *, sresult, int, dirflag) { char * c; @@ -69,7 +69,7 @@ int FDECL3(iso9660_file_length, */ if(strcmp(name,".") == 0) { - if(result) + if(result) { *result = 0; } @@ -82,7 +82,7 @@ int FDECL3(iso9660_file_length, */ if(strcmp(name,"..") == 0) { - if(result) + if(result) { *result++ = 1; *result++ = 0; @@ -115,7 +115,7 @@ int FDECL3(iso9660_file_length, while(*pnt) { #ifdef VMS - if( strcmp(pnt,".DIR;1") == 0 ) + if( strcmp(pnt,".DIR;1") == 0 ) { break; } @@ -126,11 +126,11 @@ int FDECL3(iso9660_file_length, * generated by some editors. Lower the priority of * the file. */ - if(*pnt == '#') + if(*pnt == '#') { - priority = 1; - pnt++; - continue; + priority = 1; + pnt++; + continue; } /* @@ -138,11 +138,11 @@ int FDECL3(iso9660_file_length, * generated by some editors. Lower the priority of * the file. */ - if(*pnt == '~') + if(*pnt == '~') { - priority = 1; - tildes++; - pnt++; + priority = 1; + tildes++; + pnt++; continue; } @@ -170,9 +170,9 @@ int FDECL3(iso9660_file_length, * If we have a name with multiple '.' characters, we ignore everything * after we have gotten the extension. */ - if(ignore) + if(ignore) { - pnt++; + pnt++; continue; } @@ -181,7 +181,7 @@ int FDECL3(iso9660_file_length, */ if(seen_semic) { - if(*pnt >= '0' && *pnt <= '9') + if(*pnt >= '0' && *pnt <= '9') { *result++ = *pnt; } @@ -197,19 +197,19 @@ int FDECL3(iso9660_file_length, * option. We still only allow one '.' character in the * name, however. */ - if(full_iso9660_filenames) + if(full_iso9660_filenames) { /* Here we allow a more relaxed syntax. */ - if(*pnt == '.') + if(*pnt == '.') { - if (seen_dot) + if (seen_dot) { - ignore++; + ignore++; continue; } seen_dot++; } - if(current_length < 30) + if(current_length < 30) { if( !isascii (*pnt)) { @@ -222,21 +222,21 @@ int FDECL3(iso9660_file_length, } } else - { - /* + { + /* * Dos style filenames. We really restrict the * names here. */ /* It would be nice to have .tar.gz transform to .tgz, * .ps.gz to .psz, ... */ - if(*pnt == '.') + if(*pnt == '.') { - if (!chars_before_dot && !allow_leading_dots) + if (!chars_before_dot && !allow_leading_dots) { /* DOS can't read files with dot first */ chars_before_dot++; - if (result) + if (result) { *result++ = '_'; /* Substitute underscore */ } @@ -247,36 +247,36 @@ int FDECL3(iso9660_file_length, * If this isn't the dot that we use for the extension, * then change the character into a '_' instead. */ - if(chars_before_dot < 8) + if(chars_before_dot < 8) { chars_before_dot++; - if(result) + if(result) { *result++ = '_'; } } } - else + else { - if (seen_dot) + if (seen_dot) { ignore++; continue; } - if(result) + if(result) { *result++ = '.'; } seen_dot++; } } - else + else { if( (seen_dot && (chars_after_dot < 3) && ++chars_after_dot) || (!seen_dot && (chars_before_dot < 8) && ++chars_before_dot) ) { - if(result) + if(result) { - switch (*pnt) + switch (*pnt) { default: if( !isascii (*pnt) ) @@ -289,7 +289,7 @@ int FDECL3(iso9660_file_length, } break; - /* + /* * Descriptions of DOS's 'Parse Filename' * (function 29H) describes V1 and V2.0+ * separator and terminator characters. @@ -329,7 +329,7 @@ int FDECL3(iso9660_file_length, current_length++; pnt++; } /* while (*pnt) */ - + /* * OK, that wraps up the scan of the name. Now tidy up a few other * things. @@ -345,11 +345,11 @@ int FDECL3(iso9660_file_length, { int prio1 = 0; pnt = name; - while (*pnt && *pnt != '~') + while (*pnt && *pnt != '~') { pnt++; } - if (*pnt) + if (*pnt) { pnt++; } @@ -360,7 +360,7 @@ int FDECL3(iso9660_file_length, } priority = prio1; } - + /* * If this is not a directory, force a '.' in case we haven't * seen one, and add a version number if we haven't seen one @@ -368,12 +368,12 @@ int FDECL3(iso9660_file_length, */ if (!dirflag) { - if (!seen_dot && !omit_period) + if (!seen_dot && !omit_period) { - if (result) *result++ = '.'; + if (result) *result++ = '.'; extra++; } - if(!omit_version_number && !seen_semic) + if(!omit_version_number && !seen_semic) { if(result) { @@ -383,8 +383,8 @@ int FDECL3(iso9660_file_length, extra += 2; } } - - if(result) + + if(result) { *result++ = 0; } diff --git a/util/mkisofs/rock.c b/util/mkisofs/rock.c index 224488af5..a4cc27fa9 100644 --- a/util/mkisofs/rock.c +++ b/util/mkisofs/rock.c @@ -87,7 +87,7 @@ a CE entry for the continuation record */ #define MAYBE_ADD_CE_ENTRY(BYTES) \ - ((unsigned) ((BYTES) + CE_SIZE + currlen + ipnt) > (unsigned) (recstart + reclimit) ? 1 : 0) + ((unsigned) ((BYTES) + CE_SIZE + currlen + ipnt) > (unsigned) (recstart + reclimit) ? 1 : 0) /* * Buffer to build RR attributes @@ -210,13 +210,13 @@ int deep_opt; }; /* - * Add the posix modes + * Add the posix modes */ if(MAYBE_ADD_CE_ENTRY(PX_SIZE)) add_CE_entry(); Rock[ipnt++] ='P'; Rock[ipnt++] ='X'; Rock[ipnt++] = PX_SIZE; - Rock[ipnt++] = SU_VERSION; + Rock[ipnt++] = SU_VERSION; flagval |= (1<<0); set_733((char*)Rock + ipnt, lstatbuf->st_mode); ipnt += 8; @@ -236,7 +236,7 @@ int deep_opt; Rock[ipnt++] ='P'; Rock[ipnt++] ='N'; Rock[ipnt++] = PN_SIZE; - Rock[ipnt++] = SU_VERSION; + Rock[ipnt++] = SU_VERSION; flagval |= (1<<1); #if defined(MAJOR_IN_SYSMACROS) || defined(MAJOR_IN_MKDEV) set_733((char*)Rock + ipnt, major(lstatbuf->st_rdev )); @@ -286,25 +286,25 @@ int deep_opt; cpnt = &symlink_buff[0]; flagval |= (1<<2); - if (! split_SL_field) + if (! split_SL_field) { int sl_bytes = 0; - for (cpnt1 = cpnt; *cpnt1 != '\0'; cpnt1++) + for (cpnt1 = cpnt; *cpnt1 != '\0'; cpnt1++) { - if (*cpnt1 == '/') + if (*cpnt1 == '/') { sl_bytes += 4; - } - else + } + else { sl_bytes += 1; } } - if (sl_bytes > 250) + if (sl_bytes > 250) { - /* + /* * the symbolic link won't fit into one SL System Use Field - * print an error message and continue with splited one + * print an error message and continue with splited one */ fprintf(stderr, _("symbolic link ``%s'' to long for one SL System Use Field, splitting"), cpnt); } @@ -317,7 +317,7 @@ int deep_opt; Rock[ipnt++] ='L'; lenpos = ipnt; Rock[ipnt++] = SL_SIZE; - Rock[ipnt++] = SU_VERSION; + Rock[ipnt++] = SU_VERSION; Rock[ipnt++] = 0; /* Flags */ lenval = 5; while(*cpnt){ @@ -326,7 +326,7 @@ int deep_opt; nchar--; *cpnt1 = 0; }; - + /* We treat certain components in a special way. */ if(cpnt[0] == '.' && cpnt[1] == '.' && cpnt[2] == 0){ if(MAYBE_ADD_CE_ENTRY(2)) add_CE_entry(); @@ -349,7 +349,7 @@ int deep_opt; /* If we do not have enough room for a component, start a new continuations segment now */ if(split_SL_component ? MAYBE_ADD_CE_ENTRY(6) : - MAYBE_ADD_CE_ENTRY(6 + strlen ((char *) cpnt))) + MAYBE_ADD_CE_ENTRY(6 + strlen ((char *) cpnt))) { add_CE_entry(); if(cpnt1) @@ -397,7 +397,7 @@ int deep_opt; if(nchar) Rock[lenpos + 2] = SL_CONTINUE; /* We need another SL entry */ } /* while nchar */ } /* Is a symbolic link */ - /* + /* * Add in the Rock Ridge TF time field */ if(MAYBE_ADD_CE_ENTRY(TF_SIZE)) add_CE_entry(); @@ -422,7 +422,7 @@ int deep_opt; iso9660_date((char *) &Rock[ipnt], lstatbuf->st_ctime); ipnt += 7; - /* + /* * Add in the Rock Ridge RE time field */ if(deep_opt & NEED_RE){ @@ -433,7 +433,7 @@ int deep_opt; Rock[ipnt++] = SU_VERSION; flagval |= (1<<6); }; - /* + /* * Add in the Rock Ridge PL record, if required. */ if(deep_opt & NEED_PL){ @@ -447,7 +447,7 @@ int deep_opt; flagval |= (1<<5); }; - /* + /* * Add in the Rock Ridge CL field, if required. */ if(deep_opt & NEED_CL){ @@ -464,7 +464,7 @@ int deep_opt; #ifndef VMS /* If transparent compression was requested, fill in the correct field for this file */ - if(transparent_compression && + if(transparent_compression && S_ISREG(lstatbuf->st_mode) && strlen(name) > 3 && strcmp(name + strlen(name) - 3,".gZ") == 0){ @@ -498,8 +498,8 @@ int deep_opt; else { int blocksize; blocksize = (header[3] << 8) | header[2]; - file_size = ((unsigned int)header[7] << 24) | - ((unsigned int)header[6] << 16) | + file_size = ((unsigned int)header[7] << 24) | + ((unsigned int)header[6] << 16) | ((unsigned int)header[5] << 8) | header[4]; #if 0 fprintf(stderr,"Blocksize = %d %d\n", blocksize, file_size); @@ -534,7 +534,7 @@ int deep_opt; }; } #endif - /* + /* * Add in the Rock Ridge CE field, if required. We use this for the * extension record that is stored in the root directory. */ diff --git a/util/mkisofs/tree.c b/util/mkisofs/tree.c index d11fdc2cd..0d9cf6143 100644 --- a/util/mkisofs/tree.c +++ b/util/mkisofs/tree.c @@ -195,7 +195,7 @@ static int FDECL1(sort_n_finish, struct directory *, this_dir) * missing the required '.' entries. Create these now if we need * them. */ - if( (this_dir->dir_flags & (DIR_HAS_DOT | DIR_HAS_DOTDOT)) != + if( (this_dir->dir_flags & (DIR_HAS_DOT | DIR_HAS_DOTDOT)) != (DIR_HAS_DOT | DIR_HAS_DOTDOT) ) { attach_dot_entries(this_dir, &fstatbuf); @@ -211,9 +211,9 @@ static int FDECL1(sort_n_finish, struct directory *, this_dir) s_entry = s_entry->next; continue; } - + /* - * First assume no conflict, and handle this case + * First assume no conflict, and handle this case */ if(!(s_entry1 = find_file_hash(s_entry->isorec.name))) { @@ -221,16 +221,16 @@ static int FDECL1(sort_n_finish, struct directory *, this_dir) s_entry = s_entry->next; continue; } - + if(s_entry1 == s_entry) error (1, 0, _("Fatal goof\n")); - - /* + + /* * OK, handle the conflicts. Try substitute names until we come - * up with a winner + * up with a winner */ strcpy(rootname, s_entry->isorec.name); - if(full_iso9660_filenames) + if(full_iso9660_filenames) { if(strlen(rootname) > 27) rootname[27] = 0; } @@ -241,7 +241,7 @@ static int FDECL1(sort_n_finish, struct directory *, this_dir) * a ';'. */ c = strchr(rootname, '.'); - if (c) + if (c) *c = 0; else { @@ -254,25 +254,25 @@ static int FDECL1(sort_n_finish, struct directory *, this_dir) { for(d3 = 0; d3 < 36; d3++) { - sprintf(newname,"%s.%c%c%c%s", rootname, + sprintf(newname,"%s.%c%c%c%s", rootname, (d1 <= 9 ? '0' + d1 : 'A' + d1 - 10), (d2 <= 9 ? '0' + d2 : 'A' + d2 - 10), (d3 <= 9 ? '0' + d3 : 'A' + d3 - 10), - (s_entry->isorec.flags[0] == 2 || + (s_entry->isorec.flags[0] == 2 || omit_version_number ? "" : ";1")); - + #ifdef VMS /* Sigh. VAXCRTL seems to be broken here */ { int ijk = 0; - while(newname[ijk]) + while(newname[ijk]) { if(newname[ijk] == ' ') newname[ijk] = '0'; ijk++; } } #endif - + if(!find_file_hash(newname)) goto got_valid_name; } } @@ -283,24 +283,24 @@ static int FDECL1(sort_n_finish, struct directory *, this_dir) */ error (1, 0, _("Unable to generate unique name for file %s\n"), s_entry->name); -got_valid_name: - /* +got_valid_name: + /* * OK, now we have a good replacement name. Now decide which one - * of these two beasts should get the name changed + * of these two beasts should get the name changed */ - if(s_entry->priority < s_entry1->priority) + if(s_entry->priority < s_entry1->priority) { if( verbose > 0 ) { - fprintf (stderr, _("Using %s for %s%s%s (%s)\n"), newname, - this_dir->whole_name, SPATH_SEPARATOR, + fprintf (stderr, _("Using %s for %s%s%s (%s)\n"), newname, + this_dir->whole_name, SPATH_SEPARATOR, s_entry->name, s_entry1->name); } s_entry->isorec.name_len[0] = strlen(newname); new_reclen = sizeof(struct iso_directory_record) - sizeof(s_entry->isorec.name) + strlen(newname); - if(use_RockRidge) + if(use_RockRidge) { if (new_reclen & 1) new_reclen++; /* Pad to an even byte */ new_reclen += s_entry->rr_attr_size; @@ -309,20 +309,20 @@ got_valid_name: s_entry->isorec.length[0] = new_reclen; strcpy(s_entry->isorec.name, newname); } - else + else { delete_file_hash(s_entry1); if( verbose > 0 ) { - fprintf(stderr, _("Using %s for %s%s%s (%s)\n"), newname, - this_dir->whole_name, SPATH_SEPARATOR, + fprintf(stderr, _("Using %s for %s%s%s (%s)\n"), newname, + this_dir->whole_name, SPATH_SEPARATOR, s_entry1->name, s_entry->name); } s_entry1->isorec.name_len[0] = strlen(newname); new_reclen = sizeof(struct iso_directory_record) - sizeof(s_entry1->isorec.name) + strlen(newname); - if(use_RockRidge) + if(use_RockRidge) { if (new_reclen & 1) new_reclen++; /* Pad to an even byte */ new_reclen += s_entry1->rr_attr_size; @@ -335,19 +335,19 @@ got_valid_name: add_file_hash(s_entry); s_entry = s_entry->next; } - - if(generate_tables - && !find_file_hash("TRANS.TBL") + + if(generate_tables + && !find_file_hash("TRANS.TBL") && (reloc_dir != this_dir) && (this_dir->extent == 0) ) { - /* - * First we need to figure out how big this table is + /* + * First we need to figure out how big this table is */ for (s_entry = this_dir->contents; s_entry; s_entry = s_entry->next) { if(strcmp(s_entry->name, ".") == 0 || - strcmp(s_entry->name, "..") == 0) continue; + strcmp(s_entry->name, "..") == 0) continue; if(s_entry->de_flags & INHIBIT_ISO9660_ENTRY) continue; if(s_entry->table) tablesize += 35 + strlen(s_entry->table); } @@ -355,13 +355,13 @@ got_valid_name: if( tablesize > 0 ) { - table = (struct directory_entry *) + table = (struct directory_entry *) e_malloc(sizeof (struct directory_entry)); memset(table, 0, sizeof(struct directory_entry)); table->table = NULL; table->next = this_dir->contents; this_dir->contents = table; - + table->filedir = root; table->isorec.flags[0] = 0; table->priority = 32768; @@ -379,7 +379,7 @@ got_valid_name: table->table = (char *) e_malloc(ROUND_UP(tablesize)); memset(table->table, 0, ROUND_UP(tablesize)); iso9660_file_length ("TRANS.TBL", table, 0); - + if(use_RockRidge) { fstatbuf.st_mode = 0444 | S_IFREG; @@ -389,7 +389,7 @@ got_valid_name: &fstatbuf, &fstatbuf, 0); } } - + /* * We have now chosen the 8.3 names and we should now know the length * of every entry in the directory. @@ -403,18 +403,18 @@ got_valid_name: } new_reclen = strlen(s_entry->isorec.name); - + /* * First update the path table sizes for directories. */ if(s_entry->isorec.flags[0] == 2) { - if (strcmp(s_entry->name,".") && strcmp(s_entry->name,"..")) + if (strcmp(s_entry->name,".") && strcmp(s_entry->name,"..")) { path_table_size += new_reclen + sizeof(struct iso_path_table) - 1; if (new_reclen & 1) path_table_size++; } - else + else { new_reclen = 1; if (this_dir == root && strlen(s_entry->name) == 1) @@ -425,19 +425,19 @@ got_valid_name: } if(path_table_size & 1) path_table_size++; /* For odd lengths we pad */ s_entry->isorec.name_len[0] = new_reclen; - - new_reclen += + + new_reclen += sizeof(struct iso_directory_record) - sizeof(s_entry->isorec.name); - - if (new_reclen & 1) + + if (new_reclen & 1) new_reclen++; - + new_reclen += s_entry->rr_attr_size; - + if (new_reclen & 1) new_reclen++; - - if(new_reclen > 0xff) + + if(new_reclen > 0xff) error (1, 0, _("Fatal error - RR overflow for file %s\n"), s_entry->name); s_entry->isorec.length[0] = new_reclen; @@ -476,14 +476,14 @@ got_valid_name: s_entry->table = NULL; } - if(count != tablesize) + if(count != tablesize) error (1, 0, _("Translation table size mismatch %d %d\n"), count, tablesize); } - /* + /* * Now go through the directory and figure out how large this one will be. - * Do not split a directory entry across a sector boundary + * Do not split a directory entry across a sector boundary */ s_entry = this_dir->contents; this_dir->ce_bytes = 0; @@ -497,34 +497,34 @@ got_valid_name: new_reclen = s_entry->isorec.length[0]; if ((this_dir->size & (SECTOR_SIZE - 1)) + new_reclen >= SECTOR_SIZE) - this_dir->size = (this_dir->size + (SECTOR_SIZE - 1)) & + this_dir->size = (this_dir->size + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1); this_dir->size += new_reclen; /* See if continuation entries were used on disc */ - if(use_RockRidge && - s_entry->rr_attr_size != s_entry->total_rr_attr_size) + if(use_RockRidge && + s_entry->rr_attr_size != s_entry->total_rr_attr_size) { unsigned char * pnt; int len; int nbytes; - + pnt = s_entry->rr_attributes; len = s_entry->total_rr_attr_size; - + /* * We make sure that each continuation entry record is not * split across sectors, but each file could in theory have more - * than one CE, so we scan through and figure out what we need. + * than one CE, so we scan through and figure out what we need. */ while(len > 3) { - if(pnt[0] == 'C' && pnt[1] == 'E') + if(pnt[0] == 'C' && pnt[1] == 'E') { nbytes = get_733((char *) pnt+20); - + if((this_dir->ce_bytes & (SECTOR_SIZE - 1)) + nbytes >= - SECTOR_SIZE) this_dir->ce_bytes = + SECTOR_SIZE) this_dir->ce_bytes = ROUND_UP(this_dir->ce_bytes); /* Now store the block in the ce buffer */ this_dir->ce_bytes += nbytes; @@ -546,7 +546,7 @@ static void generate_reloc_directory() /* Create an entry for our internal tree */ time (¤t_time); - reloc_dir = (struct directory *) + reloc_dir = (struct directory *) e_malloc(sizeof(struct directory)); memset(reloc_dir, 0, sizeof(struct directory)); reloc_dir->parent = root; @@ -556,10 +556,10 @@ static void generate_reloc_directory() reloc_dir->whole_name = strdup("./rr_moved"); reloc_dir->de_name = strdup("rr_moved"); reloc_dir->extent = 0; - - + + /* Now create an actual directory entry */ - s_entry = (struct directory_entry *) + s_entry = (struct directory_entry *) e_malloc(sizeof (struct directory_entry)); memset(s_entry, 0, sizeof(struct directory_entry)); s_entry->next = root->contents; @@ -589,13 +589,13 @@ static void generate_reloc_directory() "rr_moved", s_entry, &fstatbuf, &fstatbuf, 0); }; - + /* Now create the . and .. entries in rr_moved */ /* Now create an actual directory entry */ attach_dot_entries(reloc_dir, &root_statbuf); } -/* +/* * Function: attach_dot_entries * * Purpose: Create . and .. entries for a new directory. @@ -616,9 +616,9 @@ static void FDECL2(attach_dot_entries, struct directory *, dirnode, if( (dirnode->dir_flags & DIR_HAS_DOTDOT) == 0 ) { - s_entry = (struct directory_entry *) + s_entry = (struct directory_entry *) e_malloc(sizeof (struct directory_entry)); - memcpy(s_entry, dirnode->self, + memcpy(s_entry, dirnode->self, sizeof(struct directory_entry)); s_entry->name = strdup(".."); s_entry->whole_name = NULL; @@ -640,7 +640,7 @@ static void FDECL2(attach_dot_entries, struct directory *, dirnode, } generate_rock_ridge_attributes("", "..", s_entry, - parent_stat, + parent_stat, parent_stat, 0); } dirnode->dir_flags |= DIR_HAS_DOTDOT; @@ -648,9 +648,9 @@ static void FDECL2(attach_dot_entries, struct directory *, dirnode, if( (dirnode->dir_flags & DIR_HAS_DOT) == 0 ) { - s_entry = (struct directory_entry *) + s_entry = (struct directory_entry *) e_malloc(sizeof (struct directory_entry)); - memcpy(s_entry, dirnode->self, + memcpy(s_entry, dirnode->self, sizeof(struct directory_entry)); s_entry->name = strdup("."); s_entry->whole_name = NULL; @@ -659,7 +659,7 @@ static void FDECL2(attach_dot_entries, struct directory *, dirnode, iso9660_file_length (".", s_entry, 1); iso9660_date(s_entry->isorec.date, fstatbuf.st_mtime); s_entry->filedir = dirnode; - + dirnode->contents = s_entry; dirnode->contents->next = orig_contents; @@ -667,17 +667,17 @@ static void FDECL2(attach_dot_entries, struct directory *, dirnode, { fstatbuf.st_mode = 0555 | S_IFDIR; fstatbuf.st_nlink = 2; - + if( dirnode == root ) { deep_flag |= NEED_CE | NEED_SP; /* For extension record */ } - + generate_rock_ridge_attributes("", ".", s_entry, &fstatbuf, &fstatbuf, deep_flag); } - + dirnode->dir_flags |= DIR_HAS_DOT; } @@ -687,12 +687,12 @@ static void FDECL2(update_nlink, struct directory_entry *, s_entry, int, value) { unsigned char * pnt; int len; - + pnt = s_entry->rr_attributes; len = s_entry->total_rr_attr_size; while(len) { - if(pnt[0] == 'P' && pnt[1] == 'X') + if(pnt[0] == 'P' && pnt[1] == 'X') { set_733((char *) pnt+12, value); break; @@ -706,12 +706,12 @@ static void FDECL1(increment_nlink, struct directory_entry *, s_entry) { unsigned char * pnt; int len, nlink; - + pnt = s_entry->rr_attributes; len = s_entry->total_rr_attr_size; while(len) { - if(pnt[0] == 'P' && pnt[1] == 'X') + if(pnt[0] == 'P' && pnt[1] == 'X') { nlink = get_733((char *) pnt+12); set_733((char *) pnt+12, nlink+1); @@ -770,7 +770,7 @@ void finish_cl_pl_entries(){ }; } -/* +/* * Function: scan_directory_tree * * Purpose: Walk through a directory on the local machine @@ -781,7 +781,7 @@ void finish_cl_pl_entries(){ */ int FDECL3(scan_directory_tree,struct directory *, this_dir, - char *, path, + char *, path, struct directory_entry *, de) { DIR * current_dir; @@ -806,7 +806,7 @@ FDECL3(scan_directory_tree,struct directory *, this_dir, if(current_dir) d_entry = readdir(current_dir); - if(!current_dir || !d_entry) + if(!current_dir || !d_entry) { fprintf (stderr, _("Unable to open directory %s\n"), path); de->isorec.flags[0] &= ~2; /* Mark as not a directory */ @@ -827,12 +827,12 @@ FDECL3(scan_directory_tree,struct directory *, this_dir, */ if (de->de_flags & INHIBIT_ISO9660_ENTRY) this_dir->dir_flags |= INHIBIT_ISO9660_ENTRY; - + if (de->de_flags & INHIBIT_JOLIET_ENTRY) this_dir->dir_flags |= INHIBIT_JOLIET_ENTRY; - - /* - * Now we scan the directory itself, and look at what is inside of it. + + /* + * Now we scan the directory itself, and look at what is inside of it. */ dflag = 0; while(1==1){ @@ -878,7 +878,7 @@ FDECL3(scan_directory_tree,struct directory *, this_dir, continue; } - if( generate_tables + if( generate_tables && strcmp(d_entry->d_name, "TRANS.TBL") == 0 ) { /* @@ -886,7 +886,7 @@ FDECL3(scan_directory_tree,struct directory *, this_dir, * versions of these files, and we need to ignore any * originals that we might have found. */ - if (verbose > 1) + if (verbose > 1) { fprintf (stderr, _("Excluded: %s\n"), whole_path); } @@ -897,13 +897,13 @@ FDECL3(scan_directory_tree,struct directory *, this_dir, * If we already have a '.' or a '..' entry, then don't * insert new ones. */ - if( strcmp(d_entry->d_name, ".") == 0 + if( strcmp(d_entry->d_name, ".") == 0 && this_dir->dir_flags & DIR_HAS_DOT ) { continue; } - if( strcmp(d_entry->d_name, "..") == 0 + if( strcmp(d_entry->d_name, "..") == 0 && this_dir->dir_flags & DIR_HAS_DOTDOT ) { continue; @@ -918,12 +918,12 @@ FDECL3(scan_directory_tree,struct directory *, this_dir, insert_file_entry(this_dir, whole_path, d_entry->d_name); } closedir(current_dir); - + return 1; } -/* +/* * Function: insert_file_entry * * Purpose: Insert one entry into our directory node. @@ -961,12 +961,12 @@ FDECL3(insert_file_entry,struct directory *, this_dir, fprintf (stderr, _("Non-existant or inaccessible: %s\n"),whole_path); return 0; } - + if(this_dir == root && strcmp(short_name, ".") == 0) root_statbuf = statbuf; /* Save this for later on */ - + /* We do this to make sure that the root entries are consistent */ - if(this_dir == root && strcmp(short_name, "..") == 0) + if(this_dir == root && strcmp(short_name, "..") == 0) { statbuf = root_statbuf; lstatbuf = root_statbuf; @@ -974,13 +974,13 @@ FDECL3(insert_file_entry,struct directory *, this_dir, if(S_ISLNK(lstatbuf.st_mode)) { - + /* Here we decide how to handle the symbolic links. Here we handle the general case - if we are not following links or there is an error, then we must change something. If RR is in use, it is easy, we let RR describe the file. If not, then we punt the file. */ - + if((status || !follow_links)) { if(use_RockRidge) @@ -991,7 +991,7 @@ FDECL3(insert_file_entry,struct directory *, this_dir, statbuf.st_dev = (dev_t) UNCACHED_DEVICE; statbuf.st_mode = (statbuf.st_mode & ~S_IFMT) | S_IFREG; } else { - if(follow_links) + if(follow_links) { fprintf (stderr, _("Unable to stat file %s - ignoring and continuing.\n"), @@ -1006,7 +1006,7 @@ FDECL3(insert_file_entry,struct directory *, this_dir, } } } - + /* Here we handle a different kind of case. Here we have a symlink, but we want to follow symlinks. If we run across a directory loop, then we need to pretend that @@ -1014,16 +1014,16 @@ FDECL3(insert_file_entry,struct directory *, this_dir, is the first time we have seen this, then make this seem as if there was no symlink there in the first place */ - + if( follow_links - && S_ISDIR(statbuf.st_mode) ) + && S_ISDIR(statbuf.st_mode) ) { if( strcmp(short_name, ".") && strcmp(short_name, "..") ) { if(find_directory_hash(statbuf.st_dev, STAT_INODE(statbuf))) { - if(!use_RockRidge) + if(!use_RockRidge) { fprintf (stderr, _("Already cached directory seen (%s)\n"), whole_path); @@ -1034,25 +1034,25 @@ FDECL3(insert_file_entry,struct directory *, this_dir, statbuf.st_dev = (dev_t) UNCACHED_DEVICE; statbuf.st_mode = (statbuf.st_mode & ~S_IFMT) | S_IFREG; } - else + else { lstatbuf = statbuf; add_directory_hash(statbuf.st_dev, STAT_INODE(statbuf)); } } } - + /* * For non-directories, we just copy the stat information over * so we correctly include this file. */ if( follow_links - && !S_ISDIR(statbuf.st_mode) ) + && !S_ISDIR(statbuf.st_mode) ) { lstatbuf = statbuf; } } - + /* * Add directories to the cache so that we don't waste space even * if we are supposed to be following symlinks. @@ -1060,7 +1060,7 @@ FDECL3(insert_file_entry,struct directory *, this_dir, if( follow_links && strcmp(short_name, ".") && strcmp(short_name, "..") - && S_ISDIR(statbuf.st_mode) ) + && S_ISDIR(statbuf.st_mode) ) { add_directory_hash(statbuf.st_dev, STAT_INODE(statbuf)); } @@ -1071,13 +1071,13 @@ FDECL3(insert_file_entry,struct directory *, this_dir, whole_path, strerror (errno)); return 0; } - + /* Add this so that we can detect directory loops with hard links. If we are set up to follow symlinks, then we skip this checking. */ - if( !follow_links - && S_ISDIR(lstatbuf.st_mode) - && strcmp(short_name, ".") - && strcmp(short_name, "..") ) + if( !follow_links + && S_ISDIR(lstatbuf.st_mode) + && strcmp(short_name, ".") + && strcmp(short_name, "..") ) { if(find_directory_hash(statbuf.st_dev, STAT_INODE(statbuf))) error (1, 0, _("Directory loop - fatal goof (%s %lx %lu).\n"), @@ -1085,7 +1085,7 @@ FDECL3(insert_file_entry,struct directory *, this_dir, (unsigned long) STAT_INODE(statbuf)); add_directory_hash(statbuf.st_dev, STAT_INODE(statbuf)); } - + if (!S_ISCHR(lstatbuf.st_mode) && !S_ISBLK(lstatbuf.st_mode) && !S_ISFIFO(lstatbuf.st_mode) && !S_ISSOCK(lstatbuf.st_mode) && !S_ISLNK(lstatbuf.st_mode) && !S_ISREG(lstatbuf.st_mode) && @@ -1094,26 +1094,26 @@ FDECL3(insert_file_entry,struct directory *, this_dir, whole_path); return 0; } - + /* Who knows what trash this is - ignore and continue */ - - if(status) + + if(status) { fprintf (stderr, _("Unable to stat file %s - ignoring and continuing.\n"), whole_path); - return 0; + return 0; } - + /* * Check to see if we have already seen this directory node. * If so, then we don't create a new entry for it, but we do want * to recurse beneath it and add any new files we do find. */ - if (S_ISDIR(statbuf.st_mode)) + if (S_ISDIR(statbuf.st_mode)) { int dflag; - + for( s_entry = this_dir->contents; s_entry; s_entry = s_entry->next) { if( strcmp(s_entry->name, short_name) == 0 ) @@ -1121,12 +1121,12 @@ FDECL3(insert_file_entry,struct directory *, this_dir, break; } } - if ( s_entry != NULL - && strcmp(short_name,".") - && strcmp(short_name,"..")) + if ( s_entry != NULL + && strcmp(short_name,".") + && strcmp(short_name,"..")) { struct directory * child; - + if ( (s_entry->de_flags & RELOCATED_DIRECTORY) != 0) { for( s_entry = reloc_dir->contents; s_entry; s_entry = s_entry->next) @@ -1136,12 +1136,12 @@ FDECL3(insert_file_entry,struct directory *, this_dir, break; } } - child = find_or_create_directory(reloc_dir, whole_path, + child = find_or_create_directory(reloc_dir, whole_path, s_entry, 1); } else { - child = find_or_create_directory(this_dir, whole_path, + child = find_or_create_directory(this_dir, whole_path, s_entry, 1); /* If unable to scan directory, mark this as a non-directory */ } @@ -1153,15 +1153,15 @@ FDECL3(insert_file_entry,struct directory *, this_dir, return 0; } } - - s_entry = (struct directory_entry *) + + s_entry = (struct directory_entry *) e_malloc(sizeof (struct directory_entry)); s_entry->next = this_dir->contents; memset(s_entry->isorec.extent, 0, 8); this_dir->contents = s_entry; deep_flag = 0; s_entry->table = NULL; - + s_entry->name = strdup(short_name); s_entry->whole_name = strdup (whole_path); @@ -1204,21 +1204,21 @@ FDECL3(insert_file_entry,struct directory *, this_dir, if( strcmp(short_name, ".") == 0) { this_dir->dir_flags |= DIR_HAS_DOT; - } + } if( strcmp(short_name, "..") == 0) { this_dir->dir_flags |= DIR_HAS_DOTDOT; - } + } - if( this_dir->parent - && this_dir->parent == reloc_dir + if( this_dir->parent + && this_dir->parent == reloc_dir && strcmp(short_name, "..") == 0) { s_entry->inode = UNCACHED_INODE; s_entry->dev = (dev_t) UNCACHED_DEVICE; deep_flag = NEED_PL; - } + } else { s_entry->inode = STAT_INODE(statbuf); @@ -1229,42 +1229,42 @@ FDECL3(insert_file_entry,struct directory *, this_dir, s_entry->rr_attr_size = 0; s_entry->total_rr_attr_size = 0; s_entry->rr_attributes = NULL; - + /* Directories are assigned sizes later on */ - if (!S_ISDIR(statbuf.st_mode)) + if (!S_ISDIR(statbuf.st_mode)) { - if (S_ISCHR(lstatbuf.st_mode) || S_ISBLK(lstatbuf.st_mode) || + if (S_ISCHR(lstatbuf.st_mode) || S_ISBLK(lstatbuf.st_mode) || S_ISFIFO(lstatbuf.st_mode) || S_ISSOCK(lstatbuf.st_mode) || S_ISLNK(lstatbuf.st_mode)) { - s_entry->size = 0; - statbuf.st_size = 0; + s_entry->size = 0; + statbuf.st_size = 0; } else { - s_entry->size = statbuf.st_size; + s_entry->size = statbuf.st_size; } - set_733((char *) s_entry->isorec.size, statbuf.st_size); - } + set_733((char *) s_entry->isorec.size, statbuf.st_size); + } else { s_entry->isorec.flags[0] = 2; } - - if (strcmp(short_name,".") && strcmp(short_name,"..") && + + if (strcmp(short_name,".") && strcmp(short_name,"..") && S_ISDIR(statbuf.st_mode) && this_dir->depth > RR_relocation_depth) { struct directory * child; if(!reloc_dir) generate_reloc_directory(); - + /* * Replicate the entry for this directory. The old one will stay where it * is, and it will be neutered so that it no longer looks like a directory. * The new one will look like a directory, and it will be put in the reloc_dir. */ - s_entry1 = (struct directory_entry *) + s_entry1 = (struct directory_entry *) e_malloc(sizeof (struct directory_entry)); memcpy(s_entry1, s_entry, sizeof(struct directory_entry)); s_entry1->table = NULL; @@ -1274,26 +1274,26 @@ FDECL3(insert_file_entry,struct directory *, this_dir, reloc_dir->contents = s_entry1; s_entry1->priority = 32768; s_entry1->parent_rec = this_dir->contents; - + deep_flag = NEED_RE; - - if(use_RockRidge) + + if(use_RockRidge) { generate_rock_ridge_attributes(whole_path, short_name, s_entry1, &statbuf, &lstatbuf, deep_flag); } - + deep_flag = 0; - + /* We need to set this temporarily so that the parent to this is correctly determined. */ s_entry1->filedir = reloc_dir; - child = find_or_create_directory(reloc_dir, whole_path, + child = find_or_create_directory(reloc_dir, whole_path, s_entry1, 0); scan_directory_tree(child, whole_path, s_entry1); s_entry1->filedir = this_dir; - + statbuf.st_size = 0; statbuf.st_mode &= 0777; set_733((char *) s_entry->isorec.size, 0); @@ -1303,10 +1303,10 @@ FDECL3(insert_file_entry,struct directory *, this_dir, s_entry->de_flags |= RELOCATED_DIRECTORY; deep_flag = NEED_CL; } - - if(generate_tables - && strcmp(s_entry->name, ".") - && strcmp(s_entry->name, "..")) + + if(generate_tables + && strcmp(s_entry->name, ".") + && strcmp(s_entry->name, "..")) { char buffer[2048]; int nchar; @@ -1357,8 +1357,8 @@ FDECL3(insert_file_entry,struct directory *, this_dir, #endif #ifdef S_IFLNK case S_IFLNK: - nchar = readlink(whole_path, - (char *)symlink_buff, + nchar = readlink(whole_path, + (char *)symlink_buff, sizeof(symlink_buff)); symlink_buff[nchar < 0 ? 0 : nchar] = 0; sprintf(buffer,"L\t%s\t%s\n", @@ -1379,18 +1379,18 @@ FDECL3(insert_file_entry,struct directory *, this_dir, }; s_entry->table = strdup(buffer); } - + if(S_ISDIR(statbuf.st_mode)) { int dflag; - if (strcmp(short_name,".") && strcmp(short_name,"..")) + if (strcmp(short_name,".") && strcmp(short_name,"..")) { struct directory * child; - - child = find_or_create_directory(this_dir, whole_path, + + child = find_or_create_directory(this_dir, whole_path, s_entry, 1); dflag = scan_directory_tree(child, whole_path, s_entry); - + if(!dflag) { lstatbuf.st_mode = (lstatbuf.st_mode & ~S_IFMT) | S_IFREG; @@ -1402,23 +1402,23 @@ FDECL3(insert_file_entry,struct directory *, this_dir, } /* If unable to scan directory, mark this as a non-directory */ } - + if(use_RockRidge && this_dir == root && strcmp(s_entry->name, ".") == 0) { deep_flag |= NEED_CE | NEED_SP; /* For extension record */ } - + /* Now figure out how much room this file will take in the directory */ - - if(use_RockRidge) + + if(use_RockRidge) { generate_rock_ridge_attributes(whole_path, short_name, s_entry, &statbuf, &lstatbuf, deep_flag); - + } - + return 1; } @@ -1492,7 +1492,7 @@ struct directory * FDECL4(find_or_create_directory, struct directory *, parent, */ if( de == NULL ) { - de = (struct directory_entry *) + de = (struct directory_entry *) e_malloc(sizeof (struct directory_entry)); memset(de, 0, sizeof(struct directory_entry)); de->next = parent->contents; @@ -1516,7 +1516,7 @@ struct directory * FDECL4(find_or_create_directory, struct directory *, parent, fstatbuf.st_nlink = 2; generate_rock_ridge_attributes("", (char *) pnt, de, - &fstatbuf, + &fstatbuf, &fstatbuf, 0); } iso9660_date(de->isorec.date, fstatbuf.st_mtime); @@ -1570,7 +1570,7 @@ struct directory * FDECL4(find_or_create_directory, struct directory *, parent, if(!parent || parent == root) { - if (!root) + if (!root) { root = dpnt; /* First time through for root directory only */ root->depth = 0; @@ -1581,7 +1581,7 @@ struct directory * FDECL4(find_or_create_directory, struct directory *, parent, { root->subdir = dpnt; } - else + else { next_brother = root->subdir; while(next_brother->next) next_brother = next_brother->next; @@ -1589,24 +1589,24 @@ struct directory * FDECL4(find_or_create_directory, struct directory *, parent, } dpnt->parent = parent; } - } - else + } + else { /* Come through here for normal traversal of tree */ #ifdef DEBUG fprintf(stderr,"%s(%d) ", path, dpnt->depth); #endif - if(parent->depth > RR_relocation_depth) + if(parent->depth > RR_relocation_depth) error (1, 0, _("Directories too deep %s\n"), path); - - dpnt->parent = parent; + + dpnt->parent = parent; dpnt->depth = parent->depth + 1; - + if(!parent->subdir) { parent->subdir = dpnt; } - else + else { next_brother = parent->subdir; while(next_brother->next) next_brother = next_brother->next; @@ -1670,7 +1670,7 @@ int FDECL1(sort_tree, struct directory *, node){ { break; } - + if(dpnt->subdir) sort_tree(dpnt->subdir); dpnt = dpnt->next; } @@ -1697,7 +1697,7 @@ void FDECL1(update_nlink_field, struct directory *, node) int i; dpnt = node; - + while (dpnt) { if (dpnt->dir_flags & INHIBIT_ISO9660_ENTRY) { @@ -1751,9 +1751,9 @@ void FDECL1(update_nlink_field, struct directory *, node) /* * something quick and dirty to locate a file given a path * recursively walks down path in filename until it finds the - * directory entry for the desired file + * directory entry for the desired file */ -struct directory_entry * FDECL2(search_tree_file, struct directory *, +struct directory_entry * FDECL2(search_tree_file, struct directory *, node,char *, filename) { struct directory_entry * depnt; @@ -1763,7 +1763,7 @@ struct directory_entry * FDECL2(search_tree_file, struct directory *, char * subdir; /* - * strip off next directory name from filename + * strip off next directory name from filename */ subdir = strdup(filename); @@ -1776,65 +1776,65 @@ struct directory_entry * FDECL2(search_tree_file, struct directory *, } /* - * do we need to find a subdirectory + * do we need to find a subdirectory */ - if (p1) + if (p1) { *p1 = '\0'; #ifdef DEBUG_TORITO - fprintf(stderr,"Looking for subdir called %s\n",p1); + fprintf(stderr,"Looking for subdir called %s\n",p1); #endif rest = p1+1; #ifdef DEBUG_TORITO - fprintf(stderr,"Remainder of path name is now %s\n", rest); + fprintf(stderr,"Remainder of path name is now %s\n", rest); #endif - + dpnt = node->subdir; while( dpnt ) { #ifdef DEBUG_TORITO - fprintf(stderr,"%4d %5d %s\n", dpnt->extent, dpnt->size, - dpnt->de_name); + fprintf(stderr,"%4d %5d %s\n", dpnt->extent, dpnt->size, + dpnt->de_name); #endif - if (!strcmp(subdir, dpnt->de_name)) + if (!strcmp(subdir, dpnt->de_name)) { #ifdef DEBUG_TORITO - fprintf(stderr,"Calling next level with filename = %s", rest); + fprintf(stderr,"Calling next level with filename = %s", rest); #endif return(search_tree_file( dpnt, rest )); } dpnt = dpnt->next; } - + /* if we got here means we couldnt find the subdir */ return (NULL); - } - else + } + else { - /* - * look for a normal file now + /* + * look for a normal file now */ depnt = node->contents; while (depnt) { #ifdef DEBUG_TORITO - fprintf(stderr,"%4d %5d %s\n",depnt->isorec.extent, - depnt->size, depnt->name); + fprintf(stderr,"%4d %5d %s\n",depnt->isorec.extent, + depnt->size, depnt->name); #endif - if (!strcmp(filename, depnt->name)) + if (!strcmp(filename, depnt->name)) { #ifdef DEBUG_TORITO - fprintf(stderr,"Found our file %s", filename); + fprintf(stderr,"Found our file %s", filename); #endif return(depnt); } depnt = depnt->next; } - /* - * if we got here means we couldnt find the subdir + /* + * if we got here means we couldnt find the subdir */ return (NULL); } diff --git a/util/mkisofs/write.c b/util/mkisofs/write.c index 987ca1512..69b6bb623 100644 --- a/util/mkisofs/write.c +++ b/util/mkisofs/write.c @@ -40,7 +40,7 @@ #include "mkisofs.h" #include "iso9660.h" #include "msdos_partition.h" - + #ifdef __SVR4 extern char * strdup(const char *); #endif @@ -161,7 +161,7 @@ void FDECL4(xfwrite, void *, buffer, uint64_t, count, uint64_t, size, FILE *, fi error (1, errno, _("Cannot open '%s'"), nbuf); } - while(count) + while(count) { size_t got = fwrite (buffer, size, count, file); @@ -196,7 +196,7 @@ static int FDECL1(assign_directory_addresses, struct directory *, node) struct directory * dpnt; dpnt = node; - + while (dpnt) { /* skip if it's hidden */ @@ -214,13 +214,13 @@ static int FDECL1(assign_directory_addresses, struct directory *, node) { dpnt->extent = last_extent; dir_size = (dpnt->size + (SECTOR_SIZE - 1)) >> 11; - + last_extent += dir_size; - - /* + + /* * Leave room for the CE entries for this directory. Keep them - * close to the reference directory so that access will be - * quick. + * close to the reference directory so that access will be + * quick. */ if(dpnt->ce_bytes) { @@ -228,7 +228,7 @@ static int FDECL1(assign_directory_addresses, struct directory *, node) } } - if(dpnt->subdir) + if(dpnt->subdir) { assign_directory_addresses(dpnt->subdir); } @@ -238,7 +238,7 @@ static int FDECL1(assign_directory_addresses, struct directory *, node) return 0; } -static void FDECL3(write_one_file, char *, filename, +static void FDECL3(write_one_file, char *, filename, uint64_t, size, FILE *, outfile) { char buffer[SECTOR_SIZE * NSECT]; @@ -247,7 +247,7 @@ static void FDECL3(write_one_file, char *, filename, size_t use; - if ((infile = fopen(filename, "rb")) == NULL) + if ((infile = fopen(filename, "rb")) == NULL) error (1, errno, _("cannot open %s\n"), filename); remain = size; @@ -256,12 +256,12 @@ static void FDECL3(write_one_file, char *, filename, use = (remain > SECTOR_SIZE * NSECT - 1 ? NSECT*SECTOR_SIZE : remain); use = ROUND_UP(use); /* Round up to nearest sector boundary */ memset(buffer, 0, use); - if (fread(buffer, 1, use, infile) == 0) - error (1, errno, _("cannot read %llu bytes from %s"), use, filename); + if (fread(buffer, 1, use, infile) == 0) + error (1, errno, _("cannot read %llu bytes from %s"), use, filename); xfwrite(buffer, 1, use, outfile); last_extent_written += use/SECTOR_SIZE; #if 0 - if((last_extent_written % 1000) < use/SECTOR_SIZE) + if((last_extent_written % 1000) < use/SECTOR_SIZE) { fprintf(stderr,"%d..", last_extent_written); } @@ -271,7 +271,7 @@ static void FDECL3(write_one_file, char *, filename, time_t now; time_t the_end; double frac; - + time(&now); frac = last_extent_written / (double)last_extent; the_end = begun + (now - begun) / frac; @@ -290,13 +290,13 @@ static void FDECL1(write_files, FILE *, outfile) dwpnt = dw_head; while(dwpnt) { - if(dwpnt->table) + if(dwpnt->table) { write_one_file (dwpnt->table, dwpnt->size, outfile); table_size += dwpnt->size; free (dwpnt->table); } - else + else { #ifdef VMS @@ -327,11 +327,11 @@ static void dump_filelist() } #endif -static int FDECL2(compare_dirs, const void *, rr, const void *, ll) +static int FDECL2(compare_dirs, const void *, rr, const void *, ll) { char * rpnt, *lpnt; struct directory_entry ** r, **l; - + r = (struct directory_entry **) rr; l = (struct directory_entry **) ll; rpnt = (*r)->isorec.name; @@ -344,7 +344,7 @@ static int FDECL2(compare_dirs, const void *, rr, const void *, ll) { sort_goof++; } - + /* * Put the '.' and '..' entries on the head of the sorted list. * For normal ASCII, this always happens to be the case, but out of @@ -376,16 +376,16 @@ static int FDECL2(compare_dirs, const void *, rr, const void *, ll) if((*l)->isorec.name_len[0] == 1 && *lpnt == 1) return 1; #endif - while(*rpnt && *lpnt) + while(*rpnt && *lpnt) { if(*rpnt == ';' && *lpnt != ';') return -1; if(*rpnt != ';' && *lpnt == ';') return 1; - + if(*rpnt == ';' && *lpnt == ';') return 0; - + if(*rpnt == '.' && *lpnt != '.') return -1; if(*rpnt != '.' && *lpnt == '.') return 1; - + if((unsigned char)*rpnt < (unsigned char)*lpnt) return -1; if((unsigned char)*rpnt > (unsigned char)*lpnt) return 1; rpnt++; lpnt++; @@ -395,7 +395,7 @@ static int FDECL2(compare_dirs, const void *, rr, const void *, ll) return 0; } -/* +/* * Function: sort_directory * * Purpose: Sort the directory in the appropriate ISO9660 @@ -411,7 +411,7 @@ int FDECL1(sort_directory, struct directory_entry **, sort_dir) int i, len; struct directory_entry * s_entry; struct directory_entry ** sortlist; - + /* need to keep a count of how many entries are hidden */ s_entry = *sort_dir; while(s_entry) @@ -428,9 +428,9 @@ int FDECL1(sort_directory, struct directory_entry **, sort_dir) } /* - * OK, now we know how many there are. Build a vector for sorting. + * OK, now we know how many there are. Build a vector for sorting. */ - sortlist = (struct directory_entry **) + sortlist = (struct directory_entry **) e_malloc(sizeof(struct directory_entry *) * dcount); j = dcount - 1; @@ -452,29 +452,29 @@ int FDECL1(sort_directory, struct directory_entry **, sort_dir) s_entry->isorec.name[len] = 0; s_entry = s_entry->next; } - + /* * Each directory is required to contain at least . and .. */ if( dcount < 2 ) { sort_goof = 1; - + } else { /* only sort the non-hidden entries */ sort_goof = 0; #ifdef __STDC__ - qsort(sortlist, dcount, sizeof(struct directory_entry *), + qsort(sortlist, dcount, sizeof(struct directory_entry *), (int (*)(const void *, const void *))compare_dirs); #else - qsort(sortlist, dcount, sizeof(struct directory_entry *), + qsort(sortlist, dcount, sizeof(struct directory_entry *), compare_dirs); #endif - - /* - * Now reassemble the linked list in the proper sorted order + + /* + * Now reassemble the linked list in the proper sorted order * We still need the hidden entries, as they may be used in the * Joliet tree. */ @@ -482,7 +482,7 @@ int FDECL1(sort_directory, struct directory_entry **, sort_dir) { sortlist[i]->next = sortlist[i+1]; } - + sortlist[dcount+xcount-1]->next = NULL; *sort_dir = sortlist[0]; } @@ -494,7 +494,7 @@ int FDECL1(sort_directory, struct directory_entry **, sort_dir) static int root_gen() { init_fstatbuf(); - + root_record.length[0] = 1 + sizeof(struct iso_directory_record) - sizeof(root_record.name); root_record.ext_attr_length[0] = 0; @@ -533,16 +533,16 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt) { continue; } - - /* - * This saves some space if there are symlinks present + + /* + * This saves some space if there are symlinks present */ s_hash = find_hash(s_entry->dev, s_entry->inode); if(s_hash) { if(verbose > 2) { - fprintf (stderr, _("Cache hit for %s%s%s\n"), s_entry->filedir->de_name, + fprintf (stderr, _("Cache hit for %s%s%s\n"), s_entry->filedir->de_name, SPATH_SEPARATOR, s_entry->name); } set_733((char *) s_entry->isorec.extent, s_hash->starting_block); @@ -551,12 +551,12 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt) } /* - * If this is for a directory that is not a . or a .. entry, + * If this is for a directory that is not a . or a .. entry, * then look up the information for the entry. We have already * assigned extents for directories, so we just need to * fill in the blanks here. */ - if (strcmp(s_entry->name,".") && strcmp(s_entry->name,"..") && + if (strcmp(s_entry->name,".") && strcmp(s_entry->name,"..") && s_entry->isorec.flags[0] == 2) { finddir = dpnt->subdir; @@ -564,7 +564,7 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt) { if(finddir->self == s_entry) break; finddir = finddir->next; - if (!finddir) + if (!finddir) error (1, 0, _("Fatal goof\n")); } set_733((char *) s_entry->isorec.extent, finddir->extent); @@ -581,45 +581,45 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt) * If this is . or .., then look up the relevant info from the * tables. */ - if(strcmp(s_entry->name,".") == 0) + if(strcmp(s_entry->name,".") == 0) { set_733((char *) s_entry->isorec.extent, dpnt->extent); - - /* + + /* * Set these so that the hash table has the * correct information */ s_entry->starting_block = dpnt->extent; s_entry->size = ROUND_UP(dpnt->size); - + add_hash(s_entry); s_entry->starting_block = dpnt->extent; set_733((char *) s_entry->isorec.size, ROUND_UP(dpnt->size)); continue; } - if(strcmp(s_entry->name,"..") == 0) + if(strcmp(s_entry->name,"..") == 0) { if(dpnt == root) - { + { total_dir_size += root->size; } set_733((char *) s_entry->isorec.extent, dpnt->parent->extent); - - /* + + /* * Set these so that the hash table has the * correct information */ s_entry->starting_block = dpnt->parent->extent; s_entry->size = ROUND_UP(dpnt->parent->size); - + add_hash(s_entry); s_entry->starting_block = dpnt->parent->extent; set_733((char *) s_entry->isorec.size, ROUND_UP(dpnt->parent->size)); continue; } - /* + /* * Some ordinary non-directory file. Just schedule the * file to be written. This is all quite * straightforward, just make a list and assign extents @@ -627,28 +627,28 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt) * directories, we should be ready write out these * files */ - if(s_entry->size) + if(s_entry->size) { - dwpnt = (struct deferred_write *) + dwpnt = (struct deferred_write *) e_malloc(sizeof(struct deferred_write)); if(dw_tail) { dw_tail->next = dwpnt; dw_tail = dwpnt; - } - else + } + else { dw_head = dwpnt; dw_tail = dwpnt; } - if(s_entry->inode == TABLE_INODE) + if(s_entry->inode == TABLE_INODE) { dwpnt->table = s_entry->table; dwpnt->name = NULL; sprintf(whole_path,"%s%sTRANS.TBL", s_entry->filedir->whole_name, SPATH_SEPARATOR); - } - else + } + else { dwpnt->table = NULL; strcpy(whole_path, s_entry->whole_name); @@ -672,15 +672,15 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt) fprintf (stderr, "Warning: large file %s\n", whole_path); fprintf (stderr, "Starting block is %d\n", s_entry->starting_block); fprintf (stderr, "Reported file size is %d extents\n", s_entry->size); - + } #endif #ifdef NOT_NEEDED /* Never use this code if you like to create a DVD */ - if(last_extent > (800000000 >> 11)) - { + if(last_extent > (800000000 >> 11)) + { /* - * More than 800Mb? Punt + * More than 800Mb? Punt */ fprintf(stderr,"Extent overflow processing file %s\n", whole_path); fprintf(stderr,"Starting block is %d\n", s_entry->starting_block); @@ -699,7 +699,7 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt) */ set_733((char *) s_entry->isorec.extent, last_extent); } - if(dpnt->subdir) + if(dpnt->subdir) { assign_file_addresses(dpnt->subdir); } @@ -711,13 +711,13 @@ static void FDECL1(free_one_directory, struct directory *, dpnt) { struct directory_entry * s_entry; struct directory_entry * s_entry_d; - + s_entry = dpnt->contents; - while(s_entry) + while(s_entry) { s_entry_d = s_entry; s_entry = s_entry->next; - + if( s_entry_d->name != NULL ) { free (s_entry_d->name); @@ -753,31 +753,31 @@ void FDECL2(generate_one_directory, struct directory *, dpnt, FILE *, outfile) struct directory_entry * s_entry; struct directory_entry * s_entry_d; unsigned int total_size; - + total_size = (dpnt->size + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1); directory_buffer = (char *) e_malloc(total_size); memset(directory_buffer, 0, total_size); dir_index = 0; - + ce_size = (dpnt->ce_bytes + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1); ce_buffer = NULL; - - if(ce_size) + + if(ce_size) { ce_buffer = (char *) e_malloc(ce_size); memset(ce_buffer, 0, ce_size); - + ce_index = 0; - + /* - * Absolute byte address of CE entries for this directory + * Absolute byte address of CE entries for this directory */ ce_address = last_extent_written + (total_size >> 11); ce_address = ce_address << 11; } - + s_entry = dpnt->contents; - while(s_entry) + while(s_entry) { /* skip if it's hidden */ if(s_entry->de_flags & INHIBIT_ISO9660_ENTRY) { @@ -785,25 +785,25 @@ void FDECL2(generate_one_directory, struct directory *, dpnt, FILE *, outfile) continue; } - /* - * We do not allow directory entries to cross sector boundaries. - * Simply pad, and then start the next entry at the next sector + /* + * We do not allow directory entries to cross sector boundaries. + * Simply pad, and then start the next entry at the next sector */ new_reclen = s_entry->isorec.length[0]; if( (dir_index & (SECTOR_SIZE - 1)) + new_reclen >= SECTOR_SIZE ) { - dir_index = (dir_index + (SECTOR_SIZE - 1)) & + dir_index = (dir_index + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1); } - memcpy(directory_buffer + dir_index, &s_entry->isorec, + memcpy(directory_buffer + dir_index, &s_entry->isorec, sizeof(struct iso_directory_record) - sizeof(s_entry->isorec.name) + s_entry->isorec.name_len[0]); - dir_index += sizeof(struct iso_directory_record) - + dir_index += sizeof(struct iso_directory_record) - sizeof (s_entry->isorec.name)+ s_entry->isorec.name_len[0]; /* - * Add the Rock Ridge attributes, if present + * Add the Rock Ridge attributes, if present */ if(s_entry->rr_attr_size) { @@ -812,20 +812,20 @@ void FDECL2(generate_one_directory, struct directory *, dpnt, FILE *, outfile) directory_buffer[dir_index++] = 0; } - /* + /* * If the RR attributes were too long, then write the * CE records, as required. */ - if(s_entry->rr_attr_size != s_entry->total_rr_attr_size) + if(s_entry->rr_attr_size != s_entry->total_rr_attr_size) { unsigned char * pnt; int len, nbytes; - - /* + + /* * Go through the entire record and fix up the CE entries - * so that the extent and offset are correct + * so that the extent and offset are correct */ - + pnt = s_entry->rr_attributes; len = s_entry->total_rr_attr_size; while(len > 3) @@ -837,30 +837,30 @@ void FDECL2(generate_one_directory, struct directory *, dpnt, FILE *, outfile) ce_index, ce_address); } #endif - - if(pnt[0] == 'C' && pnt[1] == 'E') + + if(pnt[0] == 'C' && pnt[1] == 'E') { nbytes = get_733( (char *) pnt+20); - + if((ce_index & (SECTOR_SIZE - 1)) + nbytes >= - SECTOR_SIZE) + SECTOR_SIZE) { ce_index = ROUND_UP(ce_index); } - - set_733( (char *) pnt+4, + + set_733( (char *) pnt+4, (ce_address + ce_index) >> 11); - set_733( (char *) pnt+12, + set_733( (char *) pnt+12, (ce_address + ce_index) & (SECTOR_SIZE - 1)); - - - /* - * Now store the block in the ce buffer + + + /* + * Now store the block in the ce buffer */ - memcpy(ce_buffer + ce_index, + memcpy(ce_buffer + ce_index, pnt + pnt[2], nbytes); ce_index += nbytes; - if(ce_index & 1) + if(ce_index & 1) { ce_index++; } @@ -868,11 +868,11 @@ void FDECL2(generate_one_directory, struct directory *, dpnt, FILE *, outfile) len -= pnt[2]; pnt += pnt[2]; } - + } rockridge_size += s_entry->total_rr_attr_size; - memcpy(directory_buffer + dir_index, s_entry->rr_attributes, + memcpy(directory_buffer + dir_index, s_entry->rr_attributes, s_entry->rr_attr_size); dir_index += s_entry->rr_attr_size; } @@ -880,14 +880,14 @@ void FDECL2(generate_one_directory, struct directory *, dpnt, FILE *, outfile) { directory_buffer[dir_index++] = 0; } - + s_entry_d = s_entry; s_entry = s_entry->next; - + /* * Joliet doesn't use the Rock Ridge attributes, so we free it here. */ - if (s_entry_d->rr_attributes) + if (s_entry_d->rr_attributes) { free(s_entry_d->rr_attributes); s_entry_d->rr_attributes = NULL; @@ -915,16 +915,16 @@ void FDECL2(generate_one_directory, struct directory *, dpnt, FILE *, outfile) last_extent_written += ce_size >> 11; free(ce_buffer); } - + } /* generate_one_directory(... */ -static +static void FDECL1(build_pathlist, struct directory *, node) { struct directory * dpnt; - + dpnt = node; - + while (dpnt) { /* skip if it's hidden */ @@ -936,7 +936,7 @@ void FDECL1(build_pathlist, struct directory *, node) } } /* build_pathlist(... */ -static int FDECL2(compare_paths, void const *, r, void const *, l) +static int FDECL2(compare_paths, void const *, r, void const *, l) { struct directory const *ll = *(struct directory * const *)l; struct directory const *rr = *(struct directory * const *)r; @@ -946,13 +946,13 @@ static int FDECL2(compare_paths, void const *, r, void const *, l) return -1; } - if (rr->parent->path_index > ll->parent->path_index) + if (rr->parent->path_index > ll->parent->path_index) { return 1; } return strcmp(rr->self->isorec.name, ll->self->isorec.name); - + } /* compare_paths(... */ static int generate_path_tables() @@ -968,7 +968,7 @@ static int generate_path_tables() int tablesize; /* - * First allocate memory for the tables and initialize the memory + * First allocate memory for the tables and initialize the memory */ tablesize = path_blocks << 11; path_table_m = (char *) e_malloc(tablesize); @@ -977,7 +977,7 @@ static int generate_path_tables() memset(path_table_m, 0, tablesize); /* - * Now start filling in the path tables. Start with root directory + * Now start filling in the path tables. Start with root directory */ if( next_path_index > 0xffff ) { @@ -986,7 +986,7 @@ static int generate_path_tables() } path_table_index = 0; - pathlist = (struct directory **) e_malloc(sizeof(struct directory *) + pathlist = (struct directory **) e_malloc(sizeof(struct directory *) * next_path_index); memset(pathlist, 0, sizeof(struct directory *) * next_path_index); build_pathlist(root); @@ -995,10 +995,10 @@ static int generate_path_tables() { fix = 0; #ifdef __STDC__ - qsort(&pathlist[1], next_path_index-1, sizeof(struct directory *), + qsort(&pathlist[1], next_path_index-1, sizeof(struct directory *), (int (*)(const void *, const void *))compare_paths); #else - qsort(&pathlist[1], next_path_index-1, sizeof(struct directory *), + qsort(&pathlist[1], next_path_index-1, sizeof(struct directory *), compare_paths); #endif @@ -1020,55 +1020,55 @@ static int generate_path_tables() error (1, 0, _("Entry %d not in path tables\n"), j); } npnt = dpnt->de_name; - - /* - * So the root comes out OK + + /* + * So the root comes out OK */ - if( (*npnt == 0) || (dpnt == root) ) + if( (*npnt == 0) || (dpnt == root) ) { - npnt = "."; + npnt = "."; } npnt1 = strrchr(npnt, PATH_SEPARATOR); - if(npnt1) - { + if(npnt1) + { npnt = npnt1 + 1; } - + de = dpnt->self; - if(!de) + if(!de) { error (1, 0, _("Fatal goof\n")); } - - + + namelen = de->isorec.name_len[0]; - + path_table_l[path_table_index] = namelen; path_table_m[path_table_index] = namelen; path_table_index += 2; - - set_731(path_table_l + path_table_index, dpnt->extent); - set_732(path_table_m + path_table_index, dpnt->extent); + + set_731(path_table_l + path_table_index, dpnt->extent); + set_732(path_table_m + path_table_index, dpnt->extent); path_table_index += 4; - - set_721(path_table_l + path_table_index, - dpnt->parent->path_index); - set_722(path_table_m + path_table_index, - dpnt->parent->path_index); + + set_721(path_table_l + path_table_index, + dpnt->parent->path_index); + set_722(path_table_m + path_table_index, + dpnt->parent->path_index); path_table_index += 2; - + for(i =0; iisorec.name[i]; path_table_m[path_table_index] = de->isorec.name[i]; path_table_index++; } - if(path_table_index & 1) + if(path_table_index & 1) { path_table_index++; /* For odd lengths we pad */ } } - + free(pathlist); if(path_table_index != path_table_size) { @@ -1111,7 +1111,7 @@ static int FDECL1(file_write, FILE *, outfile) /* * OK, all done with that crap. Now write out the directories. * This is where the fur starts to fly, because we need to keep track of - * each file as we find it and keep track of where we put it. + * each file as we find it and keep track of where we put it. */ should_write = last_extent - session_start; @@ -1127,16 +1127,16 @@ static int FDECL1(file_write, FILE *, outfile) #ifdef DBG_ISO fprintf(stderr,"Total directory extents being written = %llu\n", last_extent); #endif - - fprintf (stderr, _("Total extents scheduled to be written = %llu\n"), + + fprintf (stderr, _("Total extents scheduled to be written = %llu\n"), last_extent - session_start); } - /* - * Now write all of the files that we need. + /* + * Now write all of the files that we need. */ write_files(outfile); - + /* * The rest is just fluff. */ @@ -1148,8 +1148,8 @@ static int FDECL1(file_write, FILE *, outfile) fprintf (stderr, _("Total extents actually written = %llu\n"), last_extent_written - session_start); - /* - * Hard links throw us off here + /* + * Hard links throw us off here */ assert (last_extent > session_start); if(should_write + session_start != last_extent) @@ -1195,7 +1195,7 @@ static int FDECL1(pvd_write, FILE *, outfile) /* * This will break in the year 2000, I supose, but there is no good way - * to get the top two digits of the year. + * to get the top two digits of the year. */ sprintf(iso_time, "%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d00", 1900 + local.tm_year, local.tm_mon+1, local.tm_mday, @@ -1207,28 +1207,28 @@ static int FDECL1(pvd_write, FILE *, outfile) iso_time[16] = (local.tm_min + 60*(local.tm_hour + 24*local.tm_yday)) / 15; /* - * Next we write out the primary descriptor for the disc + * Next we write out the primary descriptor for the disc */ memset(&vol_desc, 0, sizeof(vol_desc)); vol_desc.type[0] = ISO_VD_PRIMARY; memcpy(vol_desc.id, ISO_STANDARD_ID, sizeof(ISO_STANDARD_ID)); vol_desc.version[0] = 1; - + memset(vol_desc.system_id, ' ', sizeof(vol_desc.system_id)); memcpy_max(vol_desc.system_id, system_id, strlen(system_id)); - + memset(vol_desc.volume_id, ' ', sizeof(vol_desc.volume_id)); memcpy_max(vol_desc.volume_id, volume_id, strlen(volume_id)); - + should_write = last_extent - session_start; set_733((char *) vol_desc.volume_space_size, should_write); set_723(vol_desc.volume_set_size, volume_set_size); set_723(vol_desc.volume_sequence_number, volume_sequence_number); set_723(vol_desc.logical_block_size, 2048); - + /* * The path tables are used by DOS based machines to cache directory - * locations + * locations */ set_733((char *) vol_desc.path_table_size, path_table_size); @@ -1238,9 +1238,9 @@ static int FDECL1(pvd_write, FILE *, outfile) set_732(vol_desc.opt_type_m_path_table, path_table[3]); /* - * Now we copy the actual root directory record + * Now we copy the actual root directory record */ - memcpy(vol_desc.root_directory_record, &root_record, + memcpy(vol_desc.root_directory_record, &root_record, sizeof(struct iso_directory_record) + 1); /* @@ -1260,15 +1260,15 @@ static int FDECL1(pvd_write, FILE *, outfile) if(appid) memcpy_max(vol_desc.application_id, appid, strlen(appid)); FILL_SPACE(copyright_file_id); - if(copyright) memcpy_max(vol_desc.copyright_file_id, copyright, + if(copyright) memcpy_max(vol_desc.copyright_file_id, copyright, strlen(copyright)); FILL_SPACE(abstract_file_id); - if(abstract) memcpy_max(vol_desc.abstract_file_id, abstract, + if(abstract) memcpy_max(vol_desc.abstract_file_id, abstract, strlen(abstract)); FILL_SPACE(bibliographic_file_id); - if(biblio) memcpy_max(vol_desc.bibliographic_file_id, biblio, + if(biblio) memcpy_max(vol_desc.bibliographic_file_id, biblio, strlen(biblio)); FILL_SPACE(creation_date); @@ -1284,7 +1284,7 @@ static int FDECL1(pvd_write, FILE *, outfile) memcpy(vol_desc.effective_date, effective_date ? effective_date : iso_time, 17); /* - * if not a bootable cd do it the old way + * if not a bootable cd do it the old way */ xfwrite(&vol_desc, 1, 2048, outfile); last_extent_written++; @@ -1299,7 +1299,7 @@ static int FDECL1(evd_write, FILE *, outfile) struct iso_primary_descriptor evol_desc; /* - * Now write the end volume descriptor. Much simpler than the other one + * Now write the end volume descriptor. Much simpler than the other one */ memset(&evol_desc, 0, sizeof(evol_desc)); evol_desc.type[0] = ISO_VD_END; @@ -1316,7 +1316,7 @@ static int FDECL1(evd_write, FILE *, outfile) static int FDECL1(pathtab_write, FILE *, outfile) { /* - * Next we write the path tables + * Next we write the path tables */ xfwrite(path_table_l, 1, path_blocks << 11, outfile); xfwrite(path_table_m, 1, path_blocks << 11, outfile); diff --git a/video/efi_gop.c b/video/efi_gop.c index 9e019ad53..0cae91e7b 100644 --- a/video/efi_gop.c +++ b/video/efi_gop.c @@ -93,7 +93,7 @@ grub_video_gop_get_bpp (struct grub_efi_gop_mode_info *in) total_mask = in->pixel_bitmask.r | in->pixel_bitmask.g | in->pixel_bitmask.b | in->pixel_bitmask.a; - + for (i = 31; i >= 0; i--) if (total_mask & (1 << i)) return i + 1; @@ -212,7 +212,7 @@ grub_video_gop_setup (unsigned int width, unsigned int height, found = 1; } } - + if (!found) { unsigned mode; @@ -221,7 +221,7 @@ grub_video_gop_setup (unsigned int width, unsigned int height, { grub_efi_uintn_t size; grub_efi_status_t status; - + status = efi_call_4 (gop->query_mode, gop, mode, &size, &info); if (status) { @@ -255,7 +255,7 @@ grub_video_gop_setup (unsigned int width, unsigned int height, * ((unsigned long long) bpp)) { best_volume = ((unsigned long long) info->width) - * ((unsigned long long) info->height) + * ((unsigned long long) info->height) * ((unsigned long long) bpp); best_mode = mode; } @@ -293,8 +293,8 @@ grub_video_gop_setup (unsigned int width, unsigned int height, grub_dprintf ("video", "GOP: initialising FB @ %p %dx%dx%d\n", framebuffer.ptr, framebuffer.mode_info.width, framebuffer.mode_info.height, framebuffer.mode_info.bpp); - - err = grub_video_fb_create_render_target_from_pointer + + err = grub_video_fb_create_render_target_from_pointer (&framebuffer.render_target, &framebuffer.mode_info, framebuffer.ptr); if (err) @@ -302,15 +302,15 @@ grub_video_gop_setup (unsigned int width, unsigned int height, grub_dprintf ("video", "GOP: Couldn't create FB target\n"); return err; } - + err = grub_video_fb_set_active_render_target (framebuffer.render_target); - + if (err) { grub_dprintf ("video", "GOP: Couldn't set FB target\n"); return err; } - + err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS, grub_video_fbstd_colors); @@ -318,7 +318,7 @@ grub_video_gop_setup (unsigned int width, unsigned int height, grub_dprintf ("video", "GOP: Couldn't set palette\n"); else grub_dprintf ("video", "GOP: Success\n"); - + return err; } From 0eb11149c98134432021ef067c0b4e64dcb91984 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Dec 2009 19:58:33 +0100 Subject: [PATCH 059/208] eliminate dead code and data in des.c --- util/import_gcry.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/util/import_gcry.py b/util/import_gcry.py index 93bf5982f..d71924d53 100644 --- a/util/import_gcry.py +++ b/util/import_gcry.py @@ -101,6 +101,7 @@ for cipher_file in cipher_files: iscryptostart = False iscomma = False isglue = False + skip_statement = False if isc: modname = cipher_file [0:len(cipher_file) - 2] if re.match (".*-glue$", modname): @@ -108,6 +109,10 @@ for cipher_file in cipher_files: isglue = True modname = "gcry_%s" % modname for line in f: + if skip_statement: + if not re.search (";", line) is None: + skip_statement = False + continue if skip: if line[0] == "}": skip = False @@ -132,10 +137,22 @@ for cipher_file in cipher_files: fw.write (" .blocksize = %s\n" % mdblocksizes [mdname]) ismd = False iscomma = not re.search (",$", line) is None + # Used only for selftests. + m = re.match ("(static byte|static unsigned char) (weak_keys_chksum)\[[0-9]*\] =", line) + if not m is None: + skip = True + fname = m.groups ()[1] + chmsg = "(%s): Removed." % fname + if nch: + chlognew = "%s\n %s" % (chlognew, chmsg) + else: + chlognew = "%s %s" % (chlognew, chmsg) + nch = True + continue if hold: hold = False # We're optimising for size. - if not re.match ("(run_selftests|selftest|_gcry_aes_c.._..c|_gcry_[a-z0-9]*_hash_buffer)", line) is None: + if not re.match ("(run_selftests|selftest|_gcry_aes_c.._..c|_gcry_[a-z0-9]*_hash_buffer|tripledes_set2keys|do_tripledes_set_extra_info)", line) is None: skip = True fname = re.match ("[a-zA-Z0-9_]*", line).group () chmsg = "(%s): Removed." % fname @@ -184,11 +201,18 @@ for cipher_file in cipher_files: chlognew = "%s %s" % (chlognew, chmsg) nch = True continue - m = re.match ("(static const char( |)\*|static gpg_err_code_t|void)$", line) + m = re.match ("(static const char( |)\*|static gpg_err_code_t|void|static int|static gcry_err_code_t)$", line) if not m is None: hold = True holdline = line continue + m = re.match ("static int tripledes_set2keys \(.*\);", line) + if not m is None: + continue + m = re.match ("static int tripledes_set2keys \(", line) + if not m is None: + skip_statement = True + continue m = re.match ("cipher_extra_spec_t", line) if isc and not m is None: skip2 = True From a7a095c71ae9362e13bb0f38998fabd1398bba4d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Dec 2009 20:31:12 +0100 Subject: [PATCH 060/208] hashsum support --- commands/hashsum.c | 278 +++++++++++++++++++++++++++++++++++++++++++++ conf/common.rmk | 5 + 2 files changed, 283 insertions(+) create mode 100644 commands/hashsum.c diff --git a/commands/hashsum.c b/commands/hashsum.c new file mode 100644 index 000000000..60e17447b --- /dev/null +++ b/commands/hashsum.c @@ -0,0 +1,278 @@ +/* + * 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 +#include + +static const struct grub_arg_option options[] = { + {"hash", 'h', 0, "Specify hash to use.", "HASH", ARG_TYPE_STRING}, + {"check", 'c', 0, "Check hash list file.", "FILE", ARG_TYPE_STRING}, + {"prefix", 'p', 0, "Base directory for hash list.", "DIRECTORY", + ARG_TYPE_STRING}, + {"keep-going", 'k', 0, "Don't stop after first error.", 0, 0}, + {0, 0, 0, 0, 0, 0} +}; + +struct { const char *name; const char *hashname; } aliases[] = + { + {"sha256sum", "sha256"}, + {"sha512sum", "sha512"}, + {"md5sum", "md5"}, + }; + +static inline int +hextoval (char c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + return -1; +} + +static grub_err_t +hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result) +{ + grub_uint8_t context[hash->contextsize]; + char *readbuf[4096]; + + grub_memset (context, 0, sizeof (context)); + hash->init (context); + while (1) + { + grub_ssize_t r; + r = grub_file_read (file, readbuf, sizeof (readbuf)); + if (r < 0) + return grub_errno; + if (r == 0) + break; + hash->write (context, readbuf, r); + } + hash->final (context); + grub_memcpy (result, hash->read (context), hash->mdlen); + + return GRUB_ERR_NONE; +} + +static grub_err_t +check_list (const gcry_md_spec_t *hash, const char *hashfilename, + const char *prefix, int keep) +{ + grub_file_t hashlist, file; + char *buf = NULL; + grub_uint8_t expected[hash->mdlen]; + grub_uint8_t actual[hash->mdlen]; + grub_err_t err; + unsigned i; + unsigned unread = 0, mismatch = 0; + + hashlist = grub_file_open (hashfilename); + if (!hashlist) + return grub_errno; + + while (grub_free (buf), (buf = grub_file_getline (hashlist))) + { + const char *p = buf; + for (i = 0; i < hash->mdlen; i++) + { + int high, low; + high = hextoval (*p++); + low = hextoval (*p++); + if (high < 0 || low < 0) + return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list"); + expected[i] = (high << 4) | low; + } + if (*p++ != ' ' || *p++ != ' ') + return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list"); + if (prefix) + { + char *filename; + + filename = grub_malloc (grub_strlen (prefix) + + grub_strlen (p) + 2); + if (!filename) + return grub_errno; + grub_sprintf (filename, "%s/%s", prefix, p); + file = grub_file_open (filename); + grub_free (filename); + } + else + file = grub_file_open (p); + if (!file) + { + grub_file_close (hashlist); + grub_free (buf); + return grub_errno; + } + err = hash_file (file, hash, actual); + grub_file_close (file); + if (err) + { + grub_printf ("%s: READ ERROR\n", p); + if (!keep) + { + grub_file_close (hashlist); + grub_free (buf); + return err; + } + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + unread++; + continue; + } + if (grub_crypto_memcmp (expected, actual, hash->mdlen) != 0) + { + grub_printf ("%s: HASH MISMATCH\n", p); + if (!keep) + { + grub_file_close (hashlist); + grub_free (buf); + return grub_error (GRUB_ERR_TEST_FAILURE, + "hash of '%s' mismatches", p); + } + mismatch++; + continue; + } + grub_printf ("%s: OK\n", p); + } + if (mismatch || unread) + return grub_error (GRUB_ERR_TEST_FAILURE, + "%d files couldn't be read and hash " + "of %d files mismatches", unread, mismatch); + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_cmd_hashsum (struct grub_extcmd *cmd, + int argc, char **args) +{ + struct grub_arg_list *state = cmd->state; + const char *hashname = NULL; + const char *prefix = NULL; + const gcry_md_spec_t *hash; + unsigned i; + int keep = state[3].set; + unsigned unread = 0; + + for (i = 0; i < ARRAY_SIZE (aliases); i++) + if (grub_strcmp (cmd->cmd->name, aliases[i].name) == 0) + hashname = aliases[i].hashname; + if (state[0].set) + hashname = state[0].arg; + + if (!hashname) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "no hash specified"); + + hash = grub_crypto_lookup_md_by_name (hashname); + if (!hash) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown hash"); + + if (state[2].set) + prefix = state[2].arg; + + if (state[1].set) + { + if (argc != 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "--check is incompatible with file list"); + return check_list (hash, state[1].arg, prefix, keep); + } + + for (i = 0; i < (unsigned) argc; i++) + { + grub_uint8_t result[hash->mdlen]; + grub_file_t file; + grub_err_t err; + unsigned j; + file = grub_file_open (args[i]); + if (!file) + { + if (!keep) + return grub_errno; + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + unread++; + continue; + } + err = hash_file (file, hash, result); + grub_file_close (file); + if (err) + { + if (!keep) + return err; + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + unread++; + continue; + } + for (j = 0; j < hash->mdlen; j++) + grub_printf ("%02x", result[j]); + grub_printf (" %s\n", args[i]); + } + + if (unread) + return grub_error (GRUB_ERR_TEST_FAILURE, "%d files couldn't be read.", + unread); + return GRUB_ERR_NONE; +} + +static grub_extcmd_t cmd, cmd_md5, cmd_sha256, cmd_sha512; + +GRUB_MOD_INIT(hashsum) +{ + cmd = grub_register_extcmd ("hashsum", grub_cmd_hashsum, + GRUB_COMMAND_FLAG_BOTH, + "hashsum -h HASH [-c FILE [-p PREFIX]] " + "[FILE1 [FILE2 ...]]", + "Compute or check hash checksum.", + options); + cmd_md5 = grub_register_extcmd ("md5sum", grub_cmd_hashsum, + GRUB_COMMAND_FLAG_BOTH, + "md5sum [-c FILE [-p PREFIX]] " + "[FILE1 [FILE2 ...]]", + "Compute or check hash checksum.", + options); + cmd_sha256 = grub_register_extcmd ("sha256sum", grub_cmd_hashsum, + GRUB_COMMAND_FLAG_BOTH, + "sha256sum [-c FILE [-p PREFIX]] " + "[FILE1 [FILE2 ...]]", + "Compute or check hash checksum.", + options); + cmd_sha512 = grub_register_extcmd ("sha512sum", grub_cmd_hashsum, + GRUB_COMMAND_FLAG_BOTH, + "sha512sum [-c FILE [-p PREFIX]] " + "[FILE1 [FILE2 ...]]", + "Compute or check hash checksum.", + options); +} + +GRUB_MOD_FINI(hashsum) +{ + grub_unregister_extcmd (cmd); + grub_unregister_extcmd (cmd_md5); + grub_unregister_extcmd (cmd_sha256); + grub_unregister_extcmd (cmd_sha512); +} diff --git a/conf/common.rmk b/conf/common.rmk index 64be988b9..271384d53 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -649,6 +649,11 @@ crypto_mod_SOURCES = lib/crypto.c crypto_mod_CFLAGS = $(COMMON_CFLAGS) crypto_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += hashsum.mod +hashsum_mod_SOURCES = commands/hashsum.c +hashsum_mod_CFLAGS = $(COMMON_CFLAGS) +hashsum_mod_LDFLAGS = $(COMMON_LDFLAGS) + pkglib_MODULES += pbkdf2.mod pbkdf2_mod_SOURCES = lib/pbkdf2.c pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS) From f4c623e170d42b4f55172d52426251ef55c1ee66 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Dec 2009 00:37:11 +0100 Subject: [PATCH 061/208] Work on multi-out terminal --- commands/help.c | 26 ++- commands/sleep.c | 9 +- conf/any-emu.rmk | 2 +- conf/common.rmk | 2 +- include/grub/charset.h | 3 + include/grub/normal.h | 7 +- include/grub/parser.h | 1 + include/grub/reader.h | 52 +---- include/grub/term.h | 52 ++--- kern/main.c | 3 +- kern/misc.c | 13 +- kern/reader.c | 25 --- kern/rescue_reader.c | 36 ++-- kern/term.c | 209 +++++++----------- lib/charset.c | 64 ++++++ loader/i386/linux.c | 5 +- normal/cmdline.c | 477 +++++++++++++++++++++++------------------ normal/color.c | 47 ++-- normal/main.c | 112 ++++++---- normal/term.c | 128 +++++++++++ term/i386/pc/console.c | 4 - 21 files changed, 707 insertions(+), 570 deletions(-) create mode 100644 normal/term.c diff --git a/commands/help.c b/commands/help.c index c18ec6b83..4d16945af 100644 --- a/commands/help.c +++ b/commands/help.c @@ -37,18 +37,28 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) && (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE)) { - char description[GRUB_TERM_WIDTH / 2]; + struct grub_term_output *cur; int desclen = grub_strlen (cmd->summary); + for (cur = grub_term_outputs; cur; cur = cur->next) + { + if (!(cur->flags & GRUB_TERM_ACTIVE)) + continue; + int width = grub_term_width(cur); + char description[width / 2]; /* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled with the description followed by spaces. */ - grub_memset (description, ' ', GRUB_TERM_WIDTH / 2 - 1); - description[GRUB_TERM_WIDTH / 2 - 1] = '\0'; - grub_memcpy (description, cmd->summary, - (desclen < GRUB_TERM_WIDTH / 2 - 1 - ? desclen : GRUB_TERM_WIDTH / 2 - 1)); - - grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " "); + grub_memset (description, ' ', width / 2 - 1); + description[width / 2 - 1] = '\0'; + grub_memcpy (description, cmd->summary, + (desclen < width / 2 - 1 + ? desclen : width / 2 - 1)); + grub_puts_terminal (description, cur); + } + if ((cnt++) % 2) + grub_printf ("\n"); + else + grub_printf (" "); } return 0; } diff --git a/commands/sleep.c b/commands/sleep.c index 9207b60a7..aea7f2690 100644 --- a/commands/sleep.c +++ b/commands/sleep.c @@ -32,12 +32,12 @@ static const struct grub_arg_option options[] = {0, 0, 0, 0, 0, 0} }; -static grub_uint8_t x, y; +static grub_uint16_t *pos; static void do_print (int n) { - grub_gotoxy (x, y); + grub_term_restore_pos (pos); /* NOTE: Do not remove the trailing space characters. They are required to clear the line. */ grub_printf ("%d ", n); @@ -63,7 +63,6 @@ static grub_err_t grub_cmd_sleep (grub_extcmd_t cmd, int argc, char **args) { struct grub_arg_list *state = cmd->state; - grub_uint16_t xy; int n; if (argc != 1) @@ -77,9 +76,7 @@ grub_cmd_sleep (grub_extcmd_t cmd, int argc, char **args) return 0; } - xy = grub_getxy (); - x = xy >> 8; - y = xy & 0xff; + pos = grub_term_save_pos (); for (; n; n--) { diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index fb97de0a0..2c383f387 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -27,7 +27,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.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 \ + normal/menu_text.c normal/term.c \ script/main.c script/execute.c script/function.c \ script/lexer.c script/script.c grub_script.tab.c \ partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \ diff --git a/conf/common.rmk b/conf/common.rmk index 1ed30a404..02d57f0a3 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -543,7 +543,7 @@ normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.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 + normal/misc.c normal/term.c normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/include/grub/charset.h b/include/grub/charset.h index f85862f8b..daaa5c99f 100644 --- a/include/grub/charset.h +++ b/include/grub/charset.h @@ -109,4 +109,7 @@ grub_utf16_to_utf8 (grub_uint8_t *dest, grub_uint16_t *src, return dest; } +/* Convert UCS-4 to UTF-8. */ +char *grub_ucs4_to_utf8_alloc (grub_uint32_t *src, grub_size_t size); + #endif diff --git a/include/grub/normal.h b/include/grub/normal.h index e55553de5..d629338e6 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -20,6 +20,7 @@ #ifndef GRUB_NORMAL_HEADER #define GRUB_NORMAL_HEADER 1 +#include #include #include #include @@ -50,7 +51,7 @@ extern struct grub_menu_viewer grub_normal_text_menu_viewer; /* Defined in `main.c'. */ void grub_enter_normal_mode (const char *config); void grub_normal_execute (const char *config, int nested, int batch); -void grub_normal_init_page (void); +void grub_normal_init_page (struct grub_term_output *term); void grub_menu_init_page (int nested, int edit); grub_err_t grub_normal_add_menu_entry (int argc, const char **args, const char *sourcecode); @@ -58,8 +59,7 @@ char *grub_file_getline (grub_file_t file); 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 history); +char *grub_cmdline_get (const char *prompt, unsigned max_len); grub_err_t grub_set_history (int newsize); /* Defined in `completion.c'. */ @@ -95,6 +95,7 @@ void read_command_list (void); /* Defined in `autofs.c'. */ void read_fs_list (void); +void grub_set_more (int onoff); #ifdef GRUB_UTIL void grub_normal_init (void); diff --git a/include/grub/parser.h b/include/grub/parser.h index 41f768bba..17f0c4303 100644 --- a/include/grub/parser.h +++ b/include/grub/parser.h @@ -22,6 +22,7 @@ #include #include +#include #include /* All the states for the command line. */ diff --git a/include/grub/reader.h b/include/grub/reader.h index c7e67bf5e..fd72a3252 100644 --- a/include/grub/reader.h +++ b/include/grub/reader.h @@ -20,60 +20,10 @@ #ifndef GRUB_READER_HEADER #define GRUB_READER_HEADER 1 -#include #include -#include typedef grub_err_t (*grub_reader_getline_t) (char **, int); -struct grub_reader -{ - /* The next reader. */ - struct grub_parser *next; - - /* The reader name. */ - const char *name; - - /* Initialize the reader. */ - grub_err_t (*init) (void); - - /* Clean up the reader. */ - grub_err_t (*fini) (void); - - grub_reader_getline_t read_line; -}; -typedef struct grub_reader *grub_reader_t; - -extern struct grub_handler_class EXPORT_VAR(grub_reader_class); - -grub_err_t EXPORT_FUNC(grub_reader_loop) (grub_reader_getline_t getline); - -static inline void -grub_reader_register (const char *name __attribute__ ((unused)), - grub_reader_t reader) -{ - grub_handler_register (&grub_reader_class, GRUB_AS_HANDLER (reader)); -} - -static inline void -grub_reader_unregister (grub_reader_t reader) -{ - grub_handler_unregister (&grub_reader_class, GRUB_AS_HANDLER (reader)); -} - -static inline grub_reader_t -grub_reader_get_current (void) -{ - return (grub_reader_t) grub_reader_class.cur_handler; -} - -static inline grub_err_t -grub_reader_set_current (grub_reader_t reader) -{ - return grub_handler_set_current (&grub_reader_class, - GRUB_AS_HANDLER (reader)); -} - -void grub_register_rescue_reader (void); +void grub_rescue_run (void); #endif /* ! GRUB_READER_HEADER */ diff --git a/include/grub/term.h b/include/grub/term.h index 316d75390..39a10ed71 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -68,6 +68,8 @@ grub_term_color_state; #define GRUB_TERM_NO_EDIT (1 << 1) /* Set when the terminal cannot do fancy things. */ #define GRUB_TERM_DUMB (1 << 2) +/* Terminal is used as general output. */ +#define GRUB_TERM_ACTIVE (1 << 3) /* Set when the terminal needs to be initialized. */ #define GRUB_TERM_NEED_INIT (1 << 16) @@ -93,10 +95,6 @@ grub_term_color_state; /* Menu-related geometrical constants. */ -/* FIXME: Ugly way to get them form terminal. */ -#define GRUB_TERM_WIDTH ((grub_getwh()&0xFF00)>>8) -#define GRUB_TERM_HEIGHT (grub_getwh()&0xFF) - /* The number of lines of "GRUB version..." at the top. */ #define GRUB_TERM_INFO_HEIGHT 1 @@ -225,7 +223,7 @@ struct grub_term_output typedef struct grub_term_output *grub_term_output_t; extern struct grub_handler_class EXPORT_VAR(grub_term_input_class); -extern struct grub_handler_class EXPORT_VAR(grub_term_output_class); +extern struct grub_term_output *EXPORT_VAR(grub_term_outputs); static inline void grub_term_register_input (const char *name __attribute__ ((unused)), @@ -238,7 +236,7 @@ static inline void grub_term_register_output (const char *name __attribute__ ((unused)), grub_term_output_t term) { - grub_handler_register (&grub_term_output_class, GRUB_AS_HANDLER (term)); + grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs), GRUB_AS_LIST (term)); } static inline void @@ -250,7 +248,7 @@ grub_term_unregister_input (grub_term_input_t term) static inline void grub_term_unregister_output (grub_term_output_t term) { - grub_handler_unregister (&grub_term_output_class, GRUB_AS_HANDLER (term)); + grub_list_remove (GRUB_AS_LIST_P (&grub_term_outputs), GRUB_AS_LIST (term)); } static inline grub_err_t @@ -260,44 +258,34 @@ grub_term_set_current_input (grub_term_input_t term) GRUB_AS_HANDLER (term)); } -static inline grub_err_t -grub_term_set_current_output (grub_term_output_t term) -{ - return grub_handler_set_current (&grub_term_output_class, - GRUB_AS_HANDLER (term)); -} - static inline grub_term_input_t grub_term_get_current_input (void) { return (grub_term_input_t) grub_term_input_class.cur_handler; } -static inline grub_term_output_t -grub_term_get_current_output (void) -{ - return (grub_term_output_t) grub_term_output_class.cur_handler; -} - void EXPORT_FUNC(grub_putchar) (int c); -void EXPORT_FUNC(grub_putcode) (grub_uint32_t code); -grub_ssize_t EXPORT_FUNC(grub_getcharwidth) (grub_uint32_t code); +void EXPORT_FUNC(grub_putcode) (grub_uint32_t code, + struct grub_term_output *term); 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); void EXPORT_FUNC(grub_cls) (void); void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state); -void EXPORT_FUNC(grub_setcolor) (grub_uint8_t normal_color, - grub_uint8_t highlight_color); -void EXPORT_FUNC(grub_getcolor) (grub_uint8_t *normal_color, - grub_uint8_t *highlight_color); -int EXPORT_FUNC(grub_setcursor) (int on); -int EXPORT_FUNC(grub_getcursor) (void); void EXPORT_FUNC(grub_refresh) (void); -void EXPORT_FUNC(grub_set_more) (int onoff); +void grub_puts_terminal (const char *str, struct grub_term_output *term); +grub_uint16_t *grub_term_save_pos (void); +void grub_term_restore_pos (grub_uint16_t *pos); + +static inline int grub_term_width (struct grub_term_output *term) +{ + return ((term->getwh()&0xFF00)>>8); +} + +static inline int grub_term_height (struct grub_term_output *term) +{ + return (term->getwh()&0xFF); +} /* For convenience. */ #define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff) diff --git a/kern/main.c b/kern/main.c index 9215d55e7..040f89e6d 100644 --- a/kern/main.c +++ b/kern/main.c @@ -169,9 +169,8 @@ grub_main (void) grub_register_core_commands (); grub_register_rescue_parser (); - grub_register_rescue_reader (); grub_load_config (); grub_load_normal_mode (); - grub_reader_loop (0); + grub_rescue_run (); } diff --git a/kern/misc.c b/kern/misc.c index f6d189e94..7dd9bd18a 100644 --- a/kern/misc.c +++ b/kern/misc.c @@ -968,15 +968,12 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize, void grub_abort (void) { - if (grub_term_get_current_output ()) + grub_printf ("\nAborted."); + + if (grub_term_get_current_input ()) { - grub_printf ("\nAborted."); - - if (grub_term_get_current_input ()) - { - grub_printf (" Press any key to exit."); - grub_getkey (); - } + grub_printf (" Press any key to exit."); + grub_getkey (); } grub_exit (); diff --git a/kern/reader.c b/kern/reader.c index 271a90f5a..74698d34b 100644 --- a/kern/reader.c +++ b/kern/reader.c @@ -22,28 +22,3 @@ #include #include -struct grub_handler_class grub_reader_class = - { - .name = "reader" - }; - -grub_err_t -grub_reader_loop (grub_reader_getline_t getline) -{ - while (1) - { - char *line; - grub_reader_getline_t func; - - /* Print an error, if any. */ - grub_print_error (); - grub_errno = GRUB_ERR_NONE; - - func = (getline) ? : grub_reader_get_current ()->read_line; - if ((func (&line, 0)) || (! line)) - return grub_errno; - - grub_parser_get_current ()->parse_line (line, func); - grub_free (line); - } -} diff --git a/kern/rescue_reader.c b/kern/rescue_reader.c index 2a06f3fc2..732124b1a 100644 --- a/kern/rescue_reader.c +++ b/kern/rescue_reader.c @@ -19,20 +19,15 @@ #include #include +#include #include #include +#include #define GRUB_RESCUE_BUF_SIZE 256 static char linebuf[GRUB_RESCUE_BUF_SIZE]; -static grub_err_t -grub_rescue_init (void) -{ - grub_printf ("Entering rescue mode...\n"); - return 0; -} - /* Prompt to input a command and read the line. */ static grub_err_t grub_rescue_read_line (char **line, int cont) @@ -74,15 +69,24 @@ grub_rescue_read_line (char **line, int cont) return 0; } -static struct grub_reader grub_rescue_reader = - { - .name = "rescue", - .init = grub_rescue_init, - .read_line = grub_rescue_read_line - }; - void -grub_register_rescue_reader (void) +grub_rescue_run (void) { - grub_reader_register ("rescue", &grub_rescue_reader); + grub_printf ("Entering rescue mode...\n"); + + while (1) + { + char *line; + + /* Print an error, if any. */ + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + + grub_rescue_read_line (&line, 0); + if (! line) + continue; + + grub_parser_get_current ()->parse_line (line, grub_rescue_read_line); + grub_free (line); + } } diff --git a/kern/term.c b/kern/term.c index 94d5a9e1d..35660273e 100644 --- a/kern/term.c +++ b/kern/term.c @@ -22,78 +22,35 @@ #include #include -/* The amount of lines counted by the pager. */ -static int grub_more_lines; - -/* If the more pager is active. */ -static int grub_more; - -/* The current cursor state. */ -static int cursor_state = 1; - struct grub_handler_class grub_term_input_class = { .name = "terminal_input" }; -struct grub_handler_class grub_term_output_class = - { - .name = "terminal_output" - }; - #define grub_cur_term_input grub_term_get_current_input () -#define grub_cur_term_output grub_term_get_current_output () + +struct grub_term_output *grub_term_outputs; /* Put a Unicode character. */ void -grub_putcode (grub_uint32_t code) +grub_putcode (grub_uint32_t code, struct grub_term_output *term) { - int height = grub_getwh () & 255; + int height; - if (code == '\t' && grub_cur_term_output->getxy) + height = term->getwh () & 255; + + if (code == '\t' && term->getxy) { int n; - n = 8 - ((grub_getxy () >> 8) & 7); + n = 8 - ((term->getxy () >> 8) & 7); while (n--) - grub_putcode (' '); + grub_putcode (' ', term); return; } - (grub_cur_term_output->putchar) (code); - - if (code == '\n') - { - grub_putcode ('\r'); - - grub_more_lines++; - - if (grub_more && grub_more_lines == height - 1) - { - char key; - int pos = grub_getxy (); - - /* Show --MORE-- on the lower left side of the screen. */ - grub_gotoxy (1, height - 1); - grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); - grub_printf ("--MORE--"); - grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); - - key = grub_getkey (); - - /* Remove the message. */ - grub_gotoxy (1, height - 1); - grub_printf (" "); - grub_gotoxy (pos >> 8, pos & 0xFF); - - /* Scroll one lines or an entire page, depending on the key. */ - if (key == '\r' || key =='\n') - grub_more_lines--; - else - grub_more_lines = 0; - } - } + (term->putchar) (code); } /* Put a character. C is one byte of a UTF-8 stream. @@ -106,26 +63,28 @@ grub_putchar (int c) grub_uint32_t code; grub_ssize_t ret; + auto int do_putcode (grub_list_t item); + int do_putcode (grub_list_t item) + { + struct grub_term_output *term = (struct grub_term_output *) item; + + if (term->flags & GRUB_TERM_ACTIVE) + grub_putcode (code, term); + + return 0; + } + buf[size++] = c; ret = grub_utf8_to_ucs4 (&code, 1, buf, size, 0); - if (ret > 0) - { - size = 0; - grub_putcode (code); - } - else if (ret < 0) - { - size = 0; - grub_putcode ('?'); - } -} + if (ret < 0) + code = '?'; -/* Return the number of columns occupied by the character code CODE. */ -grub_ssize_t -grub_getcharwidth (grub_uint32_t code) -{ - return (grub_cur_term_output->getcharwidth) (code); + if (ret != 0) + { + size = 0; + grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), do_putcode); + } } int @@ -149,91 +108,67 @@ grub_getkeystatus (void) return 0; } -grub_uint16_t -grub_getxy (void) -{ - return (grub_cur_term_output->getxy) (); -} - -grub_uint16_t -grub_getwh (void) -{ - return (grub_cur_term_output->getwh) (); -} - -void -grub_gotoxy (grub_uint8_t x, grub_uint8_t y) -{ - (grub_cur_term_output->gotoxy) (x, y); -} - void grub_cls (void) { - if ((grub_cur_term_output->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug"))) - { - grub_putchar ('\n'); - grub_refresh (); - } - else - (grub_cur_term_output->cls) (); + auto int hook (grub_list_t item); + int hook (grub_list_t item) + { + struct grub_term_output *term = (struct grub_term_output *) item; + + if (!(term->flags & GRUB_TERM_ACTIVE)) + return 0; + + if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug"))) + { + grub_putcode ('\n', term); + grub_refresh (); + } + else + (term->cls) (); + + return 0; + } + + grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), hook); } void grub_setcolorstate (grub_term_color_state state) { - if (grub_cur_term_output->setcolorstate) - (grub_cur_term_output->setcolorstate) (state); -} + auto int hook (grub_list_t item); + int hook (grub_list_t item) + { + struct grub_term_output *term = (struct grub_term_output *) item; -void -grub_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color) -{ - if (grub_cur_term_output->setcolor) - (grub_cur_term_output->setcolor) (normal_color, highlight_color); -} + if (!(term->flags & GRUB_TERM_ACTIVE)) + return 0; -void -grub_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color) -{ - if (grub_cur_term_output->getcolor) - (grub_cur_term_output->getcolor) (normal_color, highlight_color); -} + if (term->setcolorstate) + (term->setcolorstate) (state); -int -grub_setcursor (int on) -{ - int ret = cursor_state; + return 0; + } - if (grub_cur_term_output->setcursor) - { - (grub_cur_term_output->setcursor) (on); - cursor_state = on; - } - - return ret; -} - -int -grub_getcursor (void) -{ - return cursor_state; + grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), hook); } void grub_refresh (void) { - if (grub_cur_term_output->refresh) - (grub_cur_term_output->refresh) (); -} + auto int hook (grub_list_t item); + int hook (grub_list_t item) + { + struct grub_term_output *term = (struct grub_term_output *) item; -void -grub_set_more (int onoff) -{ - if (onoff == 1) - grub_more++; - else - grub_more--; + if (!(term->flags & GRUB_TERM_ACTIVE)) + return 0; - grub_more_lines = 0; + if (term->refresh) + (term->refresh) (); + + return 0; + } + + grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), hook); } diff --git a/lib/charset.c b/lib/charset.c index 8bc5b9149..0f2c2c8ee 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -114,3 +114,67 @@ grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize, *srcend = src; return p - dest; } + +/* Convert UCS-4 to UTF-8. */ +char * +grub_ucs4_to_utf8_alloc (grub_uint32_t *src, grub_size_t size) +{ + grub_size_t remaining; + grub_uint32_t *ptr; + grub_size_t cnt = 0; + grub_uint8_t *ret, *dest; + + remaining = size; + ptr = src; + while (remaining--) + { + grub_uint32_t code = *ptr++; + + if (code <= 0x007F) + cnt++; + else if (code <= 0x07FF) + cnt += 2; + else if ((code >= 0xDC00 && code <= 0xDFFF) + || (code >= 0xD800 && code <= 0xDBFF)) + /* No surrogates in UCS-4... */ + cnt++; + else + cnt += 3; + } + cnt++; + + ret = grub_malloc (cnt); + if (!ret) + return 0; + + dest = ret; + remaining = size; + ptr = src; + while (remaining--) + { + grub_uint32_t code = *ptr++; + + if (code <= 0x007F) + *dest++ = code; + else if (code <= 0x07FF) + { + *dest++ = (code >> 6) | 0xC0; + *dest++ = (code & 0x3F) | 0x80; + } + else if ((code >= 0xDC00 && code <= 0xDFFF) + || (code >= 0xD800 && code <= 0xDBFF)) + { + /* No surrogates in UCS-4... */ + *dest++ = '?'; + } + else + { + *dest++ = (code >> 12) | 0xE0; + *dest++ = ((code >> 6) & 0x3F) | 0x80; + *dest++ = (code & 0x3F) | 0x80; + } + } + *dest = 0; + + return ret; +} diff --git a/loader/i386/linux.c b/loader/i386/linux.c index 82bfd6b95..140ed1957 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 @@ -547,8 +548,8 @@ grub_linux_boot (void) /* Initialize these last, because terminal position could be affected by printfs above. */ if (params->have_vga == GRUB_VIDEO_TYPE_TEXT) { - params->video_cursor_x = grub_getxy () >> 8; - params->video_cursor_y = grub_getxy () & 0xff; + params->video_cursor_x = grub_console_getxy () >> 8; + params->video_cursor_y = grub_console_getxy () & 0xff; } #ifdef __x86_64__ diff --git a/normal/cmdline.c b/normal/cmdline.c index 6d74e6e69..c104709c5 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -28,10 +28,10 @@ #include #include -static char *kill_buf; +static grub_uint32_t *kill_buf; static int hist_size; -static char **hist_lines = 0; +static grub_uint32_t **hist_lines = 0; static int hist_pos = 0; static int hist_end = 0; static int hist_used = 0; @@ -39,7 +39,7 @@ static int hist_used = 0; grub_err_t grub_set_history (int newsize) { - char **old_hist_lines = hist_lines; + grub_uint32_t **old_hist_lines = hist_lines; hist_lines = grub_malloc (sizeof (char *) * newsize); /* Copy the old lines into the new buffer. */ @@ -90,17 +90,42 @@ grub_set_history (int newsize) /* Get the entry POS from the history where `0' is the newest entry. */ -static char * +static grub_uint32_t * grub_history_get (int pos) { pos = (hist_pos + pos) % hist_size; return hist_lines[pos]; } +static grub_size_t +strlen_ucs4 (const grub_uint32_t *s) +{ + const grub_uint32_t *p = s; + + while (*p) + p++; + + return p - s; +} + +static grub_uint32_t * +strdup_ucs4 (const grub_uint32_t *s) +{ + grub_size_t len; + char *p; + + len = strlen_ucs4 (s) + 1; + p = (char *) grub_malloc (len * sizeof (grub_uint32_t)); + if (! p) + return 0; + + return grub_memcpy (p, s, len * sizeof (grub_uint32_t)); +} + /* Insert a new history line S on the top of the history. */ static void -grub_history_add (char *s) +grub_history_add (grub_uint32_t *s) { /* Remove the oldest entry in the history to make room for a new entry. */ @@ -121,16 +146,16 @@ grub_history_add (char *s) hist_pos = hist_size + hist_pos; /* Insert into history. */ - hist_lines[hist_pos] = grub_strdup (s); + hist_lines[hist_pos] = strdup_ucs4 (s); } /* Replace the history entry on position POS with the string S. */ static void -grub_history_replace (int pos, char *s) +grub_history_replace (int pos, grub_uint32_t *s) { pos = (hist_pos + pos) % hist_size; grub_free (hist_lines[pos]); - hist_lines[pos] = grub_strdup (s); + hist_lines[pos] = strdup_ucs4 (s); } /* A completion hook to print items. */ @@ -176,62 +201,81 @@ print_completion (const char *item, grub_completion_type_t type, int count) grub_printf (" %s", item); } -/* Get a command-line. If ECHO_CHAR is not zero, echo it instead of input - characters. If READLINE is non-zero, readline-like key bindings are - available. If ESC is pushed, return zero, otherwise return non-zero. */ -/* 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 history) +struct cmdline_term +{ + unsigned xpos, ypos, ystart, width, height; + struct grub_term_output *term; +}; + +/* Get a command-line. If ESC is pushed, return zero, + otherwise return command line. */ +/* FIXME: The dumb interface is not supported yet. */ +char * +grub_cmdline_get (const char *prompt, unsigned max_len) { - unsigned xpos, ypos, ystart; grub_size_t lpos, llen; grub_size_t plen; - char buf[max_len]; + grub_uint32_t buf[max_len]; int key; int histpos = 0; - auto void cl_insert (const char *str); + auto void cl_insert (const grub_uint32_t *str); auto void cl_delete (unsigned len); - auto void cl_print (int pos, int c); - auto void cl_set_pos (void); + auto void cl_print (struct cmdline_term *cl_term, int pos, grub_uint32_t c); + auto void cl_set_pos (struct cmdline_term *cl_term); + auto void cl_print_all (int pos, grub_uint32_t c); + auto void cl_set_pos_all (void); const char *prompt_translated = _(prompt); + struct cmdline_term *cl_terms; + unsigned nterms; - void cl_set_pos (void) + void cl_set_pos (struct cmdline_term *cl_term) + { + cl_term->xpos = (plen + lpos) % (cl_term->width - 1); + cl_term->ypos = cl_term->ystart + (plen + lpos) / (cl_term->width - 1); + cl_term->term->gotoxy (cl_term->xpos, cl_term->ypos); + } + + void cl_set_pos_all () + { + unsigned i; + for (i = 0; i < nterms; i++) + cl_set_pos (&cl_terms[i]); + } + + void cl_print (struct cmdline_term *cl_term, int pos, grub_uint32_t c) { - xpos = (plen + lpos) % 79; - ypos = ystart + (plen + lpos) / 79; - grub_gotoxy (xpos, ypos); - - grub_refresh (); - } - - void cl_print (int pos, int c) - { - char *p; + grub_uint32_t *p; for (p = buf + pos; *p; p++) { - if (xpos++ > 78) + if (cl_term->xpos++ > cl_term->width - 2) { - grub_putchar ('\n'); + grub_putcode ('\n', cl_term->term); - xpos = 1; - if (ypos == (unsigned) (grub_getxy () & 0xFF)) - ystart--; + cl_term->xpos = 1; + if (cl_term->ypos == (unsigned) (cl_term->height)) + cl_term->ystart--; else - ypos++; + cl_term->ypos++; } if (c) - grub_putchar (c); + grub_putcode (c, cl_term->term); else - grub_putchar (*p); + grub_putcode (*p, cl_term->term); } } - void cl_insert (const char *str) + void cl_print_all (int pos, grub_uint32_t c) + { + unsigned i; + for (i = 0; i < nterms; i++) + cl_print (&cl_terms[i], pos, c); + } + + void cl_insert (const grub_uint32_t *str) { - grub_size_t len = grub_strlen (str); + grub_size_t len = strlen_ucs4 (str); if (len + llen < max_len) { @@ -240,8 +284,8 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, llen += len; lpos += len; - cl_print (lpos - len, echo_char); - cl_set_pos (); + cl_print_all (lpos - len, echo_char); + cl_set_pos_all (); } grub_refresh (); @@ -254,182 +298,207 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, grub_size_t saved_lpos = lpos; lpos = llen - len; - cl_set_pos (); - cl_print (lpos, ' '); + cl_set_pos_all (); + cl_print_all (lpos, ' '); lpos = saved_lpos; - cl_set_pos (); + cl_set_pos_all (); grub_memmove (buf + lpos, buf + lpos + len, llen - lpos + 1); llen -= len; - cl_print (lpos, echo_char); - cl_set_pos (); + cl_print_all (lpos, echo_char); + cl_set_pos_all (); } grub_refresh (); } + void init_clterm (struct cmdline_term *cl_term_cur) + { + cl_term_cur->xpos = plen; + cl_term_cur->ypos = (cl_term_cur->term->getxy () & 0xFF); + cl_term_cur->ystart = cl_term_cur->ypos; + cl_term_cur->width = grub_term_width (cl_term_cur->term); + cl_term_cur->height = grub_term_height (cl_term_cur->term); + } + + void init_clterm_all (void) + { + unsigned i; + for (i = 0; i < nterms; i++) + init_clterm (&cl_terms[i]); + } + plen = grub_strlen (prompt_translated); lpos = llen = 0; buf[0] = '\0'; - if ((grub_getxy () >> 8) != 0) - grub_putchar ('\n'); + grub_putchar ('\n'); grub_printf ("%s", prompt_translated); - xpos = plen; - ystart = ypos = (grub_getxy () & 0xFF); + { + struct cmdline_term *cl_term_cur; + struct grub_term_output *cur; + nterms = 0; + for (cur = grub_term_outputs; cur; cur = cur->next) + if (cur->flags & GRUB_TERM_ACTIVE) + nterms++; - cl_insert (cmdline); + cl_terms = grub_malloc (sizeof (cl_terms[0]) * nterms); + if (!cl_terms) + return grub_errno; + cl_term_cur = cl_terms; + for (cur = grub_term_outputs; cur; cur = cur->next) + if (cur->flags & GRUB_TERM_ACTIVE) + { + cl_term_cur->term = cur; + init_clterm (cl_term_cur); + cl_term_cur++; + } + } if (history && hist_used == 0) grub_history_add (buf); while ((key = GRUB_TERM_ASCII_CHAR (grub_getkey ())) != '\n' && key != '\r') { - if (readline) - { - switch (key) - { - case 1: /* Ctrl-a */ - lpos = 0; - cl_set_pos (); - break; - - case 2: /* Ctrl-b */ - if (lpos > 0) - { - lpos--; - cl_set_pos (); - } - break; - - case 5: /* Ctrl-e */ - lpos = llen; - cl_set_pos (); - break; - - case 6: /* Ctrl-f */ - if (lpos < llen) - { - lpos++; - cl_set_pos (); - } - break; - - case 9: /* Ctrl-i or TAB */ - { - char *insert; - int restore; - - /* Backup the next character and make it 0 so it will - be easy to use string functions. */ - char backup = buf[lpos]; - buf[lpos] = '\0'; - - - insert = grub_normal_do_completion (buf, &restore, - print_completion); - /* Restore the original string. */ - buf[lpos] = backup; - - if (restore) - { - /* Restore the prompt. */ - grub_printf ("\n%s %s", prompt_translated, buf); - xpos = plen; - ystart = ypos = (grub_getxy () & 0xFF); - } - - if (insert) - { - cl_insert (insert); - grub_free (insert); - } - } - break; - - case 11: /* Ctrl-k */ - if (lpos < llen) - { - if (kill_buf) - grub_free (kill_buf); - - kill_buf = grub_strdup (buf + lpos); - grub_errno = GRUB_ERR_NONE; - - cl_delete (llen - lpos); - } - break; - - case 14: /* Ctrl-n */ - { - char *hist; - - lpos = 0; - - if (histpos > 0) - { - grub_history_replace (histpos, buf); - histpos--; - } - - cl_delete (llen); - hist = grub_history_get (histpos); - cl_insert (hist); - - break; - } - case 16: /* Ctrl-p */ - { - char *hist; - - lpos = 0; - - if (histpos < hist_used - 1) - { - grub_history_replace (histpos, buf); - histpos++; - } - - cl_delete (llen); - hist = grub_history_get (histpos); - - cl_insert (hist); - } - break; - - case 21: /* Ctrl-u */ - if (lpos > 0) - { - grub_size_t n = lpos; - - if (kill_buf) - grub_free (kill_buf); - - kill_buf = grub_malloc (n + 1); - grub_errno = GRUB_ERR_NONE; - if (kill_buf) - { - grub_memcpy (kill_buf, buf, n); - kill_buf[n] = '\0'; - } - - lpos = 0; - cl_set_pos (); - cl_delete (n); - } - break; - - case 25: /* Ctrl-y */ - if (kill_buf) - cl_insert (kill_buf); - break; - } - } - switch (key) { + case 1: /* Ctrl-a */ + lpos = 0; + cl_set_pos_all (); + break; + + case 2: /* Ctrl-b */ + if (lpos > 0) + { + lpos--; + cl_set_pos_all (); + } + break; + + case 5: /* Ctrl-e */ + lpos = llen; + cl_set_pos_all (); + break; + + case 6: /* Ctrl-f */ + if (lpos < llen) + { + lpos++; + cl_set_pos_all (); + } + break; + + case 9: /* Ctrl-i or TAB */ + { + grub_uint32_t *insert; + int restore; + + /* Backup the next character and make it 0 so it will + be easy to use string functions. */ + char backup = buf[lpos]; + buf[lpos] = '\0'; + + + insert = grub_normal_do_completion (buf, &restore, + print_completion); + /* Restore the original string. */ + buf[lpos] = backup; + + if (restore) + { + /* Restore the prompt. */ + grub_printf ("\n%s", prompt_translated); + init_clterm_all (); + cl_print_all (0, 0); + } + + if (insert) + { + cl_insert (insert); + grub_free (insert); + } + } + break; + + case 11: /* Ctrl-k */ + if (lpos < llen) + { + if (kill_buf) + grub_free (kill_buf); + + kill_buf = strdup_ucs4 (buf + lpos); + grub_errno = GRUB_ERR_NONE; + + cl_delete (llen - lpos); + } + break; + + case 14: /* Ctrl-n */ + { + grub_uint32_t *hist; + + lpos = 0; + + if (histpos > 0) + { + grub_history_replace (histpos, buf); + histpos--; + } + + cl_delete (llen); + hist = grub_history_get (histpos); + cl_insert (hist); + + break; + } + case 16: /* Ctrl-p */ + { + grub_uint32_t *hist; + + lpos = 0; + + if (histpos < hist_used - 1) + { + grub_history_replace (histpos, buf); + histpos++; + } + + cl_delete (llen); + hist = grub_history_get (histpos); + + cl_insert (hist); + } + break; + + case 21: /* Ctrl-u */ + if (lpos > 0) + { + grub_size_t n = lpos; + + if (kill_buf) + grub_free (kill_buf); + + kill_buf = grub_malloc (n + 1); + grub_errno = GRUB_ERR_NONE; + if (kill_buf) + { + grub_memcpy (kill_buf, buf, n); + kill_buf[n] = '\0'; + } + + lpos = 0; + cl_set_pos_all (); + cl_delete (n); + } + break; + + case 25: /* Ctrl-y */ + if (kill_buf) + cl_insert (kill_buf); + break; + case '\e': return 0; @@ -437,7 +506,7 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, if (lpos > 0) { lpos--; - cl_set_pos (); + cl_set_pos_all (); } else break; @@ -451,7 +520,7 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, default: if (grub_isprint (key)) { - char str[2]; + grub_uint32_t str[2]; str[0] = key; str[1] = '\0'; @@ -464,23 +533,21 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, grub_putchar ('\n'); grub_refresh (); - /* If ECHO_CHAR is NUL, remove leading spaces. */ + /* Remove leading spaces. */ lpos = 0; - if (! echo_char) - while (buf[lpos] == ' ') - lpos++; + while (buf[lpos] == ' ') + lpos++; if (history) { histpos = 0; - if (grub_strlen (buf) > 0) + if (strlen_ucs4 (buf) > 0) { + grub_uint32_t empty[] = { 0 }; grub_history_replace (histpos, buf); - grub_history_add (""); + grub_history_add (empty); } } - grub_memcpy (cmdline, buf + lpos, llen - lpos + 1); - - return 1; + return grub_ucs4_to_utf8_alloc (buf + lpos, llen - lpos + 1); } diff --git a/normal/color.c b/normal/color.c index 0b9868d3b..63bd889a5 100644 --- a/normal/color.c +++ b/normal/color.c @@ -103,23 +103,36 @@ free_and_return: grub_free (fg_name); } +static grub_uint8_t color_normal, color_highlight; + +static void +set_colors (void) +{ + struct grub_term_output *term; + + for (term = grub_term_outputs; term; term = term->next) + { + if (! (term->flags & GRUB_TERM_ACTIVE)) + continue; + + /* Reloads terminal `normal' and `highlight' colors. */ + if (term->setcolor) + term->setcolor (color_normal, color_highlight); + + /* Propagates `normal' color to terminal current color. */ + if (term->setcolorstate) + term->setcolorstate (GRUB_TERM_COLOR_NORMAL); + } +} + /* Replace default `normal' colors with the ones specified by user (if any). */ char * grub_env_write_color_normal (struct grub_env_var *var __attribute__ ((unused)), const char *val) { - grub_uint8_t color_normal, color_highlight; - - /* Use old settings in case grub_parse_color_name_pair() has no effect. */ - grub_getcolor (&color_normal, &color_highlight); - grub_parse_color_name_pair (&color_normal, val); - /* Reloads terminal `normal' and `highlight' colors. */ - grub_setcolor (color_normal, color_highlight); - - /* Propagates `normal' color to terminal current color. */ - grub_setcolorstate (GRUB_TERM_COLOR_NORMAL); + set_colors (); return grub_strdup (val); } @@ -129,21 +142,9 @@ char * grub_env_write_color_highlight (struct grub_env_var *var __attribute__ ((unused)), const char *val) { - grub_uint8_t color_normal, color_highlight; - - /* Use old settings in case grub_parse_color_name_pair() has no effect. */ - grub_getcolor (&color_normal, &color_highlight); - grub_parse_color_name_pair (&color_highlight, val); - /* Reloads terminal `normal' and `highlight' colors. */ - grub_setcolor (color_normal, color_highlight); - - /* Propagates `normal' color to terminal current color. - Note: Using GRUB_TERM_COLOR_NORMAL here rather than - GRUB_TERM_COLOR_HIGHLIGHT is intentional. We don't want to switch - to highlight state just because color was reloaded. */ - grub_setcolorstate (GRUB_TERM_COLOR_NORMAL); + set_colors (); return grub_strdup (val); } diff --git a/normal/main.c b/normal/main.c index e8dfb182b..42098e682 100644 --- a/normal/main.c +++ b/normal/main.c @@ -372,7 +372,21 @@ read_config_file (const char *config) if (! file) return 0; - grub_reader_loop (getline); + while (1) + { + char *line; + + /* Print an error, if any. */ + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + + if ((getline (&line, 0)) || (! line)) + break; + + grub_parser_get_current ()->parse_line (line, getline); + grub_free (line); + } + grub_file_close (file); if (old_parser) @@ -383,7 +397,7 @@ read_config_file (const char *config) /* Initialize the screen. */ void -grub_normal_init_page (void) +grub_normal_init_page (struct grub_term_output *term) { int msg_len; int posx; @@ -391,13 +405,12 @@ grub_normal_init_page (void) char *msg_formatted = grub_malloc (grub_strlen(msg) + grub_strlen(PACKAGE_VERSION)); + grub_uint32_t *unicode_msg; + grub_uint32_t *last_position; grub_cls (); grub_sprintf (msg_formatted, msg, PACKAGE_VERSION); - - grub_uint32_t *unicode_msg; - grub_uint32_t *last_position; msg_len = grub_utf8_to_ucs4_alloc (msg_formatted, &unicode_msg, &last_position); @@ -408,8 +421,8 @@ grub_normal_init_page (void) } posx = grub_getstringwidth (unicode_msg, last_position); - posx = (GRUB_TERM_WIDTH - posx) / 2; - grub_gotoxy (posx, 1); + posx = (grub_term_width (term) - posx) / 2; + term->gotoxy (posx, 1); grub_print_ucs4 (unicode_msg, last_position); grub_printf("\n\n"); @@ -493,48 +506,30 @@ quit: return 0; } -void -grub_cmdline_run (int nested) -{ - 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) - reader->init (); - grub_reader_loop (0); -} - static grub_err_t grub_normal_reader_init (void) { - grub_normal_init_page (); - grub_setcursor (1); - + struct grub_term_output *term; const char *msg = _("Minimal BASH-like line editing is supported. For " "the first word, TAB lists possible command completions. Anywhere " "else TAB lists possible device or file completions. %s"); - const char *msg_esc = _("ESC at any time exits."); - char *msg_formatted = grub_malloc (sizeof (char) * (grub_strlen (msg) + grub_strlen(msg_esc) + 1)); grub_sprintf (msg_formatted, msg, reader_nested ? msg_esc : ""); - grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN); - grub_puts ("\n"); + for (term = grub_term_outputs; term; term = term->next) + { + if (! (term->flags & GRUB_TERM_ACTIVE)) + continue; + grub_normal_init_page (term); + if (term->setcursor) + term->setcursor (1); + + grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN); + grub_puts ("\n"); + } grub_free (msg_formatted); return 0; @@ -567,12 +562,40 @@ grub_normal_read_line (char **line, int cont) return 0; } -static struct grub_reader grub_normal_reader = - { - .name = "normal", - .init = grub_normal_reader_init, - .read_line = grub_normal_read_line - }; +void +grub_cmdline_run (int nested) +{ + 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_nested = nested; + + grub_normal_reader_init (); + + while (1) + { + char *line; + + /* Print an error, if any. */ + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + + grub_normal_read_line (&line, 0); + if (! line) + continue; + + grub_parser_get_current ()->parse_line (line, grub_normal_read_line); + grub_free (line); + } +} static char * grub_env_write_pager (struct grub_env_var *var __attribute__ ((unused)), @@ -592,8 +615,6 @@ GRUB_MOD_INIT(normal) grub_set_history (GRUB_DEFAULT_HISTORY_SIZE); - grub_reader_register ("normal", &grub_normal_reader); - grub_reader_set_current (&grub_normal_reader); grub_register_variable_hook ("pager", 0, grub_env_write_pager); /* Register a command "normal" for the rescue mode. */ @@ -612,7 +633,6 @@ GRUB_MOD_INIT(normal) GRUB_MOD_FINI(normal) { grub_set_history (0); - grub_reader_unregister (&grub_normal_reader); grub_register_variable_hook ("pager", 0, 0); grub_fs_autoload_hook = 0; free_handler_list (); diff --git a/normal/term.c b/normal/term.c new file mode 100644 index 000000000..73eab548a --- /dev/null +++ b/normal/term.c @@ -0,0 +1,128 @@ +/* + * GRUB -- GRand Unified Bootloader + * 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 + * 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 . + */ + +/* The amount of lines counted by the pager. */ +static int grub_more_lines; + +/* If the more pager is active. */ +static int grub_more; + +static void +process_newline (void) +{ + if (code == '\n') + { + grub_putcode ('\r'); + + grub_more_lines++; + + if (grub_more && grub_more_lines == height - 1) + { + char key; + int pos = term->getxy (); + + /* Show --MORE-- on the lower left side of the screen. */ + term->gotoxy (1, height - 1); + grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); + grub_printf ("--MORE--"); + grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); + + key = grub_getkey (); + + /* Remove the message. */ + term->gotoxy (1, height - 1); + grub_printf (" "); + term->gotoxy (pos >> 8, pos & 0xFF); + + /* Scroll one lines or an entire page, depending on the key. */ + if (key == '\r' || key =='\n') + grub_more_lines--; + else + grub_more_lines = 0; + } + } +} + +void +grub_set_more (int onoff) +{ + if (onoff == 1) + grub_more++; + else + grub_more--; + + grub_more_lines = 0; +} + +void +grub_puts_terminal (const char *str, struct grub_term_output *term) +{ + grub_uint32_t code; + grub_ssize_t ret; + const char *ptr = str; + unsigned i; + + while (*ptr) + { + ret = grub_utf8_to_ucs4 (&code, 1, ptr, + grub_strlen (ptr), &ptr); + if (ret < 0) + { + grub_putcode ('?', term); + ptr++; + continue; + } + else + grub_putcode (code, term); + } +} + +grub_uint16_t * +grub_term_save_pos (void) +{ + struct grub_term_output *cur; + unsigned cnt = 0; + grub_uint16_t *ret, *ptr; + + for (cur = grub_term_outputs; cur; cur = cur->next) + if (cur->flags & GRUB_TERM_ACTIVE) + cnt++; + + ret = grub_malloc (cnt * sizeof (ret[0])); + if (!ret) + return NULL; + + for (cur = grub_term_outputs; cur; cur = cur->next) + if (cur->flags & GRUB_TERM_ACTIVE) + *ptr++ = cur->getxy (); + + return ret; +} + +void +grub_term_restore_pos (grub_uint16_t *pos) +{ + struct grub_term_output *cur; + + if (!pos) + return; + + for (cur = grub_term_outputs; cur; cur = cur->next) + if (cur->flags & GRUB_TERM_ACTIVE) + cur->gotoxy ((*ptr & 0xff00) >> 8, *ptr & 0xff); +} diff --git a/term/i386/pc/console.c b/term/i386/pc/console.c index 66475d456..b54e2f6f1 100644 --- a/term/i386/pc/console.c +++ b/term/i386/pc/console.c @@ -79,10 +79,6 @@ grub_console_init (void) void grub_console_fini (void) { - /* This is to make sure the console is restored to text mode before - we boot. */ - grub_term_set_current_output (&grub_console_term_output); - grub_term_unregister_input (&grub_console_term_input); grub_term_unregister_output (&grub_console_term_output); } From a0b70bda6c43e615987220c0669df7196f70fac0 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 24 Dec 2009 14:03:22 +0000 Subject: [PATCH 062/208] 2009-12-24 Robert Millan * include/multiboot.h: Remove `'. (multiboot_uint16_t, multiboot_uint32_t, multiboot_uint64_t): New types. Update all users. --- ChangeLog | 6 ++++ include/multiboot.h | 86 +++++++++++++++++++++++---------------------- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index e594931e1..ace5185de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-12-24 Robert Millan + + * include/multiboot.h: Remove `'. + (multiboot_uint16_t, multiboot_uint32_t, multiboot_uint64_t): New + types. Update all users. + 2009-12-23 Felix Zielcke * commands/i386/pc/drivemap.c: Remove all trailing whitespace. diff --git a/include/multiboot.h b/include/multiboot.h index 9ce34f437..92e00010c 100644 --- a/include/multiboot.h +++ b/include/multiboot.h @@ -97,101 +97,103 @@ #ifndef ASM_FILE -#include +typedef unsigned short multiboot_uint16_t; +typedef unsigned int multiboot_uint32_t; +typedef unsigned long long multiboot_uint64_t; struct multiboot_header { /* Must be MULTIBOOT_MAGIC - see above. */ - grub_uint32_t magic; + multiboot_uint32_t magic; /* Feature flags. */ - grub_uint32_t flags; + multiboot_uint32_t flags; /* The above fields plus this one must equal 0 mod 2^32. */ - grub_uint32_t checksum; + multiboot_uint32_t checksum; /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ - grub_uint32_t header_addr; - grub_uint32_t load_addr; - grub_uint32_t load_end_addr; - grub_uint32_t bss_end_addr; - grub_uint32_t entry_addr; + multiboot_uint32_t header_addr; + multiboot_uint32_t load_addr; + multiboot_uint32_t load_end_addr; + multiboot_uint32_t bss_end_addr; + multiboot_uint32_t entry_addr; /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ - grub_uint32_t mode_type; - grub_uint32_t width; - grub_uint32_t height; - grub_uint32_t depth; + multiboot_uint32_t mode_type; + multiboot_uint32_t width; + multiboot_uint32_t height; + multiboot_uint32_t depth; }; struct multiboot_info { /* Multiboot info version number */ - grub_uint32_t flags; + multiboot_uint32_t flags; /* Available memory from BIOS */ - grub_uint32_t mem_lower; - grub_uint32_t mem_upper; + multiboot_uint32_t mem_lower; + multiboot_uint32_t mem_upper; /* "root" partition */ - grub_uint32_t boot_device; + multiboot_uint32_t boot_device; /* Kernel command line */ - grub_uint32_t cmdline; + multiboot_uint32_t cmdline; /* Boot-Module list */ - grub_uint32_t mods_count; - grub_uint32_t mods_addr; + multiboot_uint32_t mods_count; + multiboot_uint32_t mods_addr; - grub_uint32_t syms[4]; + multiboot_uint32_t syms[4]; /* Memory Mapping buffer */ - grub_uint32_t mmap_length; - grub_uint32_t mmap_addr; + multiboot_uint32_t mmap_length; + multiboot_uint32_t mmap_addr; /* Drive Info buffer */ - grub_uint32_t drives_length; - grub_uint32_t drives_addr; + multiboot_uint32_t drives_length; + multiboot_uint32_t drives_addr; /* ROM configuration table */ - grub_uint32_t config_table; + multiboot_uint32_t config_table; /* Boot Loader Name */ - grub_uint32_t boot_loader_name; + multiboot_uint32_t boot_loader_name; /* APM table */ - grub_uint32_t apm_table; + multiboot_uint32_t apm_table; /* Video */ - grub_uint32_t vbe_control_info; - grub_uint32_t vbe_mode_info; - grub_uint16_t vbe_mode; - grub_uint16_t vbe_interface_seg; - grub_uint16_t vbe_interface_off; - grub_uint16_t vbe_interface_len; + multiboot_uint32_t vbe_control_info; + multiboot_uint32_t vbe_mode_info; + multiboot_uint16_t vbe_mode; + multiboot_uint16_t vbe_interface_seg; + multiboot_uint16_t vbe_interface_off; + multiboot_uint16_t vbe_interface_len; }; struct multiboot_mmap_entry { - grub_uint32_t size; - grub_uint64_t addr; - grub_uint64_t len; + multiboot_uint32_t size; + multiboot_uint64_t addr; + multiboot_uint64_t len; #define MULTIBOOT_MEMORY_AVAILABLE 1 #define MULTIBOOT_MEMORY_RESERVED 2 - grub_uint32_t type; + multiboot_uint32_t type; } __attribute__((packed)); struct multiboot_mod_list { /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ - grub_uint32_t mod_start; - grub_uint32_t mod_end; + multiboot_uint32_t mod_start; + multiboot_uint32_t mod_end; /* Module command line */ - grub_uint32_t cmdline; + multiboot_uint32_t cmdline; /* padding to take it to 16 bytes (must be zero) */ - grub_uint32_t pad; + multiboot_uint32_t pad; }; #endif /* ! ASM_FILE */ From e4d47d8d64af0f28897412a912972a4674e8db3a Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 24 Dec 2009 14:09:06 +0000 Subject: [PATCH 063/208] 2009-12-24 Robert Millan For consistency with [multiboot]/docs/boot.S. * include/multiboot.h (MULTIBOOT_MAGIC): Rename from this ... (MULTIBOOT_HEADER_MAGIC): ... to this. Update all users. (MULTIBOOT_MAGIC2): Rename from this ... (MULTIBOOT_BOOTLOADER_MAGIC): ... to this. Update all users. --- ChangeLog | 9 +++++++++ boot/i386/pc/lnxboot.S | 2 +- include/multiboot.h | 4 ++-- kern/i386/coreboot/startup.S | 2 +- loader/i386/multiboot.c | 4 ++-- loader/multiboot_loader.c | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index ace5185de..125b8af52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-12-24 Robert Millan + + For consistency with [multiboot]/docs/boot.S. + + * include/multiboot.h (MULTIBOOT_MAGIC): Rename from this ... + (MULTIBOOT_HEADER_MAGIC): ... to this. Update all users. + (MULTIBOOT_MAGIC2): Rename from this ... + (MULTIBOOT_BOOTLOADER_MAGIC): ... to this. Update all users. + 2009-12-24 Robert Millan * include/multiboot.h: Remove `'. diff --git a/boot/i386/pc/lnxboot.S b/boot/i386/pc/lnxboot.S index c51741d42..43d170c6e 100644 --- a/boot/i386/pc/lnxboot.S +++ b/boot/i386/pc/lnxboot.S @@ -185,7 +185,7 @@ real_code_2: call LOCAL(move_memory) /* Check for multiboot signature. */ - cmpl $MULTIBOOT_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_DATA_END) + cmpl $MULTIBOOT_HEADER_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_DATA_END) jz 1f movl (ramdisk_image - start), %esi diff --git a/include/multiboot.h b/include/multiboot.h index 92e00010c..3d93070bb 100644 --- a/include/multiboot.h +++ b/include/multiboot.h @@ -27,10 +27,10 @@ #define MULTIBOOT_SEARCH 8192 /* The magic field should contain this. */ -#define MULTIBOOT_MAGIC 0x1BADB002 +#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 /* This should be in %eax. */ -#define MULTIBOOT_MAGIC2 0x2BADB002 +#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 /* The bits in the required part of flags field we don't support. */ #define MULTIBOOT_UNSUPPORTED 0x0000fffc diff --git a/kern/i386/coreboot/startup.S b/kern/i386/coreboot/startup.S index 3f2dd5f50..e94950aae 100644 --- a/kern/i386/coreboot/startup.S +++ b/kern/i386/coreboot/startup.S @@ -66,7 +66,7 @@ multiboot_header: .long -0x1BADB002 - MULTIBOOT_MEMORY_INFO codestart: - cmpl $MULTIBOOT_MAGIC2, %eax + cmpl $MULTIBOOT_BOOTLOADER_MAGIC, %eax jne 0f movl %ebx, EXT_C(startup_multiboot_info) 0: diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index be824e2f4..a78ab60b7 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -65,7 +65,7 @@ grub_multiboot_boot (void) { struct grub_relocator32_state state = { - .eax = MULTIBOOT_MAGIC2, + .eax = MULTIBOOT_BOOTLOADER_MAGIC, .ebx = PTR_TO_UINT32 (mbi_dest), .ecx = 0, .edx = 0, @@ -250,7 +250,7 @@ grub_multiboot (int argc, char *argv[]) ((char *) header <= buffer + len - 12) || (header = 0); header = (struct multiboot_header *) ((char *) header + 4)) { - if (header->magic == MULTIBOOT_MAGIC + if (header->magic == MULTIBOOT_HEADER_MAGIC && !(header->magic + header->flags + header->checksum)) break; } diff --git a/loader/multiboot_loader.c b/loader/multiboot_loader.c index 9078d0622..11f2524cc 100644 --- a/loader/multiboot_loader.c +++ b/loader/multiboot_loader.c @@ -58,7 +58,7 @@ find_multi_boot1_header (grub_file_t file) ((char *) header <= buffer + len - 12) || (header = 0); header = (struct multiboot_header *) ((char *) header + 4)) { - if (header->magic == MULTIBOOT_MAGIC + if (header->magic == MULTIBOOT_HEADER_MAGIC && !(header->magic + header->flags + header->checksum)) { found_status = 1; From 681c70ab145d3553f25d8796ff26ef9a97223ea5 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 24 Dec 2009 14:11:14 +0000 Subject: [PATCH 064/208] 2009-12-24 Robert Millan * include/multiboot.h: Make comments src2texi-friendly. --- ChangeLog | 4 ++++ include/multiboot.h | 13 ++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 125b8af52..f2e906b92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-12-24 Robert Millan + + * include/multiboot.h: Make comments src2texi-friendly. + 2009-12-24 Robert Millan For consistency with [multiboot]/docs/boot.S. diff --git a/include/multiboot.h b/include/multiboot.h index 3d93070bb..3326718cc 100644 --- a/include/multiboot.h +++ b/include/multiboot.h @@ -1,6 +1,5 @@ -/* - * multiboot.h - Multiboot header file. - * Copyright (C) 2003,2007,2008,2009 Free Software Foundation, Inc. +/* multiboot.h - Multiboot header file. */ +/* Copyright (C) 2003,2007,2008,2009 Free Software Foundation, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -41,9 +40,7 @@ /* Alignment of the multiboot info structure. */ #define MULTIBOOT_INFO_ALIGN 0x00000004 -/* - * Flags set in the 'flags' member of the multiboot header. - */ +/* Flags set in the 'flags' member of the multiboot header. */ /* Align all boot modules on i386 page (4KB) boundaries. */ #define MULTIBOOT_PAGE_ALIGN 0x00000001 @@ -57,9 +54,7 @@ /* This flag indicates the use of the address fields in the header. */ #define MULTIBOOT_AOUT_KLUDGE 0x00010000 -/* - * Flags to be set in the 'flags' member of the multiboot info structure. - */ +/* Flags to be set in the 'flags' member of the multiboot info structure. */ /* is there basic lower/upper memory information? */ #define MULTIBOOT_INFO_MEMORY 0x00000001 From eeed10b4ddf29749cd26d65d446daf037a0e0af6 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 24 Dec 2009 14:15:32 +0000 Subject: [PATCH 065/208] 2009-12-24 Robert Millan * include/multiboot.h (struct multiboot_aout_symbol_table) (struct multiboot_elf_section_header_table): New structure declarations (stolen from GRUB Legacy). (struct multiboot_info): Replace opaque `syms' with a.out and ELF table information. (multiboot_aout_symbol_table_t, multiboot_elf_section_header_table_t) (multiboot_info_t, multiboot_memory_map_t, multiboot_module_t): New type aliases. --- ChangeLog | 12 ++++++++++++ include/multiboot.h | 31 +++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2e906b92..a53f7085e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2009-12-24 Robert Millan + + * include/multiboot.h (struct multiboot_aout_symbol_table) + (struct multiboot_elf_section_header_table): New structure + declarations (stolen from GRUB Legacy). + (struct multiboot_info): Replace opaque `syms' with a.out and ELF + table information. + + (multiboot_aout_symbol_table_t, multiboot_elf_section_header_table_t) + (multiboot_info_t, multiboot_memory_map_t, multiboot_module_t): New + type aliases. + 2009-12-24 Robert Millan * include/multiboot.h: Make comments src2texi-friendly. diff --git a/include/multiboot.h b/include/multiboot.h index 3326718cc..41fac756c 100644 --- a/include/multiboot.h +++ b/include/multiboot.h @@ -1,5 +1,5 @@ /* multiboot.h - Multiboot header file. */ -/* Copyright (C) 2003,2007,2008,2009 Free Software Foundation, Inc. +/* Copyright (C) 1999,2003,2007,2008,2009 Free Software Foundation, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -121,6 +121,26 @@ struct multiboot_header multiboot_uint32_t depth; }; +/* The symbol table for a.out. */ +struct multiboot_aout_symbol_table +{ + multiboot_uint32_t tabsize; + multiboot_uint32_t strsize; + multiboot_uint32_t addr; + multiboot_uint32_t reserved; +}; +typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t; + +/* The section header table for ELF. */ +struct multiboot_elf_section_header_table +{ + multiboot_uint32_t num; + multiboot_uint32_t size; + multiboot_uint32_t addr; + multiboot_uint32_t shndx; +}; +typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t; + struct multiboot_info { /* Multiboot info version number */ @@ -140,7 +160,11 @@ struct multiboot_info multiboot_uint32_t mods_count; multiboot_uint32_t mods_addr; - multiboot_uint32_t syms[4]; + union + { + multiboot_aout_symbol_table_t aout_sym; + multiboot_elf_section_header_table_t elf_sec; + } u; /* Memory Mapping buffer */ multiboot_uint32_t mmap_length; @@ -167,6 +191,7 @@ struct multiboot_info multiboot_uint16_t vbe_interface_off; multiboot_uint16_t vbe_interface_len; }; +typedef struct multiboot_info multiboot_info_t; struct multiboot_mmap_entry { @@ -177,6 +202,7 @@ struct multiboot_mmap_entry #define MULTIBOOT_MEMORY_RESERVED 2 multiboot_uint32_t type; } __attribute__((packed)); +typedef struct multiboot_mmap_entry multiboot_memory_map_t; struct multiboot_mod_list { @@ -190,6 +216,7 @@ struct multiboot_mod_list /* padding to take it to 16 bytes (must be zero) */ multiboot_uint32_t pad; }; +typedef struct multiboot_mod_list multiboot_module_t; #endif /* ! ASM_FILE */ From d14d33704e369dea48451b1bef4681a8afa436b1 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 24 Dec 2009 14:19:22 +0000 Subject: [PATCH 066/208] 2009-12-24 Robert Millan * include/multiboot.h: Indentation fixes. --- ChangeLog | 4 ++++ include/multiboot.h | 36 ++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index a53f7085e..03a57d538 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-12-24 Robert Millan + + * include/multiboot.h: Indentation fixes. + 2009-12-24 Robert Millan * include/multiboot.h (struct multiboot_aout_symbol_table) diff --git a/include/multiboot.h b/include/multiboot.h index 41fac756c..587f50832 100644 --- a/include/multiboot.h +++ b/include/multiboot.h @@ -23,66 +23,66 @@ #define MULTIBOOT_HEADER 1 /* How many bytes from the start of the file we search for the header. */ -#define MULTIBOOT_SEARCH 8192 +#define MULTIBOOT_SEARCH 8192 /* The magic field should contain this. */ -#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 +#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 /* This should be in %eax. */ -#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 +#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 /* The bits in the required part of flags field we don't support. */ -#define MULTIBOOT_UNSUPPORTED 0x0000fffc +#define MULTIBOOT_UNSUPPORTED 0x0000fffc /* Alignment of multiboot modules. */ -#define MULTIBOOT_MOD_ALIGN 0x00001000 +#define MULTIBOOT_MOD_ALIGN 0x00001000 /* Alignment of the multiboot info structure. */ -#define MULTIBOOT_INFO_ALIGN 0x00000004 +#define MULTIBOOT_INFO_ALIGN 0x00000004 /* Flags set in the 'flags' member of the multiboot header. */ /* Align all boot modules on i386 page (4KB) boundaries. */ -#define MULTIBOOT_PAGE_ALIGN 0x00000001 +#define MULTIBOOT_PAGE_ALIGN 0x00000001 /* Must pass memory information to OS. */ -#define MULTIBOOT_MEMORY_INFO 0x00000002 +#define MULTIBOOT_MEMORY_INFO 0x00000002 /* Must pass video information to OS. */ -#define MULTIBOOT_VIDEO_MODE 0x00000004 +#define MULTIBOOT_VIDEO_MODE 0x00000004 /* This flag indicates the use of the address fields in the header. */ -#define MULTIBOOT_AOUT_KLUDGE 0x00010000 +#define MULTIBOOT_AOUT_KLUDGE 0x00010000 /* Flags to be set in the 'flags' member of the multiboot info structure. */ /* is there basic lower/upper memory information? */ -#define MULTIBOOT_INFO_MEMORY 0x00000001 +#define MULTIBOOT_INFO_MEMORY 0x00000001 /* is there a boot device set? */ -#define MULTIBOOT_INFO_BOOTDEV 0x00000002 +#define MULTIBOOT_INFO_BOOTDEV 0x00000002 /* is the command-line defined? */ -#define MULTIBOOT_INFO_CMDLINE 0x00000004 +#define MULTIBOOT_INFO_CMDLINE 0x00000004 /* are there modules to do something with? */ -#define MULTIBOOT_INFO_MODS 0x00000008 +#define MULTIBOOT_INFO_MODS 0x00000008 /* These next two are mutually exclusive */ /* is there a symbol table loaded? */ #define MULTIBOOT_INFO_AOUT_SYMS 0x00000010 /* is there an ELF section header table? */ -#define MULTIBOOT_INFO_ELF_SHDR 0x00000020 +#define MULTIBOOT_INFO_ELF_SHDR 0X00000020 /* is there a full memory map? */ -#define MULTIBOOT_INFO_MEM_MAP 0x00000040 +#define MULTIBOOT_INFO_MEM_MAP 0x00000040 /* Is there drive info? */ #define MULTIBOOT_INFO_DRIVE_INFO 0x00000080 /* Is there a config table? */ -#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100 +#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100 /* Is there a boot loader name? */ -#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200 +#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200 /* Is there a APM table? */ #define MULTIBOOT_INFO_APM_TABLE 0x00000400 From 2e7138317249dfe3fe61c1b23beca1cbc75a003d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Dec 2009 15:34:33 +0100 Subject: [PATCH 067/208] Core changes hopefully finished --- commands/help.c | 2 +- include/grub/charset.h | 6 + include/grub/menu_viewer.h | 17 +- include/grub/misc.h | 10 +- include/grub/normal.h | 20 +- include/grub/term.h | 136 +++++-- kern/misc.c | 13 +- kern/term.c | 25 +- lib/charset.c | 91 ++++- normal/auth.c | 50 ++- normal/cmdline.c | 113 ++++-- normal/color.c | 8 +- normal/main.c | 43 +-- normal/menu.c | 385 ++++++++++++++++++++ normal/menu_entry.c | 659 +++++++++++++++++++++------------- normal/menu_text.c | 704 ++++++++++++------------------------- normal/menu_viewer.c | 55 --- normal/term.c | 88 ++--- term/efi/console.c | 2 +- term/i386/pc/console.c | 2 +- term/i386/pc/vga_text.c | 7 + term/ieee1275/ofconsole.c | 2 +- util/console.c | 2 +- 23 files changed, 1493 insertions(+), 947 deletions(-) diff --git a/commands/help.c b/commands/help.c index 4d16945af..5e8f0b27a 100644 --- a/commands/help.c +++ b/commands/help.c @@ -41,7 +41,7 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, int desclen = grub_strlen (cmd->summary); for (cur = grub_term_outputs; cur; cur = cur->next) { - if (!(cur->flags & GRUB_TERM_ACTIVE)) + if (!grub_term_is_active (cur)) continue; int width = grub_term_width(cur); char description[width / 2]; diff --git a/include/grub/charset.h b/include/grub/charset.h index daaa5c99f..fc050da24 100644 --- a/include/grub/charset.h +++ b/include/grub/charset.h @@ -112,4 +112,10 @@ grub_utf16_to_utf8 (grub_uint8_t *dest, grub_uint16_t *src, /* Convert UCS-4 to UTF-8. */ char *grub_ucs4_to_utf8_alloc (grub_uint32_t *src, grub_size_t size); +int +grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize); + +int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg, + grub_uint32_t **last_position); + #endif diff --git a/include/grub/menu_viewer.h b/include/grub/menu_viewer.h index 725c97548..3821219a3 100644 --- a/include/grub/menu_viewer.h +++ b/include/grub/menu_viewer.h @@ -27,17 +27,18 @@ struct grub_menu_viewer { - /* The menu viewer name. */ - const char *name; - - grub_err_t (*show_menu) (grub_menu_t menu, int nested); - struct grub_menu_viewer *next; + void *data; + void (*set_chosen_entry) (int entry, void *data); + void (*print_timeout) (int timeout, void *data); + void (*clear_timeout) (void *data); + void (*fini) (void *fini); }; -typedef struct grub_menu_viewer *grub_menu_viewer_t; -void grub_menu_viewer_register (grub_menu_viewer_t viewer); +void grub_menu_register_viewer (struct grub_menu_viewer *viewer); -grub_err_t grub_menu_viewer_show_menu (grub_menu_t menu, int nested); +grub_err_t grub_menu_register_viewer_init (void (*callback) (int entry, + grub_menu_t menu, + int nested)); #endif /* GRUB_MENU_VIEWER_HEADER */ diff --git a/include/grub/misc.h b/include/grub/misc.h index 92fb460cf..9c3193f88 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -183,11 +183,11 @@ int EXPORT_FUNC(grub_sprintf) (char *str, const char *fmt, ...) __attribute__ (( int EXPORT_FUNC(grub_vsprintf) (char *str, const char *fmt, va_list args); void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn)); -grub_ssize_t EXPORT_FUNC(grub_utf8_to_ucs4) (grub_uint32_t *dest, - grub_size_t destsize, - const grub_uint8_t *src, - grub_size_t srcsize, - const grub_uint8_t **srcend); +grub_size_t EXPORT_FUNC(grub_utf8_to_ucs4) (grub_uint32_t *dest, + grub_size_t destsize, + const grub_uint8_t *src, + grub_size_t srcsize, + const grub_uint8_t **srcend); grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, grub_uint32_t d, grub_uint32_t *r); diff --git a/include/grub/normal.h b/include/grub/normal.h index 33c30b22a..91457fc09 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -51,15 +51,16 @@ extern struct grub_menu_viewer grub_normal_text_menu_viewer; /* Defined in `main.c'. */ void grub_enter_normal_mode (const char *config); void grub_normal_execute (const char *config, int nested, int batch); +void grub_menu_init_page (int nested, int edit, + struct grub_term_output *term); void grub_normal_init_page (struct grub_term_output *term); -void grub_menu_init_page (int nested, int edit); grub_err_t grub_normal_add_menu_entry (int argc, const char **args, const char *sourcecode); char *grub_file_getline (grub_file_t file); void grub_cmdline_run (int nested); /* Defined in `cmdline.c'. */ -char *grub_cmdline_get (const char *prompt, unsigned max_len); +char *grub_cmdline_get (const char *prompt); grub_err_t grub_set_history (int newsize); /* Defined in `completion.c'. */ @@ -76,14 +77,19 @@ void grub_parse_color_name_pair (grub_uint8_t *ret, const char *name); /* Defined in `menu_text.c'. */ void grub_wait_after_message (void); -int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg, - grub_uint32_t **last_position); void grub_print_ucs4 (const grub_uint32_t * str, - const grub_uint32_t * last_position); + const grub_uint32_t * last_position, + struct grub_term_output *term); grub_ssize_t grub_getstringwidth (grub_uint32_t * str, - const grub_uint32_t * last_position); + const grub_uint32_t * last_position, + struct grub_term_output *term); void grub_print_message_indented (const char *msg, int margin_left, - int margin_right); + int margin_right, + struct grub_term_output *term); +void +grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested); +grub_err_t +grub_show_menu (grub_menu_t menu, int nested); /* Defined in `handler.c'. */ void read_handler_list (void); diff --git a/include/grub/term.h b/include/grub/term.h index 39a10ed71..a0b96b497 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -111,37 +111,12 @@ grub_term_color_state; /* The X position of the left border. */ #define GRUB_TERM_LEFT_BORDER_X GRUB_TERM_MARGIN -/* The width of the border. */ -#define GRUB_TERM_BORDER_WIDTH (GRUB_TERM_WIDTH \ - - GRUB_TERM_MARGIN * 3 \ - - GRUB_TERM_SCROLL_WIDTH) - /* The number of lines of messages at the bottom. */ #define GRUB_TERM_MESSAGE_HEIGHT 8 -/* The height of the border. */ -#define GRUB_TERM_BORDER_HEIGHT (GRUB_TERM_HEIGHT \ - - GRUB_TERM_TOP_BORDER_Y \ - - GRUB_TERM_MESSAGE_HEIGHT) - -/* The number of entries shown at a time. */ -#define GRUB_TERM_NUM_ENTRIES (GRUB_TERM_BORDER_HEIGHT - 2) - /* The Y position of the first entry. */ #define GRUB_TERM_FIRST_ENTRY_Y (GRUB_TERM_TOP_BORDER_Y + 1) -/* The max column number of an entry. The last "-1" is for a - continuation marker. */ -#define GRUB_TERM_ENTRY_WIDTH (GRUB_TERM_BORDER_WIDTH - 2 \ - - GRUB_TERM_MARGIN * 2 - 1) - -/* The standard X position of the cursor. */ -#define GRUB_TERM_CURSOR_X (GRUB_TERM_LEFT_BORDER_X \ - + GRUB_TERM_BORDER_WIDTH \ - - GRUB_TERM_MARGIN \ - - 1) - - struct grub_term_input { /* The next terminal. */ @@ -277,16 +252,123 @@ void grub_puts_terminal (const char *str, struct grub_term_output *term); grub_uint16_t *grub_term_save_pos (void); void grub_term_restore_pos (grub_uint16_t *pos); -static inline int grub_term_width (struct grub_term_output *term) +static inline unsigned grub_term_width (struct grub_term_output *term) { return ((term->getwh()&0xFF00)>>8); } -static inline int grub_term_height (struct grub_term_output *term) +static inline unsigned grub_term_height (struct grub_term_output *term) { return (term->getwh()&0xFF); } +/* The width of the border. */ +static inline unsigned +grub_term_border_width (struct grub_term_output *term) +{ + return grub_term_width (term) - GRUB_TERM_MARGIN * 3 - GRUB_TERM_SCROLL_WIDTH; +} + +/* The max column number of an entry. The last "-1" is for a + continuation marker. */ +static inline int +grub_term_entry_width (struct grub_term_output *term) +{ + return grub_term_border_width (term) - 2 - GRUB_TERM_MARGIN * 2 - 1; +} + +/* The height of the border. */ + +static inline unsigned +grub_term_border_height (struct grub_term_output *term) +{ + return grub_term_height (term) - GRUB_TERM_TOP_BORDER_Y + - GRUB_TERM_MESSAGE_HEIGHT; +} + +/* The number of entries shown at a time. */ +static inline int +grub_term_num_entries (struct grub_term_output *term) +{ + return grub_term_border_height (term) - 2; +} + +static inline int +grub_term_cursor_x (struct grub_term_output *term) +{ + return (GRUB_TERM_LEFT_BORDER_X + grub_term_border_width (term) + - GRUB_TERM_MARGIN - 1); +} + +static inline grub_uint16_t +grub_term_getxy (struct grub_term_output *term) +{ + return term->getxy (); +} + +static inline void +grub_term_refresh (struct grub_term_output *term) +{ + if (term->refresh) + term->refresh (); +} + +static inline void +grub_term_gotoxy (struct grub_term_output *term, grub_uint8_t x, grub_uint8_t y) +{ + term->gotoxy (x, y); +} + +static inline void +grub_term_setcolorstate (struct grub_term_output *term, + grub_term_color_state state) +{ + if (term->setcolorstate) + term->setcolorstate (state); +} + + /* Set the normal color and the highlight color. The format of each + color is VGA's. */ +static inline void +grub_term_setcolor (struct grub_term_output *term, + grub_uint8_t normal_color, grub_uint8_t highlight_color) +{ + if (term->setcolor) + term->setcolor (normal_color, highlight_color); +} + +/* Turn on/off the cursor. */ +static inline void +grub_term_setcursor (struct grub_term_output *term, int on) +{ + if (term->setcursor) + term->setcursor (on); +} + +static inline int +grub_term_is_active (struct grub_term_output *term) +{ + return !!(term->flags & GRUB_TERM_ACTIVE); +} + +static inline grub_ssize_t +grub_term_getcharwidth (struct grub_term_output *term, grub_uint32_t c) +{ + if (term->getcharwidth) + return term->getcharwidth (c); + else + return 1; +} + +static inline void +grub_term_getcolor (struct grub_term_output *term, + grub_uint8_t *normal_color, grub_uint8_t *highlight_color) +{ + term->getcolor (normal_color, highlight_color); +} + +extern void (*EXPORT_VAR (grub_newline_hook)) (void); + /* For convenience. */ #define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff) diff --git a/kern/misc.c b/kern/misc.c index 7dd9bd18a..ef782f5dd 100644 --- a/kern/misc.c +++ b/kern/misc.c @@ -882,10 +882,10 @@ grub_sprintf (char *str, const char *fmt, ...) /* Convert a (possibly null-terminated) UTF-8 string of at most SRCSIZE bytes (if SRCSIZE is -1, it is ignored) in length to a UCS-4 string. Return the number of characters converted. DEST must be able to hold - at least DESTSIZE characters. If an invalid sequence is found, return -1. + at least DESTSIZE characters. If SRCEND is not NULL, then *SRCEND is set to the next byte after the last byte used in SRC. */ -grub_ssize_t +grub_size_t grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize, const grub_uint8_t *src, grub_size_t srcsize, const grub_uint8_t **srcend) @@ -907,7 +907,8 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize, if ((c & 0xc0) != 0x80) { /* invalid */ - return -1; + code = '?'; + count = 0; } else { @@ -949,7 +950,11 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize, code = c & 0x01; } else - return -1; + { + /* invalid */ + code = '?'; + count = 0; + } } if (count == 0) diff --git a/kern/term.c b/kern/term.c index 35660273e..b71c12334 100644 --- a/kern/term.c +++ b/kern/term.c @@ -31,13 +31,15 @@ struct grub_handler_class grub_term_input_class = struct grub_term_output *grub_term_outputs; +void (*grub_newline_hook) (void) = NULL; + /* Put a Unicode character. */ void grub_putcode (grub_uint32_t code, struct grub_term_output *term) { int height; - height = term->getwh () & 255; + height = grub_term_height (term); if (code == '\t' && term->getxy) { @@ -50,6 +52,8 @@ grub_putcode (grub_uint32_t code, struct grub_term_output *term) return; } + if (code == '\n') + (term->putchar) ('\r'); (term->putchar) (code); } @@ -68,7 +72,7 @@ grub_putchar (int c) { struct grub_term_output *term = (struct grub_term_output *) item; - if (term->flags & GRUB_TERM_ACTIVE) + if (grub_term_is_active (term)) grub_putcode (code, term); return 0; @@ -77,14 +81,13 @@ grub_putchar (int c) buf[size++] = c; ret = grub_utf8_to_ucs4 (&code, 1, buf, size, 0); - if (ret < 0) - code = '?'; - if (ret != 0) { size = 0; grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), do_putcode); } + if (ret == '\n' && grub_newline_hook) + grub_newline_hook (); } int @@ -116,7 +119,7 @@ grub_cls (void) { struct grub_term_output *term = (struct grub_term_output *) item; - if (!(term->flags & GRUB_TERM_ACTIVE)) + if (! grub_term_is_active (term)) return 0; if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug"))) @@ -141,11 +144,10 @@ grub_setcolorstate (grub_term_color_state state) { struct grub_term_output *term = (struct grub_term_output *) item; - if (!(term->flags & GRUB_TERM_ACTIVE)) + if (! grub_term_is_active (term)) return 0; - if (term->setcolorstate) - (term->setcolorstate) (state); + grub_term_setcolorstate (term, state); return 0; } @@ -161,11 +163,10 @@ grub_refresh (void) { struct grub_term_output *term = (struct grub_term_output *) item; - if (!(term->flags & GRUB_TERM_ACTIVE)) + if (!grub_term_is_active (term)) return 0; - if (term->refresh) - (term->refresh) (); + grub_term_refresh (term); return 0; } diff --git a/lib/charset.c b/lib/charset.c index 0f2c2c8ee..f2e1b036d 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -24,6 +24,8 @@ last byte used in SRC. */ #include +#include +#include grub_ssize_t grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize, @@ -176,5 +178,92 @@ grub_ucs4_to_utf8_alloc (grub_uint32_t *src, grub_size_t size) } *dest = 0; - return ret; + return (char *) ret; +} + +int +grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize) +{ + grub_uint32_t code = 0; + int count = 0; + + while (srcsize) + { + grub_uint32_t c = *src++; + if (srcsize != (grub_size_t)-1) + srcsize--; + if (count) + { + if ((c & 0xc0) != 0x80) + { + /* invalid */ + return 0; + } + else + { + code <<= 6; + code |= (c & 0x3f); + count--; + } + } + else + { + if (c == 0) + break; + + if ((c & 0x80) == 0x00) + code = c; + else if ((c & 0xe0) == 0xc0) + { + count = 1; + code = c & 0x1f; + } + else if ((c & 0xf0) == 0xe0) + { + count = 2; + code = c & 0x0f; + } + else if ((c & 0xf8) == 0xf0) + { + count = 3; + code = c & 0x07; + } + else if ((c & 0xfc) == 0xf8) + { + count = 4; + code = c & 0x03; + } + else if ((c & 0xfe) == 0xfc) + { + count = 5; + code = c & 0x01; + } + else + return 0; + } + } + + return 1; +} + +int +grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg, + grub_uint32_t **last_position) +{ + grub_size_t msg_len = grub_strlen (msg); + + *unicode_msg = grub_malloc (grub_strlen (msg) * sizeof (grub_uint32_t)); + + if (!*unicode_msg) + { + grub_printf ("utf8_to_ucs4 ERROR1: %s", msg); + return -1; + } + + msg_len = grub_utf8_to_ucs4 (*unicode_msg, msg_len, + (grub_uint8_t *) msg, -1, 0); + + *last_position = *unicode_msg + msg_len; + + return msg_len; } diff --git a/normal/auth.c b/normal/auth.c index 240a77aee..156b84c37 100644 --- a/normal/auth.c +++ b/normal/auth.c @@ -154,6 +154,49 @@ is_authenticated (const char *userlist) return grub_list_iterate (GRUB_AS_LIST (users), hook); } +static int +grub_username_get (char buf[], unsigned buf_size) +{ + unsigned cur_len = 0; + int key; + + while (1) + { + key = GRUB_TERM_ASCII_CHAR (grub_getkey ()); + if (key == '\n' || key == '\r') + break; + + if (key == '\e') + { + cur_len = 0; + break; + } + + if (key == '\b') + { + cur_len--; + grub_printf ("\b"); + continue; + } + + if (!grub_isprint (key)) + continue; + + if (cur_len + 2 < buf_size) + { + buf[cur_len++] = key; + grub_putchar (key); + } + } + + grub_memset (buf + cur_len, 0, buf_size - cur_len); + + grub_putchar ('\n'); + grub_refresh (); + + return (key != '\e'); +} + grub_err_t grub_auth_check_authentication (const char *userlist) { @@ -187,11 +230,12 @@ grub_auth_check_authentication (const char *userlist) return GRUB_ERR_NONE; } - if (!grub_cmdline_get (N_("Enter username:"), login, sizeof (login) - 1, - 0, 0, 0)) + grub_puts_ (N_("Enter username: ")); + + if (!grub_username_get (login, sizeof (login) - 1)) goto access_denied; - grub_printf ("Enter password: "); + grub_puts_ (N_("Enter password: ")); if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN)) goto access_denied; diff --git a/normal/cmdline.c b/normal/cmdline.c index c104709c5..1412a6d6a 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -27,6 +27,7 @@ #include #include #include +#include static grub_uint32_t *kill_buf; @@ -211,11 +212,12 @@ struct cmdline_term otherwise return command line. */ /* FIXME: The dumb interface is not supported yet. */ char * -grub_cmdline_get (const char *prompt, unsigned max_len) +grub_cmdline_get (const char *prompt) { grub_size_t lpos, llen; grub_size_t plen; - grub_uint32_t buf[max_len]; + grub_uint32_t *buf; + grub_size_t max_len = 256; int key; int histpos = 0; auto void cl_insert (const grub_uint32_t *str); @@ -226,13 +228,14 @@ grub_cmdline_get (const char *prompt, unsigned max_len) auto void cl_set_pos_all (void); const char *prompt_translated = _(prompt); struct cmdline_term *cl_terms; + char *ret; unsigned nterms; void cl_set_pos (struct cmdline_term *cl_term) { cl_term->xpos = (plen + lpos) % (cl_term->width - 1); cl_term->ypos = cl_term->ystart + (plen + lpos) / (cl_term->width - 1); - cl_term->term->gotoxy (cl_term->xpos, cl_term->ypos); + grub_term_gotoxy (cl_term->term, cl_term->xpos, cl_term->ypos); } void cl_set_pos_all () @@ -246,7 +249,7 @@ grub_cmdline_get (const char *prompt, unsigned max_len) { grub_uint32_t *p; - for (p = buf + pos; *p; p++) + for (p = buf + pos; p < buf + llen; p++) { if (cl_term->xpos++ > cl_term->width - 2) { @@ -277,14 +280,30 @@ grub_cmdline_get (const char *prompt, unsigned max_len) { grub_size_t len = strlen_ucs4 (str); + if (len + llen >= max_len) + { + grub_uint32_t *nbuf; + max_len *= 2; + nbuf = grub_realloc (buf, sizeof (grub_uint32_t) * max_len); + if (nbuf) + buf = nbuf; + else + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + max_len /= 2; + } + } + if (len + llen < max_len) { - grub_memmove (buf + lpos + len, buf + lpos, llen - lpos + 1); - grub_memmove (buf + lpos, str, len); + grub_memmove (buf + lpos + len, buf + lpos, + (llen - lpos + 1) * sizeof (grub_uint32_t)); + grub_memmove (buf + lpos, str, len * sizeof (grub_uint32_t)); llen += len; lpos += len; - cl_print_all (lpos - len, echo_char); + cl_print_all (lpos - len, 0); cl_set_pos_all (); } @@ -305,7 +324,7 @@ grub_cmdline_get (const char *prompt, unsigned max_len) grub_memmove (buf + lpos, buf + lpos + len, llen - lpos + 1); llen -= len; - cl_print_all (lpos, echo_char); + cl_print_all (lpos, 0); cl_set_pos_all (); } @@ -315,7 +334,7 @@ grub_cmdline_get (const char *prompt, unsigned max_len) void init_clterm (struct cmdline_term *cl_term_cur) { cl_term_cur->xpos = plen; - cl_term_cur->ypos = (cl_term_cur->term->getxy () & 0xFF); + cl_term_cur->ypos = (grub_term_getxy (cl_term_cur->term) & 0xFF); cl_term_cur->ystart = cl_term_cur->ypos; cl_term_cur->width = grub_term_width (cl_term_cur->term); cl_term_cur->height = grub_term_height (cl_term_cur->term); @@ -328,6 +347,10 @@ grub_cmdline_get (const char *prompt, unsigned max_len) init_clterm (&cl_terms[i]); } + buf = grub_malloc (max_len * sizeof (grub_uint32_t)); + if (!buf) + return 0; + plen = grub_strlen (prompt_translated); lpos = llen = 0; buf[0] = '\0'; @@ -341,15 +364,15 @@ grub_cmdline_get (const char *prompt, unsigned max_len) struct grub_term_output *cur; nterms = 0; for (cur = grub_term_outputs; cur; cur = cur->next) - if (cur->flags & GRUB_TERM_ACTIVE) + if (grub_term_is_active (cur)) nterms++; cl_terms = grub_malloc (sizeof (cl_terms[0]) * nterms); if (!cl_terms) - return grub_errno; + return 0; cl_term_cur = cl_terms; for (cur = grub_term_outputs; cur; cur = cur->next) - if (cur->flags & GRUB_TERM_ACTIVE) + if (grub_term_is_active (cur)) { cl_term_cur->term = cur; init_clterm (cl_term_cur); @@ -357,7 +380,7 @@ grub_cmdline_get (const char *prompt, unsigned max_len) } } - if (history && hist_used == 0) + if (hist_used == 0) grub_history_add (buf); while ((key = GRUB_TERM_ASCII_CHAR (grub_getkey ())) != '\n' && key != '\r') @@ -394,17 +417,38 @@ grub_cmdline_get (const char *prompt, unsigned max_len) { grub_uint32_t *insert; int restore; + char *bufu8, *insertu8; + grub_size_t insertlen; + grub_size_t t; - /* Backup the next character and make it 0 so it will - be easy to use string functions. */ - char backup = buf[lpos]; buf[lpos] = '\0'; + bufu8 = grub_ucs4_to_utf8_alloc (buf, lpos); + if (!bufu8) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + break; + } - insert = grub_normal_do_completion (buf, &restore, - print_completion); - /* Restore the original string. */ - buf[lpos] = backup; + insertu8 = grub_normal_do_completion (bufu8, &restore, + print_completion); + grub_free (bufu8); + insertlen = grub_strlen (bufu8); + insert = grub_malloc ((insertlen + 1) * sizeof (grub_uint32_t)); + if (!insert) + { + grub_free (insertu8); + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + break; + } + t = grub_utf8_to_ucs4 (insert, insertlen, + (grub_uint8_t *) insertu8, + insertlen, 0); + insert[t] = 0; + + grub_free (insertu8); if (restore) { @@ -429,7 +473,11 @@ grub_cmdline_get (const char *prompt, unsigned max_len) grub_free (kill_buf); kill_buf = strdup_ucs4 (buf + lpos); - grub_errno = GRUB_ERR_NONE; + if (grub_errno) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + } cl_delete (llen - lpos); } @@ -481,7 +529,11 @@ grub_cmdline_get (const char *prompt, unsigned max_len) grub_free (kill_buf); kill_buf = grub_malloc (n + 1); - grub_errno = GRUB_ERR_NONE; + if (grub_errno) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + } if (kill_buf) { grub_memcpy (kill_buf, buf, n); @@ -538,16 +590,15 @@ grub_cmdline_get (const char *prompt, unsigned max_len) while (buf[lpos] == ' ') lpos++; - if (history) + histpos = 0; + if (strlen_ucs4 (buf) > 0) { - histpos = 0; - if (strlen_ucs4 (buf) > 0) - { - grub_uint32_t empty[] = { 0 }; - grub_history_replace (histpos, buf); - grub_history_add (empty); - } + grub_uint32_t empty[] = { 0 }; + grub_history_replace (histpos, buf); + grub_history_add (empty); } - return grub_ucs4_to_utf8_alloc (buf + lpos, llen - lpos + 1); + ret = grub_ucs4_to_utf8_alloc (buf + lpos, llen - lpos + 1); + grub_free (buf); + return ret; } diff --git a/normal/color.c b/normal/color.c index 63bd889a5..80a285787 100644 --- a/normal/color.c +++ b/normal/color.c @@ -112,16 +112,14 @@ set_colors (void) for (term = grub_term_outputs; term; term = term->next) { - if (! (term->flags & GRUB_TERM_ACTIVE)) + if (! grub_term_is_active (term)) continue; /* Reloads terminal `normal' and `highlight' colors. */ - if (term->setcolor) - term->setcolor (color_normal, color_highlight); + grub_term_setcolor (term, color_normal, color_highlight); /* Propagates `normal' color to terminal current color. */ - if (term->setcolorstate) - term->setcolorstate (GRUB_TERM_COLOR_NORMAL); + grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); } } diff --git a/normal/main.c b/normal/main.c index 0dab9e09e..b490f49e5 100644 --- a/normal/main.c +++ b/normal/main.c @@ -30,6 +30,7 @@ #include #include #include +#include #define GRUB_DEFAULT_HISTORY_SIZE 50 @@ -420,11 +421,11 @@ grub_normal_init_page (struct grub_term_output *term) return; } - posx = grub_getstringwidth (unicode_msg, last_position); + posx = grub_getstringwidth (unicode_msg, last_position, term); posx = (grub_term_width (term) - posx) / 2; - term->gotoxy (posx, 1); + grub_term_gotoxy (term, posx, 1); - grub_print_ucs4 (unicode_msg, last_position); + grub_print_ucs4 (unicode_msg, last_position, term); grub_printf("\n\n"); grub_free (unicode_msg); } @@ -458,7 +459,7 @@ grub_normal_execute (const char *config, int nested, int batch) { if (menu && menu->size) { - grub_menu_viewer_show_menu (menu, nested); + grub_show_menu (menu, nested); if (nested) free_menu (menu); } @@ -470,20 +471,19 @@ void grub_enter_normal_mode (const char *config) { grub_normal_execute (config, 0, 0); + grub_cmdline_run (1); } /* Enter normal mode from rescue mode. */ static grub_err_t -grub_cmd_normal (struct grub_command *cmd, +grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), int argc, char *argv[]) { - grub_unregister_command (cmd); - if (argc == 0) { /* Guess the config filename. It is necessary to make CONFIG static, so that it won't get broken by longjmp. */ - static char *config; + char *config; const char *prefix; prefix = grub_env_get ("prefix"); @@ -525,10 +525,9 @@ grub_normal_reader_init (void) if (! (term->flags & GRUB_TERM_ACTIVE)) continue; grub_normal_init_page (term); - if (term->setcursor) - term->setcursor (1); + grub_term_setcursor (term, 1); - grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN); + grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN, term); grub_puts ("\n"); } grub_free (msg_formatted); @@ -536,7 +535,6 @@ grub_normal_reader_init (void) return 0; } -static char cmdline[GRUB_MAX_CMDLINE]; static grub_err_t grub_normal_read_line (char **line, int cont) @@ -548,18 +546,18 @@ grub_normal_read_line (char **line, int cont) while (1) { - cmdline[0] = 0; - if (grub_cmdline_get (prompt, cmdline, sizeof (cmdline), 0, 1, 1)) + *line = grub_cmdline_get (prompt); + if (*line) break; if ((reader_nested) || (cont)) { + grub_free (*line); *line = 0; return grub_errno; } } - *line = grub_strdup (cmdline); return 0; } @@ -591,7 +589,7 @@ grub_cmdline_run (int nested) grub_normal_read_line (&line, 0); if (! line) - continue; + break; grub_parser_get_current ()->parse_line (line, grub_normal_read_line); grub_free (line); @@ -612,15 +610,20 @@ GRUB_MOD_INIT(normal) if (mod) grub_dl_ref (mod); - grub_menu_viewer_register (&grub_normal_text_menu_viewer); - grub_set_history (GRUB_DEFAULT_HISTORY_SIZE); + grub_menu_register_viewer_init (grub_menu_text_register_instances); + if (grub_errno) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + } + grub_register_variable_hook ("pager", 0, grub_env_write_pager); /* Register a command "normal" for the rescue mode. */ - grub_register_command_prio ("normal", grub_cmd_normal, - 0, "Enter normal mode", 0); + grub_register_command ("normal", grub_cmd_normal, + 0, "Enter normal mode"); /* Reload terminal colors when these variables are written to. */ grub_register_variable_hook ("color_normal", NULL, grub_env_write_color_normal); diff --git a/normal/menu.c b/normal/menu.c index 8ee7d1c22..824779db6 100644 --- a/normal/menu.c +++ b/normal/menu.c @@ -27,6 +27,30 @@ #include #include #include +#include + +/* Time to delay after displaying an error message about a default/fallback + entry failing to boot. */ +#define DEFAULT_ENTRY_ERROR_DELAY_MS 2500 + +struct menu_run_callback +{ + struct menu_run_callback *next; + void (*hook) (int entry, grub_menu_t menu, int nested); +}; + +struct menu_run_callback *callbacks = NULL; + +/* Wait until the user pushes any key so that the user + can see what happened. */ +void +grub_wait_after_message (void) +{ + grub_putchar ('\n'); + grub_printf_ (N_("Press any key to continue...")); + (void) grub_getkey (); + grub_putchar ('\n'); +} /* Get a menu entry by its index in the entry list. */ grub_menu_entry_t @@ -178,3 +202,364 @@ grub_menu_execute_with_fallback (grub_menu_t menu, callback->notify_failure (callback_data); } + +static struct grub_menu_viewer *viewers; + +static void +menu_set_chosen_entry (int entry) +{ + struct grub_menu_viewer *cur; + for (cur = viewers; cur; cur = cur->next) + cur->set_chosen_entry (entry, cur->data); +} + +static void +menu_print_timeout (int timeout) +{ + struct grub_menu_viewer *cur; + for (cur = viewers; cur; cur = cur->next) + cur->print_timeout (timeout, cur->data); +} + +static void +menu_fini (void) +{ + struct grub_menu_viewer *cur, *next; + for (cur = viewers; cur; cur = next) + { + next = cur->next; + cur->fini (cur->data); + grub_free (cur); + } + viewers = NULL; +} + +static void +menu_init (int entry, grub_menu_t menu, int nested) +{ + struct menu_run_callback *cb; + for (cb = callbacks; cb; cb = cb->next) + cb->hook (entry, menu, nested); +} + +static void +clear_timeout (void) +{ + struct grub_menu_viewer *cur; + for (cur = viewers; cur; cur = cur->next) + cur->clear_timeout (cur->data); +} + +void +grub_menu_register_viewer (struct grub_menu_viewer *viewer) +{ + viewer->next = viewers; + viewers = viewer; +} + +grub_err_t +grub_menu_register_viewer_init (void (*callback) (int entry, grub_menu_t menu, + int nested)) +{ + struct menu_run_callback *cb; + cb = grub_malloc (sizeof (*cb)); + if (!cb) + return grub_errno; + cb->hook = callback; + cb->next = callbacks; + callbacks = cb; + return GRUB_ERR_NONE; +} + +/* Get the entry number from the variable NAME. */ +static int +get_entry_number (const char *name) +{ + char *val; + int entry; + + val = grub_env_get (name); + if (! val) + return -1; + + grub_error_push (); + + entry = (int) grub_strtoul (val, 0, 0); + + if (grub_errno != GRUB_ERR_NONE) + { + grub_errno = GRUB_ERR_NONE; + entry = -1; + } + + grub_error_pop (); + + return entry; +} + +#define GRUB_MENU_PAGE_SIZE 10 + +/* Show the menu and handle menu entry selection. Returns the menu entry + index that should be executed or -1 if no entry should be executed (e.g., + Esc pressed to exit a sub-menu or switching menu viewers). + If the return value is not -1, then *AUTO_BOOT is nonzero iff the menu + entry to be executed is a result of an automatic default selection because + of the timeout. */ +static int +run_menu (grub_menu_t menu, int nested, int *auto_boot) +{ + grub_uint64_t saved_time; + int default_entry, current_entry; + int timeout; + + default_entry = get_entry_number ("default"); + + /* If DEFAULT_ENTRY is not within the menu entries, fall back to + the first entry. */ + if (default_entry < 0 || default_entry >= menu->size) + default_entry = 0; + + /* If timeout is 0, drawing is pointless (and ugly). */ + if (grub_menu_get_timeout () == 0) + { + *auto_boot = 1; + return default_entry; + } + + current_entry = default_entry; + + /* Initialize the time. */ + saved_time = grub_get_time_ms (); + + refresh: + menu_init (current_entry, menu, nested); + + timeout = grub_menu_get_timeout (); + + if (timeout > 0) + menu_print_timeout (timeout); + + while (1) + { + int c; + timeout = grub_menu_get_timeout (); + + if (timeout > 0) + { + grub_uint64_t current_time; + + current_time = grub_get_time_ms (); + if (current_time - saved_time >= 1000) + { + timeout--; + grub_menu_set_timeout (timeout); + saved_time = current_time; + menu_print_timeout (timeout); + } + } + + if (timeout == 0) + { + grub_env_unset ("timeout"); + *auto_boot = 1; + menu_fini (); + return default_entry; + } + + if (grub_checkkey () >= 0 || timeout < 0) + { + c = GRUB_TERM_ASCII_CHAR (grub_getkey ()); + + if (timeout >= 0) + { + grub_env_unset ("timeout"); + grub_env_unset ("fallback"); + clear_timeout (); + } + + switch (c) + { + case GRUB_TERM_HOME: + current_entry = 0; + menu_set_chosen_entry (current_entry); + break; + + case GRUB_TERM_END: + current_entry = menu->size - 1; + menu_set_chosen_entry (current_entry); + break; + + case GRUB_TERM_UP: + case '^': + current_entry--; + menu_set_chosen_entry (current_entry); + break; + + case GRUB_TERM_DOWN: + case 'v': + current_entry++; + menu_set_chosen_entry (current_entry); + break; + + case GRUB_TERM_PPAGE: + if (current_entry < GRUB_MENU_PAGE_SIZE) + current_entry = 0; + else + current_entry -= GRUB_MENU_PAGE_SIZE; + menu_set_chosen_entry (current_entry); + break; + + case GRUB_TERM_NPAGE: + if (current_entry + GRUB_MENU_PAGE_SIZE < menu->size) + current_entry = 0; + else + current_entry += GRUB_MENU_PAGE_SIZE; + menu_set_chosen_entry (current_entry); + break; + + case '\n': + case '\r': + case 6: + menu_fini (); + *auto_boot = 0; + return current_entry; + + case '\e': + if (nested) + { + menu_fini (); + return -1; + } + break; + + case 'c': + grub_cmdline_run (1); + goto refresh; + + case 'e': + { + grub_menu_entry_t e = grub_menu_get_entry (menu, current_entry); + if (e) + grub_menu_entry_run (e); + } + goto refresh; + + default: + break; + } + } + } + + /* Never reach here. */ + return -1; +} + +/* Callback invoked immediately before a menu entry is executed. */ +static void +notify_booting (grub_menu_entry_t entry, + void *userdata __attribute__((unused))) +{ + grub_printf (" "); + grub_printf_ (N_("Booting \'%s\'"), entry->title); + grub_printf ("\n\n"); +} + +/* Callback invoked when a default menu entry executed because of a timeout + has failed and an attempt will be made to execute the next fallback + entry, ENTRY. */ +static void +notify_fallback (grub_menu_entry_t entry, + void *userdata __attribute__((unused))) +{ + grub_printf ("\n "); + grub_printf_ (N_("Falling back to \'%s\'"), entry->title); + grub_printf ("\n\n"); + grub_millisleep (DEFAULT_ENTRY_ERROR_DELAY_MS); +} + +/* Callback invoked when a menu entry has failed and there is no remaining + fallback entry to attempt. */ +static void +notify_execution_failure (void *userdata __attribute__((unused))) +{ + if (grub_errno != GRUB_ERR_NONE) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + } + grub_printf ("\n "); + grub_printf_ (N_("Failed to boot default entries.\n")); + grub_wait_after_message (); +} + +/* Callbacks used by the text menu to provide user feedback when menu entries + are executed. */ +static struct grub_menu_execute_callback execution_callback = +{ + .notify_booting = notify_booting, + .notify_fallback = notify_fallback, + .notify_failure = notify_execution_failure +}; + +static grub_err_t +show_menu (grub_menu_t menu, int nested) +{ + while (1) + { + int boot_entry; + grub_menu_entry_t e; + int auto_boot; + + boot_entry = run_menu (menu, nested, &auto_boot); + if (boot_entry < 0) + break; + + e = grub_menu_get_entry (menu, boot_entry); + if (! e) + continue; /* Menu is empty. */ + + grub_cls (); + + if (auto_boot) + { + grub_menu_execute_with_fallback (menu, e, &execution_callback, 0); + } + else + { + grub_errno = GRUB_ERR_NONE; + grub_menu_execute_entry (e); + if (grub_errno != GRUB_ERR_NONE) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + grub_wait_after_message (); + } + } + } + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_show_menu (grub_menu_t menu, int nested) +{ + grub_err_t err1, err2; + + while (1) + { + err1 = 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; +} diff --git a/normal/menu_entry.c b/normal/menu_entry.c index 7a31c27af..da4eff496 100644 --- a/normal/menu_entry.c +++ b/normal/menu_entry.c @@ -43,6 +43,15 @@ struct line int max_len; }; +struct per_term_screen +{ + struct grub_term_output *term; + /* The X coordinate. */ + int x; + /* The Y coordinate. */ + int y; +}; + struct screen { /* The array of lines. */ @@ -55,18 +64,18 @@ struct screen int real_column; /* The current line. */ int line; - /* The X coordinate. */ - int x; - /* The Y coordinate. */ - int y; /* The kill buffer. */ char *killed_text; /* The flag of a completion window. */ int completion_shown; + + struct per_term_screen *terms; + unsigned nterms; }; /* Used for storing completion items temporarily. */ static struct line completion_buffer; +static int completion_type; /* Initialize a line. */ static int @@ -98,77 +107,88 @@ ensure_space (struct line *linep, int extra) /* Return the number of lines occupied by this line on the screen. */ static int -get_logical_num_lines (struct line *linep) +get_logical_num_lines (struct line *linep, struct per_term_screen *term_screen) { - return (linep->len / GRUB_TERM_ENTRY_WIDTH) + 1; + return (linep->len / grub_term_entry_width (term_screen->term)) + 1; } /* Print a line. */ static void -print_line (struct line *linep, int offset, int start, int y) +print_line (struct line *linep, int offset, int start, int y, + struct per_term_screen *term_screen) { - int i; - char *p; + grub_term_gotoxy (term_screen->term, + GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + start + 1, + y + GRUB_TERM_FIRST_ENTRY_Y); - grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + start + 1, - y + GRUB_TERM_FIRST_ENTRY_Y); - - for (p = linep->buf + offset + start, i = start; - i < GRUB_TERM_ENTRY_WIDTH && offset + i < linep->len; - p++, i++) - grub_putchar (*p); - - for (; i < GRUB_TERM_ENTRY_WIDTH; i++) - grub_putchar (' '); - - if (linep->len >= offset + GRUB_TERM_ENTRY_WIDTH) - grub_putchar ('\\'); + if (linep->len >= offset + grub_term_entry_width (term_screen->term)) + { + char *p, c; + p = linep->buf + offset + start + + grub_term_entry_width (term_screen->term); + c = *p; + *p = 0; + grub_puts_terminal (linep->buf + offset + start, term_screen->term); + *p = c; + grub_putcode ('\\', term_screen->term); + } else - grub_putchar (' '); + { + int i; + for (i = 0; + i <= grub_term_entry_width (term_screen->term) - linep->len + offset; + i++) + grub_putcode (' ', term_screen->term); + } } /* Print an empty line. */ static void -print_empty_line (int y) +print_empty_line (int y, struct per_term_screen *term_screen) { int i; - grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + 1, - y + GRUB_TERM_FIRST_ENTRY_Y); + grub_term_gotoxy (term_screen->term, + GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + 1, + y + GRUB_TERM_FIRST_ENTRY_Y); - for (i = 0; i < GRUB_TERM_ENTRY_WIDTH + 1; i++) - grub_putchar (' '); + for (i = 0; i < grub_term_entry_width (term_screen->term) + 1; i++) + grub_putcode (' ', term_screen->term); } /* Print an up arrow. */ static void -print_up (int flag) +print_up (int flag, struct per_term_screen *term_screen) { - grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH, - GRUB_TERM_FIRST_ENTRY_Y); + grub_term_gotoxy (term_screen->term, GRUB_TERM_LEFT_BORDER_X + + grub_term_entry_width (term_screen->term), + GRUB_TERM_FIRST_ENTRY_Y); if (flag) - grub_putcode (GRUB_TERM_DISP_UP); + grub_putcode (GRUB_TERM_DISP_UP, term_screen->term); else - grub_putchar (' '); + grub_putcode (' ', term_screen->term); } /* Print a down arrow. */ static void -print_down (int flag) +print_down (int flag, struct per_term_screen *term_screen) { - grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH, - GRUB_TERM_TOP_BORDER_Y + GRUB_TERM_NUM_ENTRIES); + grub_term_gotoxy (term_screen->term, GRUB_TERM_LEFT_BORDER_X + + grub_term_border_width (term_screen->term), + GRUB_TERM_TOP_BORDER_Y + + grub_term_num_entries (term_screen->term)); if (flag) - grub_putcode (GRUB_TERM_DISP_DOWN); + grub_putcode (GRUB_TERM_DISP_DOWN, term_screen->term); else - grub_putchar (' '); + grub_putcode (' ', term_screen->term); } /* Draw the lines of the screen SCREEN. */ static void -update_screen (struct screen *screen, int region_start, int region_column, +update_screen (struct screen *screen, struct per_term_screen *term_screen, + int region_start, int region_column, int up, int down, enum update_mode mode) { int up_flag = 0; @@ -178,12 +198,13 @@ update_screen (struct screen *screen, int region_start, int region_column, struct line *linep; /* Check if scrolling is necessary. */ - if (screen->y < 0 || screen->y >= GRUB_TERM_NUM_ENTRIES) + if (term_screen->y < 0 || term_screen->y + >= grub_term_num_entries (term_screen->term)) { - if (screen->y < 0) - screen->y = 0; + if (term_screen->y < 0) + term_screen->y = 0; else - screen->y = GRUB_TERM_NUM_ENTRIES - 1; + term_screen->y = grub_term_num_entries (term_screen->term) - 1; region_start = 0; region_column = 0; @@ -196,14 +217,15 @@ update_screen (struct screen *screen, int region_start, int region_column, { /* Draw lines. This code is tricky, because this must calculate logical positions. */ - y = screen->y - screen->column / GRUB_TERM_ENTRY_WIDTH; + y = term_screen->y - screen->column + / grub_term_entry_width (term_screen->term); i = screen->line; linep = screen->lines + i; while (y > 0) { i--; linep--; - y -= get_logical_num_lines (linep); + y -= get_logical_num_lines (linep, term_screen); } if (y < 0 || i > 0) @@ -214,8 +236,9 @@ update_screen (struct screen *screen, int region_start, int region_column, int column; for (column = 0; - column <= linep->len && y < GRUB_TERM_NUM_ENTRIES; - column += GRUB_TERM_ENTRY_WIDTH, y++) + column <= linep->len + && y < grub_term_num_entries (term_screen->term); + column += grub_term_entry_width (term_screen->term), y++) { if (y < 0) continue; @@ -223,16 +246,19 @@ update_screen (struct screen *screen, int region_start, int region_column, if (i == region_start) { if (region_column >= column - && region_column < column + GRUB_TERM_ENTRY_WIDTH) - print_line (linep, column, region_column - column, y); + && region_column + < (column + + grub_term_entry_width (term_screen->term))) + print_line (linep, column, region_column - column, y, + term_screen); else if (region_column < column) - print_line (linep, column, 0, y); + print_line (linep, column, 0, y, term_screen); } else if (i > region_start && mode == ALL_LINES) - print_line (linep, column, 0, y); + print_line (linep, column, 0, y, term_screen); } - if (y == GRUB_TERM_NUM_ENTRIES) + if (y == grub_term_num_entries (term_screen->term)) { if (column <= linep->len || i + 1 < screen->num_lines) down_flag = 1; @@ -242,35 +268,53 @@ update_screen (struct screen *screen, int region_start, int region_column, i++; if (mode == ALL_LINES && i == screen->num_lines) - for (; y < GRUB_TERM_NUM_ENTRIES; y++) - print_empty_line (y); + for (; y < grub_term_num_entries (term_screen->term); y++) + print_empty_line (y, term_screen); } - while (y < GRUB_TERM_NUM_ENTRIES); + while (y < grub_term_num_entries (term_screen->term)); /* Draw up and down arrows. */ if (up) - print_up (up_flag); + print_up (up_flag, term_screen); if (down) - print_down (down_flag); + print_down (down_flag, term_screen); } /* Place the cursor. */ - grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + 1 + screen->x, - GRUB_TERM_FIRST_ENTRY_Y + screen->y); + grub_term_gotoxy (term_screen->term, + GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + 1 + + term_screen->x, + GRUB_TERM_FIRST_ENTRY_Y + term_screen->y); - grub_refresh (); + grub_term_refresh (term_screen->term); +} + +static void +update_screen_all (struct screen *screen, + int region_start, int region_column, + int up, int down, enum update_mode mode) +{ + unsigned i; + for (i = 0; i < screen->nterms; i++) + update_screen (screen, &screen->terms[i], region_start, region_column, + up, down, mode); } -/* Insert the string S into the screen SCREEN. This updates the cursor - position and redraw the screen. Return zero if fails. */ static int insert_string (struct screen *screen, char *s, int update) { int region_start = screen->num_lines; int region_column = 0; - int down = 0; - enum update_mode mode = NO_LINE; + int down[screen->nterms]; + enum update_mode mode[screen->nterms]; + unsigned i; + + for (i = 0; i < screen->nterms; i++) + { + down[i] = 0; + mode[i] = NO_LINE; + } while (*s) { @@ -319,15 +363,20 @@ insert_string (struct screen *screen, char *s, int update) region_column = screen->column; } - mode = ALL_LINES; - down = 1; /* XXX not optimal. */ + for (i = 0; i < screen->nterms; i++) + { + mode[i] = ALL_LINES; + down[i] = 1; /* XXX not optimal. */ + } /* Move the cursor. */ screen->column = screen->real_column = 0; screen->line++; - screen->x = 0; - screen->y++; - + for (i = 0; i < screen->nterms; i++) + { + screen->terms[i].x = 0; + screen->terms[i].y++; + } s++; } else @@ -336,7 +385,7 @@ insert_string (struct screen *screen, char *s, int update) char *p; struct line *current_linep; int size; - int orig_num, new_num; + int orig_num[screen->nterms], new_num[screen->nterms]; /* Find a string delimited by LF. */ p = grub_strchr (s, '\n'); @@ -355,9 +404,13 @@ insert_string (struct screen *screen, char *s, int update) grub_memmove (current_linep->buf + screen->column, s, size); - orig_num = get_logical_num_lines (current_linep); + for (i = 0; i < screen->nterms; i++) + orig_num[i] = get_logical_num_lines (current_linep, + &screen->terms[i]); current_linep->len += size; - new_num = get_logical_num_lines (current_linep); + for (i = 0; i < screen->nterms; i++) + new_num[i] = get_logical_num_lines (current_linep, + &screen->terms[i]); /* Update the dirty region. */ if (region_start > screen->line) @@ -366,27 +419,34 @@ insert_string (struct screen *screen, char *s, int update) region_column = screen->column; } - if (orig_num != new_num) - { - mode = ALL_LINES; - down = 1; /* XXX not optimal. */ - } - else if (mode != ALL_LINES) - mode = SINGLE_LINE; + for (i = 0; i < screen->nterms; i++) + if (orig_num[i] != new_num[i]) + { + mode[i] = ALL_LINES; + down[i] = 1; /* XXX not optimal. */ + } + else if (mode[i] != ALL_LINES) + mode[i] = SINGLE_LINE; /* Move the cursor. */ screen->column += size; screen->real_column = screen->column; - screen->x += size; - screen->y += screen->x / GRUB_TERM_ENTRY_WIDTH; - screen->x %= GRUB_TERM_ENTRY_WIDTH; - + for (i = 0; i < screen->nterms; i++) + { + screen->terms[i].x += size; + screen->terms[i].y += screen->terms[i].x + / grub_term_entry_width (screen->terms[i].term); + screen->terms[i].x + %= grub_term_entry_width (screen->terms[i].term); + } s = p; } } if (update) - update_screen (screen, region_start, region_column, 0, down, mode); + for (i = 0; i < screen->nterms; i++) + update_screen (screen, &screen->terms[i], + region_start, region_column, 0, down[i], mode[i]); return 1; } @@ -408,6 +468,7 @@ destroy_screen (struct screen *screen) grub_free (screen->killed_text); grub_free (screen->lines); + grub_free (screen->terms); grub_free (screen); } @@ -416,6 +477,7 @@ static struct screen * make_screen (grub_menu_entry_t entry) { struct screen *screen; + unsigned i; /* Initialize the screen. */ screen = grub_zalloc (sizeof (*screen)); @@ -437,8 +499,11 @@ make_screen (grub_menu_entry_t entry) screen->column = 0; screen->real_column = 0; screen->line = 0; - screen->x = 0; - screen->y = 0; + for (i = 0; i < screen->nterms; i++) + { + screen->terms[i].x = 0; + screen->terms[i].y = 0; + } return screen; @@ -451,44 +516,58 @@ static int forward_char (struct screen *screen, int update) { struct line *linep; + unsigned i; linep = screen->lines + screen->line; if (screen->column < linep->len) { screen->column++; - screen->x++; - if (screen->x == GRUB_TERM_ENTRY_WIDTH) + for (i = 0; i < screen->nterms; i++) { - screen->x = 0; - screen->y++; + screen->terms[i].x++; + if (screen->terms[i].x + == grub_term_entry_width (screen->terms[i].term)) + { + screen->terms[i].x = 0; + screen->terms[i].y++; + } } } else if (screen->num_lines > screen->line + 1) { screen->column = 0; screen->line++; - screen->x = 0; - screen->y++; + for (i = 0; i < screen->nterms; i++) + { + screen->terms[i].x = 0; + screen->terms[i].y++; + } } screen->real_column = screen->column; if (update) - update_screen (screen, screen->num_lines, 0, 0, 0, NO_LINE); + update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE); return 1; } static int backward_char (struct screen *screen, int update) { + unsigned i; + if (screen->column > 0) { screen->column--; - screen->x--; - if (screen->x == -1) + for (i = 0; i < screen->nterms; i++) { - screen->x = GRUB_TERM_ENTRY_WIDTH - 1; - screen->y--; + screen->terms[i].x--; + if (screen->terms[i].x == -1) + { + screen->terms[i].x + = grub_term_entry_width (screen->terms[i].term) - 1; + screen->terms[i].y--; + } } } else if (screen->line > 0) @@ -498,14 +577,18 @@ backward_char (struct screen *screen, int update) screen->line--; linep = screen->lines + screen->line; screen->column = linep->len; - screen->x = screen->column % GRUB_TERM_ENTRY_WIDTH; - screen->y--; + for (i = 0; i < screen->nterms; i++) + { + screen->terms[i].x = screen->column + % grub_term_entry_width (screen->terms[i].term); + screen->terms[i].y--; + } } screen->real_column = screen->column; if (update) - update_screen (screen, screen->num_lines, 0, 0, 0, NO_LINE); + update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE); return 1; } @@ -513,14 +596,16 @@ backward_char (struct screen *screen, int update) static int previous_line (struct screen *screen, int update) { + unsigned i; + if (screen->line > 0) { struct line *linep; - int dy; + int col; /* How many physical lines from the current position to the first physical line? */ - dy = screen->column / GRUB_TERM_ENTRY_WIDTH; + col = screen->column; screen->line--; @@ -530,23 +615,35 @@ previous_line (struct screen *screen, int update) else screen->column = screen->real_column; - /* How many physical lines from the current position - to the last physical line? */ - dy += (linep->len / GRUB_TERM_ENTRY_WIDTH - - screen->column / GRUB_TERM_ENTRY_WIDTH); + for (i = 0; i < screen->nterms; i++) + { + int dy; + dy = col / grub_term_entry_width (screen->terms[i].term); - screen->y -= dy + 1; - screen->x = screen->column % GRUB_TERM_ENTRY_WIDTH; + /* How many physical lines from the current position + to the last physical line? */ + dy += (linep->len / grub_term_entry_width (screen->terms[i].term) + - screen->column + / grub_term_entry_width (screen->terms[i].term)); + + screen->terms[i].y -= dy + 1; + screen->terms[i].x + = screen->column % grub_term_entry_width (screen->terms[i].term); + } } else { - screen->y -= screen->column / GRUB_TERM_ENTRY_WIDTH; + for (i = 0; i < screen->nterms; i++) + { + screen->terms[i].y + -= screen->column / grub_term_entry_width (screen->terms[i].term); + screen->terms[i].x = 0; + } screen->column = 0; - screen->x = 0; } if (update) - update_screen (screen, screen->num_lines, 0, 0, 0, NO_LINE); + update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE); return 1; } @@ -554,16 +651,18 @@ previous_line (struct screen *screen, int update) static int next_line (struct screen *screen, int update) { + unsigned i; + if (screen->line < screen->num_lines - 1) { struct line *linep; - int dy; + int l1, c1; /* How many physical lines from the current position to the last physical line? */ linep = screen->lines + screen->line; - dy = (linep->len / GRUB_TERM_ENTRY_WIDTH - - screen->column / GRUB_TERM_ENTRY_WIDTH); + l1 = linep->len; + c1 = screen->column; screen->line++; @@ -573,26 +672,40 @@ next_line (struct screen *screen, int update) else screen->column = screen->real_column; - /* How many physical lines from the current position - to the first physical line? */ - dy += screen->column / GRUB_TERM_ENTRY_WIDTH; - - screen->y += dy + 1; - screen->x = screen->column % GRUB_TERM_ENTRY_WIDTH; + for (i = 0; i < screen->nterms; i++) + { + int dy; + dy = l1 / grub_term_entry_width (screen->terms[i].term) + - c1 / grub_term_entry_width (screen->terms[i].term); + /* How many physical lines from the current position + to the first physical line? */ + dy += screen->column / grub_term_entry_width (screen->terms[i].term); + screen->terms[i].y += dy + 1; + screen->terms[i].x = screen->column + % grub_term_entry_width (screen->terms[i].term); + } } else { struct line *linep; - + int l, s; + linep = screen->lines + screen->line; - screen->y += (linep->len / GRUB_TERM_ENTRY_WIDTH - - screen->column / GRUB_TERM_ENTRY_WIDTH); + l = linep->len; + s = screen->column; screen->column = linep->len; - screen->x = screen->column % GRUB_TERM_ENTRY_WIDTH; + for (i = 0; i < screen->nterms; i++) + { + screen->terms[i].y + += (l / grub_term_entry_width (screen->terms[i].term) + - s / grub_term_entry_width (screen->terms[i].term)); + screen->terms[i].x + = screen->column % grub_term_entry_width (screen->terms[i].term); + } } if (update) - update_screen (screen, screen->num_lines, 0, 0, 0, NO_LINE); + update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE); return 1; } @@ -600,12 +713,19 @@ next_line (struct screen *screen, int update) static int beginning_of_line (struct screen *screen, int update) { - screen->y -= screen->column / GRUB_TERM_ENTRY_WIDTH; + unsigned i; + int col; + + col = screen->column; screen->column = screen->real_column = 0; - screen->x = 0; + for (i = 0; i < screen->nterms; i++) + { + screen->terms[i].x = 0; + screen->terms[i].y -= col / grub_term_entry_width (screen->terms[i].term); + } if (update) - update_screen (screen, screen->num_lines, 0, 0, 0, NO_LINE); + update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE); return 1; } @@ -614,15 +734,23 @@ static int end_of_line (struct screen *screen, int update) { struct line *linep; + unsigned i; + int col; linep = screen->lines + screen->line; - screen->y += (linep->len / GRUB_TERM_ENTRY_WIDTH - - screen->column / GRUB_TERM_ENTRY_WIDTH); + col = screen->column; screen->column = screen->real_column = linep->len; - screen->x = screen->column % GRUB_TERM_ENTRY_WIDTH; + for (i = 0; i < screen->nterms; i++) + { + screen->terms[i].y + += (linep->len / grub_term_entry_width (screen->terms->term) + - col / grub_term_entry_width (screen->terms->term)); + screen->terms[i].x + = screen->column % grub_term_entry_width (screen->terms->term); + } if (update) - update_screen (screen, screen->num_lines, 0, 0, 0, NO_LINE); + update_screen_all (screen, screen->num_lines, 0, 0, 0, NO_LINE); return 1; } @@ -631,32 +759,41 @@ static int delete_char (struct screen *screen, int update) { struct line *linep; - enum update_mode mode = NO_LINE; int start = screen->num_lines; int column = 0; - int down = 0; linep = screen->lines + screen->line; if (linep->len > screen->column) { - int orig_num, new_num; + int orig_num[screen->nterms], new_num; + unsigned i; - orig_num = get_logical_num_lines (linep); + for (i = 0; i < screen->nterms; i++) + orig_num[i] = get_logical_num_lines (linep, &screen->terms[i]); grub_memmove (linep->buf + screen->column, linep->buf + screen->column + 1, linep->len - screen->column - 1); linep->len--; - new_num = get_logical_num_lines (linep); - - if (orig_num != new_num) - mode = ALL_LINES; - else - mode = SINGLE_LINE; - start = screen->line; column = screen->column; + + screen->real_column = screen->column; + + if (update) + { + for (i = 0; i < screen->nterms; i++) + { + new_num = get_logical_num_lines (linep, &screen->terms[i]); + if (orig_num[i] != new_num) + update_screen (screen, &screen->terms[i], + start, column, 0, 0, ALL_LINES); + else + update_screen (screen, &screen->terms[i], + start, column, 0, 0, SINGLE_LINE); + } + } } else if (screen->num_lines > screen->line + 1) { @@ -676,17 +813,14 @@ delete_char (struct screen *screen, int update) * sizeof (struct line)); screen->num_lines--; - mode = ALL_LINES; start = screen->line; column = screen->column; - down = 1; + + screen->real_column = screen->column; + if (update) + update_screen_all (screen, start, column, 0, 1, ALL_LINES); } - screen->real_column = screen->column; - - if (update) - update_screen (screen, start, column, 0, down, mode); - return 1; } @@ -731,9 +865,8 @@ kill_line (struct screen *screen, int continuous, int update) if (size > 0) { - enum update_mode mode = SINGLE_LINE; - int down = 0; - int orig_num, new_num; + int orig_num[screen->nterms], new_num; + unsigned i; p = grub_realloc (p, offset + size + 1); if (! p) @@ -744,18 +877,23 @@ kill_line (struct screen *screen, int continuous, int update) screen->killed_text = p; - orig_num = get_logical_num_lines (linep); + for (i = 0; i < screen->nterms; i++) + orig_num[i] = get_logical_num_lines (linep, &screen->terms[i]); linep->len = screen->column; - new_num = get_logical_num_lines (linep); - - if (orig_num != new_num) - { - mode = ALL_LINES; - down = 1; - } if (update) - update_screen (screen, screen->line, screen->column, 0, down, mode); + { + new_num = get_logical_num_lines (linep, &screen->terms[i]); + for (i = 0; i < screen->nterms; i++) + { + if (orig_num[i] != new_num) + update_screen (screen, &screen->terms[i], + screen->line, screen->column, 0, 1, ALL_LINES); + else + update_screen (screen, &screen->terms[i], + screen->line, screen->column, 0, 0, SINGLE_LINE); + } + } } else if (screen->line + 1 < screen->num_lines) { @@ -786,7 +924,11 @@ yank (struct screen *screen, int update) static int open_line (struct screen *screen, int update) { - int saved_y = screen->y; + int saved_y[screen->nterms]; + unsigned i; + + for (i = 0; i < screen->nterms; i++) + saved_y[i] = screen->terms[i].y; if (! insert_string (screen, "\n", 0)) return 0; @@ -794,52 +936,23 @@ open_line (struct screen *screen, int update) if (! backward_char (screen, 0)) return 0; - screen->y = saved_y; + for (i = 0; i < screen->nterms; i++) + screen->terms[i].y = saved_y[i]; if (update) - update_screen (screen, screen->line, screen->column, 0, 1, ALL_LINES); + update_screen_all (screen, screen->line, screen->column, 0, 1, ALL_LINES); return 1; } /* A completion hook to print items. */ static void -store_completion (const char *item, grub_completion_type_t type, int count) +store_completion (const char *item, grub_completion_type_t type, + int count __attribute__ ((unused))) { char *p; - if (count == 0) - { - /* If this is the first time, print a label. */ - const char *what; - - switch (type) - { - case GRUB_COMPLETION_TYPE_COMMAND: - what = "commands"; - break; - case GRUB_COMPLETION_TYPE_DEVICE: - what = "devices"; - break; - case GRUB_COMPLETION_TYPE_FILE: - what = "files"; - break; - case GRUB_COMPLETION_TYPE_PARTITION: - what = "partitions"; - break; - case GRUB_COMPLETION_TYPE_ARGUMENT: - what = "arguments"; - break; - default: - what = "things"; - break; - } - - grub_gotoxy (0, GRUB_TERM_HEIGHT - 3); - grub_printf (" "); - grub_printf_ (N_("Possible %s are:"), what); - grub_printf ("\n "); - } + completion_type = type; /* Make sure that the completion buffer has enough room. */ if (completion_buffer.max_len < (completion_buffer.len @@ -873,21 +986,21 @@ store_completion (const char *item, grub_completion_type_t type, int count) static int complete (struct screen *screen, int continuous, int update) { - grub_uint16_t pos; char saved_char; struct line *linep; int restore; char *insert; static int count = -1; + unsigned i; + grub_uint32_t *ucs4; + grub_size_t buflen; + grub_ssize_t ucs4len; if (continuous) count++; else count = 0; - pos = grub_getxy (); - grub_gotoxy (0, GRUB_TERM_HEIGHT - 3); - completion_buffer.buf = 0; completion_buffer.len = 0; completion_buffer.max_len = 0; @@ -900,35 +1013,86 @@ complete (struct screen *screen, int continuous, int update) linep->buf[screen->column] = saved_char; - if (restore) + buflen = grub_strlen (completion_buffer.buf); + ucs4 = grub_malloc (sizeof (grub_uint32_t) * (buflen + 1)); + + if (!ucs4) { - char *p = completion_buffer.buf; - - screen->completion_shown = 1; - - if (p) - { - int num_sections = ((completion_buffer.len + GRUB_TERM_WIDTH - 8 - 1) - / (GRUB_TERM_WIDTH - 8)); - char *endp; - - p += (count % num_sections) * (GRUB_TERM_WIDTH - 8); - endp = p + (GRUB_TERM_WIDTH - 8); - - if (p != completion_buffer.buf) - grub_putcode (GRUB_TERM_DISP_LEFT); - else - grub_putchar (' '); - - while (*p && p < endp) - grub_putchar (*p++); - - if (*p) - grub_putcode (GRUB_TERM_DISP_RIGHT); - } + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + return 1; } - grub_gotoxy (pos >> 8, pos & 0xFF); + ucs4len = grub_utf8_to_ucs4 (ucs4, buflen, + (grub_uint8_t *) completion_buffer.buf, + buflen, 0); + ucs4[ucs4len] = 0; + + if (restore) + for (i = 0; i < screen->nterms; i++) + { + int num_sections = ((completion_buffer.len + + grub_term_width (screen->terms[i].term) - 8 - 1) + / (grub_term_width (screen->terms[i].term) - 8)); + grub_uint32_t *endp; + grub_uint16_t pos; + grub_uint32_t *p = ucs4; + + pos = grub_term_getxy (screen->terms[i].term); + grub_term_gotoxy (screen->terms[i].term, 0, + grub_term_height (screen->terms[i].term) - 3); + + screen->completion_shown = 1; + + grub_term_gotoxy (screen->terms[i].term, 0, + grub_term_height (screen->terms[i].term) - 3); + grub_puts_terminal (" ", screen->terms[i].term); + switch (completion_type) + { + case GRUB_COMPLETION_TYPE_COMMAND: + grub_puts_terminal (_("Possible commands are:"), + screen->terms[i].term); + break; + case GRUB_COMPLETION_TYPE_DEVICE: + grub_puts_terminal (_("Possible devices are:"), + screen->terms[i].term); + break; + case GRUB_COMPLETION_TYPE_FILE: + grub_puts_terminal (_("Possible files are:"), + screen->terms[i].term); + break; + case GRUB_COMPLETION_TYPE_PARTITION: + grub_puts_terminal (_("Possible partitions are:"), + screen->terms[i].term); + break; + case GRUB_COMPLETION_TYPE_ARGUMENT: + grub_puts_terminal (_("Possible arguments are:"), + screen->terms[i].term); + break; + default: + grub_puts_terminal (_("Possible things are:"), + screen->terms[i].term); + break; + } + + grub_puts_terminal ("\n ", screen->terms[i].term); + + p += (count % num_sections) + * (grub_term_width (screen->terms[i].term) - 8); + endp = p + (grub_term_width (screen->terms[i].term) - 8); + + if (p != ucs4) + grub_putcode (GRUB_TERM_DISP_LEFT, screen->terms[i].term); + else + grub_putcode (' ', screen->terms[i].term); + + while (*p && p < endp) + grub_putcode (*p++, screen->terms[i].term); + + if (*p) + grub_putcode (GRUB_TERM_DISP_RIGHT, screen->terms[i].term); + grub_term_gotoxy (screen->terms[i].term, pos >> 8, pos & 0xFF); + } if (insert) { @@ -945,23 +1109,33 @@ complete (struct screen *screen, int continuous, int update) /* Clear displayed completions. */ static void -clear_completions (void) +clear_completions (struct per_term_screen *term_screen) { grub_uint16_t pos; - int i, j; + unsigned i, j; - pos = grub_getxy (); - grub_gotoxy (0, GRUB_TERM_HEIGHT - 3); + pos = grub_term_getxy (term_screen->term); + grub_term_gotoxy (term_screen->term, 0, + grub_term_height (term_screen->term) - 3); for (i = 0; i < 2; i++) { - for (j = 0; j < GRUB_TERM_WIDTH - 1; j++) - grub_putchar (' '); - grub_putchar ('\n'); + for (j = 0; j < grub_term_width (term_screen->term) - 1; j++) + grub_putcode (' ', term_screen->term); + grub_putcode ('\n', term_screen->term); } - grub_gotoxy (pos >> 8, pos & 0xFF); - grub_refresh (); + grub_term_gotoxy (term_screen->term, pos >> 8, pos & 0xFF); + grub_term_refresh (term_screen->term); +} + +static void +clear_completions_all (struct screen *screen) +{ + unsigned i; + + for (i = 0; i < screen->nterms; i++) + clear_completions (&screen->terms[i]); } /* Execute the command list in the screen SCREEN. */ @@ -1033,6 +1207,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) struct screen *screen; int prev_c; grub_err_t err = GRUB_ERR_NONE; + unsigned i; err = grub_auth_check_authentication (NULL); @@ -1049,9 +1224,11 @@ grub_menu_entry_run (grub_menu_entry_t entry) refresh: /* Draw the screen. */ - grub_menu_init_page (0, 1); - update_screen (screen, 0, 0, 1, 1, ALL_LINES); - grub_setcursor (1); + for (i = 0; i < screen->nterms; i++) + grub_menu_init_page (0, 1, screen->terms[i].term); + update_screen_all (screen, 0, 0, 1, 1, ALL_LINES); + for (i = 0; i < screen->nterms; i++) + grub_term_setcursor (screen->terms[i].term, 1); prev_c = '\0'; while (1) @@ -1060,7 +1237,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) if (screen->completion_shown) { - clear_completions (); + clear_completions_all (screen); screen->completion_shown = 0; } diff --git a/normal/menu_text.c b/normal/menu_text.c index 4f2dfb78e..edb315524 100644 --- a/normal/menu_text.c +++ b/normal/menu_text.c @@ -26,96 +26,66 @@ #include #include #include - -/* Time to delay after displaying an error message about a default/fallback - entry failing to boot. */ -#define DEFAULT_ENTRY_ERROR_DELAY_MS 2500 +#include static grub_uint8_t grub_color_menu_normal; static grub_uint8_t grub_color_menu_highlight; -/* Wait until the user pushes any key so that the user - can see what happened. */ -void -grub_wait_after_message (void) +struct menu_viewer_data { - grub_putchar ('\n'); - grub_printf_ (N_("Press any key to continue...")); - (void) grub_getkey (); - grub_putchar ('\n'); -} + int first, offset; + grub_menu_t menu; + struct grub_term_output *term; +}; static void -print_spaces (int number_spaces) +print_spaces (int number_spaces, struct grub_term_output *term) { int i; for (i = 0; i < number_spaces; i++) - grub_putchar (' '); + grub_putcode (' ', term); } void grub_print_ucs4 (const grub_uint32_t * str, - const grub_uint32_t * last_position) + const grub_uint32_t * last_position, + struct grub_term_output *term) { while (str < last_position) { - grub_putcode (*str); + grub_putcode (*str, term); str++; } } -int -grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg, - grub_uint32_t **last_position) -{ - grub_ssize_t msg_len = grub_strlen (msg); - - *unicode_msg = grub_malloc (grub_strlen (msg) * sizeof (grub_uint32_t)); - - if (!*unicode_msg) - { - grub_printf ("utf8_to_ucs4 ERROR1: %s", msg); - return -1; - } - - msg_len = grub_utf8_to_ucs4 (*unicode_msg, msg_len, - (grub_uint8_t *) msg, -1, 0); - - *last_position = *unicode_msg + msg_len; - - if (msg_len < 0) - { - grub_printf ("utf8_to_ucs4 ERROR2: %s", msg); - grub_free (*unicode_msg); - } - return msg_len; -} - grub_ssize_t -grub_getstringwidth (grub_uint32_t * str, const grub_uint32_t * last_position) +grub_getstringwidth (grub_uint32_t * str, const grub_uint32_t * last_position, + struct grub_term_output *term) { grub_ssize_t width = 0; while (str < last_position) { - width += grub_getcharwidth (*str); + width += grub_term_getcharwidth (term, *str); str++; } return width; } void -grub_print_message_indented (const char *msg, int margin_left, int margin_right) +grub_print_message_indented (const char *msg, int margin_left, int margin_right, + struct grub_term_output *term) { int line_len; - line_len = GRUB_TERM_WIDTH - grub_getcharwidth ('m') * - (margin_left + margin_right); grub_uint32_t *unicode_msg; grub_uint32_t *last_position; int msg_len; + line_len = grub_term_width (term) - grub_term_getcharwidth (term, 'm') * + (margin_left + margin_right); + msg_len = grub_utf8_to_ucs4_alloc (msg, &unicode_msg, &last_position); if (msg_len < 0) @@ -132,11 +102,12 @@ grub_print_message_indented (const char *msg, int margin_left, int margin_right) while (current_position < last_position) { if (! first_loop) - grub_putchar ('\n'); + grub_putcode ('\n', term); next_new_line = (grub_uint32_t *) last_position; - while (grub_getstringwidth (current_position, next_new_line) > line_len + while (grub_getstringwidth (current_position, next_new_line,term) + > line_len || (*next_new_line != ' ' && next_new_line > current_position && next_new_line != last_position)) { @@ -149,8 +120,8 @@ grub_print_message_indented (const char *msg, int margin_left, int margin_right) (grub_uint32_t *) last_position : next_new_line + line_len; } - print_spaces (margin_left); - grub_print_ucs4 (current_position, next_new_line); + print_spaces (margin_left, term); + grub_print_ucs4 (current_position, next_new_line, term); next_new_line++; current_position = next_new_line; @@ -161,52 +132,54 @@ grub_print_message_indented (const char *msg, int margin_left, int margin_right) static void -draw_border (void) +draw_border (struct grub_term_output *term) { unsigned i; - grub_setcolorstate (GRUB_TERM_COLOR_NORMAL); + grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); - grub_gotoxy (GRUB_TERM_MARGIN, GRUB_TERM_TOP_BORDER_Y); - grub_putcode (GRUB_TERM_DISP_UL); - for (i = 0; i < (unsigned) GRUB_TERM_BORDER_WIDTH - 2; i++) - grub_putcode (GRUB_TERM_DISP_HLINE); - grub_putcode (GRUB_TERM_DISP_UR); + grub_term_gotoxy (term, GRUB_TERM_MARGIN, GRUB_TERM_TOP_BORDER_Y); + grub_putcode (GRUB_TERM_DISP_UL, term); + for (i = 0; i < (unsigned) grub_term_border_width (term) - 2; i++) + grub_putcode (GRUB_TERM_DISP_HLINE, term); + grub_putcode (GRUB_TERM_DISP_UR, term); - for (i = 0; i < (unsigned) GRUB_TERM_NUM_ENTRIES; i++) + for (i = 0; i < (unsigned) grub_term_num_entries (term); i++) { - grub_gotoxy (GRUB_TERM_MARGIN, GRUB_TERM_TOP_BORDER_Y + i + 1); - grub_putcode (GRUB_TERM_DISP_VLINE); - grub_gotoxy (GRUB_TERM_MARGIN + GRUB_TERM_BORDER_WIDTH - 1, - GRUB_TERM_TOP_BORDER_Y + i + 1); - grub_putcode (GRUB_TERM_DISP_VLINE); + grub_term_gotoxy (term, GRUB_TERM_MARGIN, GRUB_TERM_TOP_BORDER_Y + i + 1); + grub_putcode (GRUB_TERM_DISP_VLINE, term); + grub_term_gotoxy (term, GRUB_TERM_MARGIN + grub_term_border_width (term) + - 1, + GRUB_TERM_TOP_BORDER_Y + i + 1); + grub_putcode (GRUB_TERM_DISP_VLINE, term); } - grub_gotoxy (GRUB_TERM_MARGIN, - GRUB_TERM_TOP_BORDER_Y + GRUB_TERM_NUM_ENTRIES + 1); - grub_putcode (GRUB_TERM_DISP_LL); - for (i = 0; i < (unsigned) GRUB_TERM_BORDER_WIDTH - 2; i++) - grub_putcode (GRUB_TERM_DISP_HLINE); - grub_putcode (GRUB_TERM_DISP_LR); + grub_term_gotoxy (term, GRUB_TERM_MARGIN, + GRUB_TERM_TOP_BORDER_Y + grub_term_num_entries (term) + 1); + grub_putcode (GRUB_TERM_DISP_LL, term); + for (i = 0; i < (unsigned) grub_term_border_width (term) - 2; i++) + grub_putcode (GRUB_TERM_DISP_HLINE, term); + grub_putcode (GRUB_TERM_DISP_LR, term); - grub_setcolorstate (GRUB_TERM_COLOR_NORMAL); + grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); - grub_gotoxy (GRUB_TERM_MARGIN, - (GRUB_TERM_TOP_BORDER_Y + GRUB_TERM_NUM_ENTRIES - + GRUB_TERM_MARGIN + 1)); + grub_term_gotoxy (term, GRUB_TERM_MARGIN, + (GRUB_TERM_TOP_BORDER_Y + grub_term_num_entries (term) + + GRUB_TERM_MARGIN + 1)); } static void -print_message (int nested, int edit) +print_message (int nested, int edit, struct grub_term_output *term) { - grub_setcolorstate (GRUB_TERM_COLOR_NORMAL); + grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); if (edit) { - grub_putchar ('\n'); + grub_putcode ('\n', term); grub_print_message_indented (_("Minimum Emacs-like screen editing is \ supported. TAB lists completions. Press Ctrl-x to boot, Ctrl-c for a \ -command-line or ESC to return menu."), STANDARD_MARGIN, STANDARD_MARGIN); +command-line or ESC to return menu."), STANDARD_MARGIN, STANDARD_MARGIN, + term); } else { @@ -218,12 +191,14 @@ entry is highlighted.\n"); grub_sprintf (msg_translated, msg, (grub_uint32_t) GRUB_TERM_DISP_UP, (grub_uint32_t) GRUB_TERM_DISP_DOWN); grub_putchar ('\n'); - grub_print_message_indented (msg_translated, STANDARD_MARGIN, STANDARD_MARGIN); + grub_print_message_indented (msg_translated, STANDARD_MARGIN, + STANDARD_MARGIN, term); grub_free (msg_translated); grub_print_message_indented (_("Press enter to boot the selected OS, \ -\'e\' to edit the commands before booting or \'c\' for a command-line.\n"), STANDARD_MARGIN, STANDARD_MARGIN); +\'e\' to edit the commands before booting or \'c\' for a command-line.\n"), + STANDARD_MARGIN, STANDARD_MARGIN, term); if (nested) { @@ -234,7 +209,8 @@ entry is highlighted.\n"); } static void -print_entry (int y, int highlight, grub_menu_entry_t entry) +print_entry (int y, int highlight, grub_menu_entry_t entry, + struct grub_term_output *term) { int x; const char *title; @@ -260,482 +236,248 @@ print_entry (int y, int highlight, grub_menu_entry_t entry) return; } - grub_getcolor (&old_color_normal, &old_color_highlight); - grub_setcolor (grub_color_menu_normal, grub_color_menu_highlight); - grub_setcolorstate (highlight - ? GRUB_TERM_COLOR_HIGHLIGHT - : GRUB_TERM_COLOR_NORMAL); + grub_term_getcolor (term, &old_color_normal, &old_color_highlight); + grub_term_setcolor (term, grub_color_menu_normal, grub_color_menu_highlight); + grub_term_setcolorstate (term, highlight + ? GRUB_TERM_COLOR_HIGHLIGHT + : GRUB_TERM_COLOR_NORMAL); - grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN, y); + grub_term_gotoxy (term, GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN, y); for (x = GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + 1, i = 0; - x < GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH - GRUB_TERM_MARGIN; + x < (int) (GRUB_TERM_LEFT_BORDER_X + grub_term_border_width (term) + - GRUB_TERM_MARGIN); i++) { if (i < len - && x <= (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH - - GRUB_TERM_MARGIN - 1)) + && x <= (int) (GRUB_TERM_LEFT_BORDER_X + grub_term_border_width (term) + - GRUB_TERM_MARGIN - 1)) { grub_ssize_t width; - width = grub_getcharwidth (unicode_title[i]); + width = grub_term_getcharwidth (term, unicode_title[i]); - if (x + width > (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH - - GRUB_TERM_MARGIN - 1)) - grub_putcode (GRUB_TERM_DISP_RIGHT); + if (x + width > (int) (GRUB_TERM_LEFT_BORDER_X + + grub_term_border_width (term) + - GRUB_TERM_MARGIN - 1)) + grub_putcode (GRUB_TERM_DISP_RIGHT, term); else - grub_putcode (unicode_title[i]); + grub_putcode (unicode_title[i], term); x += width; } else { - grub_putchar (' '); + grub_putcode (' ', term); x++; } } - grub_setcolorstate (GRUB_TERM_COLOR_NORMAL); - grub_putchar (' '); + grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); + grub_putcode (' ', term); - grub_gotoxy (GRUB_TERM_CURSOR_X, y); + grub_term_gotoxy (term, grub_term_cursor_x (term), y); - grub_setcolor (old_color_normal, old_color_highlight); - grub_setcolorstate (GRUB_TERM_COLOR_NORMAL); + grub_term_setcolor (term, old_color_normal, old_color_highlight); + grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); grub_free (unicode_title); } static void -print_entries (grub_menu_t menu, int first, int offset) +print_entries (grub_menu_t menu, int first, int offset, + struct grub_term_output *term) { grub_menu_entry_t e; int i; - grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH, - GRUB_TERM_FIRST_ENTRY_Y); + grub_term_gotoxy (term, + GRUB_TERM_LEFT_BORDER_X + grub_term_border_width (term), + GRUB_TERM_FIRST_ENTRY_Y); if (first) - grub_putcode (GRUB_TERM_DISP_UP); + grub_putcode (GRUB_TERM_DISP_UP, term); else - grub_putchar (' '); + grub_putcode (' ', term); e = grub_menu_get_entry (menu, first); - for (i = 0; i < GRUB_TERM_NUM_ENTRIES; i++) + for (i = 0; i < grub_term_num_entries (term); i++) { - print_entry (GRUB_TERM_FIRST_ENTRY_Y + i, offset == i, e); + print_entry (GRUB_TERM_FIRST_ENTRY_Y + i, offset == i, e, term); if (e) e = e->next; } - grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH, - GRUB_TERM_TOP_BORDER_Y + GRUB_TERM_NUM_ENTRIES); + grub_term_gotoxy (term, GRUB_TERM_LEFT_BORDER_X + + grub_term_border_width (term), + GRUB_TERM_TOP_BORDER_Y + grub_term_num_entries (term)); if (e) - grub_putcode (GRUB_TERM_DISP_DOWN); + grub_putcode (GRUB_TERM_DISP_DOWN, term); else - grub_putchar (' '); + grub_putcode (' ', term); - grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset); + grub_term_gotoxy (term, grub_term_cursor_x (term), + GRUB_TERM_FIRST_ENTRY_Y + offset); } /* Initialize the screen. If NESTED is non-zero, assume that this menu is run from another menu or a command-line. If EDIT is non-zero, show a message for the menu entry editor. */ void -grub_menu_init_page (int nested, int edit) +grub_menu_init_page (int nested, int edit, + struct grub_term_output *term) { grub_uint8_t old_color_normal, old_color_highlight; - grub_getcolor (&old_color_normal, &old_color_highlight); + grub_term_getcolor (term, &old_color_normal, &old_color_highlight); /* By default, use the same colors for the menu. */ grub_color_menu_normal = old_color_normal; grub_color_menu_highlight = old_color_highlight; /* Then give user a chance to replace them. */ - grub_parse_color_name_pair (&grub_color_menu_normal, grub_env_get ("menu_color_normal")); - grub_parse_color_name_pair (&grub_color_menu_highlight, grub_env_get ("menu_color_highlight")); + grub_parse_color_name_pair (&grub_color_menu_normal, + grub_env_get ("menu_color_normal")); + grub_parse_color_name_pair (&grub_color_menu_highlight, + grub_env_get ("menu_color_highlight")); - grub_normal_init_page (); - grub_setcolor (grub_color_menu_normal, grub_color_menu_highlight); - draw_border (); - grub_setcolor (old_color_normal, old_color_highlight); - print_message (nested, edit); -} - -/* Get the entry number from the variable NAME. */ -static int -get_entry_number (const char *name) -{ - char *val; - int entry; - - val = grub_env_get (name); - if (! val) - return -1; - - grub_error_push (); - - entry = (int) grub_strtoul (val, 0, 0); - - if (grub_errno != GRUB_ERR_NONE) - { - grub_errno = GRUB_ERR_NONE; - entry = -1; - } - - grub_error_pop (); - - return entry; + grub_normal_init_page (term); + grub_term_setcolor (term, grub_color_menu_normal, grub_color_menu_highlight); + draw_border (term); + grub_term_setcolor (term, old_color_normal, old_color_highlight); + print_message (nested, edit, term); } static void -print_timeout (int timeout, int offset) +menu_text_print_timeout (int timeout, void *dataptr) { const char *msg = _("The highlighted entry will be booted automatically in %ds."); - - grub_gotoxy (0, GRUB_TERM_HEIGHT - 3); - - char *msg_translated = - grub_malloc (sizeof (char) * grub_strlen (msg) + 5); - - grub_sprintf (msg_translated, msg, timeout); - grub_print_message_indented (msg_translated, 3, 0); - + struct menu_viewer_data *data = dataptr; + char *msg_translated; int posx; - posx = grub_getxy() >> 8; - print_spaces (GRUB_TERM_WIDTH - posx - 1); - grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset); - grub_refresh (); -} + grub_term_gotoxy (data->term, 0, grub_term_height (data->term) - 3); -/* Show the menu and handle menu entry selection. Returns the menu entry - index that should be executed or -1 if no entry should be executed (e.g., - Esc pressed to exit a sub-menu or switching menu viewers). - If the return value is not -1, then *AUTO_BOOT is nonzero iff the menu - entry to be executed is a result of an automatic default selection because - of the timeout. */ -static int -run_menu (grub_menu_t menu, int nested, int *auto_boot) -{ - int first, offset; - grub_uint64_t saved_time; - int default_entry; - int timeout; - - first = 0; - - default_entry = get_entry_number ("default"); - - /* If DEFAULT_ENTRY is not within the menu entries, fall back to - the first entry. */ - if (default_entry < 0 || default_entry >= menu->size) - default_entry = 0; - - /* If timeout is 0, drawing is pointless (and ugly). */ - if (grub_menu_get_timeout () == 0) - { - *auto_boot = 1; - return default_entry; - } - - offset = default_entry; - if (offset > GRUB_TERM_NUM_ENTRIES - 1) - { - first = offset - (GRUB_TERM_NUM_ENTRIES - 1); - offset = GRUB_TERM_NUM_ENTRIES - 1; - } - - /* Initialize the time. */ - saved_time = grub_get_time_ms (); - - refresh: - grub_setcursor (0); - grub_menu_init_page (nested, 0); - print_entries (menu, first, offset); - grub_refresh (); - - timeout = grub_menu_get_timeout (); - - if (timeout > 0) - print_timeout (timeout, offset); - - while (1) - { - int c; - timeout = grub_menu_get_timeout (); - - if (timeout > 0) - { - grub_uint64_t current_time; - - current_time = grub_get_time_ms (); - if (current_time - saved_time >= 1000) - { - timeout--; - grub_menu_set_timeout (timeout); - saved_time = current_time; - print_timeout (timeout, offset); - } - } - - if (timeout == 0) - { - grub_env_unset ("timeout"); - *auto_boot = 1; - return default_entry; - } - - if (grub_checkkey () >= 0 || timeout < 0) - { - c = GRUB_TERM_ASCII_CHAR (grub_getkey ()); - - if (timeout >= 0) - { - grub_gotoxy (0, GRUB_TERM_HEIGHT - 3); - print_spaces (GRUB_TERM_WIDTH - 1); - - grub_env_unset ("timeout"); - grub_env_unset ("fallback"); - grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset); - } - - switch (c) - { - case GRUB_TERM_HOME: - first = 0; - offset = 0; - print_entries (menu, first, offset); - break; - - case GRUB_TERM_END: - offset = menu->size - 1; - if (offset > GRUB_TERM_NUM_ENTRIES - 1) - { - first = offset - (GRUB_TERM_NUM_ENTRIES - 1); - offset = GRUB_TERM_NUM_ENTRIES - 1; - } - print_entries (menu, first, offset); - break; - - case GRUB_TERM_UP: - case '^': - if (offset > 0) - { - print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 0, - grub_menu_get_entry (menu, first + offset)); - offset--; - print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 1, - grub_menu_get_entry (menu, first + offset)); - } - else if (first > 0) - { - first--; - print_entries (menu, first, offset); - } - break; - - case GRUB_TERM_DOWN: - case 'v': - if (menu->size > first + offset + 1) - { - if (offset < GRUB_TERM_NUM_ENTRIES - 1) - { - print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 0, - grub_menu_get_entry (menu, first + offset)); - offset++; - print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 1, - grub_menu_get_entry (menu, first + offset)); - } - else - { - first++; - print_entries (menu, first, offset); - } - } - break; - - case GRUB_TERM_PPAGE: - if (first == 0) - { - offset = 0; - } - else - { - first -= GRUB_TERM_NUM_ENTRIES; - - if (first < 0) - { - offset += first; - first = 0; - } - } - print_entries (menu, first, offset); - break; - - case GRUB_TERM_NPAGE: - if (offset == 0) - { - offset += GRUB_TERM_NUM_ENTRIES - 1; - if (first + offset >= menu->size) - { - offset = menu->size - first - 1; - } - } - else - { - first += GRUB_TERM_NUM_ENTRIES; - - if (first + offset >= menu->size) - { - first -= GRUB_TERM_NUM_ENTRIES; - offset += GRUB_TERM_NUM_ENTRIES; - - if (offset > menu->size - 1 || - offset > GRUB_TERM_NUM_ENTRIES - 1) - { - offset = menu->size - first - 1; - } - if (offset > GRUB_TERM_NUM_ENTRIES) - { - first += offset - GRUB_TERM_NUM_ENTRIES + 1; - offset = GRUB_TERM_NUM_ENTRIES - 1; - } - } - } - print_entries (menu, first, offset); - break; - - case '\n': - case '\r': - case 6: - grub_setcursor (1); - *auto_boot = 0; - return first + offset; - - case '\e': - if (nested) - { - grub_setcursor (1); - return -1; - } - break; - - case 'c': - grub_cmdline_run (1); - goto refresh; - - case 'e': - { - grub_menu_entry_t e = grub_menu_get_entry (menu, first + offset); - if (e) - grub_menu_entry_run (e); - } - goto refresh; - - default: - break; - } - - grub_refresh (); - } - } - - /* Never reach here. */ - return -1; -} - -/* Callback invoked immediately before a menu entry is executed. */ -static void -notify_booting (grub_menu_entry_t entry, - void *userdata __attribute__((unused))) -{ - grub_printf (" "); - grub_printf_ (N_("Booting \'%s\'"), entry->title); - grub_printf ("\n\n"); -} - -/* Callback invoked when a default menu entry executed because of a timeout - has failed and an attempt will be made to execute the next fallback - entry, ENTRY. */ -static void -notify_fallback (grub_menu_entry_t entry, - void *userdata __attribute__((unused))) -{ - grub_printf ("\n "); - grub_printf_ (N_("Falling back to \'%s\'"), entry->title); - grub_printf ("\n\n"); - grub_millisleep (DEFAULT_ENTRY_ERROR_DELAY_MS); -} - -/* Callback invoked when a menu entry has failed and there is no remaining - fallback entry to attempt. */ -static void -notify_execution_failure (void *userdata __attribute__((unused))) -{ - if (grub_errno != GRUB_ERR_NONE) + msg_translated = grub_malloc (sizeof (char) * grub_strlen (msg) + 5); + if (!msg_translated) { grub_print_error (); grub_errno = GRUB_ERR_NONE; + return; } - grub_printf ("\n "); - grub_printf_ (N_("Failed to boot default entries.\n")); - grub_wait_after_message (); + + grub_sprintf (msg_translated, msg, timeout); + grub_print_message_indented (msg_translated, 3, 0, data->term); + + posx = grub_term_getxy (data->term) >> 8; + print_spaces (grub_term_width (data->term) - posx - 1, data->term); + + grub_term_gotoxy (data->term, + grub_term_cursor_x (data->term), + GRUB_TERM_FIRST_ENTRY_Y + data->offset); + grub_term_refresh (data->term); } -/* Callbacks used by the text menu to provide user feedback when menu entries - are executed. */ -static struct grub_menu_execute_callback execution_callback = +static void +menu_text_set_chosen_entry (int entry, void *dataptr) { - .notify_booting = notify_booting, - .notify_fallback = notify_fallback, - .notify_failure = notify_execution_failure -}; - -static grub_err_t -show_text_menu (grub_menu_t menu, int nested) -{ - while (1) + struct menu_viewer_data *data = dataptr; + int oldoffset = data->offset; + int complete_redraw = 0; + data->offset = entry - data->first; + if (data->offset > grub_term_num_entries (data->term) - 1) { - int boot_entry; - grub_menu_entry_t e; - int auto_boot; - - boot_entry = run_menu (menu, nested, &auto_boot); - if (boot_entry < 0) - break; - - e = grub_menu_get_entry (menu, boot_entry); - if (! e) - continue; /* Menu is empty. */ - - grub_cls (); - grub_setcursor (1); - - if (auto_boot) - { - grub_menu_execute_with_fallback (menu, e, &execution_callback, 0); - } - else - { - grub_errno = GRUB_ERR_NONE; - grub_menu_execute_entry (e); - if (grub_errno != GRUB_ERR_NONE) - { - grub_print_error (); - grub_errno = GRUB_ERR_NONE; - grub_wait_after_message (); - } - } + data->first = data->offset - (grub_term_num_entries (data->term) - 1); + data->offset = grub_term_num_entries (data->term) - 1; + complete_redraw = 1; } - - return GRUB_ERR_NONE; + if (data->offset < 0) + { + data->offset = 0; + data->first = entry; + complete_redraw = 1; + } + if (complete_redraw) + print_entries (data->menu, data->first, data->offset, data->term); + else + { + print_entry (GRUB_TERM_FIRST_ENTRY_Y + oldoffset, 0, + grub_menu_get_entry (data->menu, data->first + oldoffset), + data->term); + print_entry (GRUB_TERM_FIRST_ENTRY_Y + data->offset, 1, + grub_menu_get_entry (data->menu, data->first + data->offset), + data->term); + } + grub_term_refresh (data->term); } -struct grub_menu_viewer grub_normal_text_menu_viewer = +static void +menu_text_fini (void *dataptr) { - .name = "text", - .show_menu = show_text_menu -}; + struct menu_viewer_data *data = dataptr; + + grub_term_setcursor (data->term, 1); +} + +static void +menu_text_clear_timeout (void *dataptr) +{ + struct menu_viewer_data *data = dataptr; + + grub_term_gotoxy (data->term, 0, grub_term_height (data->term) - 3); + print_spaces (grub_term_width (data->term) - 1, data->term); + grub_term_gotoxy (data->term, grub_term_cursor_x (data->term), + GRUB_TERM_FIRST_ENTRY_Y + data->offset); + grub_term_refresh (data->term); +} + +void +grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested) +{ + struct menu_viewer_data *data; + struct grub_menu_viewer *instance; + struct grub_term_output *term; + + for (term = grub_term_outputs; term; term = term->next) + { + if (!grub_term_is_active (term)) + continue; + instance = grub_zalloc (sizeof (*instance)); + if (!instance) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + continue; + } + data = grub_zalloc (sizeof (*data)); + if (!data) + { + grub_free (instance); + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + continue; + } + data->term = term; + instance->data = data; + instance->set_chosen_entry = menu_text_set_chosen_entry; + instance->print_timeout = menu_text_print_timeout; + instance->clear_timeout = menu_text_clear_timeout; + instance->fini = menu_text_fini; + + data->menu = menu; + + data->offset = entry; + data->first = 0; + if (data->offset > grub_term_num_entries (data->term) - 1) + { + data->first = data->offset - (grub_term_num_entries (data->term) - 1); + data->offset = grub_term_num_entries (data->term) - 1; + } + + grub_term_setcursor (data->term, 0); + grub_menu_init_page (nested, 0, data->term); + print_entries (menu, data->first, data->offset, data->term); + grub_term_refresh (data->term); + } +} diff --git a/normal/menu_viewer.c b/normal/menu_viewer.c index 1bd271a21..b600e7500 100644 --- a/normal/menu_viewer.c +++ b/normal/menu_viewer.c @@ -23,59 +23,4 @@ #include #include -/* The list of menu viewers. */ -static grub_menu_viewer_t menu_viewer_list; - -void -grub_menu_viewer_register (grub_menu_viewer_t viewer) -{ - viewer->next = menu_viewer_list; - menu_viewer_list = viewer; -} - -static grub_menu_viewer_t get_current_menu_viewer (void) -{ - const char *selected_name = grub_env_get ("menuviewer"); - - /* If none selected, pick the last registered one. */ - if (selected_name == 0) - return menu_viewer_list; - - grub_menu_viewer_t cur; - for (cur = menu_viewer_list; cur; cur = cur->next) - { - if (grub_strcmp (cur->name, selected_name) == 0) - return cur; - } - - /* Fall back to the first entry (or null). */ - return menu_viewer_list; -} - -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."); - - 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; -} diff --git a/normal/term.c b/normal/term.c index 73eab548a..ff5120d48 100644 --- a/normal/term.c +++ b/normal/term.c @@ -16,8 +16,12 @@ * along with GRUB. If not, see . */ +#include +#include +#include + /* The amount of lines counted by the pager. */ -static int grub_more_lines; +static unsigned grub_more_lines; /* If the more pager is active. */ static int grub_more; @@ -25,36 +29,37 @@ static int grub_more; static void process_newline (void) { - if (code == '\n') + struct grub_term_output *cur; + unsigned height = -1; + + for (cur = grub_term_outputs; cur; cur = cur->next) + if (grub_term_is_active(cur) && grub_term_height (cur) < height) + height = grub_term_height (cur); + grub_more_lines++; + + if (grub_more && grub_more_lines == height - 1) { - grub_putcode ('\r'); + char key; + grub_uint16_t *pos; - grub_more_lines++; + pos = grub_term_save_pos (); - if (grub_more && grub_more_lines == height - 1) - { - char key; - int pos = term->getxy (); + grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); + grub_printf ("--MORE--"); + grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); - /* Show --MORE-- on the lower left side of the screen. */ - term->gotoxy (1, height - 1); - grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); - grub_printf ("--MORE--"); - grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); + key = grub_getkey (); - key = grub_getkey (); + /* Remove the message. */ + grub_term_restore_pos (pos); + grub_printf (" "); + grub_term_restore_pos (pos); - /* Remove the message. */ - term->gotoxy (1, height - 1); - grub_printf (" "); - term->gotoxy (pos >> 8, pos & 0xFF); - - /* Scroll one lines or an entire page, depending on the key. */ - if (key == '\r' || key =='\n') - grub_more_lines--; - else - grub_more_lines = 0; - } + /* Scroll one lines or an entire page, depending on the key. */ + if (key == '\r' || key =='\n') + grub_more_lines--; + else + grub_more_lines = 0; } } @@ -67,6 +72,7 @@ grub_set_more (int onoff) grub_more--; grub_more_lines = 0; + grub_newline_hook = process_newline; } void @@ -74,21 +80,14 @@ grub_puts_terminal (const char *str, struct grub_term_output *term) { grub_uint32_t code; grub_ssize_t ret; - const char *ptr = str; - unsigned i; + const grub_uint8_t *ptr = (const grub_uint8_t *) str; + const grub_uint8_t *end; + end = (const grub_uint8_t *) (str + grub_strlen (str)); while (*ptr) { - ret = grub_utf8_to_ucs4 (&code, 1, ptr, - grub_strlen (ptr), &ptr); - if (ret < 0) - { - grub_putcode ('?', term); - ptr++; - continue; - } - else - grub_putcode (code, term); + ret = grub_utf8_to_ucs4 (&code, 1, ptr, end - ptr, &ptr); + grub_putcode (code, term); } } @@ -100,16 +99,17 @@ grub_term_save_pos (void) grub_uint16_t *ret, *ptr; for (cur = grub_term_outputs; cur; cur = cur->next) - if (cur->flags & GRUB_TERM_ACTIVE) + if (grub_term_is_active (cur)) cnt++; ret = grub_malloc (cnt * sizeof (ret[0])); if (!ret) return NULL; + ptr = ret; for (cur = grub_term_outputs; cur; cur = cur->next) - if (cur->flags & GRUB_TERM_ACTIVE) - *ptr++ = cur->getxy (); + if (grub_term_is_active (cur)) + *ptr++ = grub_term_getxy (cur); return ret; } @@ -118,11 +118,15 @@ void grub_term_restore_pos (grub_uint16_t *pos) { struct grub_term_output *cur; + grub_uint16_t *ptr = pos; if (!pos) return; for (cur = grub_term_outputs; cur; cur = cur->next) - if (cur->flags & GRUB_TERM_ACTIVE) - cur->gotoxy ((*ptr & 0xff00) >> 8, *ptr & 0xff); + if (grub_term_is_active (cur)) + { + grub_term_gotoxy (cur, (*ptr & 0xff00) >> 8, *ptr & 0xff); + ptr++; + } } diff --git a/term/efi/console.c b/term/efi/console.c index f3845089c..bde101ebc 100644 --- a/term/efi/console.c +++ b/term/efi/console.c @@ -352,7 +352,7 @@ static struct grub_term_output grub_console_term_output = .setcolor = grub_console_setcolor, .getcolor = grub_console_getcolor, .setcursor = grub_console_setcursor, - .flags = 0, + .flags = GRUB_TERM_ACTIVE, }; void diff --git a/term/i386/pc/console.c b/term/i386/pc/console.c index b54e2f6f1..6f56fc0d7 100644 --- a/term/i386/pc/console.c +++ b/term/i386/pc/console.c @@ -66,7 +66,7 @@ static struct grub_term_output grub_console_term_output = .setcolor = grub_console_setcolor, .getcolor = grub_console_getcolor, .setcursor = grub_console_setcursor, - .flags = 0, + .flags = GRUB_TERM_ACTIVE, }; void diff --git a/term/i386/pc/vga_text.c b/term/i386/pc/vga_text.c index 170f74de8..4fc54a60d 100644 --- a/term/i386/pc/vga_text.c +++ b/term/i386/pc/vga_text.c @@ -164,10 +164,17 @@ static struct grub_term_output grub_vga_text_term = .setcolor = grub_console_setcolor, .getcolor = grub_console_getcolor, .setcursor = grub_vga_text_setcursor, +#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) + .flags = GRUB_TERM_ACTIVE, +#endif }; GRUB_MOD_INIT(vga_text) { +#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) + grub_vga_text_init_fini (); +#endif + grub_term_register_output ("vga_text", &grub_vga_text_term); } diff --git a/term/ieee1275/ofconsole.c b/term/ieee1275/ofconsole.c index ab11e9fb2..95479379e 100644 --- a/term/ieee1275/ofconsole.c +++ b/term/ieee1275/ofconsole.c @@ -415,7 +415,7 @@ static struct grub_term_output grub_ofconsole_term_output = .getcolor = grub_ofconsole_getcolor, .setcursor = grub_ofconsole_setcursor, .refresh = grub_ofconsole_refresh, - .flags = 0, + .flags = GRUB_TERM_ACTIVE, }; void diff --git a/util/console.c b/util/console.c index 9d8bb1a63..d9a907308 100644 --- a/util/console.c +++ b/util/console.c @@ -368,7 +368,7 @@ static struct grub_term_output grub_ncurses_term_output = .getcolor = grub_ncurses_getcolor, .setcursor = grub_ncurses_setcursor, .refresh = grub_ncurses_refresh, - .flags = 0, + .flags = GRUB_TERM_ACTIVE }; void From 2322a1269372e8b9186da63c2384a407f73cbffb Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Dec 2009 16:25:10 +0100 Subject: [PATCH 068/208] remove list iterators to save space --- kern/term.c | 85 +++++++++++++++++------------------------------------ 1 file changed, 27 insertions(+), 58 deletions(-) diff --git a/kern/term.c b/kern/term.c index b71c12334..d0d29eb9c 100644 --- a/kern/term.c +++ b/kern/term.c @@ -67,24 +67,16 @@ grub_putchar (int c) grub_uint32_t code; grub_ssize_t ret; - auto int do_putcode (grub_list_t item); - int do_putcode (grub_list_t item) - { - struct grub_term_output *term = (struct grub_term_output *) item; - - if (grub_term_is_active (term)) - grub_putcode (code, term); - - return 0; - } - buf[size++] = c; ret = grub_utf8_to_ucs4 (&code, 1, buf, size, 0); if (ret != 0) { + struct grub_term_output *term; size = 0; - grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), do_putcode); + for (term = grub_term_outputs; term; term = term->next) + if (grub_term_is_active (term)) + grub_putcode (code, term); } if (ret == '\n' && grub_newline_hook) grub_newline_hook (); @@ -114,62 +106,39 @@ grub_getkeystatus (void) void grub_cls (void) { - auto int hook (grub_list_t item); - int hook (grub_list_t item) - { - struct grub_term_output *term = (struct grub_term_output *) item; + struct grub_term_output *term; + + for (term = grub_term_outputs; term; term = term->next) + { + if (! grub_term_is_active (term)) + continue; - if (! grub_term_is_active (term)) - return 0; - - if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug"))) - { - grub_putcode ('\n', term); - grub_refresh (); - } - else - (term->cls) (); - - return 0; - } - - grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), hook); + if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug"))) + { + grub_putcode ('\n', term); + grub_refresh (); + } + else + (term->cls) (); + } } void grub_setcolorstate (grub_term_color_state state) { - auto int hook (grub_list_t item); - int hook (grub_list_t item) - { - struct grub_term_output *term = (struct grub_term_output *) item; - - if (! grub_term_is_active (term)) - return 0; - - grub_term_setcolorstate (term, state); - - return 0; - } - - grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), hook); + struct grub_term_output *term; + + for (term = grub_term_outputs; term; term = term->next) + if (grub_term_is_active (term)) + grub_term_setcolorstate (term, state); } void grub_refresh (void) { - auto int hook (grub_list_t item); - int hook (grub_list_t item) - { - struct grub_term_output *term = (struct grub_term_output *) item; + struct grub_term_output *term; - if (!grub_term_is_active (term)) - return 0; - - grub_term_refresh (term); - - return 0; - } - - grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), hook); + for (term = grub_term_outputs; term; term = term->next) + if (grub_term_is_active (term)) + grub_term_refresh (term); } From 8eca55a6eb63bf2ad24fe2655286e644e8d2ddd8 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 24 Dec 2009 17:08:14 +0100 Subject: [PATCH 069/208] Imported nyu's multi-input --- commands/keystatus.c | 17 +++++++++++----- include/grub/term.h | 19 ++++-------------- kern/misc.c | 4 +++- kern/term.c | 48 ++++++++++++++++++++++++++++++++------------ util/console.c | 1 - util/grub-editenv.c | 3 --- 6 files changed, 54 insertions(+), 38 deletions(-) diff --git a/commands/keystatus.c b/commands/keystatus.c index 0a4667645..1bb22bde3 100644 --- a/commands/keystatus.c +++ b/commands/keystatus.c @@ -48,13 +48,20 @@ grub_cmd_keystatus (grub_extcmd_t cmd, if (state[2].set) expect_mods |= GRUB_TERM_STATUS_ALT; + grub_dprintf ("keystatus", "expect_mods: %d\n", expect_mods); + /* 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; + if (expect_mods == 0) + { + grub_term_input_t term; + + FOR_ACTIVE_TERM_INPUTS (term) + if (term->getkeystatus) + return 0; + + return grub_error (GRUB_ERR_TEST_FAILURE, "false"); + } mods = grub_getkeystatus (); grub_dprintf ("keystatus", "mods: %d\n", mods); diff --git a/include/grub/term.h b/include/grub/term.h index a0b96b497..fb9ed6f0c 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -197,14 +197,14 @@ struct grub_term_output }; typedef struct grub_term_output *grub_term_output_t; -extern struct grub_handler_class EXPORT_VAR(grub_term_input_class); extern struct grub_term_output *EXPORT_VAR(grub_term_outputs); +extern struct grub_term_input *EXPORT_VAR(grub_term_inputs); static inline void grub_term_register_input (const char *name __attribute__ ((unused)), grub_term_input_t term) { - grub_handler_register (&grub_term_input_class, GRUB_AS_HANDLER (term)); + grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term)); } static inline void @@ -217,7 +217,7 @@ grub_term_register_output (const char *name __attribute__ ((unused)), static inline void grub_term_unregister_input (grub_term_input_t term) { - grub_handler_unregister (&grub_term_input_class, GRUB_AS_HANDLER (term)); + grub_list_remove (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term)); } static inline void @@ -226,18 +226,7 @@ grub_term_unregister_output (grub_term_output_t term) grub_list_remove (GRUB_AS_LIST_P (&grub_term_outputs), GRUB_AS_LIST (term)); } -static inline grub_err_t -grub_term_set_current_input (grub_term_input_t term) -{ - return grub_handler_set_current (&grub_term_input_class, - GRUB_AS_HANDLER (term)); -} - -static inline grub_term_input_t -grub_term_get_current_input (void) -{ - return (grub_term_input_t) grub_term_input_class.cur_handler; -} +#define FOR_ACTIVE_TERM_INPUTS(var) for (var = grub_term_inputs; var; var = var->next) void EXPORT_FUNC(grub_putchar) (int c); void EXPORT_FUNC(grub_putcode) (grub_uint32_t code, diff --git a/kern/misc.c b/kern/misc.c index ef782f5dd..af6f97758 100644 --- a/kern/misc.c +++ b/kern/misc.c @@ -975,7 +975,9 @@ grub_abort (void) { grub_printf ("\nAborted."); - if (grub_term_get_current_input ()) +#ifndef GRUB_UTIL + if (grub_term_inputs) +#endif { grub_printf (" Press any key to exit."); grub_getkey (); diff --git a/kern/term.c b/kern/term.c index d0d29eb9c..9ce906719 100644 --- a/kern/term.c +++ b/kern/term.c @@ -21,15 +21,10 @@ #include #include #include - -struct grub_handler_class grub_term_input_class = - { - .name = "terminal_input" - }; - -#define grub_cur_term_input grub_term_get_current_input () +#include struct grub_term_output *grub_term_outputs; +struct grub_term_input *grub_term_inputs; void (*grub_newline_hook) (void) = NULL; @@ -85,22 +80,49 @@ grub_putchar (int c) int grub_getkey (void) { - return (grub_cur_term_input->getkey) (); + grub_term_input_t term; + + while (1) + { + FOR_ACTIVE_TERM_INPUTS(term) + { + int key = term->checkkey (); + if (key != -1) + return term->getkey (); + } + + grub_cpu_idle (); + } } int grub_checkkey (void) { - return (grub_cur_term_input->checkkey) (); + grub_term_input_t term; + + FOR_ACTIVE_TERM_INPUTS(term) + { + int key = term->checkkey (); + if (key != -1) + return key; + } + + return -1; } int grub_getkeystatus (void) { - if (grub_cur_term_input->getkeystatus) - return (grub_cur_term_input->getkeystatus) (); - else - return 0; + int status = 0; + grub_term_input_t term; + + FOR_ACTIVE_TERM_INPUTS(term) + { + if (term->getkeystatus) + status |= term->getkeystatus (); + } + + return status; } void diff --git a/util/console.c b/util/console.c index d9a907308..be64eb9d8 100644 --- a/util/console.c +++ b/util/console.c @@ -377,7 +377,6 @@ grub_console_init (void) grub_term_register_output ("console", &grub_ncurses_term_output); grub_term_register_input ("console", &grub_ncurses_term_input); grub_term_set_current_output (&grub_ncurses_term_output); - grub_term_set_current_input (&grub_ncurses_term_input); } void diff --git a/util/grub-editenv.c b/util/grub-editenv.c index 68fb23b15..e75892430 100644 --- a/util/grub-editenv.c +++ b/util/grub-editenv.c @@ -46,9 +46,6 @@ grub_refresh (void) fflush (stdout); } -struct grub_handler_class grub_term_input_class; -struct grub_handler_class grub_term_output_class; - int grub_getkey (void) { From 3be7f8de12a9ea524cf8209770bf39e7c464736c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Dec 2009 17:51:43 +0100 Subject: [PATCH 070/208] FORALL_ACTIVE_TERM_OUTPUTS macro --- commands/help.c | 34 ++++++++++---------- include/grub/term.h | 1 + kern/term.c | 38 ++++++++++------------- normal/cmdline.c | 18 +++++------ normal/color.c | 17 +++++----- normal/main.c | 18 +++++------ normal/menu_text.c | 76 ++++++++++++++++++++++----------------------- normal/term.c | 25 +++++++-------- 8 files changed, 106 insertions(+), 121 deletions(-) diff --git a/commands/help.c b/commands/help.c index 5e8f0b27a..bfca5e0cc 100644 --- a/commands/help.c +++ b/commands/help.c @@ -39,22 +39,20 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, { struct grub_term_output *cur; int desclen = grub_strlen (cmd->summary); - for (cur = grub_term_outputs; cur; cur = cur->next) - { - if (!grub_term_is_active (cur)) - continue; - int width = grub_term_width(cur); - char description[width / 2]; + FOR_ACTIVE_TERM_OUTPUTS(cur) + { + int width = grub_term_width(cur); + char description[width / 2]; - /* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled - with the description followed by spaces. */ - grub_memset (description, ' ', width / 2 - 1); - description[width / 2 - 1] = '\0'; - grub_memcpy (description, cmd->summary, - (desclen < width / 2 - 1 - ? desclen : width / 2 - 1)); - grub_puts_terminal (description, cur); - } + /* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled + with the description followed by spaces. */ + grub_memset (description, ' ', width / 2 - 1); + description[width / 2 - 1] = '\0'; + grub_memcpy (description, cmd->summary, + (desclen < width / 2 - 1 + ? desclen : width / 2 - 1)); + grub_puts_terminal (description, cur); + } if ((cnt++) % 2) grub_printf ("\n"); else @@ -83,7 +81,11 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, } if (argc == 0) - grub_command_iterate (print_command_info); + { + grub_command_iterate (print_command_info); + if (!(cnt % 2)) + grub_printf ("\n"); + } else { int i; diff --git a/include/grub/term.h b/include/grub/term.h index fb9ed6f0c..bf6766af6 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -227,6 +227,7 @@ grub_term_unregister_output (grub_term_output_t term) } #define FOR_ACTIVE_TERM_INPUTS(var) for (var = grub_term_inputs; var; var = var->next) +#define FOR_ACTIVE_TERM_OUTPUTS(var) for (var = grub_term_outputs; var; var = var->next) if (grub_term_is_active (var)) void EXPORT_FUNC(grub_putchar) (int c); void EXPORT_FUNC(grub_putcode) (grub_uint32_t code, diff --git a/kern/term.c b/kern/term.c index 9ce906719..dbcac1b19 100644 --- a/kern/term.c +++ b/kern/term.c @@ -69,9 +69,8 @@ grub_putchar (int c) { struct grub_term_output *term; size = 0; - for (term = grub_term_outputs; term; term = term->next) - if (grub_term_is_active (term)) - grub_putcode (code, term); + FOR_ACTIVE_TERM_OUTPUTS(term) + grub_putcode (code, term); } if (ret == '\n' && grub_newline_hook) grub_newline_hook (); @@ -129,20 +128,17 @@ void grub_cls (void) { struct grub_term_output *term; - - for (term = grub_term_outputs; term; term = term->next) - { - if (! grub_term_is_active (term)) - continue; - if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug"))) - { - grub_putcode ('\n', term); - grub_refresh (); - } - else - (term->cls) (); - } + FOR_ACTIVE_TERM_OUTPUTS(term) + { + if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug"))) + { + grub_putcode ('\n', term); + grub_refresh (); + } + else + (term->cls) (); + } } void @@ -150,9 +146,8 @@ grub_setcolorstate (grub_term_color_state state) { struct grub_term_output *term; - for (term = grub_term_outputs; term; term = term->next) - if (grub_term_is_active (term)) - grub_term_setcolorstate (term, state); + FOR_ACTIVE_TERM_OUTPUTS(term) + grub_term_setcolorstate (term, state); } void @@ -160,7 +155,6 @@ grub_refresh (void) { struct grub_term_output *term; - for (term = grub_term_outputs; term; term = term->next) - if (grub_term_is_active (term)) - grub_term_refresh (term); + FOR_ACTIVE_TERM_OUTPUTS(term) + grub_term_refresh (term); } diff --git a/normal/cmdline.c b/normal/cmdline.c index 1412a6d6a..0f90fc2fe 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -363,21 +363,19 @@ grub_cmdline_get (const char *prompt) struct cmdline_term *cl_term_cur; struct grub_term_output *cur; nterms = 0; - for (cur = grub_term_outputs; cur; cur = cur->next) - if (grub_term_is_active (cur)) - nterms++; + FOR_ACTIVE_TERM_OUTPUTS(cur) + nterms++; cl_terms = grub_malloc (sizeof (cl_terms[0]) * nterms); if (!cl_terms) return 0; cl_term_cur = cl_terms; - for (cur = grub_term_outputs; cur; cur = cur->next) - if (grub_term_is_active (cur)) - { - cl_term_cur->term = cur; - init_clterm (cl_term_cur); - cl_term_cur++; - } + FOR_ACTIVE_TERM_OUTPUTS(cur) + { + cl_term_cur->term = cur; + init_clterm (cl_term_cur); + cl_term_cur++; + } } if (hist_used == 0) diff --git a/normal/color.c b/normal/color.c index 80a285787..bae082911 100644 --- a/normal/color.c +++ b/normal/color.c @@ -110,17 +110,14 @@ set_colors (void) { struct grub_term_output *term; - for (term = grub_term_outputs; term; term = term->next) - { - if (! grub_term_is_active (term)) - continue; + FOR_ACTIVE_TERM_OUTPUTS(term) + { + /* Reloads terminal `normal' and `highlight' colors. */ + grub_term_setcolor (term, color_normal, color_highlight); - /* Reloads terminal `normal' and `highlight' colors. */ - grub_term_setcolor (term, color_normal, color_highlight); - - /* Propagates `normal' color to terminal current color. */ - grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); - } + /* Propagates `normal' color to terminal current color. */ + grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); + } } /* Replace default `normal' colors with the ones specified by user (if any). */ diff --git a/normal/main.c b/normal/main.c index b490f49e5..e1ffddae7 100644 --- a/normal/main.c +++ b/normal/main.c @@ -520,16 +520,14 @@ grub_normal_reader_init (void) grub_sprintf (msg_formatted, msg, reader_nested ? msg_esc : ""); - for (term = grub_term_outputs; term; term = term->next) - { - if (! (term->flags & GRUB_TERM_ACTIVE)) - continue; - grub_normal_init_page (term); - grub_term_setcursor (term, 1); - - grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN, term); - grub_puts ("\n"); - } + FOR_ACTIVE_TERM_OUTPUTS(term) + { + grub_normal_init_page (term); + grub_term_setcursor (term, 1); + + grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN, term); + grub_puts ("\n"); + } grub_free (msg_formatted); return 0; diff --git a/normal/menu_text.c b/normal/menu_text.c index edb315524..991a9ba4d 100644 --- a/normal/menu_text.c +++ b/normal/menu_text.c @@ -439,45 +439,43 @@ grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested) struct grub_menu_viewer *instance; struct grub_term_output *term; - for (term = grub_term_outputs; term; term = term->next) - { - if (!grub_term_is_active (term)) + FOR_ACTIVE_TERM_OUTPUTS(term) + { + instance = grub_zalloc (sizeof (*instance)); + if (!instance) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; continue; - instance = grub_zalloc (sizeof (*instance)); - if (!instance) - { - grub_print_error (); - grub_errno = GRUB_ERR_NONE; - continue; - } - data = grub_zalloc (sizeof (*data)); - if (!data) - { - grub_free (instance); - grub_print_error (); - grub_errno = GRUB_ERR_NONE; - continue; - } - data->term = term; - instance->data = data; - instance->set_chosen_entry = menu_text_set_chosen_entry; - instance->print_timeout = menu_text_print_timeout; - instance->clear_timeout = menu_text_clear_timeout; - instance->fini = menu_text_fini; + } + data = grub_zalloc (sizeof (*data)); + if (!data) + { + grub_free (instance); + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + continue; + } + data->term = term; + instance->data = data; + instance->set_chosen_entry = menu_text_set_chosen_entry; + instance->print_timeout = menu_text_print_timeout; + instance->clear_timeout = menu_text_clear_timeout; + instance->fini = menu_text_fini; + + data->menu = menu; + + data->offset = entry; + data->first = 0; + if (data->offset > grub_term_num_entries (data->term) - 1) + { + data->first = data->offset - (grub_term_num_entries (data->term) - 1); + data->offset = grub_term_num_entries (data->term) - 1; + } - data->menu = menu; - - data->offset = entry; - data->first = 0; - if (data->offset > grub_term_num_entries (data->term) - 1) - { - data->first = data->offset - (grub_term_num_entries (data->term) - 1); - data->offset = grub_term_num_entries (data->term) - 1; - } - - grub_term_setcursor (data->term, 0); - grub_menu_init_page (nested, 0, data->term); - print_entries (menu, data->first, data->offset, data->term); - grub_term_refresh (data->term); - } + grub_term_setcursor (data->term, 0); + grub_menu_init_page (nested, 0, data->term); + print_entries (menu, data->first, data->offset, data->term); + grub_term_refresh (data->term); + } } diff --git a/normal/term.c b/normal/term.c index ff5120d48..eb8f8e844 100644 --- a/normal/term.c +++ b/normal/term.c @@ -32,8 +32,8 @@ process_newline (void) struct grub_term_output *cur; unsigned height = -1; - for (cur = grub_term_outputs; cur; cur = cur->next) - if (grub_term_is_active(cur) && grub_term_height (cur) < height) + FOR_ACTIVE_TERM_OUTPUTS(cur) + if (grub_term_height (cur) < height) height = grub_term_height (cur); grub_more_lines++; @@ -98,18 +98,16 @@ grub_term_save_pos (void) unsigned cnt = 0; grub_uint16_t *ret, *ptr; - for (cur = grub_term_outputs; cur; cur = cur->next) - if (grub_term_is_active (cur)) - cnt++; + FOR_ACTIVE_TERM_OUTPUTS(cur) + cnt++; ret = grub_malloc (cnt * sizeof (ret[0])); if (!ret) return NULL; ptr = ret; - for (cur = grub_term_outputs; cur; cur = cur->next) - if (grub_term_is_active (cur)) - *ptr++ = grub_term_getxy (cur); + FOR_ACTIVE_TERM_OUTPUTS(cur) + *ptr++ = grub_term_getxy (cur); return ret; } @@ -123,10 +121,9 @@ grub_term_restore_pos (grub_uint16_t *pos) if (!pos) return; - for (cur = grub_term_outputs; cur; cur = cur->next) - if (grub_term_is_active (cur)) - { - grub_term_gotoxy (cur, (*ptr & 0xff00) >> 8, *ptr & 0xff); - ptr++; - } + FOR_ACTIVE_TERM_OUTPUTS(cur) + { + grub_term_gotoxy (cur, (*ptr & 0xff00) >> 8, *ptr & 0xff); + ptr++; + } } From 401c0ad6fd215c532157a9c685c8ffd720c97395 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 24 Dec 2009 18:00:48 +0000 Subject: [PATCH 071/208] 2009-12-24 Robert Millan * util/mkisofs/write.c (padblock_write): Abort when given an excedingly large embed image, instead of silently truncating it. --- ChangeLog | 5 +++++ util/mkisofs/write.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 03a57d538..75683b8d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-24 Robert Millan + + * util/mkisofs/write.c (padblock_write): Abort when given an + excedingly large embed image, instead of silently truncating it. + 2009-12-24 Robert Millan * include/multiboot.h: Indentation fixes. diff --git a/util/mkisofs/write.c b/util/mkisofs/write.c index 69b6bb623..896e2833b 100644 --- a/util/mkisofs/write.c +++ b/util/mkisofs/write.c @@ -1436,7 +1436,10 @@ static int FDECL1(padblock_write, FILE *, outfile) FILE *fp = fopen (boot_image_embed, "rb"); if (! fp) error (1, errno, _("Unable to open %s"), boot_image_embed); + fread (buffer, 2048 * PADBLOCK_SIZE, 1, fp); + if (fgetc (fp) != EOF) + error (1, 0, _("%s is too big for embed area"), boot_image_embed); } if (use_protective_msdos_label) From 0aa6339849fb73487ccc304ec37cddc4f1bfd63e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Dec 2009 21:54:37 +0100 Subject: [PATCH 072/208] Working multi-terminal --- commands/handler.c | 29 +---- commands/terminal.c | 290 +++++++++++++++++++++++++++++++++++++++++ genhandlerlist.sh | 6 +- include/grub/term.h | 42 ++++-- kern/term.c | 2 + term/i386/pc/console.c | 7 +- 6 files changed, 334 insertions(+), 42 deletions(-) create mode 100644 commands/terminal.c diff --git a/commands/handler.c b/commands/handler.c index d65a703e4..60889dd5e 100644 --- a/commands/handler.c +++ b/commands/handler.c @@ -25,10 +25,9 @@ #include static grub_err_t -grub_cmd_handler (struct grub_command *cmd, +grub_cmd_handler (struct grub_command *cmd __attribute__ ((unused)), int argc, char **args) { - char *class_name; void *curr_item = 0; grub_handler_class_t head; @@ -43,23 +42,19 @@ grub_cmd_handler (struct grub_command *cmd, return 0; } - class_name = (grub_strcmp (cmd->name, "handler")) ? (char *) cmd->name : 0; - head = grub_handler_class_list; - if ((argc == 0) && (class_name == 0)) + if (argc == 0) { grub_list_iterate (GRUB_AS_LIST (head), (grub_list_hook_t) list_item); } else { + char *class_name; grub_handler_class_t class; - if (class_name == 0) - { - class_name = args[0]; - argc--; - args++; - } + class_name = args[0]; + argc--; + args++; class = grub_named_list_find (GRUB_AS_NAMED_LIST (head), class_name); if (! class) @@ -89,7 +84,7 @@ grub_cmd_handler (struct grub_command *cmd, return 0; } -static grub_command_t cmd_handler, cmd_terminal_input, cmd_terminal_output; +static grub_command_t cmd_handler; GRUB_MOD_INIT(handler) { @@ -97,19 +92,9 @@ GRUB_MOD_INIT(handler) grub_register_command ("handler", grub_cmd_handler, "handler [class [handler]]", "List or select a handler."); - cmd_terminal_input = - grub_register_command ("terminal_input", grub_cmd_handler, - "terminal_input [handler]", - "List or select an input terminal."); - cmd_terminal_output = - grub_register_command ("terminal_output", grub_cmd_handler, - "terminal_output [handler]", - "List or select an output terminal."); } GRUB_MOD_FINI(handler) { grub_unregister_command (cmd_handler); - grub_unregister_command (cmd_terminal_input); - grub_unregister_command (cmd_terminal_output); } diff --git a/commands/terminal.c b/commands/terminal.c new file mode 100644 index 000000000..850d8296a --- /dev/null +++ b/commands/terminal.c @@ -0,0 +1,290 @@ +/* + * 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 + +grub_err_t +grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)), + int argc, char **args) +{ + int i; + grub_term_input_t term; + + if (argc == 0) + { + grub_puts_ (N_ ("Active input terminals:")); + FOR_ACTIVE_TERM_INPUTS(term) + grub_printf ("%s ", term->name); + grub_printf ("\n"); + grub_puts_ (N_ ("Available input terminals:")); + FOR_DISABLED_TERM_INPUTS(term) + grub_printf ("%s ", term->name); + grub_printf ("\n"); + return GRUB_ERR_NONE; + } + i = 0; + + if (grub_strcmp (args[0], "--append") == 0 + || grub_strcmp (args[0], "--removed") == 0) + i++; + + if (i == argc) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_ ("no terminal specified")); + + for (; i < argc; i++) + { + FOR_DISABLED_TERM_INPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term == 0) + FOR_DISABLED_TERM_INPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term == 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n", + args[i]); + } + + if (grub_strcmp (args[0], "--append") == 0) + { + for (i = 1; i < argc; i++) + { + FOR_DISABLED_TERM_INPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term) + { + grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs_disabled)), + GRUB_AS_LIST (term)); + if (term->init) + term->init (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), + GRUB_AS_LIST (term)); + } + } + return GRUB_ERR_NONE; + } + + if (grub_strcmp (args[0], "--remove") == 0) + { + for (i = 1; i < argc; i++) + { + FOR_ACTIVE_TERM_INPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term) + { + if (!term->next && term == grub_term_inputs) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "can't remove the last terminal"); + grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs)), + GRUB_AS_LIST (term)); + if (term->fini) + term->fini (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled), + GRUB_AS_LIST (term)); + } + } + return GRUB_ERR_NONE; + } + for (i = 0; i < argc; i++) + { + FOR_DISABLED_TERM_INPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term) + { + grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs_disabled)), + GRUB_AS_LIST (term)); + if (term->init) + term->init (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), + GRUB_AS_LIST (term)); + } + } + + FOR_ACTIVE_TERM_INPUTS(term) + { + for (i = 0; i < argc; i++) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (i != argc) + { + if (!term->next && term == grub_term_inputs) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "can't remove the last terminal"); + grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs)), + GRUB_AS_LIST (term)); + if (term->fini) + term->fini (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled), + GRUB_AS_LIST (term)); + } + } + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)), + int argc, char **args) +{ + int i; + grub_term_output_t term; + + if (argc == 0) + { + grub_puts_ (N_ ("Active output terminals:")); + FOR_ACTIVE_TERM_OUTPUTS(term) + grub_printf ("%s ", term->name); + grub_printf ("\n"); + grub_puts_ (N_ ("Available output terminals:")); + FOR_DISABLED_TERM_OUTPUTS(term) + grub_printf ("%s ", term->name); + grub_printf ("\n"); + return GRUB_ERR_NONE; + } + i = 0; + + if (grub_strcmp (args[0], "--append") == 0 + || grub_strcmp (args[0], "--removed") == 0) + i++; + + if (i == argc) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_ ("no terminal specified")); + + for (; i < argc; i++) + { + FOR_DISABLED_TERM_OUTPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term == 0) + FOR_DISABLED_TERM_OUTPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term == 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n", + args[i]); + } + + if (grub_strcmp (args[0], "--append") == 0) + { + for (i = 1; i < argc; i++) + { + FOR_DISABLED_TERM_OUTPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term) + { + grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)), + GRUB_AS_LIST (term)); + if (term->init) + term->init (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs), + GRUB_AS_LIST (term)); + } + } + return GRUB_ERR_NONE; + } + + if (grub_strcmp (args[0], "--remove") == 0) + { + for (i = 1; i < argc; i++) + { + FOR_ACTIVE_TERM_OUTPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term) + { + if (!term->next && term == grub_term_outputs) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "can't remove the last terminal"); + grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs)), + GRUB_AS_LIST (term)); + if (term->fini) + term->fini (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled), + GRUB_AS_LIST (term)); + } + } + return GRUB_ERR_NONE; + } + for (i = 0; i < argc; i++) + { + FOR_DISABLED_TERM_OUTPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term) + { + grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)), + GRUB_AS_LIST (term)); + if (term->init) + term->init (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs), + GRUB_AS_LIST (term)); + } + } + + FOR_ACTIVE_TERM_OUTPUTS(term) + { + for (i = 0; i < argc; i++) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (i != argc) + { + if (!term->next && term == grub_term_outputs) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "can't remove the last terminal"); + grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs)), + GRUB_AS_LIST (term)); + if (term->fini) + term->fini (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled), + GRUB_AS_LIST (term)); + } + } + + return GRUB_ERR_NONE; +} + +static grub_command_t cmd_terminal_input, cmd_terminal_output; + +GRUB_MOD_INIT(terminal) +{ + cmd_terminal_input = + grub_register_command ("terminal_input", grub_cmd_terminal_input, + "terminal_input [--append|--remove] " + "[TERMINAL1] [TERMINAL2] ...", + "List or select an input terminal."); + cmd_terminal_output = + grub_register_command ("terminal_output", grub_cmd_terminal_output, + "terminal_output [--append|--remove] " + "[TERMINAL1] [TERMINAL2] ...", + "List or select an output terminal."); +} + +GRUB_MOD_FINI(terminal) +{ + grub_unregister_command (cmd_terminal_input); + grub_unregister_command (cmd_terminal_output); +} diff --git a/genhandlerlist.sh b/genhandlerlist.sh index 6446a98ff..e4cb0d9de 100644 --- a/genhandlerlist.sh +++ b/genhandlerlist.sh @@ -16,8 +16,4 @@ module=$1 grep -v "^#" | sed -n \ - -e "/grub_parser_register *( *\"/{s/.*( *\"\([^\"]*\)\".*/parser.\1: $module/;p;}" \ - -e "/grub_reader_register *( *\"/{s/.*( *\"\([^\"]*\)\".*/reader.\1: $module/;p;}" \ - -e "/grub_term_register_input *( *\"/{s/.*( *\"\([^\"]*\)\".*/terminal_input.\1: $module/;p;}" \ - -e "/grub_term_register_output *( *\"/{s/.*( *\"\([^\"]*\)\".*/terminal_output.\1: $module/;p;}" \ - -e "/grub_menu_viewer_register *( *\"/{s/.*( *\"\([^\"]*\)\".*/menu_viewer.\1: $module/;p;}" + -e "/grub_parser_register *( *\"/{s/.*( *\"\([^\"]*\)\".*/parser.\1: $module/;p;}" diff --git a/include/grub/term.h b/include/grub/term.h index bf6766af6..24bb503ba 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -68,8 +68,6 @@ grub_term_color_state; #define GRUB_TERM_NO_EDIT (1 << 1) /* Set when the terminal cannot do fancy things. */ #define GRUB_TERM_DUMB (1 << 2) -/* Terminal is used as general output. */ -#define GRUB_TERM_ACTIVE (1 << 3) /* Set when the terminal needs to be initialized. */ #define GRUB_TERM_NEED_INIT (1 << 16) @@ -197,37 +195,65 @@ struct grub_term_output }; typedef struct grub_term_output *grub_term_output_t; +extern struct grub_term_output *EXPORT_VAR(grub_term_outputs_disabled); +extern struct grub_term_input *EXPORT_VAR(grub_term_inputs_disabled); extern struct grub_term_output *EXPORT_VAR(grub_term_outputs); extern struct grub_term_input *EXPORT_VAR(grub_term_inputs); +static inline void +grub_term_register_input_active (const char *name __attribute__ ((unused)), + grub_term_input_t term) +{ + if (term->init) + term->init (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term)); +} + static inline void grub_term_register_input (const char *name __attribute__ ((unused)), grub_term_input_t term) { - grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term)); + grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled), + GRUB_AS_LIST (term)); +} + +static inline void +grub_term_register_output_active (const char *name __attribute__ ((unused)), + grub_term_output_t term) +{ + if (term->init) + term->init (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs), GRUB_AS_LIST (term)); } static inline void grub_term_register_output (const char *name __attribute__ ((unused)), grub_term_output_t term) { - grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs), GRUB_AS_LIST (term)); + grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled), + GRUB_AS_LIST (term)); } static inline void grub_term_unregister_input (grub_term_input_t term) { grub_list_remove (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term)); + grub_list_remove (GRUB_AS_LIST_P (&grub_term_inputs_disabled), + GRUB_AS_LIST (term)); } static inline void grub_term_unregister_output (grub_term_output_t term) { grub_list_remove (GRUB_AS_LIST_P (&grub_term_outputs), GRUB_AS_LIST (term)); + grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)), + GRUB_AS_LIST (term)); } #define FOR_ACTIVE_TERM_INPUTS(var) for (var = grub_term_inputs; var; var = var->next) -#define FOR_ACTIVE_TERM_OUTPUTS(var) for (var = grub_term_outputs; var; var = var->next) if (grub_term_is_active (var)) +#define FOR_DISABLED_TERM_INPUTS(var) for (var = grub_term_inputs_disabled; var; var = var->next) +#define FOR_ACTIVE_TERM_OUTPUTS(var) for (var = grub_term_outputs; var; var = var->next) +#define FOR_DISABLED_TERM_OUTPUTS(var) for (var = grub_term_outputs_disabled; var; var = var->next) void EXPORT_FUNC(grub_putchar) (int c); void EXPORT_FUNC(grub_putcode) (grub_uint32_t code, @@ -335,12 +361,6 @@ grub_term_setcursor (struct grub_term_output *term, int on) term->setcursor (on); } -static inline int -grub_term_is_active (struct grub_term_output *term) -{ - return !!(term->flags & GRUB_TERM_ACTIVE); -} - static inline grub_ssize_t grub_term_getcharwidth (struct grub_term_output *term, grub_uint32_t c) { diff --git a/kern/term.c b/kern/term.c index dbcac1b19..51eee3b08 100644 --- a/kern/term.c +++ b/kern/term.c @@ -23,6 +23,8 @@ #include #include +struct grub_term_output *grub_term_outputs_disabled; +struct grub_term_input *grub_term_inputs_disabled; struct grub_term_output *grub_term_outputs; struct grub_term_input *grub_term_inputs; diff --git a/term/i386/pc/console.c b/term/i386/pc/console.c index 6f56fc0d7..3c0fcccad 100644 --- a/term/i386/pc/console.c +++ b/term/i386/pc/console.c @@ -65,15 +65,14 @@ static struct grub_term_output grub_console_term_output = .setcolorstate = grub_console_setcolorstate, .setcolor = grub_console_setcolor, .getcolor = grub_console_getcolor, - .setcursor = grub_console_setcursor, - .flags = GRUB_TERM_ACTIVE, + .setcursor = grub_console_setcursor }; void grub_console_init (void) { - grub_term_register_output ("console", &grub_console_term_output); - grub_term_register_input ("console", &grub_console_term_input); + grub_term_register_output_active ("console", &grub_console_term_output); + grub_term_register_input_active ("console", &grub_console_term_input); } void From 4b4513adb360888c8e438bf5828d4d624e0da110 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Dec 2009 22:55:06 +0100 Subject: [PATCH 073/208] bugfix in cmdline handling --- normal/cmdline.c | 113 ++++++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 50 deletions(-) diff --git a/normal/cmdline.c b/normal/cmdline.c index 0f90fc2fe..c71ac47ce 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -41,7 +41,7 @@ grub_err_t grub_set_history (int newsize) { grub_uint32_t **old_hist_lines = hist_lines; - hist_lines = grub_malloc (sizeof (char *) * newsize); + hist_lines = grub_malloc (sizeof (grub_uint32_t *) * newsize); /* Copy the old lines into the new buffer. */ if (old_hist_lines) @@ -68,16 +68,16 @@ grub_set_history (int newsize) if (hist_pos < hist_end) grub_memmove (hist_lines, old_hist_lines + hist_pos, - (hist_end - hist_pos) * sizeof (char *)); + (hist_end - hist_pos) * sizeof (grub_uint32_t *)); else if (hist_used) { /* Copy the older part. */ grub_memmove (hist_lines, old_hist_lines + hist_pos, - (hist_size - hist_pos) * sizeof (char *)); + (hist_size - hist_pos) * sizeof (grub_uint32_t *)); /* Copy the newer part. */ grub_memmove (hist_lines + hist_size - hist_pos, old_hist_lines, - hist_end * sizeof (char *)); + hist_end * sizeof (grub_uint32_t *)); } } @@ -109,24 +109,25 @@ strlen_ucs4 (const grub_uint32_t *s) return p - s; } -static grub_uint32_t * -strdup_ucs4 (const grub_uint32_t *s) +/* Replace the history entry on position POS with the string S. */ +static void +grub_history_set (int pos, grub_uint32_t *s, grub_size_t len) { - grub_size_t len; - char *p; - - len = strlen_ucs4 (s) + 1; - p = (char *) grub_malloc (len * sizeof (grub_uint32_t)); - if (! p) - return 0; - - return grub_memcpy (p, s, len * sizeof (grub_uint32_t)); + grub_free (hist_lines[pos]); + hist_lines[pos] = grub_malloc ((len + 1) * sizeof (grub_uint32_t)); + if (!hist_lines[pos]) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + return ; + } + grub_memcpy (hist_lines[pos], s, len * sizeof (grub_uint32_t)); + hist_lines[pos][len] = 0; } - /* Insert a new history line S on the top of the history. */ static void -grub_history_add (grub_uint32_t *s) +grub_history_add (grub_uint32_t *s, grub_size_t len) { /* Remove the oldest entry in the history to make room for a new entry. */ @@ -147,16 +148,15 @@ grub_history_add (grub_uint32_t *s) hist_pos = hist_size + hist_pos; /* Insert into history. */ - hist_lines[hist_pos] = strdup_ucs4 (s); + hist_lines[hist_pos] = NULL; + grub_history_set (hist_pos, s, len); } /* Replace the history entry on position POS with the string S. */ static void -grub_history_replace (int pos, grub_uint32_t *s) +grub_history_replace (int pos, grub_uint32_t *s, grub_size_t len) { - pos = (hist_pos + pos) % hist_size; - grub_free (hist_lines[pos]); - hist_lines[pos] = strdup_ucs4 (s); + grub_history_set ((hist_pos + pos) % hist_size, s, len); } /* A completion hook to print items. */ @@ -322,7 +322,8 @@ grub_cmdline_get (const char *prompt) lpos = saved_lpos; cl_set_pos_all (); - grub_memmove (buf + lpos, buf + lpos + len, llen - lpos + 1); + grub_memmove (buf + lpos, buf + lpos + len, + sizeof (grub_uint32_t) * (llen - lpos + 1)); llen -= len; cl_print_all (lpos, 0); cl_set_pos_all (); @@ -379,7 +380,7 @@ grub_cmdline_get (const char *prompt) } if (hist_used == 0) - grub_history_add (buf); + grub_history_add (buf, llen); while ((key = GRUB_TERM_ASCII_CHAR (grub_getkey ())) != '\n' && key != '\r') { @@ -413,11 +414,9 @@ grub_cmdline_get (const char *prompt) case 9: /* Ctrl-i or TAB */ { - grub_uint32_t *insert; int restore; - char *bufu8, *insertu8; - grub_size_t insertlen; - grub_size_t t; + char *insertu8; + char *bufu8; buf[lpos] = '\0'; @@ -432,21 +431,6 @@ grub_cmdline_get (const char *prompt) insertu8 = grub_normal_do_completion (bufu8, &restore, print_completion); grub_free (bufu8); - insertlen = grub_strlen (bufu8); - insert = grub_malloc ((insertlen + 1) * sizeof (grub_uint32_t)); - if (!insert) - { - grub_free (insertu8); - grub_print_error (); - grub_errno = GRUB_ERR_NONE; - break; - } - t = grub_utf8_to_ucs4 (insert, insertlen, - (grub_uint8_t *) insertu8, - insertlen, 0); - insert[t] = 0; - - grub_free (insertu8); if (restore) { @@ -456,9 +440,31 @@ grub_cmdline_get (const char *prompt) cl_print_all (0, 0); } - if (insert) + if (insertu8) { - cl_insert (insert); + grub_size_t insertlen; + grub_ssize_t t; + grub_uint32_t *insert; + + insertlen = grub_strlen (insertu8); + insert = grub_malloc ((insertlen + 1) * sizeof (grub_uint32_t)); + if (!insert) + { + grub_free (insertu8); + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + break; + } + t = grub_utf8_to_ucs4 (insert, insertlen, + (grub_uint8_t *) insertu8, + insertlen, 0); + if (t > 0) + { + insert[t] = 0; + cl_insert (insert); + } + + grub_free (insertu8); grub_free (insert); } } @@ -470,12 +476,19 @@ grub_cmdline_get (const char *prompt) if (kill_buf) grub_free (kill_buf); - kill_buf = strdup_ucs4 (buf + lpos); + kill_buf = grub_malloc ((llen - lpos + 1) + * sizeof (grub_uint32_t)); if (grub_errno) { grub_print_error (); grub_errno = GRUB_ERR_NONE; } + else + { + grub_memcpy (kill_buf, buf + lpos, + (llen - lpos + 1) * sizeof (grub_uint32_t)); + kill_buf[llen - lpos] = 0; + } cl_delete (llen - lpos); } @@ -489,7 +502,7 @@ grub_cmdline_get (const char *prompt) if (histpos > 0) { - grub_history_replace (histpos, buf); + grub_history_replace (histpos, buf, llen); histpos--; } @@ -507,7 +520,7 @@ grub_cmdline_get (const char *prompt) if (histpos < hist_used - 1) { - grub_history_replace (histpos, buf); + grub_history_replace (histpos, buf, llen); histpos++; } @@ -592,8 +605,8 @@ grub_cmdline_get (const char *prompt) if (strlen_ucs4 (buf) > 0) { grub_uint32_t empty[] = { 0 }; - grub_history_replace (histpos, buf); - grub_history_add (empty); + grub_history_replace (histpos, buf, llen); + grub_history_add (empty, 0); } ret = grub_ucs4_to_utf8_alloc (buf + lpos, llen - lpos + 1); From 686ff5b4d17d22198b6150479878560ddb53a3f2 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Dec 2009 23:19:54 +0100 Subject: [PATCH 074/208] Don't output unnecessary newline in command line prompt --- normal/cmdline.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/normal/cmdline.c b/normal/cmdline.c index c71ac47ce..d7f41c7e3 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -356,8 +356,13 @@ grub_cmdline_get (const char *prompt) lpos = llen = 0; buf[0] = '\0'; - grub_putchar ('\n'); + { + grub_term_output_t term; + FOR_ACTIVE_TERM_OUTPUTS(term) + if ((grub_term_getxy (term) >> 8) != 0) + grub_putcode ('\n', term); + } grub_printf ("%s", prompt_translated); { From 9f0cd916a48f554707dd58ae4aad13114a7c7e6a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Dec 2009 23:20:43 +0100 Subject: [PATCH 075/208] Restrict terminfo to serial --- include/grub/terminfo.h | 14 ++++++++------ term/i386/pc/serial.c | 13 +++++++------ term/terminfo.c | 28 ++++++++++++++-------------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/include/grub/terminfo.h b/include/grub/terminfo.h index 1ea741e04..e3a2c170a 100644 --- a/include/grub/terminfo.h +++ b/include/grub/terminfo.h @@ -21,15 +21,17 @@ #include #include +#include char *grub_terminfo_get_current (void); grub_err_t grub_terminfo_set_current (const char *); -void grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y); -void grub_terminfo_cls (void); -void grub_terminfo_reverse_video_on (void); -void grub_terminfo_reverse_video_off (void); -void grub_terminfo_cursor_on (void); -void grub_terminfo_cursor_off (void); +void grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y, + grub_term_output_t oterm); +void grub_terminfo_cls (grub_term_output_t oterm); +void grub_terminfo_reverse_video_on (grub_term_output_t oterm); +void grub_terminfo_reverse_video_off (grub_term_output_t oterm); +void grub_terminfo_cursor_on (grub_term_output_t oterm); +void grub_terminfo_cursor_off (grub_term_output_t oterm); #endif /* ! GRUB_TERMINFO_HEADER */ diff --git a/term/i386/pc/serial.c b/term/i386/pc/serial.c index 3f1c6d062..12612efcd 100644 --- a/term/i386/pc/serial.c +++ b/term/i386/pc/serial.c @@ -30,6 +30,7 @@ #define TEXT_WIDTH 80 #define TEXT_HEIGHT 25 +static struct grub_term_output grub_serial_term_output; static unsigned int xpos, ypos; static unsigned int keep_track = 1; static unsigned int registered = 0; @@ -413,7 +414,7 @@ grub_serial_gotoxy (grub_uint8_t x, grub_uint8_t y) else { keep_track = 0; - grub_terminfo_gotoxy (x, y); + grub_terminfo_gotoxy (x, y, &grub_serial_term_output); keep_track = 1; xpos = x; @@ -425,7 +426,7 @@ static void grub_serial_cls (void) { keep_track = 0; - grub_terminfo_cls (); + grub_terminfo_cls (&grub_serial_term_output); keep_track = 1; xpos = ypos = 0; @@ -439,10 +440,10 @@ grub_serial_setcolorstate (const grub_term_color_state state) { case GRUB_TERM_COLOR_STANDARD: case GRUB_TERM_COLOR_NORMAL: - grub_terminfo_reverse_video_off (); + grub_terminfo_reverse_video_off (&grub_serial_term_output); break; case GRUB_TERM_COLOR_HIGHLIGHT: - grub_terminfo_reverse_video_on (); + grub_terminfo_reverse_video_on (&grub_serial_term_output); break; default: break; @@ -454,9 +455,9 @@ static void grub_serial_setcursor (const int on) { if (on) - grub_terminfo_cursor_on (); + grub_terminfo_cursor_on (&grub_serial_term_output); else - grub_terminfo_cursor_off (); + grub_terminfo_cursor_off (&grub_serial_term_output); } static struct grub_term_input grub_serial_term_input = diff --git a/term/terminfo.c b/term/terminfo.c index 80ae9b100..a793564fd 100644 --- a/term/terminfo.c +++ b/term/terminfo.c @@ -108,52 +108,52 @@ grub_terminfo_set_current (const char *str) /* Wrapper for grub_putchar to write strings. */ static void -putstr (const char *str) +putstr (const char *str, grub_term_output_t oterm) { while (*str) - grub_putchar (*str++); + grub_putcode (*str++, oterm); } /* Move the cursor to the given position starting with "0". */ void -grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y) +grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y, grub_term_output_t oterm) { - putstr (grub_terminfo_tparm (term.gotoxy, y, x)); + putstr (grub_terminfo_tparm (term.gotoxy, y, x), oterm); } /* Clear the screen. */ void -grub_terminfo_cls (void) +grub_terminfo_cls (grub_term_output_t oterm) { - putstr (grub_terminfo_tparm (term.cls)); + putstr (grub_terminfo_tparm (term.cls), oterm); } /* Set reverse video mode on. */ void -grub_terminfo_reverse_video_on (void) +grub_terminfo_reverse_video_on (grub_term_output_t oterm) { - putstr (grub_terminfo_tparm (term.reverse_video_on)); + putstr (grub_terminfo_tparm (term.reverse_video_on), oterm); } /* Set reverse video mode off. */ void -grub_terminfo_reverse_video_off (void) +grub_terminfo_reverse_video_off (grub_term_output_t oterm) { - putstr (grub_terminfo_tparm (term.reverse_video_off)); + putstr (grub_terminfo_tparm (term.reverse_video_off), oterm); } /* Show cursor. */ void -grub_terminfo_cursor_on (void) +grub_terminfo_cursor_on (grub_term_output_t oterm) { - putstr (grub_terminfo_tparm (term.cursor_on)); + putstr (grub_terminfo_tparm (term.cursor_on), oterm); } /* Hide cursor. */ void -grub_terminfo_cursor_off (void) +grub_terminfo_cursor_off (grub_term_output_t oterm) { - putstr (grub_terminfo_tparm (term.cursor_off)); + putstr (grub_terminfo_tparm (term.cursor_off), oterm); } /* GRUB Command. */ From abd1cab3d9a2ad8f56cea3466b221c429fc880b0 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Dec 2009 23:21:27 +0100 Subject: [PATCH 076/208] Fix terminal_* commands --- commands/terminal.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/commands/terminal.c b/commands/terminal.c index 850d8296a..a667825f4 100644 --- a/commands/terminal.c +++ b/commands/terminal.c @@ -45,7 +45,7 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)), i = 0; if (grub_strcmp (args[0], "--append") == 0 - || grub_strcmp (args[0], "--removed") == 0) + || grub_strcmp (args[0], "--remove") == 0) i++; if (i == argc) @@ -57,7 +57,7 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)), if (grub_strcmp (args[i], term->name) == 0) break; if (term == 0) - FOR_DISABLED_TERM_INPUTS(term) + FOR_ACTIVE_TERM_INPUTS(term) if (grub_strcmp (args[i], term->name) == 0) break; if (term == 0) @@ -128,7 +128,7 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)), for (i = 0; i < argc; i++) if (grub_strcmp (args[i], term->name) == 0) break; - if (i != argc) + if (i == argc) { if (!term->next && term == grub_term_inputs) return grub_error (GRUB_ERR_BAD_ARGUMENT, @@ -167,7 +167,7 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)), i = 0; if (grub_strcmp (args[0], "--append") == 0 - || grub_strcmp (args[0], "--removed") == 0) + || grub_strcmp (args[0], "--remove") == 0) i++; if (i == argc) @@ -179,7 +179,7 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)), if (grub_strcmp (args[i], term->name) == 0) break; if (term == 0) - FOR_DISABLED_TERM_OUTPUTS(term) + FOR_ACTIVE_TERM_OUTPUTS(term) if (grub_strcmp (args[i], term->name) == 0) break; if (term == 0) @@ -229,6 +229,7 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)), } return GRUB_ERR_NONE; } + for (i = 0; i < argc; i++) { FOR_DISABLED_TERM_OUTPUTS(term) @@ -250,7 +251,7 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)), for (i = 0; i < argc; i++) if (grub_strcmp (args[i], term->name) == 0) break; - if (i != argc) + if (i == argc) { if (!term->next && term == grub_term_outputs) return grub_error (GRUB_ERR_BAD_ARGUMENT, From d0e158c2f3322c4c9ea4ae7de080bb4c74dab290 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 24 Dec 2009 22:23:22 +0000 Subject: [PATCH 077/208] 2009-12-24 Robert Millan * util/grub-install.in (host_os): New variable. * util/i386/efi/grub-install.in (host_os): Likewise. --- ChangeLog | 5 +++++ util/grub-install.in | 1 + util/i386/efi/grub-install.in | 1 + 3 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 75683b8d5..d9fb2cb1f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-24 Robert Millan + + * util/grub-install.in (host_os): New variable. + * util/i386/efi/grub-install.in (host_os): Likewise. + 2009-12-24 Robert Millan * util/mkisofs/write.c (padblock_write): Abort when given an diff --git a/util/grub-install.in b/util/grub-install.in index 4df620812..7283e1b40 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -29,6 +29,7 @@ PACKAGE_TARNAME=@PACKAGE_TARNAME@ PACKAGE_VERSION=@PACKAGE_VERSION@ target_cpu=@target_cpu@ platform=@platform@ +host_os=@host_os@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` grub_setup=${sbindir}/`echo grub-setup | sed ${transform}` diff --git a/util/i386/efi/grub-install.in b/util/i386/efi/grub-install.in index a5f97e346..e0e0f2717 100644 --- a/util/i386/efi/grub-install.in +++ b/util/i386/efi/grub-install.in @@ -29,6 +29,7 @@ PACKAGE_TARNAME=@PACKAGE_TARNAME@ PACKAGE_VERSION=@PACKAGE_VERSION@ target_cpu=@target_cpu@ platform=@platform@ +host_os=@host_os@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` From 6d305d4f7da4e3203e279a2748e388bcdd183cf9 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Dec 2009 23:37:38 +0100 Subject: [PATCH 078/208] Fix paging. --- kern/term.c | 10 +++------- normal/term.c | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/kern/term.c b/kern/term.c index 51eee3b08..8f8576aa2 100644 --- a/kern/term.c +++ b/kern/term.c @@ -34,10 +34,6 @@ void (*grub_newline_hook) (void) = NULL; void grub_putcode (grub_uint32_t code, struct grub_term_output *term) { - int height; - - height = grub_term_height (term); - if (code == '\t' && term->getxy) { int n; @@ -62,7 +58,7 @@ grub_putchar (int c) static grub_size_t size = 0; static grub_uint8_t buf[6]; grub_uint32_t code; - grub_ssize_t ret; + grub_size_t ret; buf[size++] = c; ret = grub_utf8_to_ucs4 (&code, 1, buf, size, 0); @@ -73,9 +69,9 @@ grub_putchar (int c) size = 0; FOR_ACTIVE_TERM_OUTPUTS(term) grub_putcode (code, term); + if (code == '\n' && grub_newline_hook) + grub_newline_hook (); } - if (ret == '\n' && grub_newline_hook) - grub_newline_hook (); } int diff --git a/normal/term.c b/normal/term.c index eb8f8e844..5a8e9cffc 100644 --- a/normal/term.c +++ b/normal/term.c @@ -37,7 +37,7 @@ process_newline (void) height = grub_term_height (cur); grub_more_lines++; - if (grub_more && grub_more_lines == height - 1) + if (grub_more && grub_more_lines >= height - 1) { char key; grub_uint16_t *pos; @@ -57,7 +57,7 @@ process_newline (void) /* Scroll one lines or an entire page, depending on the key. */ if (key == '\r' || key =='\n') - grub_more_lines--; + grub_more_lines = height - 2; else grub_more_lines = 0; } From 7fd0baee0fcea7fd52be7a7895350f213b5f8e32 Mon Sep 17 00:00:00 2001 From: carles Date: Thu, 24 Dec 2009 23:53:05 +0100 Subject: [PATCH 079/208] 2009-12-24 Carles Pina i Estany * bus/usb/usbhub.c: Fix capitalization, fullstop and newlines in grub_errno calls. * commands/acpi.c: Likewise. * commands/blocklist.c: Likewise. * commands/efi/loadbios.c: Likewise. * commands/i386/pc/drivemap.c: Likewise. * commands/loadenv.c: Likewise. * commands/memrw.c: Likewise. * commands/password.c: Likewise. * commands/videotest.c: Likewise. * disk/ata.c: Likewise. * disk/ata_pthru.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/ieee1275/nand.c: Likewise. * disk/ieee1275/ofdisk.c: Likewise. * disk/loopback.c: Likewise. * disk/lvm.c: Likewise. * disk/mdraid_linux.c: Likewise. * disk/raid.c: Likewise. * disk/raid6_recover.c: Likewise. * disk/scsi.c: Likewise. * efiemu/main.c: Likewise. * efiemu/mm.c: Likewise. * efiemu/pnvram.c: Likewise. * efiemu/symbols.c: Likewise. * font/font.c: Likewise. * fs/cpio.c: Likewise. * fs/hfsplus.c: Likewise. * fs/iso9660.c: Likewise. * fs/jfs.c: Likewise. * fs/minix.c: Likewise. * fs/ntfs.c: Likewise. * fs/ntfscomp.c: Likewise. * fs/reiserfs.c: Likewise. * fs/ufs.c: Likewise. * fs/xfs.c: Likewise. * gettext/gettext.c: Likewise. * include/grub/auth.h: Likewise. * kern/elf.c: Likewise. * kern/file.c: Likewise. * kern/ieee1275/init.c: Likewise. * kern/ieee1275/mmap.c: Likewise. * kern/ieee1275/openfw.c: Likewise. * kern/powerpc/dl.c: Likewise. * kern/sparc64/dl.c: Likewise. * lib/arg.c: Likewise. * loader/i386/bsd.c: Likewise. * loader/i386/bsdXX.c: Likewise. * loader/i386/efi/linux.c: Likewise. * loader/i386/efi/xnu.c: Likewise. * loader/i386/ieee1275/linux.c: Likewise. * loader/i386/linux.c: Likewise. * loader/i386/multiboot.c: Likewise. * loader/i386/pc/linux.c: Likewise. * loader/i386/pc/multiboot2.c: Likewise. * loader/i386/xnu.c: Likewise. * loader/ieee1275/multiboot2.c: Likewise. * loader/macho.c: Likewise. * loader/machoXX.c: Likewise. * loader/multiboot2.c: Likewise. * loader/multiboot_loader.c: Likewise. * loader/powerpc/ieee1275/linux.c: Likewise. * loader/sparc64/ieee1275/linux.c: Likewise. * loader/xnu.c: Likewise. * loader/xnu_resume.c: Likewise. * mmap/i386/pc/mmap.c: Likewise. * normal/menu_viewer.c: Likewise. * partmap/acorn.c: Likewise. * partmap/amiga.c: Likewise. * partmap/apple.c: Likewise. * script/lexer.c: Likewise. * term/gfxterm.c: Likewise. * term/i386/pc/serial.c: Likewise. * term/i386/pc/vga.c: Likewise. * term/ieee1275/ofconsole.c: Likewise. * term/terminfo.c: Likewise. * video/bitmap.c: Likewise. * video/efi_gop.c: Likewise. * video/efi_uga.c: Likewise. * video/fb/video_fb.c: Likewise. * video/i386/pc/vbe.c: Likewise. * video/readers/tga.c: Likewise. * video/video.c: Likewise. --- ChangeLog | 86 +++++++++++++++++++++++++++++++++ bus/usb/usbhub.c | 2 +- commands/acpi.c | 12 ++--- commands/blocklist.c | 2 +- commands/efi/loadbios.c | 6 +-- commands/i386/pc/drivemap.c | 2 +- commands/loadenv.c | 2 +- commands/memrw.c | 4 +- commands/password.c | 2 +- commands/videotest.c | 2 +- disk/ata.c | 6 +-- disk/ata_pthru.c | 2 +- disk/dmraid_nvidia.c | 4 +- disk/ieee1275/nand.c | 10 ++-- disk/ieee1275/ofdisk.c | 12 ++--- disk/loopback.c | 4 +- disk/lvm.c | 8 +-- disk/mdraid_linux.c | 4 +- disk/raid.c | 4 +- disk/raid6_recover.c | 4 +- disk/scsi.c | 4 +- efiemu/main.c | 2 +- efiemu/mm.c | 4 +- efiemu/pnvram.c | 10 ++-- efiemu/symbols.c | 2 +- font/font.c | 18 +++---- fs/cpio.c | 4 +- fs/hfsplus.c | 2 +- fs/iso9660.c | 2 +- fs/jfs.c | 2 +- fs/minix.c | 2 +- fs/ntfs.c | 24 ++++----- fs/ntfscomp.c | 10 ++-- fs/reiserfs.c | 6 +-- fs/ufs.c | 2 +- fs/xfs.c | 4 +- gettext/gettext.c | 2 +- include/grub/auth.h | 2 +- kern/elf.c | 26 +++++----- kern/file.c | 2 +- kern/ieee1275/init.c | 2 +- kern/ieee1275/mmap.c | 4 +- kern/ieee1275/openfw.c | 4 +- kern/powerpc/dl.c | 4 +- kern/sparc64/dl.c | 8 +-- lib/arg.c | 12 ++--- loader/i386/bsd.c | 46 +++++++++--------- loader/i386/bsdXX.c | 8 +-- loader/i386/efi/linux.c | 10 ++-- loader/i386/efi/xnu.c | 6 +-- loader/i386/ieee1275/linux.c | 8 +-- loader/i386/linux.c | 12 ++--- loader/i386/multiboot.c | 16 +++--- loader/i386/pc/linux.c | 14 +++--- loader/i386/pc/multiboot2.c | 4 +- loader/i386/xnu.c | 4 +- loader/ieee1275/multiboot2.c | 6 +-- loader/macho.c | 4 +- loader/machoXX.c | 24 ++++----- loader/multiboot2.c | 16 +++--- loader/multiboot_loader.c | 6 +-- loader/powerpc/ieee1275/linux.c | 18 +++---- loader/sparc64/ieee1275/linux.c | 16 +++--- loader/xnu.c | 28 +++++------ loader/xnu_resume.c | 4 +- mmap/i386/pc/mmap.c | 2 +- normal/menu_viewer.c | 2 +- partmap/acorn.c | 2 +- partmap/amiga.c | 2 +- partmap/apple.c | 2 +- script/lexer.c | 2 +- term/gfxterm.c | 2 +- term/i386/pc/serial.c | 2 +- term/i386/pc/vga.c | 2 +- term/ieee1275/ofconsole.c | 4 +- term/terminfo.c | 4 +- video/bitmap.c | 8 +-- video/efi_gop.c | 6 +-- video/efi_uga.c | 2 +- video/fb/video_fb.c | 4 +- video/i386/pc/vbe.c | 2 +- video/readers/tga.c | 4 +- video/video.c | 46 +++++++++--------- 83 files changed, 388 insertions(+), 302 deletions(-) diff --git a/ChangeLog b/ChangeLog index e594931e1..9601cb2c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,89 @@ +2009-12-24 Carles Pina i Estany + + * bus/usb/usbhub.c: Fix capitalization, fullstop and newlines in + grub_errno calls. + * commands/acpi.c: Likewise. + * commands/blocklist.c: Likewise. + * commands/efi/loadbios.c: Likewise. + * commands/i386/pc/drivemap.c: Likewise. + * commands/loadenv.c: Likewise. + * commands/memrw.c: Likewise. + * commands/password.c: Likewise. + * commands/videotest.c: Likewise. + * disk/ata.c: Likewise. + * disk/ata_pthru.c: Likewise. + * disk/dmraid_nvidia.c: Likewise. + * disk/ieee1275/nand.c: Likewise. + * disk/ieee1275/ofdisk.c: Likewise. + * disk/loopback.c: Likewise. + * disk/lvm.c: Likewise. + * disk/mdraid_linux.c: Likewise. + * disk/raid.c: Likewise. + * disk/raid6_recover.c: Likewise. + * disk/scsi.c: Likewise. + * efiemu/main.c: Likewise. + * efiemu/mm.c: Likewise. + * efiemu/pnvram.c: Likewise. + * efiemu/symbols.c: Likewise. + * font/font.c: Likewise. + * fs/cpio.c: Likewise. + * fs/hfsplus.c: Likewise. + * fs/iso9660.c: Likewise. + * fs/jfs.c: Likewise. + * fs/minix.c: Likewise. + * fs/ntfs.c: Likewise. + * fs/ntfscomp.c: Likewise. + * fs/reiserfs.c: Likewise. + * fs/ufs.c: Likewise. + * fs/xfs.c: Likewise. + * gettext/gettext.c: Likewise. + * include/grub/auth.h: Likewise. + * kern/elf.c: Likewise. + * kern/file.c: Likewise. + * kern/ieee1275/init.c: Likewise. + * kern/ieee1275/mmap.c: Likewise. + * kern/ieee1275/openfw.c: Likewise. + * kern/powerpc/dl.c: Likewise. + * kern/sparc64/dl.c: Likewise. + * lib/arg.c: Likewise. + * loader/i386/bsd.c: Likewise. + * loader/i386/bsdXX.c: Likewise. + * loader/i386/efi/linux.c: Likewise. + * loader/i386/efi/xnu.c: Likewise. + * loader/i386/ieee1275/linux.c: Likewise. + * loader/i386/linux.c: Likewise. + * loader/i386/multiboot.c: Likewise. + * loader/i386/pc/linux.c: Likewise. + * loader/i386/pc/multiboot2.c: Likewise. + * loader/i386/xnu.c: Likewise. + * loader/ieee1275/multiboot2.c: Likewise. + * loader/macho.c: Likewise. + * loader/machoXX.c: Likewise. + * loader/multiboot2.c: Likewise. + * loader/multiboot_loader.c: Likewise. + * loader/powerpc/ieee1275/linux.c: Likewise. + * loader/sparc64/ieee1275/linux.c: Likewise. + * loader/xnu.c: Likewise. + * loader/xnu_resume.c: Likewise. + * mmap/i386/pc/mmap.c: Likewise. + * normal/menu_viewer.c: Likewise. + * partmap/acorn.c: Likewise. + * partmap/amiga.c: Likewise. + * partmap/apple.c: Likewise. + * script/lexer.c: Likewise. + * term/gfxterm.c: Likewise. + * term/i386/pc/serial.c: Likewise. + * term/i386/pc/vga.c: Likewise. + * term/ieee1275/ofconsole.c: Likewise. + * term/terminfo.c: Likewise. + * video/bitmap.c: Likewise. + * video/efi_gop.c: Likewise. + * video/efi_uga.c: Likewise. + * video/fb/video_fb.c: Likewise. + * video/i386/pc/vbe.c: Likewise. + * video/readers/tga.c: Likewise. + * video/video.c: Likewise. + 2009-12-23 Felix Zielcke * commands/i386/pc/drivemap.c: Remove all trailing whitespace. diff --git a/bus/usb/usbhub.c b/bus/usb/usbhub.c index a22ca60c2..523abf93e 100644 --- a/bus/usb/usbhub.c +++ b/bus/usb/usbhub.c @@ -50,7 +50,7 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller, grub_usb_speed_t speed) } if (i == 128) { - grub_error (GRUB_ERR_IO, "Can't assign address to USB device"); + grub_error (GRUB_ERR_IO, "can't assign address to USB device"); return NULL; } diff --git a/commands/acpi.c b/commands/acpi.c index c9acf5abe..6bf9f696b 100644 --- a/commands/acpi.c +++ b/commands/acpi.c @@ -277,7 +277,7 @@ grub_acpi_create_ebda (void) { grub_mmap_unregister (mmapregion); return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Couldn't find suitable spot in EBDA"); + "couldn't find suitable spot in EBDA"); } /* Remove any other RSDT. */ @@ -551,7 +551,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd, grub_free (exclude); grub_free (load_only); return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Couldn't allocate table"); + "couldn't allocate table"); } grub_memcpy (table_dsdt, dsdt, dsdt->length); } @@ -578,7 +578,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd, grub_free (exclude); grub_free (load_only); return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Couldn't allocate table structure"); + "couldn't allocate table structure"); } table->size = curtable->length; table->addr = grub_malloc (table->size); @@ -587,7 +587,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd, { free_tables (); return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Couldn't allocate table"); + "couldn't allocate table"); } table->next = acpi_tables; acpi_tables = table; @@ -674,7 +674,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd, { free_tables (); return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Couldn't allocate table structure"); + "couldn't allocate table structure"); } table->size = size; @@ -709,7 +709,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd, { free_tables (); return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Couldn't allocate space for ACPI tables"); + "couldn't allocate space for ACPI tables"); } setup_common_tables (); diff --git a/commands/blocklist.c b/commands/blocklist.c index b457b7c39..51a91e2d7 100644 --- a/commands/blocklist.c +++ b/commands/blocklist.c @@ -87,7 +87,7 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)), if (! file->device->disk) return grub_error (GRUB_ERR_BAD_DEVICE, - "this command is available only for disk devices."); + "this command is available only for disk devices"); if (file->device->disk->partition) part_start = grub_partition_get_start (file->device->disk->partition); diff --git a/commands/efi/loadbios.c b/commands/efi/loadbios.c index d7ad42690..6f96d4826 100644 --- a/commands/efi/loadbios.c +++ b/commands/efi/loadbios.c @@ -160,7 +160,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)), int size; if (argc == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "No rom image specified"); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "no rom image specified"); if (argc > 1) { @@ -169,7 +169,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)), return grub_errno; if (file->size != 4) - grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid int10 dump size"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid int10 dump size"); else grub_file_read (file, (void *) 0x40, 4); @@ -184,7 +184,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)), size = file->size; if ((size < 0x10000) || (size > 0x40000)) - grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid bios dump size"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid bios dump size"); else if (enable_rom_area ()) { grub_file_read (file, (void *) VBIOS_ADDR, size); diff --git a/commands/i386/pc/drivemap.c b/commands/i386/pc/drivemap.c index 7d1420eea..967c95239 100644 --- a/commands/i386/pc/drivemap.c +++ b/commands/i386/pc/drivemap.c @@ -308,7 +308,7 @@ install_int13_handler (int noret __attribute__ ((unused))) GRUB_MACHINE_MEMORY_RESERVED, GRUB_MMAP_MALLOC_LOW); if (! handler_base) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "Could not reserve " + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "could not reserve " "memory for the int13h handler"); /* Copy int13h handler bundle to reserved area. */ diff --git a/commands/loadenv.c b/commands/loadenv.c index c10dd0e27..ac5064df9 100644 --- a/commands/loadenv.c +++ b/commands/loadenv.c @@ -328,7 +328,7 @@ grub_cmd_save_env (grub_extcmd_t cmd, int argc, char **args) } if (! argc) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "No variable is specified"); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "no variable is specified"); file = open_envblk_file ((state[0].set) ? state[0].arg : 0); if (! file) diff --git a/commands/memrw.c b/commands/memrw.c index eada1d232..de3ac38e1 100644 --- a/commands/memrw.c +++ b/commands/memrw.c @@ -41,7 +41,7 @@ grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv) char buf[sizeof ("XXXXXXXX")]; if (argc != 1) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments"); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid number of arguments"); addr = grub_strtoul (argv[0], 0, 0); switch (cmd->cmd->name[sizeof ("read_") - 1]) @@ -78,7 +78,7 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv) grub_uint32_t mask = 0xffffffff; if (argc != 2 && argc != 3) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments"); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid number of arguments"); addr = grub_strtoul (argv[0], 0, 0); value = grub_strtoul (argv[1], 0, 0); diff --git a/commands/password.c b/commands/password.c index 0e048797e..710283b3d 100644 --- a/commands/password.c +++ b/commands/password.c @@ -53,7 +53,7 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)), char *pass; if (argc != 2) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "Two arguments expected."); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "two arguments expected"); pass = grub_strdup (args[1]); if (!pass) diff --git a/commands/videotest.c b/commands/videotest.c index 15525524b..e27552510 100644 --- a/commands/videotest.c +++ b/commands/videotest.c @@ -71,7 +71,7 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)), sanssmall = grub_font_get ("Helvetica 8"); fixed = grub_font_get ("Fixed 20"); if (! sansbig || ! sans || ! sanssmall || ! fixed) - return grub_error (GRUB_ERR_BAD_FONT, "No font loaded."); + return grub_error (GRUB_ERR_BAD_FONT, "no font loaded"); glyph = grub_font_get_glyph (fixed, '*'); grub_font_draw_glyph (glyph, color, 200 ,0); diff --git a/disk/ata.c b/disk/ata.c index af8c87180..bfd53cbaf 100644 --- a/disk/ata.c +++ b/disk/ata.c @@ -675,7 +675,7 @@ grub_ata_open (const char *name, grub_disk_t disk) } if (! dev) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device"); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); if (dev->atapi) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not an ATA harddisk"); @@ -775,7 +775,7 @@ grub_atapi_read (struct grub_scsi *scsi, /* Count of last transfer may be uneven. */ if (! (0 < cnt && cnt <= size - nread && (! (cnt & 1) || cnt == size - nread))) - return grub_error (GRUB_ERR_READ_ERROR, "Invalid ATAPI transfer count"); + return grub_error (GRUB_ERR_READ_ERROR, "invalid ATAPI transfer count"); /* Read the data. */ grub_ata_pio_read (dev, buf + nread, cnt); @@ -821,7 +821,7 @@ grub_atapi_open (const char *name, struct grub_scsi *scsi) grub_dprintf ("ata", "opening ATAPI dev `%s'\n", name); if (! devfnd) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "No such ATAPI device"); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such ATAPI device"); scsi->data = devfnd; diff --git a/disk/ata_pthru.c b/disk/ata_pthru.c index 70d4f3a78..f52725a49 100644 --- a/disk/ata_pthru.c +++ b/disk/ata_pthru.c @@ -30,7 +30,7 @@ grub_ata_pass_through (grub_disk_t disk, { if (disk->dev->id != GRUB_DISK_DEVICE_ATA_ID) return grub_error (GRUB_ERR_BAD_DEVICE, - "Device not accessed via ata.mod"); + "device not accessed via ata.mod"); struct grub_ata_device *dev = (struct grub_ata_device *) disk->data; diff --git a/disk/dmraid_nvidia.c b/disk/dmraid_nvidia.c index 84dfad8c4..46eac6ac5 100644 --- a/disk/dmraid_nvidia.c +++ b/disk/dmraid_nvidia.c @@ -107,7 +107,7 @@ grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array) if (sb.version != NV_VERSION) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "Unknown version: %d.%d", sb.version); + "unknown version: %d.%d", sb.version); switch (sb.array.raid_level) { @@ -129,7 +129,7 @@ grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array) default: return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "Unsupported RAID level: %d", sb.array.raid_level); + "unsupported RAID level: %d", sb.array.raid_level); } array->number = 0; diff --git a/disk/ieee1275/nand.c b/disk/ieee1275/nand.c index 37427f884..76402a9a6 100644 --- a/disk/ieee1275/nand.c +++ b/disk/ieee1275/nand.c @@ -67,7 +67,7 @@ grub_nand_open (const char *name, grub_disk_t disk) } args; if (! grub_strstr (name, "nand")) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Not a nand device"); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a nand device"); data = grub_malloc (sizeof (*data)); if (! data) @@ -76,7 +76,7 @@ grub_nand_open (const char *name, grub_disk_t disk) grub_ieee1275_open (name, &dev_ihandle); if (! dev_ihandle) { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device"); + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); goto fail; } @@ -89,7 +89,7 @@ grub_nand_open (const char *name, grub_disk_t disk) if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result)) { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't get block size"); + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get block size"); goto fail; } @@ -102,7 +102,7 @@ grub_nand_open (const char *name, grub_disk_t disk) if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result)) { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't get disk size"); + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get disk size"); goto fail; } @@ -172,7 +172,7 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector, args.result = 1; if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result)) - return grub_error (GRUB_ERR_READ_ERROR, "Read error"); + return grub_error (GRUB_ERR_READ_ERROR, "read error"); ofs = 0; size -= len; diff --git a/disk/ieee1275/ofdisk.c b/disk/ieee1275/ofdisk.c index a33d729e3..c2a3a2c3a 100644 --- a/disk/ieee1275/ofdisk.c +++ b/disk/ieee1275/ofdisk.c @@ -175,7 +175,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) grub_ieee1275_open (op->devpath, &dev_ihandle); if (! dev_ihandle) { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device"); + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); goto fail; } @@ -184,20 +184,20 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) if (grub_ieee1275_finddevice (op->devpath, &dev)) { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read device properties"); + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't read device properties"); goto fail; } if (grub_ieee1275_get_property (dev, "device_type", prop, sizeof (prop), &actual)) { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read the device type"); + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't read the device type"); goto fail; } if (grub_strcmp (prop, "block")) { - grub_error (GRUB_ERR_BAD_DEVICE, "Not a block device"); + grub_error (GRUB_ERR_BAD_DEVICE, "not a block device"); goto fail; } @@ -244,12 +244,12 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector, (int) (pos >> 32), (int) pos & 0xFFFFFFFFUL, &status); if (status < 0) return grub_error (GRUB_ERR_READ_ERROR, - "Seek error, can't seek block %llu", + "seek error, can't seek block %llu", (long long) sector); grub_ieee1275_read ((grub_ieee1275_ihandle_t) (unsigned long) disk->data, buf, size * 512UL, &actual); if (actual != actual) - return grub_error (GRUB_ERR_READ_ERROR, "Read error on block: %llu", + return grub_error (GRUB_ERR_READ_ERROR, "read error on block: %llu", (long long) sector); return 0; diff --git a/disk/loopback.c b/disk/loopback.c index 29805182e..c877dd8af 100644 --- a/disk/loopback.c +++ b/disk/loopback.c @@ -56,7 +56,7 @@ delete_loopback (const char *name) break; if (! dev) - return grub_error (GRUB_ERR_BAD_DEVICE, "Device not found"); + return grub_error (GRUB_ERR_BAD_DEVICE, "device not found"); /* Remove the device from the list. */ *prev = dev->next; @@ -167,7 +167,7 @@ grub_loopback_open (const char *name, grub_disk_t disk) break; if (! dev) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device"); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); file = grub_file_open (dev->filename); if (! file) diff --git a/disk/lvm.c b/disk/lvm.c index 126b49439..8d0c75a6d 100644 --- a/disk/lvm.c +++ b/disk/lvm.c @@ -95,7 +95,7 @@ grub_lvm_open (const char *name, grub_disk_t disk) } if (! lv) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown LVM device %s", name); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown LVM device %s", name); disk->has_partitions = 0; disk->id = lv->number; @@ -188,7 +188,7 @@ grub_lvm_read (grub_disk_t disk, grub_disk_addr_t sector, size << GRUB_DISK_SECTOR_BITS, buf); else err = grub_error (GRUB_ERR_UNKNOWN_DEVICE, - "Physical volume %s not found", pv->name); + "physical volume %s not found", pv->name); return err; } @@ -263,7 +263,7 @@ grub_lvm_scan_device (const char *name) if (dlocn->offset) { grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "We don't support multiple LVM data areas"); + "we don't support multiple LVM data areas"); goto fail; } @@ -290,7 +290,7 @@ grub_lvm_scan_device (const char *name) || (grub_le_to_cpu32 (mdah->version) != GRUB_LVM_FMTT_VERSION)) { grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "Unknown LVM metadata header"); + "unknown LVM metadata header"); goto fail2; } diff --git a/disk/mdraid_linux.c b/disk/mdraid_linux.c index 29a21b4c7..306c66a8b 100644 --- a/disk/mdraid_linux.c +++ b/disk/mdraid_linux.c @@ -181,7 +181,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array) /* FIXME: Also support version 1.0. */ if (sb.major_version != 0 || sb.minor_version != 90) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "Unsupported RAID version: %d.%d", + "unsupported RAID version: %d.%d", sb.major_version, sb.minor_version); /* FIXME: Check the checksum. */ @@ -193,7 +193,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array) if (sb.level != 0 && sb.level != 1 && sb.level != 4 && sb.level != 5 && sb.level != 6 && sb.level != 10) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "Unsupported RAID level: %d", sb.level); + "unsupported RAID level: %d", sb.level); array->number = sb.md_minor; array->level = sb.level; diff --git a/disk/raid.c b/disk/raid.c index c720fb36c..c48a41d8d 100644 --- a/disk/raid.c +++ b/disk/raid.c @@ -123,7 +123,7 @@ grub_raid_open (const char *name, grub_disk_t disk) } if (!array) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown RAID device %s", + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown RAID device %s", name); disk->has_partitions = 1; @@ -265,7 +265,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector, } else err = grub_error (GRUB_ERR_READ_ERROR, - "disk missing."); + "disk missing"); k++; if (k == array->total_devs) diff --git a/disk/raid6_recover.c b/disk/raid6_recover.c index 7bbf8eaef..ed0e92523 100644 --- a/disk/raid6_recover.c +++ b/disk/raid6_recover.c @@ -157,7 +157,7 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p, if (! array->device[q]) { - grub_error (GRUB_ERR_READ_ERROR, "Not enough disk to restore"); + grub_error (GRUB_ERR_READ_ERROR, "not enough disk to restore"); goto quit; } @@ -176,7 +176,7 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p, if ((! array->device[p]) || (! array->device[q])) { - grub_error (GRUB_ERR_READ_ERROR, "Not enough disk to restore"); + grub_error (GRUB_ERR_READ_ERROR, "not enough disk to restore"); goto quit; } diff --git a/disk/scsi.c b/disk/scsi.c index d0e248511..21b888559 100644 --- a/disk/scsi.c +++ b/disk/scsi.c @@ -337,14 +337,14 @@ grub_scsi_read (grub_disk_t disk, grub_disk_addr_t sector, unsigned spb = scsi->blocksize >> GRUB_DISK_SECTOR_BITS; if (! (spb != 0 && (scsi->blocksize & GRUB_DISK_SECTOR_SIZE) == 0)) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "Unsupported SCSI block size"); + "unsupported SCSI block size"); grub_uint32_t sector_mod = 0; sector = grub_divmod64 (sector, spb, §or_mod); if (! (sector_mod == 0 && size % spb == 0)) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "Unaligned SCSI read not supported"); + "unaligned SCSI read not supported"); size /= spb; } diff --git a/efiemu/main.c b/efiemu/main.c index 05787284d..f6d7b2e4c 100644 --- a/efiemu/main.c +++ b/efiemu/main.c @@ -214,7 +214,7 @@ grub_efiemu_load_file (const char *filename) { grub_file_close (file); grub_efiemu_unload (); - return grub_error (grub_errno, "Couldn't init memory management"); + return grub_error (grub_errno, "couldn't init memory management"); } grub_dprintf ("efiemu", "mm initialized\n"); diff --git a/efiemu/mm.c b/efiemu/mm.c index 8b0322942..6099a14ee 100644 --- a/efiemu/mm.c +++ b/efiemu/mm.c @@ -67,7 +67,7 @@ grub_efiemu_add_to_mmap (grub_uint64_t start, grub_uint64_t size, * sizeof (grub_efi_memory_descriptor_t)); if (!efiemu_mmap) return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Not enough space for memory map"); + "not enough space for memory map"); } /* Fill slot*/ @@ -622,7 +622,7 @@ grub_efiemu_mm_do_alloc (void) if (!efiemu_mmap) { grub_efiemu_unload (); - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "Couldn't initialize mmap"); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't initialize mmap"); } if ((err = efiemu_alloc_requests ())) diff --git a/efiemu/pnvram.c b/efiemu/pnvram.c index 7af01c055..e58fce84e 100644 --- a/efiemu/pnvram.c +++ b/efiemu/pnvram.c @@ -78,8 +78,8 @@ unescape (char *in, char *out, char *outmax, int *len) } if (dptr == outmax) return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Too many NVRAM variables for reserved variable space." - " Try increasing EfiEmu.pnvram.size."); + "too many NVRAM variables for reserved variable space." + " Try increasing EfiEmu.pnvram.size"); *len = dptr - out; return 0; } @@ -132,8 +132,8 @@ nvram_set (void * data __attribute__ ((unused))) if (nvramptr - nvram + sizeof (struct efi_variable) > nvramsize) { grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Too many NVRAM variables for reserved variable space." - " Try increasing EfiEmu.pnvram.size."); + "too many NVRAM variables for reserved variable space." + " Try increasing EfiEmu.pnvram.size"); return 1; } @@ -173,7 +173,7 @@ nvram_set (void * data __attribute__ ((unused))) if (len < 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "Broken UTF-8 in variable name\n"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "broken UTF-8 in variable name"); return 1; } diff --git a/efiemu/symbols.c b/efiemu/symbols.c index 5b9b2aec7..4fc546b59 100644 --- a/efiemu/symbols.c +++ b/efiemu/symbols.c @@ -222,7 +222,7 @@ grub_efiemu_set_virtual_address_map (grub_efi_uintn_t memory_map_size, /* Ensure that we are called only once */ if (*ptv_relocated) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "EfiEmu is already relocated."); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "EfiEmu is already relocated"); *ptv_relocated = 1; /* Correct addresses using information supplied by grub */ diff --git a/font/font.c b/font/font.c index a81291916..44827a9a1 100644 --- a/font/font.c +++ b/font/font.c @@ -210,7 +210,7 @@ open_section (grub_file_t file, struct font_file_section *section) else if (retval < 0) { grub_error (GRUB_ERR_BAD_FONT, - "Font format error: can't read section name"); + "font format error: can't read section name"); return 1; } @@ -225,7 +225,7 @@ open_section (grub_file_t file, struct font_file_section *section) else if (retval < 0) { grub_error (GRUB_ERR_BAD_FONT, - "Font format error: can't read section length"); + "font format error: can't read section length"); return 1; } @@ -259,7 +259,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct if ((sect_length % FONT_CHAR_INDEX_ENTRY_SIZE) != 0) { grub_error (GRUB_ERR_BAD_FONT, - "Font file format error: character index length %d " + "font file format error: character index length %d " "is not a multiple of the entry size %d", sect_length, FONT_CHAR_INDEX_ENTRY_SIZE); return 1; @@ -294,7 +294,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct if (i != 0 && entry->code <= last_code) { grub_error (GRUB_ERR_BAD_FONT, - "Font characters not in ascending order: %u <= %u", + "font characters not in ascending order: %u <= %u", entry->code, last_code); return 1; } @@ -357,7 +357,7 @@ read_section_as_short (struct font_file_section *section, grub_int16_t *value) if (section->length != 2) { grub_error (GRUB_ERR_BAD_FONT, - "Font file format error: section %c%c%c%c length " + "font file format error: section %c%c%c%c length " "is %d but should be 2", section->name[0], section->name[1], section->name[2], section->name[3], @@ -403,7 +403,7 @@ grub_font_load (const char *filename) if (grub_memcmp (section.name, section_names_file, 4) != 0) { grub_error (GRUB_ERR_BAD_FONT, - "Font file format error: 1st section must be FILE"); + "font file format error: 1st section must be FILE"); goto fail; } @@ -413,7 +413,7 @@ grub_font_load (const char *filename) if (section.length != 4) { grub_error (GRUB_ERR_BAD_FONT, - "Font file format error (file type ID length is %d " + "font file format error (file type ID length is %d " "but should be 4)", section.length); goto fail; } @@ -431,7 +431,7 @@ grub_font_load (const char *filename) if (grub_memcmp (magic, pff2_magic, 4) != 0) { - grub_error (GRUB_ERR_BAD_FONT, "Invalid font magic %x %x %x %x", + grub_error (GRUB_ERR_BAD_FONT, "invalid font magic %x %x %x %x", magic[0], magic[1], magic[2], magic[3]); goto fail; } @@ -558,7 +558,7 @@ grub_font_load (const char *filename) || font->descent == 0) { grub_error (GRUB_ERR_BAD_FONT, - "Invalid font file: missing some required data."); + "invalid font file: missing some required data"); goto fail; } diff --git a/fs/cpio.c b/fs/cpio.c index 3f3a3d1a0..852c4dcd8 100644 --- a/fs/cpio.c +++ b/fs/cpio.c @@ -88,7 +88,7 @@ grub_cpio_find_file (struct grub_cpio_data *data, char **name, return grub_errno; if (hd.magic != MAGIC_BCPIO) - return grub_error (GRUB_ERR_BAD_FS, "Invalid cpio archive"); + return grub_error (GRUB_ERR_BAD_FS, "invalid cpio archive"); data->size = (((grub_uint32_t) hd.filesize_1) << 16) + hd.filesize_2; @@ -130,7 +130,7 @@ grub_cpio_find_file (struct grub_cpio_data *data, char **name, } if (grub_memcmp (hd.magic, MAGIC_USTAR, sizeof (MAGIC_USTAR) - 1)) - return grub_error (GRUB_ERR_BAD_FS, "Invalid tar archive"); + return grub_error (GRUB_ERR_BAD_FS, "invalid tar archive"); if ((*name = grub_strdup (hd.name)) == NULL) return grub_errno; diff --git a/fs/hfsplus.c b/fs/hfsplus.c index 71910330f..b57ad949f 100644 --- a/fs/hfsplus.c +++ b/fs/hfsplus.c @@ -653,7 +653,7 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree, btree->nodesize, (char *) node) <= 0) { grub_free (node); - return grub_error (GRUB_ERR_BAD_FS, "Couldn't read i-node."); + return grub_error (GRUB_ERR_BAD_FS, "couldn't read i-node"); } nodedesc = (struct grub_hfsplus_btnode *) node; diff --git a/fs/iso9660.c b/fs/iso9660.c index 976222a45..fb642e769 100644 --- a/fs/iso9660.c +++ b/fs/iso9660.c @@ -832,7 +832,7 @@ grub_iso9660_uuid (grub_device_t device, char **uuid) && ! data->voldesc.modified.second[0] && ! data->voldesc.modified.second[1] && ! data->voldesc.modified.hundredth[0] && ! data->voldesc.modified.hundredth[1]) { - grub_error (GRUB_ERR_BAD_NUMBER, "No creation date in filesystem to generate UUID."); + grub_error (GRUB_ERR_BAD_NUMBER, "no creation date in filesystem to generate UUID"); *uuid = NULL; } else diff --git a/fs/jfs.c b/fs/jfs.c index 589b6ae5a..2c7f0f220 100644 --- a/fs/jfs.c +++ b/fs/jfs.c @@ -715,7 +715,7 @@ grub_jfs_lookup_symlink (struct grub_jfs_data *data, int ino) grub_jfs_find_file (data, symlink); if (grub_errno) - grub_error (grub_errno, "Can not follow symlink `%s'.", symlink); + grub_error (grub_errno, "can not follow symlink `%s'", symlink); return grub_errno; } diff --git a/fs/minix.c b/fs/minix.c index 08eb60729..0b7a49e16 100644 --- a/fs/minix.c +++ b/fs/minix.c @@ -311,7 +311,7 @@ grub_minix_lookup_symlink (struct grub_minix_data *data, int ino) grub_minix_find_file (data, symlink); if (grub_errno) - grub_error (grub_errno, "Can not follow symlink `%s'.", symlink); + grub_error (grub_errno, "can not follow symlink `%s'", symlink); return grub_errno; } diff --git a/fs/ntfs.c b/fs/ntfs.c index f3097d60b..87db1a561 100644 --- a/fs/ntfs.c +++ b/fs/ntfs.c @@ -42,7 +42,7 @@ fixup (struct grub_ntfs_data *data, char *buf, int len, char *magic) ss = u16at (buf, 6) - 1; if (ss * (int) data->blocksize != len * GRUB_DISK_SECTOR_SIZE) - return grub_error (GRUB_ERR_BAD_FS, "Size not match", + return grub_error (GRUB_ERR_BAD_FS, "size not match", ss * (int) data->blocksize, len * GRUB_DISK_SECTOR_SIZE); pu = buf + u16at (buf, 4); @@ -53,7 +53,7 @@ fixup (struct grub_ntfs_data *data, char *buf, int len, char *magic) buf += data->blocksize; pu += 2; if (u16at (buf, 0) != us) - return grub_error (GRUB_ERR_BAD_FS, "Fixup signature not match"); + return grub_error (GRUB_ERR_BAD_FS, "fixup signature not match"); v16at (buf, 0) = v16at (pu, 0); ss--; } @@ -147,7 +147,7 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr) new_pos += u16at (new_pos, 4); } grub_error (GRUB_ERR_BAD_FS, - "Can\'t find 0x%X in attribute list", + "can\'t find 0x%X in attribute list", (unsigned char) *at->attr_cur); return NULL; } @@ -186,7 +186,7 @@ find_attr (struct grub_ntfs_attr *at, unsigned char attr) if (read_data (at, pa, at->edat_buf, 0, n, 0, 0)) { grub_error (GRUB_ERR_BAD_FS, - "Fail to read non-resident attribute list"); + "fail to read non-resident attribute list"); return NULL; } at->attr_nxt = at->edat_buf; @@ -315,7 +315,7 @@ retry: goto retry; } } - return grub_error (GRUB_ERR_BAD_FS, "Run list overflown"); + return grub_error (GRUB_ERR_BAD_FS, "run list overflown"); } run = read_run_data (run + 1, c1, &val, 0); /* length of current VCN */ ctx->curr_vcn = ctx->next_vcn; @@ -369,7 +369,7 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest, if (pa[8] == 0) { if (ofs + len > u32at (pa, 0x10)) - return grub_error (GRUB_ERR_BAD_FS, "Read out of range"); + return grub_error (GRUB_ERR_BAD_FS, "read out of range"); grub_memcpy (dest, pa + u32at (pa, 0x14) + ofs, len); return 0; } @@ -383,7 +383,7 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest, if (ctx->flags & RF_COMP) { if (!cached) - return grub_error (GRUB_ERR_BAD_FS, "Attribute can\'t be compressed"); + return grub_error (GRUB_ERR_BAD_FS, "attribute can\'t be compressed"); if (at->sbuf) { @@ -502,7 +502,7 @@ read_attr (struct grub_ntfs_attr *at, char *dest, grub_disk_addr_t ofs, else ret = (grub_errno) ? grub_errno : grub_error (GRUB_ERR_BAD_FS, - "Attribute not found"); + "attribute not found"); at->attr_cur = save_cur; return ret; } @@ -513,7 +513,7 @@ read_mft (struct grub_ntfs_data *data, char *buf, grub_uint32_t mftno) if (read_attr (&data->mmft.attr, buf, mftno * ((grub_disk_addr_t) data->mft_size << BLK_SHR), data->mft_size << BLK_SHR, 0, 0)) - return grub_error (GRUB_ERR_BAD_FS, "Read MFT 0x%X fails", mftno); + return grub_error (GRUB_ERR_BAD_FS, "read MFT 0x%X fails", mftno); return fixup (data, buf, data->mft_size, "FILE"); } @@ -541,7 +541,7 @@ init_file (struct grub_ntfs_file *mft, grub_uint32_t mftno) pa = locate_attr (&mft->attr, mft, AT_DATA); if (pa == NULL) - return grub_error (GRUB_ERR_BAD_FS, "No $DATA in MFT 0x%X", mftno); + return grub_error (GRUB_ERR_BAD_FS, "no $DATA in MFT 0x%X", mftno); if (!pa[8]) mft->size = u32at (pa, 0x10); @@ -664,7 +664,7 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir, { if ((cur_pos = find_attr (at, AT_INDEX_ROOT)) == NULL) { - grub_error (GRUB_ERR_BAD_FS, "No $INDEX_ROOT"); + grub_error (GRUB_ERR_BAD_FS, "no $INDEX_ROOT"); goto done; } @@ -717,7 +717,7 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir, if (read_data (at, cur_pos, bmp, 0, bitmap_len, 0, 0)) { grub_error (GRUB_ERR_BAD_FS, - "Fails to read non-resident $BITMAP"); + "fails to read non-resident $BITMAP"); goto done; } bitmap_len = u32at (cur_pos, 0x30); diff --git a/fs/ntfscomp.c b/fs/ntfscomp.c index 6bb33ffb1..c29979edc 100644 --- a/fs/ntfscomp.c +++ b/fs/ntfscomp.c @@ -28,7 +28,7 @@ static grub_err_t decomp_nextvcn (struct grub_ntfs_comp *cc) { if (cc->comp_head >= cc->comp_tail) - return grub_error (GRUB_ERR_BAD_FS, "Compression block overflown"); + return grub_error (GRUB_ERR_BAD_FS, "compression block overflown"); if (grub_disk_read (cc->disk, (cc->comp_table[cc->comp_head][1] - @@ -87,7 +87,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest) { if (copied > COM_LEN) return grub_error (GRUB_ERR_BAD_FS, - "Compression block too large"); + "compression block too large"); if (!bits) { @@ -112,7 +112,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest) if (!copied) { - grub_error (GRUB_ERR_BAD_FS, "Context window empty"); + grub_error (GRUB_ERR_BAD_FS, "nontext window empty"); return 0; } @@ -150,7 +150,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest) { if (cnt != COM_LEN) return grub_error (GRUB_ERR_BAD_FS, - "Invalid compression block size"); + "invalid compression block size"); } } @@ -187,7 +187,7 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num) { if (ctx->comp.comp_head != ctx->comp.comp_tail) - return grub_error (GRUB_ERR_BAD_FS, "Invalid compression block"); + return grub_error (GRUB_ERR_BAD_FS, "invalid compression block"); ctx->comp.comp_head = ctx->comp.comp_tail = 0; ctx->comp.cbuf_vcn = ctx->target_vcn; ctx->comp.cbuf_ofs = (ctx->comp.spc << BLK_SHR); diff --git a/fs/reiserfs.c b/fs/reiserfs.c index fb4f1bc59..f9c37ed7b 100644 --- a/fs/reiserfs.c +++ b/fs/reiserfs.c @@ -998,7 +998,7 @@ grub_reiserfs_open (struct grub_file *file, const char *name) goto fail; if (root.block_number == 0) { - grub_error (GRUB_ERR_BAD_FS, "Unable to find root item"); + grub_error (GRUB_ERR_BAD_FS, "unable to find root item"); goto fail; /* Should never happen since checked at mount. */ } grub_fshelp_find_file (name, &root, &found, @@ -1014,7 +1014,7 @@ grub_reiserfs_open (struct grub_file *file, const char *name) goto fail; if (info.block_number == 0) { - grub_error (GRUB_ERR_BAD_FS, "Unable to find searched item"); + grub_error (GRUB_ERR_BAD_FS, "unable to find searched item"); goto fail; } entry_version = grub_le_to_cpu16 (info.header.version); @@ -1289,7 +1289,7 @@ grub_reiserfs_dir (grub_device_t device, const char *path, goto fail; if (root.block_number == 0) { - grub_error(GRUB_ERR_BAD_FS, "Root not found"); + grub_error(GRUB_ERR_BAD_FS, "root not found"); goto fail; } grub_fshelp_find_file (path, &root, &found, grub_reiserfs_iterate_dir, diff --git a/fs/ufs.c b/fs/ufs.c index c94ad9922..6d3117d5f 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -415,7 +415,7 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino) grub_ufs_find_file (data, symlink); if (grub_errno) - grub_error (grub_errno, "Can not follow symlink `%s'.", symlink); + grub_error (grub_errno, "can not follow symlink `%s'", symlink); return grub_errno; } diff --git a/fs/xfs.c b/fs/xfs.c index 1b18bef3b..d627ea9f8 100644 --- a/fs/xfs.c +++ b/fs/xfs.c @@ -222,7 +222,7 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, return grub_errno; if (grub_strncmp ((char *) inode->magic, "IN", 2)) - return grub_error (GRUB_ERR_BAD_FS, "not a correct XFS inode.\n"); + return grub_error (GRUB_ERR_BAD_FS, "not a correct XFS inode"); return 0; } @@ -273,7 +273,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) if (grub_strncmp ((char *) leaf->magic, "BMAP", 4)) { grub_free (leaf); - grub_error (GRUB_ERR_BAD_FS, "not a correct XFS BMAP node.\n"); + grub_error (GRUB_ERR_BAD_FS, "not a correct XFS BMAP node"); return 0; } diff --git a/gettext/gettext.c b/gettext/gettext.c index fe14dab2e..c48b5fd95 100644 --- a/gettext/gettext.c +++ b/gettext/gettext.c @@ -243,7 +243,7 @@ grub_mofile_open (const char *filename) if (version != 0) { grub_error (GRUB_ERR_BAD_FILE_TYPE, - "mo: invalid mo version in file: %s\n", filename); + "mo: invalid mo version in file: %s", filename); fd_mo = 0; return 0; } diff --git a/include/grub/auth.h b/include/grub/auth.h index 823442941..99f9d7260 100644 --- a/include/grub/auth.h +++ b/include/grub/auth.h @@ -22,7 +22,7 @@ #include /* Macros for indistinguishibility. */ -#define GRUB_ACCESS_DENIED grub_error (GRUB_ERR_ACCESS_DENIED, "Access denied.") +#define GRUB_ACCESS_DENIED grub_error (GRUB_ERR_ACCESS_DENIED, "access denied") #define GRUB_GET_PASSWORD(string, len) grub_cmdline_get (N_("Enter password:"), \ string, len, \ '*', 0, 0) diff --git a/kern/elf.c b/kern/elf.c index 951049e73..10fe9c758 100644 --- a/kern/elf.c +++ b/kern/elf.c @@ -74,7 +74,7 @@ grub_elf_file (grub_file_t file) != sizeof (elf->ehdr)) { grub_error_push (); - grub_error (GRUB_ERR_READ_ERROR, "Cannot read ELF header."); + grub_error (GRUB_ERR_READ_ERROR, "cannot read ELF header"); goto fail; } @@ -134,7 +134,7 @@ grub_elf32_load_phdrs (grub_elf_t elf) || (grub_file_read (elf->file, elf->phdrs, phdrs_size) != phdrs_size)) { grub_error_push (); - return grub_error (GRUB_ERR_READ_ERROR, "Cannot read program headers"); + return grub_error (GRUB_ERR_READ_ERROR, "cannot read program headers"); } return GRUB_ERR_NONE; @@ -200,14 +200,14 @@ grub_elf32_size (grub_elf_t elf) if (nr_phdrs == 0) { - grub_error (GRUB_ERR_BAD_OS, "No program headers present"); + grub_error (GRUB_ERR_BAD_OS, "no program headers present"); return 0; } if (segments_end < segments_start) { /* Very bad addresses. */ - grub_error (GRUB_ERR_BAD_OS, "Bad program header load addresses"); + grub_error (GRUB_ERR_BAD_OS, "bad program header load addresses"); return 0; } @@ -249,7 +249,7 @@ grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook, { grub_error_push (); return grub_error (GRUB_ERR_BAD_OS, - "Invalid offset in program header."); + "invalid offset in program header"); } if (phdr->p_filesz) @@ -261,8 +261,8 @@ grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook, /* XXX How can we free memory from `load_hook'? */ grub_error_push (); return grub_error (GRUB_ERR_BAD_OS, - "Couldn't read segment from file: " - "wanted 0x%lx bytes; read 0x%lx bytes.", + "couldn't read segment from file: " + "wanted 0x%lx bytes; read 0x%lx bytes", phdr->p_filesz, read); } } @@ -315,7 +315,7 @@ grub_elf64_load_phdrs (grub_elf_t elf) || (grub_file_read (elf->file, elf->phdrs, phdrs_size) != phdrs_size)) { grub_error_push (); - return grub_error (GRUB_ERR_READ_ERROR, "Cannot read program headers"); + return grub_error (GRUB_ERR_READ_ERROR, "cannot read program headers"); } return GRUB_ERR_NONE; @@ -381,14 +381,14 @@ grub_elf64_size (grub_elf_t elf) if (nr_phdrs == 0) { - grub_error (GRUB_ERR_BAD_OS, "No program headers present"); + grub_error (GRUB_ERR_BAD_OS, "no program headers present"); return 0; } if (segments_end < segments_start) { /* Very bad addresses. */ - grub_error (GRUB_ERR_BAD_OS, "Bad program header load addresses"); + grub_error (GRUB_ERR_BAD_OS, "bad program header load addresses"); return 0; } @@ -431,7 +431,7 @@ grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook, { grub_error_push (); return grub_error (GRUB_ERR_BAD_OS, - "Invalid offset in program header."); + "invalid offset in program header"); } if (phdr->p_filesz) @@ -443,8 +443,8 @@ grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook, /* XXX How can we free memory from `load_hook'? */ grub_error_push (); return grub_error (GRUB_ERR_BAD_OS, - "Couldn't read segment from file: " - "wanted 0x%lx bytes; read 0x%lx bytes.", + "couldn't read segment from file: " + "wanted 0x%lx bytes; read 0x%lx bytes", phdr->p_filesz, read); } } diff --git a/kern/file.c b/kern/file.c index f713acbca..4224cf910 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 past the end of file."); + "attempt to read past the end of file"); return -1; } diff --git a/kern/ieee1275/init.c b/kern/ieee1275/init.c index 5d5d733d9..f3305d71c 100644 --- a/kern/ieee1275/init.c +++ b/kern/ieee1275/init.c @@ -164,7 +164,7 @@ static void grub_claim_heap (void) /* Claim and use it. */ if (grub_claimmap (addr, len) < 0) return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Failed to claim heap at 0x%llx, len 0x%llx\n", + "failed to claim heap at 0x%llx, len 0x%llx", addr, len); grub_mm_init_region ((void *) (grub_addr_t) addr, len); } diff --git a/kern/ieee1275/mmap.c b/kern/ieee1275/mmap.c index 317a12117..6f0652770 100644 --- a/kern/ieee1275/mmap.c +++ b/kern/ieee1275/mmap.c @@ -44,11 +44,11 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin /* Load `/memory/available'. */ if (grub_ieee1275_finddevice ("/memory", &memory)) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, - "Couldn't find /memory node"); + "couldn't find /memory node"); if (grub_ieee1275_get_integer_property (memory, "available", available, sizeof available, &available_size)) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, - "Couldn't examine /memory/available property"); + "couldn't examine /memory/available property"); /* Decode each entry and call `hook'. */ i = 0; diff --git a/kern/ieee1275/openfw.c b/kern/ieee1275/openfw.c index 9a2b0c9aa..c38eb450f 100644 --- a/kern/ieee1275/openfw.c +++ b/kern/ieee1275/openfw.c @@ -308,13 +308,13 @@ grub_ieee1275_parse_args (const char *path, enum grub_ieee1275_parse_type ptype) file path properly. */ if (grub_ieee1275_finddevice (device, &dev)) { - grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Device %s not found\n", device); + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "device %s not found", device); goto fail; } if (grub_ieee1275_get_property (dev, "device_type", &type, sizeof type, 0)) { grub_error (GRUB_ERR_UNKNOWN_DEVICE, - "Device %s lacks a device_type property\n", device); + "device %s lacks a device_type property", device); goto fail; } diff --git a/kern/powerpc/dl.c b/kern/powerpc/dl.c index 2891b0dbb..fa112b16f 100644 --- a/kern/powerpc/dl.c +++ b/kern/powerpc/dl.c @@ -106,7 +106,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) Elf_Sword delta = value - (Elf_Word) addr; if (delta << 6 >> 6 != delta) - return grub_error (GRUB_ERR_BAD_MODULE, "Relocation overflow"); + return grub_error (GRUB_ERR_BAD_MODULE, "relocation overflow"); *addr = (*addr & 0xfc000003) | (delta & 0x3fffffc); break; } @@ -125,7 +125,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) default: return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "This relocation (%d) is not implemented yet", + "this relocation (%d) is not implemented yet", ELF_R_TYPE (rel->r_info)); } } diff --git a/kern/sparc64/dl.c b/kern/sparc64/dl.c index a4d99ff08..7932b4969 100644 --- a/kern/sparc64/dl.c +++ b/kern/sparc64/dl.c @@ -98,7 +98,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) case R_SPARC_32: /* 3 V-word32 */ if (value & 0xFFFFFFFF00000000) return grub_error (GRUB_ERR_BAD_MODULE, - "Address out of 32 bits range"); + "address out of 32 bits range"); *addr = value; break; case R_SPARC_WDISP30: /* 7 V-disp30 */ @@ -106,7 +106,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) (((value - (Elf_Addr) addr) & 0xFFFFFFFF00000000) != 0xFFFFFFFF00000000)) return grub_error (GRUB_ERR_BAD_MODULE, - "Displacement out of 30 bits range"); + "displacement out of 30 bits range"); *addr = (*addr & 0xC0000000) | (((grub_int32_t) ((value - (Elf_Addr) addr) >> 2)) & 0x3FFFFFFF); @@ -114,7 +114,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) case R_SPARC_HI22: /* 9 V-imm22 */ if (((grub_int32_t) value) & 0xFF00000000) return grub_error (GRUB_ERR_BAD_MODULE, - "High address out of 22 bits range"); + "high address out of 22 bits range"); *addr = (*addr & 0xFFC00000) | ((value >> 10) & 0x3FFFFF); break; case R_SPARC_LO10: /* 12 T-simm13 */ @@ -131,7 +131,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) break; default: return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "This relocation (%d) is not implemented yet", + "this relocation (%d) is not implemented yet", ELF_R_TYPE (rel->r_info)); } } diff --git a/lib/arg.c b/lib/arg.c index 6da9bb5dd..c40731368 100644 --- a/lib/arg.c +++ b/lib/arg.c @@ -274,7 +274,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv, if (! opt) { grub_error (GRUB_ERR_BAD_ARGUMENT, - "Unknown argument `-%c'\n", *curshort); + "unknown argument `-%c'", *curshort); goto fail; } @@ -326,7 +326,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv, opt = find_long (cmd->options, arg + 2, arglen); if (! opt) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown argument `%s'\n", arg); + grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown argument `%s'", arg); goto fail; } } @@ -337,7 +337,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv, if (! option) { grub_error (GRUB_ERR_BAD_ARGUMENT, - "Missing mandatory option for `%s'\n", opt->longarg); + "missing mandatory option for `%s'", opt->longarg); goto fail; } @@ -359,7 +359,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv, if (tail == 0 || tail == option || *tail != '\0' || grub_errno) { grub_error (GRUB_ERR_BAD_ARGUMENT, - "The argument `%s' requires an integer.", + "the argument `%s' requires an integer", arg); goto fail; @@ -382,8 +382,8 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv, if (option) { grub_error (GRUB_ERR_BAD_ARGUMENT, - "A value was assigned to the argument `%s' while it " - "doesn't require an argument\n", arg); + "a value was assigned to the argument `%s' while it " + "doesn't require an argument", arg); goto fail; } diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 84eb13d74..620c4bbf3 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -679,7 +679,7 @@ grub_netbsd_boot (void) + 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."); + 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); @@ -750,10 +750,10 @@ grub_bsd_load_aout (grub_file_t file) return grub_errno; if (grub_file_read (file, &ah, sizeof (ah)) != sizeof (ah)) - return grub_error (GRUB_ERR_READ_ERROR, "Cannot read the a.out header"); + return grub_error (GRUB_ERR_READ_ERROR, "cannot read the a.out header"); if (grub_aout_get_type (&ah) != AOUT_TYPE_AOUT32) - return grub_error (GRUB_ERR_BAD_OS, "Invalid a.out header"); + return grub_error (GRUB_ERR_BAD_OS, "invalid a.out header"); entry = ah.aout32.a_entry & 0xFFFFFF; @@ -771,7 +771,7 @@ grub_bsd_load_aout (grub_file_t file) } if (load_addr < 0x100000) - return grub_error (GRUB_ERR_BAD_OS, "Load address below 1M"); + return grub_error (GRUB_ERR_BAD_OS, "load address below 1M"); kern_start = load_addr; kern_end = load_addr + ah.aout32.a_text + ah.aout32.a_data; @@ -811,7 +811,7 @@ grub_bsd_elf32_hook (Elf32_Phdr * phdr, grub_addr_t * addr, int *do_load) if ((paddr < grub_os_area_addr) || (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size)) - return grub_error (GRUB_ERR_OUT_OF_RANGE, "Address 0x%x is out of range", + return grub_error (GRUB_ERR_OUT_OF_RANGE, "address 0x%x is out of range", paddr); if ((!kern_start) || (paddr < kern_start)) @@ -842,7 +842,7 @@ grub_bsd_elf64_hook (Elf64_Phdr * phdr, grub_addr_t * addr, int *do_load) if ((paddr < grub_os_area_addr) || (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size)) - return grub_error (GRUB_ERR_OUT_OF_RANGE, "Address 0x%x is out of range", + return grub_error (GRUB_ERR_OUT_OF_RANGE, "address 0x%x is out of range", paddr); if ((!kern_start) || (paddr < kern_start)) @@ -871,7 +871,7 @@ grub_bsd_load_elf (grub_elf_t elf) is_64bit = 1; if (! grub_cpuid_has_longmode) - return grub_error (GRUB_ERR_BAD_OS, "Your CPU does not implement AMD64 architecture."); + return grub_error (GRUB_ERR_BAD_OS, "your CPU does not implement AMD64 architecture"); /* FreeBSD has 64-bit entry point. */ if (kernel_type == KERNEL_TYPE_FREEBSD) @@ -887,7 +887,7 @@ grub_bsd_load_elf (grub_elf_t elf) return grub_elf64_load (elf, grub_bsd_elf64_hook, 0, 0); } else - return grub_error (GRUB_ERR_BAD_OS, "Invalid elf"); + return grub_error (GRUB_ERR_BAD_OS, "invalid elf"); } static grub_err_t @@ -902,7 +902,7 @@ grub_bsd_load (int argc, char *argv[]) if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No kernel specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified"); goto fail; } @@ -1024,14 +1024,14 @@ grub_cmd_openbsd (grub_extcmd_t cmd, int argc, char *argv[]) int unit, part; if (*(arg++) != 'w' || *(arg++) != 'd') return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Only device specifications of form " - "wd are supported."); + "only device specifications of form " + "wd are supported"); unit = grub_strtoul (arg, (char **) &arg, 10); if (! (arg && *arg >= 'a' && *arg <= 'z')) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Only device specifications of form " - "wd are supported."); + "only device specifications of form " + "wd are supported"); part = *arg - 'a'; @@ -1076,15 +1076,15 @@ grub_cmd_freebsd_loadenv (grub_command_t cmd __attribute__ ((unused)), if (kernel_type == KERNEL_TYPE_NONE) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "You need to load the kernel first."); + "you need to load the kernel first"); if (kernel_type != KERNEL_TYPE_FREEBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Only FreeBSD support environment"); + "only FreeBSD support environment"); if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No filename"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no filename"); goto fail; } @@ -1170,15 +1170,15 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)), if (kernel_type == KERNEL_TYPE_NONE) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "You need to load the kernel first."); + "you need to load the kernel first"); if (kernel_type != KERNEL_TYPE_FREEBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Only FreeBSD support module"); + "only FreeBSD support module"); if (!is_elf_kernel) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Only ELF kernel support module"); + "only ELF kernel support module"); /* List the current modules if no parameter. */ if (!argc) @@ -1193,7 +1193,7 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)), if (kern_end + file->size > grub_os_area_addr + grub_os_area_size) { - grub_error (GRUB_ERR_OUT_OF_RANGE, "Not enough memory for the module"); + grub_error (GRUB_ERR_OUT_OF_RANGE, "not enough memory for the module"); goto fail; } @@ -1236,15 +1236,15 @@ grub_cmd_freebsd_module_elf (grub_command_t cmd __attribute__ ((unused)), if (kernel_type == KERNEL_TYPE_NONE) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "You need to load the kernel first."); + "you need to load the kernel first"); if (kernel_type != KERNEL_TYPE_FREEBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Only FreeBSD support module"); + "only FreeBSD support module"); if (! is_elf_kernel) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Only ELF kernel support module"); + "only ELF kernel support module"); /* List the current modules if no parameter. */ if (! argc) diff --git a/loader/i386/bsdXX.c b/loader/i386/bsdXX.c index aedc204b2..4c1c035a9 100644 --- a/loader/i386/bsdXX.c +++ b/loader/i386/bsdXX.c @@ -12,7 +12,7 @@ load (grub_file_t file, void *where, grub_off_t off, grub_size_t size) { if (PTR_TO_UINT32 (where) + size > grub_os_area_addr + grub_os_area_size) return grub_error (GRUB_ERR_OUT_OF_RANGE, - "Not enough memory for the module"); + "not enough memory for the module"); if (grub_file_seek (file, off) == (grub_off_t) -1) return grub_errno; if (grub_file_read (file, where, size) @@ -116,7 +116,7 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (grub_file_t file, int argc, case SHT_NOBITS: if (curload + s->sh_size > grub_os_area_addr + grub_os_area_size) return grub_error (GRUB_ERR_OUT_OF_RANGE, - "Not enough memory for the module"); + "not enough memory for the module"); grub_memset (UINT_TO_PTR (curload), 0, s->sh_size); break; } @@ -185,7 +185,7 @@ SUFFIX (grub_freebsd_load_elfmodule) (grub_file_t file, int argc, char *argv[], if (module + s->sh_addr + s->sh_size > grub_os_area_addr + grub_os_area_size) return grub_error (GRUB_ERR_OUT_OF_RANGE, - "Not enough memory for the module"); + "not enough memory for the module"); grub_memset (UINT_TO_PTR (module + s->sh_addr), 0, s->sh_size); break; } @@ -259,7 +259,7 @@ SUFFIX (grub_freebsd_load_elf_meta) (grub_file_t file, grub_addr_t *kern_end) if (*kern_end + 4 * sizeof (grub_freebsd_addr_t) + symsize + strsize > grub_os_area_addr + grub_os_area_size) return grub_error (GRUB_ERR_OUT_OF_RANGE, - "Not enough memory for kernel symbols"); + "not enough memory for kernel symbols"); symstart = curload = ALIGN_UP (*kern_end, sizeof (grub_freebsd_addr_t)); *((grub_freebsd_addr_t *) UINT_TO_PTR (curload)) = symsize; diff --git a/loader/i386/efi/linux.c b/loader/i386/efi/linux.c index 8cd4d23f2..d0b218b08 100644 --- a/loader/i386/efi/linux.c +++ b/loader/i386/efi/linux.c @@ -671,7 +671,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), len = 0x400 - sizeof (lh); if (grub_file_read (file, (char *) real_mode_mem + sizeof (lh), len) != len) { - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto fail; } @@ -853,7 +853,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), len = prot_size; if (grub_file_read (file, (void *) GRUB_LINUX_BZIMAGE_ADDR, len) != len) - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); if (grub_errno == GRUB_ERR_NONE) { @@ -890,13 +890,13 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No module specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no module specified"); goto fail; } if (! loaded) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "You need to load the kernel first."); + grub_error (GRUB_ERR_BAD_ARGUMENT, "you need to load the kernel first"); goto fail; } @@ -966,7 +966,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, initrd_mem, size) != size) { - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto fail; } diff --git a/loader/i386/efi/xnu.c b/loader/i386/efi/xnu.c index 236732804..a7ede1960 100644 --- a/loader/i386/efi/xnu.c +++ b/loader/i386/efi/xnu.c @@ -148,10 +148,10 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params) c = grub_efi_locate_protocol (&uga_draw_guid, 0); if (! c) - return grub_error (GRUB_ERR_IO, "Couldn't find UGADraw"); + return grub_error (GRUB_ERR_IO, "couldn't find UGADraw"); if (efi_call_5 (c->get_mode, c, &width, &height, &depth, &rate)) - return grub_error (GRUB_ERR_IO, "Couldn't retrieve video mode"); + return grub_error (GRUB_ERR_IO, "couldn't retrieve video mode"); grub_printf ("Video mode: %ux%u-%u@%u\n", width, height, depth, rate); @@ -163,7 +163,7 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params) grub_efi_set_text_mode (1); if (! ret) - return grub_error (GRUB_ERR_IO, "Can\'t find frame buffer address\n"); + return grub_error (GRUB_ERR_IO, "can\'t find frame buffer address"); grub_printf ("Frame buffer base: 0x%x\n", fb_base); grub_printf ("Video line length: %d\n", line_len); diff --git a/loader/i386/ieee1275/linux.c b/loader/i386/ieee1275/linux.c index 529d1590a..97f9a8216 100644 --- a/loader/i386/ieee1275/linux.c +++ b/loader/i386/ieee1275/linux.c @@ -211,7 +211,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), kernel_size = prot_size; if (grub_file_read (file, kernel_addr, prot_size) != (int) prot_size) - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); if (grub_errno == GRUB_ERR_NONE) grub_loader_set (grub_linux_boot, grub_linux_unload, 1); @@ -242,13 +242,13 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No module specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no module specified"); goto fail; } if (! kernel_addr) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "You need to load the kernel first."); + grub_error (GRUB_ERR_BAD_ARGUMENT, "you need to load the kernel first"); goto fail; } @@ -260,7 +260,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, (void *) GRUB_OFW_LINUX_INITRD_ADDR, initrd_size) != (int) initrd_size) { - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto fail; } diff --git a/loader/i386/linux.c b/loader/i386/linux.c index 82bfd6b95..805ec7962 100644 --- a/loader/i386/linux.c +++ b/loader/i386/linux.c @@ -673,7 +673,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), len = 0x400 - sizeof (lh); if (grub_file_read (file, (char *) real_mode_mem + sizeof (lh), len) != len) { - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto fail; } @@ -862,7 +862,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), len = prot_size; if (grub_file_read (file, (void *) GRUB_LINUX_BZIMAGE_ADDR, len) != len) - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); if (grub_errno == GRUB_ERR_NONE) { @@ -897,13 +897,13 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No module specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no module specified"); goto fail; } if (! loaded) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "You need to load the kernel first."); + grub_error (GRUB_ERR_BAD_ARGUMENT, "you need to load the kernel first"); goto fail; } @@ -951,7 +951,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (addr < addr_min) { - grub_error (GRUB_ERR_OUT_OF_RANGE, "The initrd is too big"); + grub_error (GRUB_ERR_OUT_OF_RANGE, "the initrd is too big"); goto fail; } @@ -959,7 +959,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, initrd_mem, size) != size) { - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto fail; } diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index be824e2f4..75a9699b1 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -226,21 +226,21 @@ grub_multiboot (int argc, char *argv[]) if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No kernel specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified"); goto fail; } file = grub_gzfile_open (argv[0], 1); if (! file) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "Couldn't open file"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "couldn't open file"); goto fail; } len = grub_file_read (file, buffer, MULTIBOOT_SEARCH); if (len < 32) { - grub_error (GRUB_ERR_BAD_OS, "File too small"); + grub_error (GRUB_ERR_BAD_OS, "file too small"); goto fail; } @@ -257,14 +257,14 @@ grub_multiboot (int argc, char *argv[]) if (header == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No multiboot header found"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no multiboot header found"); goto fail; } if (header->flags & MULTIBOOT_UNSUPPORTED) { grub_error (GRUB_ERR_UNKNOWN_OS, - "Unsupported flag: 0x%x", header->flags); + "unsupported flag: 0x%x", header->flags); goto fail; } @@ -408,14 +408,14 @@ grub_module (int argc, char *argv[]) if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No module specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no module specified"); goto fail; } if (!mbi) { grub_error (GRUB_ERR_BAD_ARGUMENT, - "You need to load the multiboot kernel first"); + "you need to load the multiboot kernel first"); goto fail; } @@ -430,7 +430,7 @@ grub_module (int argc, char *argv[]) if (grub_file_read (file, module, size) != size) { - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto fail; } diff --git a/loader/i386/pc/linux.c b/loader/i386/pc/linux.c index c5279f6ce..9e2543e62 100644 --- a/loader/i386/pc/linux.c +++ b/loader/i386/pc/linux.c @@ -234,7 +234,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), len = real_size + GRUB_DISK_SECTOR_SIZE - sizeof (lh); if (grub_file_read (file, grub_linux_tmp_addr + sizeof (lh), len) != len) { - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto fail; } @@ -265,7 +265,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), len = prot_size; if (grub_file_read (file, (void *) GRUB_LINUX_BZIMAGE_ADDR, len) != len) - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); if (grub_errno == GRUB_ERR_NONE) { @@ -299,13 +299,13 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No module specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no module specified"); goto fail; } if (!loaded) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "You need to load the kernel first."); + grub_error (GRUB_ERR_BAD_ARGUMENT, "you need to load the kernel first"); goto fail; } @@ -314,7 +314,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (!(lh->header == grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE) && grub_le_to_cpu16 (lh->version) >= 0x0200)) { - grub_error (GRUB_ERR_BAD_OS, "The kernel is too old for initrd."); + grub_error (GRUB_ERR_BAD_OS, "the kernel is too old for initrd"); goto fail; } @@ -357,13 +357,13 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (addr < addr_min) { - grub_error (GRUB_ERR_OUT_OF_RANGE, "The initrd is too big"); + grub_error (GRUB_ERR_OUT_OF_RANGE, "the initrd is too big"); goto fail; } if (grub_file_read (file, (void *) addr, size) != size) { - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto fail; } diff --git a/loader/i386/pc/multiboot2.c b/loader/i386/pc/multiboot2.c index 6ef8c70ca..9bfe5d248 100644 --- a/loader/i386/pc/multiboot2.c +++ b/loader/i386/pc/multiboot2.c @@ -42,7 +42,7 @@ grub_mb2_arch_elf32_hook (Elf32_Phdr *phdr, if ((paddr < grub_os_area_addr) || (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size)) - return grub_error(GRUB_ERR_OUT_OF_RANGE,"Address 0x%x is out of range", + return grub_error(GRUB_ERR_OUT_OF_RANGE,"address 0x%x is out of range", paddr); return GRUB_ERR_NONE; @@ -64,7 +64,7 @@ grub_mb2_arch_elf64_hook (Elf64_Phdr *phdr, if ((paddr < grub_os_area_addr) || (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size)) - return grub_error (GRUB_ERR_OUT_OF_RANGE, "Address 0x%x is out of range", + return grub_error (GRUB_ERR_OUT_OF_RANGE, "address 0x%x is out of range", paddr); return GRUB_ERR_NONE; diff --git a/loader/i386/xnu.c b/loader/i386/xnu.c index 4786bfd39..f71e2c306 100644 --- a/loader/i386/xnu.c +++ b/loader/i386/xnu.c @@ -527,12 +527,12 @@ grub_cmd_devprop_load (grub_command_t cmd __attribute__ ((unused)), unsigned i, j; if (argc != 1) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "File name required. "); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); file = grub_gzfile_open (args[0], 1); if (! file) return grub_error (GRUB_ERR_FILE_NOT_FOUND, - "Couldn't load device-propertie dump. "); + "couldn't load device-propertie dump"); size = grub_file_size (file); buf = grub_malloc (size); if (!buf) diff --git a/loader/ieee1275/multiboot2.c b/loader/ieee1275/multiboot2.c index 3b0ab758e..8c0bc09ec 100644 --- a/loader/ieee1275/multiboot2.c +++ b/loader/ieee1275/multiboot2.c @@ -51,7 +51,7 @@ grub_mb2_arch_elf32_hook (Elf32_Phdr *phdr, rc = grub_claimmap (phdr->p_paddr, phdr->p_memsz); if (rc) - return grub_error(GRUB_ERR_OUT_OF_MEMORY, "Couldn't claim %x - %x", + return grub_error(GRUB_ERR_OUT_OF_MEMORY, "couldn't claim %x - %x", phdr->p_paddr, phdr->p_paddr + phdr->p_memsz); grub_dprintf ("loader", "Loading segment at 0x%x - 0x%x\n", phdr->p_paddr, @@ -77,7 +77,7 @@ grub_mb2_arch_elf64_hook (Elf64_Phdr *phdr, rc = grub_claimmap (phdr->p_paddr, phdr->p_memsz); if (rc) - return grub_error(GRUB_ERR_OUT_OF_MEMORY, "Couldn't claim 0x%lx - 0x%lx", + return grub_error(GRUB_ERR_OUT_OF_MEMORY, "couldn't claim 0x%lx - 0x%lx", phdr->p_paddr, phdr->p_paddr + phdr->p_memsz); grub_dprintf ("loader", "Loading segment at 0x%lx - 0x%lx\n", @@ -96,7 +96,7 @@ grub_mb2_arch_module_alloc (grub_size_t size, grub_addr_t *addr) rc = grub_ieee1275_claim (0, size, MULTIBOOT2_MOD_ALIGN, addr); if (rc) return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Firmware couldn't allocate memory (size 0x%lx)", size); + "firmware couldn't allocate memory (size 0x%lx)", size); return GRUB_ERR_NONE; } diff --git a/loader/macho.c b/loader/macho.c index a23f5b206..199d6f111 100644 --- a/loader/macho.c +++ b/loader/macho.c @@ -71,7 +71,7 @@ grub_macho_file (grub_file_t file) != sizeof (filestart)) { grub_error_push (); - grub_error (GRUB_ERR_READ_ERROR, "Cannot read Mach-O header."); + grub_error (GRUB_ERR_READ_ERROR, "cannot read Mach-O header"); goto fail; } @@ -95,7 +95,7 @@ grub_macho_file (grub_file_t file) { grub_free (archs); grub_error_push (); - grub_error (GRUB_ERR_READ_ERROR, "Cannot read Mach-O header."); + grub_error (GRUB_ERR_READ_ERROR, "cannot read Mach-O header"); goto fail; } diff --git a/loader/machoXX.c b/loader/machoXX.c index 8441e0128..918ddbb20 100644 --- a/loader/machoXX.c +++ b/loader/machoXX.c @@ -25,13 +25,13 @@ SUFFIX (grub_macho_parse) (grub_macho_t macho) || grub_file_read (macho->file, &head, sizeof (head)) != sizeof(head)) { - grub_error (GRUB_ERR_READ_ERROR, "Cannot read Mach-O header."); + grub_error (GRUB_ERR_READ_ERROR, "cannot read Mach-O header"); macho->offsetXX = -1; return; } if (head.magic != GRUB_MACHO_MAGIC) { - grub_error (GRUB_ERR_BAD_OS, "Invalid Mach-O " XX "-bit header."); + grub_error (GRUB_ERR_BAD_OS, "invalid Mach-O " XX "-bit header"); macho->offsetXX = -1; return; } @@ -49,7 +49,7 @@ SUFFIX (grub_macho_parse) (grub_macho_t macho) (grub_size_t) macho->cmdsizeXX) != (grub_ssize_t) macho->cmdsizeXX) { - grub_error (GRUB_ERR_READ_ERROR, "Cannot read Mach-O header."); + grub_error (GRUB_ERR_READ_ERROR, "cannot read Mach-O header"); macho->offsetXX = -1; } } @@ -66,7 +66,7 @@ grub_macho_cmds_iterate (grub_macho_t macho, grub_uint8_t *hdrs = macho->cmdsXX; int i; if (! macho->cmdsXX) - return grub_error (GRUB_ERR_BAD_OS, "Couldn't find " XX "-bit Mach-O"); + return grub_error (GRUB_ERR_BAD_OS, "couldn't find " XX "-bit Mach-O"); for (i = 0; i < macho->ncmdsXX; i++) { struct grub_macho_cmd *hdr = (struct grub_macho_cmd *) hdrs; @@ -92,13 +92,13 @@ SUFFIX (grub_macho_readfile) (grub_macho_t macho, void *dest) grub_ssize_t read; if (! SUFFIX (grub_macho_contains_macho) (macho)) return grub_error (GRUB_ERR_BAD_OS, - "Couldn't read architecture-specific part"); + "couldn't read architecture-specific part"); if (grub_file_seek (macho->file, macho->offsetXX) == (grub_off_t) -1) { grub_error_push (); return grub_error (GRUB_ERR_BAD_OS, - "Invalid offset in program header."); + "invalid offset in program header"); } read = grub_file_read (macho->file, dest, @@ -107,7 +107,7 @@ SUFFIX (grub_macho_readfile) (grub_macho_t macho, void *dest) { grub_error_push (); return grub_error (GRUB_ERR_BAD_OS, - "Couldn't read architecture-specific part"); + "couldn't read architecture-specific part"); } return GRUB_ERR_NONE; } @@ -151,11 +151,11 @@ SUFFIX (grub_macho_size) (grub_macho_t macho, grub_macho_addr_t *segments_start, grub_macho_cmds_iterate (macho, calcsize, 0); if (nr_phdrs == 0) - return grub_error (GRUB_ERR_BAD_OS, "No program headers present"); + return grub_error (GRUB_ERR_BAD_OS, "no program headers present"); if (*segments_end < *segments_start) /* Very bad addresses. */ - return grub_error (GRUB_ERR_BAD_OS, "Bad program header load addresses"); + return grub_error (GRUB_ERR_BAD_OS, "bad program header load addresses"); return GRUB_ERR_NONE; } @@ -187,7 +187,7 @@ SUFFIX (grub_macho_load) (grub_macho_t macho, char *offset, int flags) { grub_error_push (); grub_error (GRUB_ERR_BAD_OS, - "Invalid offset in program header."); + "invalid offset in program header"); return 1; } @@ -201,8 +201,8 @@ SUFFIX (grub_macho_load) (grub_macho_t macho, char *offset, int flags) /* XXX How can we free memory from `load_hook'? */ grub_error_push (); err=grub_error (GRUB_ERR_BAD_OS, - "Couldn't read segment from file: " - "wanted 0x%lx bytes; read 0x%lx bytes.", + "couldn't read segment from file: " + "wanted 0x%lx bytes; read 0x%lx bytes", hdr->filesize, read); return 1; } diff --git a/loader/multiboot2.c b/loader/multiboot2.c index 4c73a2f17..dbdee9c87 100644 --- a/loader/multiboot2.c +++ b/loader/multiboot2.c @@ -319,14 +319,14 @@ grub_multiboot2 (int argc, char *argv[]) if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No kernel specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified"); goto fail; } file = grub_gzfile_open (argv[0], 1); if (! file) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "Couldn't open file"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "couldn't open file"); goto fail; } @@ -337,7 +337,7 @@ grub_multiboot2 (int argc, char *argv[]) len = grub_file_read (file, buffer, MULTIBOOT2_HEADER_SEARCH); if (len < 32) { - grub_error (GRUB_ERR_BAD_OS, "File too small"); + grub_error (GRUB_ERR_BAD_OS, "file too small"); goto fail; } @@ -378,7 +378,7 @@ grub_multiboot2 (int argc, char *argv[]) err = grub_mb2_load_other (file, header); else err = grub_error (GRUB_ERR_BAD_OS, - "Need multiboot 2 header to load non-ELF files."); + "need multiboot 2 header to load non-ELF files"); grub_file_close (file); } @@ -406,20 +406,20 @@ grub_module2 (int argc, char *argv[]) if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No module specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no module specified"); return; } if (argc == 1) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No module type specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no module type specified"); return; } if (entry == 0) { grub_error (GRUB_ERR_BAD_ARGUMENT, - "You need to load the multiboot kernel first"); + "you need to load the multiboot kernel first"); return; } @@ -437,7 +437,7 @@ grub_module2 (int argc, char *argv[]) modaddr + modsize); if (grub_file_read (file, (void *) modaddr, modsize) != modsize) { - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto out; } diff --git a/loader/multiboot_loader.c b/loader/multiboot_loader.c index 9078d0622..152ea3321 100644 --- a/loader/multiboot_loader.c +++ b/loader/multiboot_loader.c @@ -108,14 +108,14 @@ grub_cmd_multiboot_loader (grub_command_t cmd __attribute__ ((unused)), if (argc == 0) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "No kernel specified"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified"); goto fail; } file = grub_gzfile_open (argv[0], 1); if (! file) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "Couldn't open file"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "couldn't open file"); goto fail; } @@ -126,7 +126,7 @@ grub_cmd_multiboot_loader (grub_command_t cmd __attribute__ ((unused)), header_multi_ver_found = 2; else { - grub_error (GRUB_ERR_BAD_OS, "Multiboot header not found"); + grub_error (GRUB_ERR_BAD_OS, "multiboot header not found"); goto fail; } diff --git a/loader/powerpc/ieee1275/linux.c b/loader/powerpc/ieee1275/linux.c index 79fbf0b02..fbee68001 100644 --- a/loader/powerpc/ieee1275/linux.c +++ b/loader/powerpc/ieee1275/linux.c @@ -75,10 +75,10 @@ grub_linux_release_mem (void) linux_args = 0; if (linux_addr && grub_ieee1275_release (linux_addr, linux_size)) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "Can not release memory"); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "can not release memory"); if (initrd_addr && grub_ieee1275_release (initrd_addr, initrd_size)) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "Can not release memory"); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "can not release memory"); linux_addr = 0; initrd_addr = 0; @@ -128,7 +128,7 @@ grub_linux_load32 (grub_elf_t elf) break; } if (found_addr == -1) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "Could not claim memory."); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "could not claim memory"); /* Now load the segments into the area we claimed. */ auto grub_err_t offset_phdr (Elf32_Phdr *phdr, grub_addr_t *addr, int *do_load); @@ -178,7 +178,7 @@ grub_linux_load64 (grub_elf_t elf) break; } if (found_addr == -1) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "Could not claim memory."); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "could not claim memory"); /* Now load the segments into the area we claimed. */ auto grub_err_t offset_phdr (Elf64_Phdr *phdr, grub_addr_t *addr, int *do_load); @@ -222,7 +222,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (elf->ehdr.ehdr32.e_type != ET_EXEC) { grub_error (GRUB_ERR_UNKNOWN_OS, - "This ELF file is not of the right type\n"); + "this ELF file is not of the right type"); goto out; } @@ -236,7 +236,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_linux_load64 (elf); else { - grub_error (GRUB_ERR_BAD_FILE_TYPE, "Unknown ELF class"); + grub_error (GRUB_ERR_BAD_FILE_TYPE, "unknown ELF class"); goto out; } @@ -297,7 +297,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (!loaded) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "You need to load the kernel first."); + grub_error (GRUB_ERR_BAD_ARGUMENT, "you need to load the kernel first"); goto fail; } @@ -321,7 +321,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (found_addr == -1) { - grub_error (GRUB_ERR_OUT_OF_MEMORY, "Can not claim memory"); + grub_error (GRUB_ERR_OUT_OF_MEMORY, "can not claim memory"); goto fail; } @@ -330,7 +330,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, (void *) addr, size) != size) { grub_ieee1275_release (addr, size); - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto fail; } diff --git a/loader/sparc64/ieee1275/linux.c b/loader/sparc64/ieee1275/linux.c index df420d8a0..887edd27a 100644 --- a/loader/sparc64/ieee1275/linux.c +++ b/loader/sparc64/ieee1275/linux.c @@ -256,12 +256,12 @@ grub_linux_load64 (grub_elf_t elf) paddr = alloc_phys (linux_size + off); if (paddr == (grub_addr_t) -1) return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Could not allocate physical memory."); + "could not allocate physical memory"); ret = grub_ieee1275_map_physical (paddr, linux_addr - off, linux_size + off, IEEE1275_MAP_DEFAULT); if (ret) return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Could not map physical memory."); + "could not map physical memory"); grub_dprintf ("loader", "Loading linux at vaddr 0x%lx, paddr 0x%lx, size 0x%lx\n", linux_addr, paddr, linux_size); @@ -317,7 +317,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (elf->ehdr.ehdr32.e_type != ET_EXEC) { grub_error (GRUB_ERR_UNKNOWN_OS, - "This ELF file is not of the right type\n"); + "this ELF file is not of the right type"); goto out; } @@ -328,7 +328,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_linux_load64 (elf); else { - grub_error (GRUB_ERR_BAD_FILE_TYPE, "Unknown ELF class"); + grub_error (GRUB_ERR_BAD_FILE_TYPE, "unknown ELF class"); goto out; } @@ -390,7 +390,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (!loaded) { - grub_error (GRUB_ERR_BAD_ARGUMENT, "You need to load the kernel first."); + grub_error (GRUB_ERR_BAD_ARGUMENT, "you need to load the kernel first"); goto fail; } @@ -405,14 +405,14 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (paddr == (grub_addr_t) -1) { grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Could not allocate physical memory."); + "could not allocate physical memory"); goto fail; } ret = grub_ieee1275_map_physical (paddr, addr, size, IEEE1275_MAP_DEFAULT); if (ret) { grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Could not map physical memory."); + "could not map physical memory"); goto fail; } @@ -421,7 +421,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, (void *) addr, size) != size) { - grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file"); + grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto fail; } diff --git a/loader/xnu.c b/loader/xnu.c index 37239e23c..85d2882b6 100644 --- a/loader/xnu.c +++ b/loader/xnu.c @@ -365,7 +365,7 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), { grub_macho_close (macho); return grub_error (GRUB_ERR_BAD_OS, - "Kernel doesn't contain suitable 32-bit architecture"); + "kernel doesn't contain suitable 32-bit architecture"); } err = grub_macho_size32 (macho, &startcode, &endcode, GRUB_MACHO_NOBSS); @@ -463,7 +463,7 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), { grub_macho_close (macho); return grub_error (GRUB_ERR_BAD_OS, - "Kernel doesn't contain suitable 64-bit architecture"); + "kernel doesn't contain suitable 64-bit architecture"); } err = grub_macho_size64 (macho, &startcode, &endcode, GRUB_MACHO_NOBSS); @@ -654,7 +654,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) if (macho) grub_macho_close (macho); return grub_error (GRUB_ERR_BAD_OS, - "Extension doesn't contain suitable architecture"); + "extension doesn't contain suitable architecture"); } if (grub_xnu_is_64bit) machosize = grub_macho_filesize64 (macho); @@ -719,7 +719,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) { grub_file_close (infoplist); grub_error_push (); - return grub_error (GRUB_ERR_BAD_OS, "Couldn't read file %s: ", + return grub_error (GRUB_ERR_BAD_OS, "couldn't read file %s: ", infoplistname); } grub_file_close (infoplist); @@ -763,7 +763,7 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)), file = grub_gzfile_open (args[0], 1); if (! file) return grub_error (GRUB_ERR_FILE_NOT_FOUND, - "Couldn't load driver package"); + "couldn't load driver package"); /* Sometimes caches are fat binary. Errgh. */ if (grub_file_read (file, &head, sizeof (head)) @@ -773,7 +773,7 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)), can hardly imagine a valid package shorter than 20 bytes. */ grub_file_close (file); grub_error_push (); - return grub_error (GRUB_ERR_BAD_OS, "Couldn't read file %s", args[0]); + return grub_error (GRUB_ERR_BAD_OS, "couldn't read file %s", args[0]); } /* Find the corresponding architecture. */ @@ -786,7 +786,7 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)), grub_file_close (file); grub_error_push (); return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "Couldn't read file %s", args[0]); + "couldn't read file %s", args[0]); } if (grub_file_read (file, archs, @@ -795,7 +795,7 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)), { grub_free (archs); grub_error_push (); - return grub_error (GRUB_ERR_READ_ERROR, "Cannot read fat header."); + return grub_error (GRUB_ERR_READ_ERROR, "cannot read fat header"); } for (i = 0; i < narchs; i++) { @@ -848,7 +848,7 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)), { grub_file_close (file); grub_error_push (); - return grub_error (GRUB_ERR_BAD_OS, "Couldn't read file %s", args[0]); + return grub_error (GRUB_ERR_BAD_OS, "couldn't read file %s", args[0]); } grub_file_close (file); @@ -875,7 +875,7 @@ grub_cmd_xnu_ramdisk (grub_command_t cmd __attribute__ ((unused)), file = grub_gzfile_open (args[0], 1); if (! file) return grub_error (GRUB_ERR_FILE_NOT_FOUND, - "Couldn't load ramdisk"); + "couldn't load ramdisk"); err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE); if (err) @@ -891,7 +891,7 @@ grub_cmd_xnu_ramdisk (grub_command_t cmd __attribute__ ((unused)), { grub_file_close (file); grub_error_push (); - return grub_error (GRUB_ERR_BAD_OS, "Couldn't read file %s", args[0]); + return grub_error (GRUB_ERR_BAD_OS, "couldn't read file %s", args[0]); } return grub_xnu_register_memory ("RAMDisk", 0, loadto, size); } @@ -917,7 +917,7 @@ grub_xnu_check_os_bundle_required (char *plistname, char *osbundlereq, { grub_file_close (file); grub_error_push (); - grub_error (GRUB_ERR_BAD_OS, "Couldn't read file %s", plistname); + grub_error (GRUB_ERR_BAD_OS, "couldn't read file %s", plistname); return 0; } @@ -927,14 +927,14 @@ grub_xnu_check_os_bundle_required (char *plistname, char *osbundlereq, { grub_file_close (file); grub_error_push (); - grub_error (GRUB_ERR_OUT_OF_MEMORY, "Couldn't read file %s", plistname); + grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't read file %s", plistname); return 0; } if (grub_file_read (file, buf, size) != (grub_ssize_t) (size)) { grub_file_close (file); grub_error_push (); - grub_error (GRUB_ERR_BAD_OS, "Couldn't read file %s", plistname); + grub_error (GRUB_ERR_BAD_OS, "couldn't read file %s", plistname); return 0; } grub_file_close (file); diff --git a/loader/xnu_resume.c b/loader/xnu_resume.c index 83c2c3cd1..e6620e7b7 100644 --- a/loader/xnu_resume.c +++ b/loader/xnu_resume.c @@ -109,7 +109,7 @@ grub_xnu_resume (char *imagename) != (grub_ssize_t) codesize) { grub_file_close (file); - return grub_error (GRUB_ERR_READ_ERROR, "Cannot read resume image."); + return grub_error (GRUB_ERR_READ_ERROR, "cannot read resume image"); } /* Read image. */ @@ -119,7 +119,7 @@ grub_xnu_resume (char *imagename) != (grub_ssize_t) hibhead.image_size) { grub_file_close (file); - return grub_error (GRUB_ERR_READ_ERROR, "Cannot read resume image."); + return grub_error (GRUB_ERR_READ_ERROR, "cannot read resume image"); } grub_file_close (file); diff --git a/mmap/i386/pc/mmap.c b/mmap/i386/pc/mmap.c index 0e2dfe6a6..7d5a43fec 100644 --- a/mmap/i386/pc/mmap.c +++ b/mmap/i386/pc/mmap.c @@ -179,7 +179,7 @@ malloc_hook (void) if (! hooktarget) { slots_available = 0; - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "No space for mmap hook"); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "no space for mmap hook"); } return GRUB_ERR_NONE; } diff --git a/normal/menu_viewer.c b/normal/menu_viewer.c index 1bd271a21..f870ccd53 100644 --- a/normal/menu_viewer.c +++ b/normal/menu_viewer.c @@ -58,7 +58,7 @@ 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 grub_error (GRUB_ERR_BAD_ARGUMENT, "no menu viewer available"); while (1) { diff --git a/partmap/acorn.c b/partmap/acorn.c index e005975c0..076d998f8 100644 --- a/partmap/acorn.c +++ b/partmap/acorn.c @@ -85,7 +85,7 @@ acorn_partition_map_find (grub_disk_t disk, struct linux_part *m, fail: return grub_error (GRUB_ERR_BAD_PART_TABLE, - "Linux/ADFS partition map not found."); + "Linux/ADFS partition map not found"); } diff --git a/partmap/amiga.c b/partmap/amiga.c index dce9f4f1f..e8ba9181c 100644 --- a/partmap/amiga.c +++ b/partmap/amiga.c @@ -102,7 +102,7 @@ amiga_partition_map_iterate (grub_disk_t disk, if (next == -1) return grub_error (GRUB_ERR_BAD_PART_TABLE, - "Amiga partition map not found."); + "Amiga partition map not found"); /* The end of the partition list is marked using "-1". */ while (next != -1) diff --git a/partmap/apple.c b/partmap/apple.c index 4dea55a32..765912672 100644 --- a/partmap/apple.c +++ b/partmap/apple.c @@ -176,7 +176,7 @@ apple_partition_map_iterate (grub_disk_t disk, fail: return grub_error (GRUB_ERR_BAD_PART_TABLE, - "Apple partition map not found."); + "Apple partition map not found"); } diff --git a/script/lexer.c b/script/lexer.c index a30e3c005..5bcdf628b 100644 --- a/script/lexer.c +++ b/script/lexer.c @@ -389,7 +389,7 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate) { /* There is either text or a variable name. In the case you arrive here there is a serious problem with the lexer. */ - grub_error (GRUB_ERR_BAD_ARGUMENT, "Internal error\n"); + grub_error (GRUB_ERR_BAD_ARGUMENT, "internal error"); return 0; } } diff --git a/term/gfxterm.c b/term/gfxterm.c index f161499e6..3e8a081fc 100644 --- a/term/gfxterm.c +++ b/term/gfxterm.c @@ -189,7 +189,7 @@ grub_virtual_screen_setup (unsigned int x, unsigned int y, virtual_screen.font = grub_font_get (font_name); if (!virtual_screen.font) return grub_error (GRUB_ERR_BAD_FONT, - "No font loaded."); + "no font loaded"); virtual_screen.width = width; virtual_screen.height = height; virtual_screen.offset_x = x; diff --git a/term/i386/pc/serial.c b/term/i386/pc/serial.c index 3f1c6d062..1c68f9bfc 100644 --- a/term/i386/pc/serial.c +++ b/term/i386/pc/serial.c @@ -498,7 +498,7 @@ grub_cmd_serial (grub_extcmd_t cmd, unit = grub_strtoul (state[0].arg, 0, 0); serial_settings.port = serial_hw_get_port (unit); if (!serial_settings.port) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "bad unit number."); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "bad unit number"); } if (state[1].set) diff --git a/term/i386/pc/vga.c b/term/i386/pc/vga.c index 9deb6a6d7..402b30fe6 100644 --- a/term/i386/pc/vga.c +++ b/term/i386/pc/vga.c @@ -163,7 +163,7 @@ grub_vga_mod_init (void) set_start_address (PAGE_OFFSET (page)); font = grub_font_get (""); /* Choose any font, for now. */ if (!font) - return grub_error (GRUB_ERR_BAD_FONT, "No font loaded."); + return grub_error (GRUB_ERR_BAD_FONT, "no font loaded"); return GRUB_ERR_NONE; } diff --git a/term/ieee1275/ofconsole.c b/term/ieee1275/ofconsole.c index ab11e9fb2..fbed9eca1 100644 --- a/term/ieee1275/ofconsole.c +++ b/term/ieee1275/ofconsole.c @@ -346,7 +346,7 @@ grub_ofconsole_init_input (void) if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen, "stdin", &stdin_ihandle, sizeof stdin_ihandle, &actual) || actual != sizeof stdin_ihandle) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find stdin"); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot find stdin"); return 0; } @@ -365,7 +365,7 @@ grub_ofconsole_init_output (void) if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen, "stdout", &stdout_ihandle, sizeof stdout_ihandle, &actual) || actual != sizeof stdout_ihandle) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find stdout"); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot find stdout"); /* Initialize colors. */ if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS)) diff --git a/term/terminfo.c b/term/terminfo.c index 80ae9b100..e5328d06b 100644 --- a/term/terminfo.c +++ b/term/terminfo.c @@ -103,7 +103,7 @@ grub_terminfo_set_current (const char *str) return grub_errno; } - return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminfo type."); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminfo type"); } /* Wrapper for grub_putchar to write strings. */ @@ -168,7 +168,7 @@ grub_cmd_terminfo (grub_command_t cmd __attribute__ ((unused)), return GRUB_ERR_NONE; } else if (argc != 1) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many parameters."); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many parameters"); else return grub_terminfo_set_current (args[0]); } diff --git a/video/bitmap.c b/video/bitmap.c index 7b135a5dc..2ea640728 100644 --- a/video/bitmap.c +++ b/video/bitmap.c @@ -58,12 +58,12 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap, unsigned int size; if (!bitmap) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid argument."); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument"); *bitmap = 0; if (width == 0 || height == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid argument."); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument"); *bitmap = (struct grub_video_bitmap *)grub_malloc (sizeof (struct grub_video_bitmap)); if (! *bitmap) @@ -129,7 +129,7 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap, *bitmap = 0; return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Unsupported bitmap format"); + "unsupported bitmap format"); } mode_info->pitch = width * mode_info->bytes_per_pixel; @@ -188,7 +188,7 @@ grub_video_bitmap_load (struct grub_video_bitmap **bitmap, grub_video_bitmap_reader_t reader = bitmap_readers_list; if (!bitmap) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid argument."); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument"); *bitmap = 0; diff --git a/video/efi_gop.c b/video/efi_gop.c index 0cae91e7b..30863c1ed 100644 --- a/video/efi_gop.c +++ b/video/efi_gop.c @@ -137,7 +137,7 @@ grub_video_gop_fill_mode_info (struct grub_efi_gop_mode_info *in, out->bpp = grub_video_gop_get_bpp (in); out->bytes_per_pixel = out->bpp >> 3; if (!out->bpp) - return grub_error (GRUB_ERR_IO, "Unsupported video mode"); + return grub_error (GRUB_ERR_IO, "unsupported video mode"); out->pitch = in->pixels_per_scanline * out->bytes_per_pixel; switch (in->pixel_format) @@ -176,7 +176,7 @@ grub_video_gop_fill_mode_info (struct grub_efi_gop_mode_info *in, break; default: - return grub_error (GRUB_ERR_IO, "Unsupported video mode"); + return grub_error (GRUB_ERR_IO, "unsupported video mode"); } out->blit_format = grub_video_get_blit_format (out); @@ -266,7 +266,7 @@ grub_video_gop_setup (unsigned int width, unsigned int height, if (!found) { grub_dprintf ("video", "GOP: no mode found\n"); - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found."); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found"); } if (best_mode != gop->mode->mode) diff --git a/video/efi_uga.c b/video/efi_uga.c index 9bca64306..12ca35cde 100644 --- a/video/efi_uga.c +++ b/video/efi_uga.c @@ -266,7 +266,7 @@ grub_video_uga_setup (unsigned int width, unsigned int height, return err; } - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found."); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found"); } static grub_err_t diff --git a/video/fb/video_fb.c b/video/fb/video_fb.c index 5f2917da6..5532a343c 100644 --- a/video/fb/video_fb.c +++ b/video/fb/video_fb.c @@ -1048,7 +1048,7 @@ grub_video_fb_create_render_target (struct grub_video_fbrender_target **result, || (width == 0) || (height == 0)) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "invalid argument given."); + "invalid argument given"); /* Allocate memory for render target. */ target = grub_malloc (sizeof (struct grub_video_fbrender_target)); @@ -1168,7 +1168,7 @@ grub_video_fb_set_active_render_target (struct grub_video_fbrender_target *targe { if (! target->data) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "invalid render target given."); + "invalid render target given"); render_target = target; diff --git a/video/i386/pc/vbe.c b/video/i386/pc/vbe.c index 28442eab6..17d9b3282 100644 --- a/video/i386/pc/vbe.c +++ b/video/i386/pc/vbe.c @@ -500,7 +500,7 @@ grub_video_vbe_setup (unsigned int width, unsigned int height, } /* Couldn't found matching mode. */ - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found."); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found"); } static grub_err_t diff --git a/video/readers/tga.c b/video/readers/tga.c index d0ca2770f..277458fa8 100644 --- a/video/readers/tga.c +++ b/video/readers/tga.c @@ -370,7 +370,7 @@ grub_video_reader_tga (struct grub_video_bitmap **bitmap, default: grub_file_close (file); return grub_error (GRUB_ERR_BAD_FILE_TYPE, - "Unsupported bitmap format (unknown encoding)."); + "unsupported bitmap format (unknown encoding)"); } /* Check that bitmap depth is supported. */ @@ -387,7 +387,7 @@ grub_video_reader_tga (struct grub_video_bitmap **bitmap, default: grub_file_close (file); return grub_error (GRUB_ERR_BAD_FILE_TYPE, - "Unsupported bitmap format (bpp=%d).", + "unsupported bitmap format (bpp=%d)", header.image_bpp); } diff --git a/video/video.c b/video/video.c index c1d66bdd0..682bebcbf 100644 --- a/video/video.c +++ b/video/video.c @@ -81,7 +81,7 @@ grub_err_t grub_video_get_info (struct grub_video_mode_info *mode_info) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); /* If mode_info is NULL just report that video adapter is active. */ if (! mode_info) @@ -101,7 +101,7 @@ grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info, grub_err_t err; if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); err = grub_video_adapter_active->get_info_and_fini (mode_info, framebuffer); if (err) @@ -209,7 +209,7 @@ grub_video_set_palette (unsigned int start, unsigned int count, struct grub_video_palette_data *palette_data) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->set_palette (start, count, palette_data); } @@ -220,7 +220,7 @@ grub_video_get_palette (unsigned int start, unsigned int count, struct grub_video_palette_data *palette_data) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->get_palette (start, count, palette_data); } @@ -231,7 +231,7 @@ grub_video_set_viewport (unsigned int x, unsigned int y, unsigned int width, unsigned int height) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->set_viewport (x, y, width, height); } @@ -242,7 +242,7 @@ grub_video_get_viewport (unsigned int *x, unsigned int *y, unsigned int *width, unsigned int *height) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->get_viewport (x, y, width, height); } @@ -285,7 +285,7 @@ grub_video_unmap_color (grub_video_color_t color, grub_uint8_t *red, grub_uint8_t *alpha) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->unmap_color (color, red, @@ -300,7 +300,7 @@ grub_video_fill_rect (grub_video_color_t color, int x, int y, unsigned int width, unsigned int height) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->fill_rect (color, x, y, width, height); } @@ -313,7 +313,7 @@ grub_video_blit_bitmap (struct grub_video_bitmap *bitmap, unsigned int width, unsigned int height) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->blit_bitmap (bitmap, oper, x, y, offset_x, offset_y, @@ -328,7 +328,7 @@ grub_video_blit_render_target (struct grub_video_render_target *target, unsigned int width, unsigned int height) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->blit_render_target (target, oper, x, y, offset_x, offset_y, @@ -340,7 +340,7 @@ grub_err_t grub_video_scroll (grub_video_color_t color, int dx, int dy) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->scroll (color, dx, dy); } @@ -350,7 +350,7 @@ grub_err_t grub_video_swap_buffers (void) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->swap_buffers (); } @@ -362,7 +362,7 @@ grub_video_create_render_target (struct grub_video_render_target **result, unsigned int mode_type) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->create_render_target (result, width, height, @@ -374,7 +374,7 @@ grub_err_t grub_video_delete_render_target (struct grub_video_render_target *target) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->delete_render_target (target); } @@ -384,7 +384,7 @@ grub_err_t grub_video_set_active_render_target (struct grub_video_render_target *target) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->set_active_render_target (target); } @@ -394,7 +394,7 @@ grub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target) { if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated"); + return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); return grub_video_adapter_active->get_active_render_target (target); } @@ -460,7 +460,7 @@ grub_video_set_mode (const char *modestring, grub_free (modevar); return grub_error (GRUB_ERR_BAD_ARGUMENT, - "No suitable mode found."); + "no suitable mode found"); } /* Skip separator. */ @@ -545,7 +545,7 @@ grub_video_set_mode (const char *modestring, /* First setup error message. */ rc = grub_error (GRUB_ERR_BAD_ARGUMENT, - "Invalid mode: %s\n", + "invalid mode: %s", current_mode); /* Free memory before returning. */ @@ -564,7 +564,7 @@ grub_video_set_mode (const char *modestring, /* First setup error message. */ rc = grub_error (GRUB_ERR_BAD_ARGUMENT, - "Invalid mode: %s\n", + "invalid mode: %s", current_mode); /* Free memory before returning. */ @@ -585,7 +585,7 @@ grub_video_set_mode (const char *modestring, /* First setup error message. */ rc = grub_error (GRUB_ERR_BAD_ARGUMENT, - "Invalid mode: %s\n", + "invalid mode: %s", current_mode); /* Free memory before returning. */ @@ -607,7 +607,7 @@ grub_video_set_mode (const char *modestring, /* First setup error message. */ rc = grub_error (GRUB_ERR_BAD_ARGUMENT, - "Invalid mode: %s\n", + "invalid mode: %s", current_mode); /* Free memory before returning. */ @@ -625,7 +625,7 @@ grub_video_set_mode (const char *modestring, /* First setup error message. */ rc = grub_error (GRUB_ERR_BAD_ARGUMENT, - "Invalid mode: %s\n", + "invalid mode: %s", current_mode); /* Free memory before returning. */ @@ -709,7 +709,7 @@ grub_video_set_mode (const char *modestring, grub_free (modevar); return grub_error (GRUB_ERR_BAD_ARGUMENT, - "No suitable mode found."); + "no suitable mode found"); } /* Initialize Video API module. */ From 288031b37cc2046898f91249c1001d251eb485f0 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 00:07:52 +0100 Subject: [PATCH 080/208] REtrieve position from right console in loader/i386/linux.c --- loader/i386/linux.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/loader/i386/linux.c b/loader/i386/linux.c index 140ed1957..e3b8638d2 100644 --- a/loader/i386/linux.c +++ b/loader/i386/linux.c @@ -548,8 +548,30 @@ grub_linux_boot (void) /* Initialize these last, because terminal position could be affected by printfs above. */ if (params->have_vga == GRUB_VIDEO_TYPE_TEXT) { - params->video_cursor_x = grub_console_getxy () >> 8; - params->video_cursor_y = grub_console_getxy () & 0xff; + grub_term_output_t term; + int found = 0; + FOR_ACTIVE_TERM_OUTPUTS(term) + if (grub_strcmp (term->name, "vga_text") == 0) + { + grub_uint16_t pos = grub_term_getxy (term); + params->video_cursor_x = pos >> 8; + params->video_cursor_y = pos & 0xff; + found = 1; + } + if (!found) + FOR_ACTIVE_TERM_OUTPUTS(term) + if (grub_strcmp (term->name, "console") == 0) + { + grub_uint16_t pos = grub_term_getxy (term); + params->video_cursor_x = pos >> 8; + params->video_cursor_y = pos & 0xff; + found = 1; + } + if (!found) + { + params->video_cursor_x = 0; + params->video_cursor_y = 0; + } } #ifdef __x86_64__ From 840f2e6e08124fc5bdd3c82de78de38eedb4177e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 00:12:36 +0100 Subject: [PATCH 081/208] Remove NEED_INIT. --- include/grub/term.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/grub/term.h b/include/grub/term.h index 24bb503ba..479081d86 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -68,8 +68,6 @@ grub_term_color_state; #define GRUB_TERM_NO_EDIT (1 << 1) /* Set when the terminal cannot do fancy things. */ #define GRUB_TERM_DUMB (1 << 2) -/* Set when the terminal needs to be initialized. */ -#define GRUB_TERM_NEED_INIT (1 << 16) /* Bitmasks for modifier keys returned by grub_getkeystatus. */ From 4fc4ee303dc7449db542cce7209f2dd4e5cd5042 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 00:13:03 +0100 Subject: [PATCH 082/208] Set default console on non-i386-pc --- term/efi/console.c | 7 +++---- term/i386/pc/at_keyboard.c | 4 ++++ term/i386/pc/vga_text.c | 11 ++++------- term/ieee1275/ofconsole.c | 7 +++---- util/console.c | 8 +++----- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/term/efi/console.c b/term/efi/console.c index bde101ebc..dc07c401e 100644 --- a/term/efi/console.c +++ b/term/efi/console.c @@ -351,8 +351,7 @@ static struct grub_term_output grub_console_term_output = .setcolorstate = grub_console_setcolorstate, .setcolor = grub_console_setcolor, .getcolor = grub_console_getcolor, - .setcursor = grub_console_setcursor, - .flags = GRUB_TERM_ACTIVE, + .setcursor = grub_console_setcursor }; void @@ -366,8 +365,8 @@ grub_console_init (void) return; } - grub_term_register_input ("console", &grub_console_term_input); - grub_term_register_output ("console", &grub_console_term_output); + grub_term_register_input_active ("console", &grub_console_term_input); + grub_term_register_output_active ("console", &grub_console_term_output); } void diff --git a/term/i386/pc/at_keyboard.c b/term/i386/pc/at_keyboard.c index cf30e7242..379cb3a4b 100644 --- a/term/i386/pc/at_keyboard.c +++ b/term/i386/pc/at_keyboard.c @@ -233,7 +233,11 @@ static struct grub_term_input grub_at_keyboard_term = GRUB_MOD_INIT(at_keyboard) { +#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) + grub_term_register_input_active ("at_keyboard", &grub_at_keyboard_term); +#else grub_term_register_input ("at_keyboard", &grub_at_keyboard_term); +#endif } GRUB_MOD_FINI(at_keyboard) diff --git a/term/i386/pc/vga_text.c b/term/i386/pc/vga_text.c index 4fc54a60d..01191cef0 100644 --- a/term/i386/pc/vga_text.c +++ b/term/i386/pc/vga_text.c @@ -163,19 +163,16 @@ static struct grub_term_output grub_vga_text_term = .setcolorstate = grub_console_setcolorstate, .setcolor = grub_console_setcolor, .getcolor = grub_console_getcolor, - .setcursor = grub_vga_text_setcursor, -#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) - .flags = GRUB_TERM_ACTIVE, -#endif + .setcursor = grub_vga_text_setcursor }; GRUB_MOD_INIT(vga_text) { #if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) - grub_vga_text_init_fini (); -#endif - + grub_term_register_output_active ("vga_text", &grub_vga_text_term); +#else grub_term_register_output ("vga_text", &grub_vga_text_term); +#endif } GRUB_MOD_FINI(vga_text) diff --git a/term/ieee1275/ofconsole.c b/term/ieee1275/ofconsole.c index 95479379e..f5db7c146 100644 --- a/term/ieee1275/ofconsole.c +++ b/term/ieee1275/ofconsole.c @@ -414,15 +414,14 @@ static struct grub_term_output grub_ofconsole_term_output = .setcolor = grub_ofconsole_setcolor, .getcolor = grub_ofconsole_getcolor, .setcursor = grub_ofconsole_setcursor, - .refresh = grub_ofconsole_refresh, - .flags = GRUB_TERM_ACTIVE, + .refresh = grub_ofconsole_refresh }; void grub_console_init (void) { - grub_term_register_input ("ofconsole", &grub_ofconsole_term_input); - grub_term_register_output ("ofconsole", &grub_ofconsole_term_output); + grub_term_register_input_active ("ofconsole", &grub_ofconsole_term_input); + grub_term_register_output_active ("ofconsole", &grub_ofconsole_term_output); } void diff --git a/util/console.c b/util/console.c index be64eb9d8..40ee3a638 100644 --- a/util/console.c +++ b/util/console.c @@ -367,16 +367,14 @@ static struct grub_term_output grub_ncurses_term_output = .setcolor = grub_ncurses_setcolor, .getcolor = grub_ncurses_getcolor, .setcursor = grub_ncurses_setcursor, - .refresh = grub_ncurses_refresh, - .flags = GRUB_TERM_ACTIVE + .refresh = grub_ncurses_refresh }; void grub_console_init (void) { - grub_term_register_output ("console", &grub_ncurses_term_output); - grub_term_register_input ("console", &grub_ncurses_term_input); - grub_term_set_current_output (&grub_ncurses_term_output); + grub_term_register_output_active ("console", &grub_ncurses_term_output); + grub_term_register_input_active ("console", &grub_ncurses_term_input); } void From 61ba42be032241492ec41229a82e4ab646710764 Mon Sep 17 00:00:00 2001 From: carles Date: Fri, 25 Dec 2009 01:04:51 +0100 Subject: [PATCH 083/208] 2009-12-25 Carles Pina i Estany * commands/efi/loadbios.c: Capitalize acronyms, replace `could not' by `couldn't' and `can not' by `cannot'. * commands/i386/pc/drivemap.c: Likewise. * disk/ata.c: Likewise. * disk/ieee1275/nand.c: Likewise. * fs/affs.c: Likewise. * fs/fat.c: Likewise. * fs/hfs.c: Likewise. * fs/hfsplus.c: Likewise. * fs/iso9660.c: Likewise. * fs/jfs.c: Likewise. * fs/minix.c: Likewise. * fs/reiserfs.c: Likewise. * fs/sfs.c: Likewise. * fs/udf.c: Likewise. * fs/ufs.c: Likewise. * fs/xfs.c: Likewise. * loader/powerpc/ieee1275/linux.c: Likewise. * loader/sparc64/ieee1275/linux.c: Likewise. * util/grub-probe.c: Likewise. * util/misc.c: Likewise. --- ChangeLog | 24 ++++++++++++++++++++++++ commands/efi/loadbios.c | 2 +- commands/i386/pc/drivemap.c | 2 +- disk/ata.c | 4 ++-- disk/ieee1275/nand.c | 2 +- fs/affs.c | 8 ++++---- fs/fat.c | 2 +- fs/hfs.c | 4 ++-- fs/hfsplus.c | 2 +- fs/iso9660.c | 8 ++++---- fs/jfs.c | 6 +++--- fs/minix.c | 2 +- fs/reiserfs.c | 4 ++-- fs/sfs.c | 4 ++-- fs/udf.c | 16 ++++++++-------- fs/ufs.c | 2 +- fs/xfs.c | 8 ++++---- loader/powerpc/ieee1275/linux.c | 10 +++++----- loader/sparc64/ieee1275/linux.c | 8 ++++---- util/grub-probe.c | 2 +- util/misc.c | 4 ++-- 21 files changed, 74 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9601cb2c4..e32efc6d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2009-12-25 Carles Pina i Estany + + * commands/efi/loadbios.c: Capitalize acronyms, replace `could not' by + `couldn't' and `can not' by `cannot'. + * commands/i386/pc/drivemap.c: Likewise. + * disk/ata.c: Likewise. + * disk/ieee1275/nand.c: Likewise. + * fs/affs.c: Likewise. + * fs/fat.c: Likewise. + * fs/hfs.c: Likewise. + * fs/hfsplus.c: Likewise. + * fs/iso9660.c: Likewise. + * fs/jfs.c: Likewise. + * fs/minix.c: Likewise. + * fs/reiserfs.c: Likewise. + * fs/sfs.c: Likewise. + * fs/udf.c: Likewise. + * fs/ufs.c: Likewise. + * fs/xfs.c: Likewise. + * loader/powerpc/ieee1275/linux.c: Likewise. + * loader/sparc64/ieee1275/linux.c: Likewise. + * util/grub-probe.c: Likewise. + * util/misc.c: Likewise. + 2009-12-24 Carles Pina i Estany * bus/usb/usbhub.c: Fix capitalization, fullstop and newlines in diff --git a/commands/efi/loadbios.c b/commands/efi/loadbios.c index 6f96d4826..877b5da17 100644 --- a/commands/efi/loadbios.c +++ b/commands/efi/loadbios.c @@ -160,7 +160,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)), int size; if (argc == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "no rom image specified"); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "no ROM image specified"); if (argc > 1) { diff --git a/commands/i386/pc/drivemap.c b/commands/i386/pc/drivemap.c index 967c95239..adef57576 100644 --- a/commands/i386/pc/drivemap.c +++ b/commands/i386/pc/drivemap.c @@ -308,7 +308,7 @@ install_int13_handler (int noret __attribute__ ((unused))) GRUB_MACHINE_MEMORY_RESERVED, GRUB_MMAP_MALLOC_LOW); if (! handler_base) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "could not reserve " + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't reserve " "memory for the int13h handler"); /* Copy int13h handler bundle to reserved area. */ diff --git a/disk/ata.c b/disk/ata.c index bfd53cbaf..864ae9488 100644 --- a/disk/ata.c +++ b/disk/ata.c @@ -281,7 +281,7 @@ grub_ata_identify (struct grub_ata_device *dev) else /* Other Error. */ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, - "device can not be identified"); + "device cannot be identified"); } grub_ata_pio_read (dev, info, GRUB_DISK_SECTOR_SIZE); @@ -520,7 +520,7 @@ grub_ata_setaddress (struct grub_ata_device *dev, || cylinder > dev->cylinders || head > dev->heads) return grub_error (GRUB_ERR_OUT_OF_RANGE, - "sector %d can not be addressed " + "sector %d cannot be addressed " "using CHS addressing", sector); grub_ata_regset (dev, GRUB_ATA_REG_DISK, (dev->device << 4) | head); diff --git a/disk/ieee1275/nand.c b/disk/ieee1275/nand.c index 76402a9a6..a9ed553cf 100644 --- a/disk/ieee1275/nand.c +++ b/disk/ieee1275/nand.c @@ -67,7 +67,7 @@ grub_nand_open (const char *name, grub_disk_t disk) } args; if (! grub_strstr (name, "nand")) - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a nand device"); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a NAND device"); data = grub_malloc (sizeof (*data)); if (! data) diff --git a/fs/affs.c b/fs/affs.c index cfe7d579b..de20fbca1 100644 --- a/fs/affs.c +++ b/fs/affs.c @@ -182,14 +182,14 @@ grub_affs_mount (grub_disk_t disk) /* Make sure this is an affs filesystem. */ if (grub_strncmp ((char *) (data->bblock.type), "DOS", 3)) { - grub_error (GRUB_ERR_BAD_FS, "not an affs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an AFFS filesystem"); goto fail; } /* Test if the filesystem is a OFS filesystem. */ if (! (data->bblock.flags & GRUB_AFFS_FLAG_FFS)) { - grub_error (GRUB_ERR_BAD_FS, "ofs not yet supported"); + grub_error (GRUB_ERR_BAD_FS, "OFS not yet supported"); goto fail; } @@ -231,7 +231,7 @@ grub_affs_mount (grub_disk_t disk) } if (-checksum != checksumr) { - grub_error (GRUB_ERR_BAD_FS, "affs blocksize could not be determined"); + grub_error (GRUB_ERR_BAD_FS, "AFFS blocksize couldn't be determined"); goto fail; } blocksize++; @@ -248,7 +248,7 @@ grub_affs_mount (grub_disk_t disk) fail: if (grub_errno == GRUB_ERR_OUT_OF_RANGE) - grub_error (GRUB_ERR_BAD_FS, "not an affs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an AFFS filesystem"); grub_free (data); grub_free (rootblock); diff --git a/fs/fat.c b/fs/fat.c index ab84ee49a..8a0fc0292 100644 --- a/fs/fat.c +++ b/fs/fat.c @@ -338,7 +338,7 @@ grub_fat_mount (grub_disk_t disk) fail: grub_free (data); - grub_error (GRUB_ERR_BAD_FS, "not a fat filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a FAT filesystem"); return 0; } diff --git a/fs/hfs.c b/fs/hfs.c index 493455054..4dd1e3131 100644 --- a/fs/hfs.c +++ b/fs/hfs.c @@ -365,7 +365,7 @@ grub_hfs_mount (grub_disk_t disk) if (grub_hfs_find_node (data, (char *) &key, data->cat_root, 0, (char *) &dir, sizeof (dir)) == 0) { - grub_error (GRUB_ERR_BAD_FS, "can not find the hfs root directory"); + grub_error (GRUB_ERR_BAD_FS, "cannot find the HFS root directory"); goto fail; } @@ -379,7 +379,7 @@ grub_hfs_mount (grub_disk_t disk) grub_free (data); if (grub_errno == GRUB_ERR_OUT_OF_RANGE) - grub_error (GRUB_ERR_BAD_FS, "not a hfs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a HFS filesystem"); return 0; } diff --git a/fs/hfsplus.c b/fs/hfsplus.c index b57ad949f..9310b6502 100644 --- a/fs/hfsplus.c +++ b/fs/hfsplus.c @@ -502,7 +502,7 @@ grub_hfsplus_mount (grub_disk_t disk) fail: if (grub_errno == GRUB_ERR_OUT_OF_RANGE) - grub_error (GRUB_ERR_BAD_FS, "not a hfsplus filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a HFS+ filesystem"); grub_free (data); return 0; diff --git a/fs/iso9660.c b/fs/iso9660.c index fb642e769..2fb0ffb63 100644 --- a/fs/iso9660.c +++ b/fs/iso9660.c @@ -280,13 +280,13 @@ grub_iso9660_mount (grub_disk_t disk) sizeof (struct grub_iso9660_primary_voldesc), (char *) &voldesc)) { - grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem"); goto fail; } if (grub_strncmp ((char *) voldesc.voldesc.magic, "CD001", 5) != 0) { - grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem"); goto fail; } @@ -315,7 +315,7 @@ grub_iso9660_mount (grub_disk_t disk) << GRUB_ISO9660_LOG2_BLKSZ), 0, sizeof (rootdir), (char *) &rootdir)) { - grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem"); goto fail; } @@ -331,7 +331,7 @@ grub_iso9660_mount (grub_disk_t disk) << GRUB_ISO9660_LOG2_BLKSZ), sua_pos, sua_size, sua)) { - grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem"); goto fail; } diff --git a/fs/jfs.c b/fs/jfs.c index 2c7f0f220..dc5eaed67 100644 --- a/fs/jfs.c +++ b/fs/jfs.c @@ -344,7 +344,7 @@ grub_jfs_mount (grub_disk_t disk) if (grub_strncmp ((char *) (data->sblock.magic), "JFS1", 4)) { - grub_error (GRUB_ERR_BAD_FS, "not a jfs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a JFS filesystem"); goto fail; } @@ -363,7 +363,7 @@ grub_jfs_mount (grub_disk_t disk) grub_free (data); if (grub_errno == GRUB_ERR_OUT_OF_RANGE) - grub_error (GRUB_ERR_BAD_FS, "not a jfs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a JFS filesystem"); return 0; } @@ -715,7 +715,7 @@ grub_jfs_lookup_symlink (struct grub_jfs_data *data, int ino) grub_jfs_find_file (data, symlink); if (grub_errno) - grub_error (grub_errno, "can not follow symlink `%s'", symlink); + grub_error (grub_errno, "cannot follow symlink `%s'", symlink); return grub_errno; } diff --git a/fs/minix.c b/fs/minix.c index 0b7a49e16..a856e38c4 100644 --- a/fs/minix.c +++ b/fs/minix.c @@ -311,7 +311,7 @@ grub_minix_lookup_symlink (struct grub_minix_data *data, int ino) grub_minix_find_file (data, symlink); if (grub_errno) - grub_error (grub_errno, "can not follow symlink `%s'", symlink); + grub_error (grub_errno, "cannot follow symlink `%s'", symlink); return grub_errno; } diff --git a/fs/reiserfs.c b/fs/reiserfs.c index f9c37ed7b..a8ba75910 100644 --- a/fs/reiserfs.c +++ b/fs/reiserfs.c @@ -691,7 +691,7 @@ grub_reiserfs_mount (grub_disk_t disk) if (grub_memcmp (data->superblock.magic_string, REISERFS_MAGIC_STRING, sizeof (REISERFS_MAGIC_STRING) - 1)) { - grub_error (GRUB_ERR_BAD_FS, "not a reiserfs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a ReiserFS filesystem"); goto fail; } data->disk = disk; @@ -700,7 +700,7 @@ grub_reiserfs_mount (grub_disk_t disk) fail: /* Disk is too small to contain a ReiserFS. */ if (grub_errno == GRUB_ERR_OUT_OF_RANGE) - grub_error (GRUB_ERR_BAD_FS, "not a reiserfs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a ReiserFS filesystem"); grub_free (data); return 0; diff --git a/fs/sfs.c b/fs/sfs.c index ec59b73ca..4f70ad3ec 100644 --- a/fs/sfs.c +++ b/fs/sfs.c @@ -279,7 +279,7 @@ grub_sfs_mount (grub_disk_t disk) /* Make sure this is a sfs filesystem. */ if (grub_strncmp ((char *) (data->rblock.header.magic), "SFS", 4)) { - grub_error (GRUB_ERR_BAD_FS, "not a sfs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a SFS filesystem"); goto fail; } @@ -307,7 +307,7 @@ grub_sfs_mount (grub_disk_t disk) fail: if (grub_errno == GRUB_ERR_OUT_OF_RANGE) - grub_error (GRUB_ERR_BAD_FS, "not an sfs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an SFS filesystem"); grub_free (data); grub_free (rootobjc_data); diff --git a/fs/udf.c b/fs/udf.c index 9dfe431f6..b44fa8a6d 100644 --- a/fs/udf.c +++ b/fs/udf.c @@ -525,7 +525,7 @@ grub_udf_mount (grub_disk_t disk) if (grub_disk_read (disk, block << GRUB_UDF_LOG2_BLKSZ, 0, sizeof (struct grub_udf_vrs), &vrs)) { - grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem"); goto fail; } @@ -539,7 +539,7 @@ grub_udf_mount (grub_disk_t disk) (grub_memcmp (vrs.magic, GRUB_UDF_STD_IDENT_CDW02, 5)) && (grub_memcmp (vrs.magic, GRUB_UDF_STD_IDENT_TEA01, 5))) { - grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem"); goto fail; } } @@ -552,7 +552,7 @@ grub_udf_mount (grub_disk_t disk) if (grub_disk_read (disk, *sblklist << GRUB_UDF_LOG2_BLKSZ, 0, sizeof (struct grub_udf_avdp), &avdp)) { - grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem"); goto fail; } @@ -565,7 +565,7 @@ grub_udf_mount (grub_disk_t disk) sblklist++; if (*sblklist == 0) { - grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem"); goto fail; } } @@ -579,7 +579,7 @@ grub_udf_mount (grub_disk_t disk) if (grub_disk_read (disk, block << GRUB_UDF_LOG2_BLKSZ, 0, sizeof (struct grub_udf_tag), &tag)) { - grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem"); goto fail; } @@ -596,7 +596,7 @@ grub_udf_mount (grub_disk_t disk) sizeof (struct grub_udf_pd), &data->pds[data->npd])) { - grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem"); goto fail; } @@ -612,7 +612,7 @@ grub_udf_mount (grub_disk_t disk) sizeof (struct grub_udf_lvd), &data->lvd)) { - grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem"); goto fail; } @@ -675,7 +675,7 @@ grub_udf_mount (grub_disk_t disk) if (grub_disk_read (disk, block << GRUB_UDF_LOG2_BLKSZ, 0, sizeof (struct grub_udf_fileset), &root_fs)) { - grub_error (GRUB_ERR_BAD_FS, "not an udf filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem"); goto fail; } diff --git a/fs/ufs.c b/fs/ufs.c index 6d3117d5f..f95a6e12e 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -415,7 +415,7 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino) grub_ufs_find_file (data, symlink); if (grub_errno) - grub_error (grub_errno, "can not follow symlink `%s'", symlink); + grub_error (grub_errno, "cannot follow symlink `%s'", symlink); return grub_errno; } diff --git a/fs/xfs.c b/fs/xfs.c index d627ea9f8..c15ec7341 100644 --- a/fs/xfs.c +++ b/fs/xfs.c @@ -290,7 +290,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) else { grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "xfs does not support inode format %d yet", + "XFS does not support inode format %d yet", node->inode.format); return 0; } @@ -567,7 +567,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, default: grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "xfs does not support inode format %d yet", + "XFS does not support inode format %d yet", diro->inode.format); } return 0; @@ -590,7 +590,7 @@ grub_xfs_mount (grub_disk_t disk) if (grub_strncmp ((char *) (data->sblock.magic), "XFSB", 4)) { - grub_error (GRUB_ERR_BAD_FS, "not a xfs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a XFS filesystem"); goto fail; } @@ -617,7 +617,7 @@ grub_xfs_mount (grub_disk_t disk) fail: if (grub_errno == GRUB_ERR_OUT_OF_RANGE) - grub_error (GRUB_ERR_BAD_FS, "not an xfs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not an XFS filesystem"); grub_free (data); diff --git a/loader/powerpc/ieee1275/linux.c b/loader/powerpc/ieee1275/linux.c index fbee68001..9d755450e 100644 --- a/loader/powerpc/ieee1275/linux.c +++ b/loader/powerpc/ieee1275/linux.c @@ -75,10 +75,10 @@ grub_linux_release_mem (void) linux_args = 0; if (linux_addr && grub_ieee1275_release (linux_addr, linux_size)) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "can not release memory"); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot release memory"); if (initrd_addr && grub_ieee1275_release (initrd_addr, initrd_size)) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "can not release memory"); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot release memory"); linux_addr = 0; initrd_addr = 0; @@ -128,7 +128,7 @@ grub_linux_load32 (grub_elf_t elf) break; } if (found_addr == -1) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "could not claim memory"); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't claim memory"); /* Now load the segments into the area we claimed. */ auto grub_err_t offset_phdr (Elf32_Phdr *phdr, grub_addr_t *addr, int *do_load); @@ -178,7 +178,7 @@ grub_linux_load64 (grub_elf_t elf) break; } if (found_addr == -1) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, "could not claim memory"); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't claim memory"); /* Now load the segments into the area we claimed. */ auto grub_err_t offset_phdr (Elf64_Phdr *phdr, grub_addr_t *addr, int *do_load); @@ -321,7 +321,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (found_addr == -1) { - grub_error (GRUB_ERR_OUT_OF_MEMORY, "can not claim memory"); + grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot claim memory"); goto fail; } diff --git a/loader/sparc64/ieee1275/linux.c b/loader/sparc64/ieee1275/linux.c index 887edd27a..820110847 100644 --- a/loader/sparc64/ieee1275/linux.c +++ b/loader/sparc64/ieee1275/linux.c @@ -256,12 +256,12 @@ grub_linux_load64 (grub_elf_t elf) paddr = alloc_phys (linux_size + off); if (paddr == (grub_addr_t) -1) return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "could not allocate physical memory"); + "couldn't allocate physical memory"); ret = grub_ieee1275_map_physical (paddr, linux_addr - off, linux_size + off, IEEE1275_MAP_DEFAULT); if (ret) return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "could not map physical memory"); + "couldn't map physical memory"); grub_dprintf ("loader", "Loading linux at vaddr 0x%lx, paddr 0x%lx, size 0x%lx\n", linux_addr, paddr, linux_size); @@ -405,14 +405,14 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), if (paddr == (grub_addr_t) -1) { grub_error (GRUB_ERR_OUT_OF_MEMORY, - "could not allocate physical memory"); + "couldn't allocate physical memory"); goto fail; } ret = grub_ieee1275_map_physical (paddr, addr, size, IEEE1275_MAP_DEFAULT); if (ret) { grub_error (GRUB_ERR_OUT_OF_MEMORY, - "could not map physical memory"); + "couldn't map physical memory"); goto fail; } diff --git a/util/grub-probe.c b/util/grub-probe.c index 1958308c3..ebf5142d4 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -259,7 +259,7 @@ probe (const char *path, char *device_name) grub_util_info ("reading %s via GRUB facilities", grub_path); file = grub_file_open (grub_path); if (! file) - grub_util_error ("can not open %s via GRUB facilities", grub_path); + grub_util_error ("cannot open %s via GRUB facilities", grub_path); filebuf_via_grub = xmalloc (file->size); grub_file_read (file, filebuf_via_grub, file->size); diff --git a/util/misc.c b/util/misc.c index 5896da0c8..6aa92fb64 100644 --- a/util/misc.c +++ b/util/misc.c @@ -504,7 +504,7 @@ make_system_path_relative_to_its_root (const char *path) free (p); if (stat (buf, &st) < 0) - grub_util_error ("can not stat %s: %s", buf, strerror (errno)); + grub_util_error ("cannot stat %s: %s", buf, strerror (errno)); buf2 = strdup (buf); num = st.st_dev; @@ -523,7 +523,7 @@ make_system_path_relative_to_its_root (const char *path) *++p = 0; if (stat (buf, &st) < 0) - grub_util_error ("can not stat %s: %s", buf, strerror (errno)); + grub_util_error ("cannot stat %s: %s", buf, strerror (errno)); /* buf is another filesystem; we found it. */ if (st.st_dev != num) From fa533ebb5c44bdc61e9fb74f8c7c6108fec81c01 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 01:13:21 +0100 Subject: [PATCH 084/208] Various fixes to make multiterm work --- include/grub/term.h | 20 +++++++++++++++++++- kern/term.c | 2 +- normal/main.c | 2 +- normal/menu.c | 10 ++++++---- normal/menu_text.c | 13 +++++++++---- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/include/grub/term.h b/include/grub/term.h index 479081d86..e8cf727be 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -359,6 +359,18 @@ grub_term_setcursor (struct grub_term_output *term, int on) term->setcursor (on); } +static inline void +grub_term_cls (struct grub_term_output *term) +{ + if (term->cls) + (term->cls) (); + else + { + grub_putcode ('\n', term); + grub_term_refresh (term); + } +} + static inline grub_ssize_t grub_term_getcharwidth (struct grub_term_output *term, grub_uint32_t c) { @@ -372,7 +384,13 @@ static inline void grub_term_getcolor (struct grub_term_output *term, grub_uint8_t *normal_color, grub_uint8_t *highlight_color) { - term->getcolor (normal_color, highlight_color); + if (term->getcolor) + term->getcolor (normal_color, highlight_color); + else + { + *normal_color = 0x07; + *highlight_color = 0x07; + } } extern void (*EXPORT_VAR (grub_newline_hook)) (void); diff --git a/kern/term.c b/kern/term.c index 8f8576aa2..b76771d86 100644 --- a/kern/term.c +++ b/kern/term.c @@ -132,7 +132,7 @@ grub_cls (void) if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug"))) { grub_putcode ('\n', term); - grub_refresh (); + grub_term_refresh (term); } else (term->cls) (); diff --git a/normal/main.c b/normal/main.c index e1ffddae7..b4af09be9 100644 --- a/normal/main.c +++ b/normal/main.c @@ -409,7 +409,7 @@ grub_normal_init_page (struct grub_term_output *term) grub_uint32_t *unicode_msg; grub_uint32_t *last_position; - grub_cls (); + grub_term_cls (term); grub_sprintf (msg_formatted, msg, PACKAGE_VERSION); diff --git a/normal/menu.c b/normal/menu.c index 824779db6..b64213185 100644 --- a/normal/menu.c +++ b/normal/menu.c @@ -391,13 +391,15 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) case GRUB_TERM_UP: case '^': - current_entry--; + if (current_entry > 0) + current_entry--; menu_set_chosen_entry (current_entry); break; case GRUB_TERM_DOWN: case 'v': - current_entry++; + if (current_entry < menu->size - 1) + current_entry++; menu_set_chosen_entry (current_entry); break; @@ -411,9 +413,9 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) case GRUB_TERM_NPAGE: if (current_entry + GRUB_MENU_PAGE_SIZE < menu->size) - current_entry = 0; - else current_entry += GRUB_MENU_PAGE_SIZE; + else + current_entry = menu->size - 1; menu_set_chosen_entry (current_entry); break; diff --git a/normal/menu_text.c b/normal/menu_text.c index 991a9ba4d..71bd104aa 100644 --- a/normal/menu_text.c +++ b/normal/menu_text.c @@ -202,8 +202,8 @@ entry is highlighted.\n"); if (nested) { - grub_printf ("\n "); - grub_printf_ (N_("ESC to return previous menu.")); + grub_puts_terminal ("\n ", term); + grub_puts_terminal (_("ESC to return previous menu."), term); } } } @@ -385,10 +385,11 @@ menu_text_set_chosen_entry (int entry, void *dataptr) struct menu_viewer_data *data = dataptr; int oldoffset = data->offset; int complete_redraw = 0; + data->offset = entry - data->first; if (data->offset > grub_term_num_entries (data->term) - 1) { - data->first = data->offset - (grub_term_num_entries (data->term) - 1); + data->first = entry - (grub_term_num_entries (data->term) - 1); data->offset = grub_term_num_entries (data->term) - 1; complete_redraw = 1; } @@ -418,6 +419,8 @@ menu_text_fini (void *dataptr) struct menu_viewer_data *data = dataptr; grub_term_setcursor (data->term, 1); + grub_term_cls (data->term); + } static void @@ -456,13 +459,14 @@ grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested) grub_errno = GRUB_ERR_NONE; continue; } + data->term = term; instance->data = data; instance->set_chosen_entry = menu_text_set_chosen_entry; instance->print_timeout = menu_text_print_timeout; instance->clear_timeout = menu_text_clear_timeout; instance->fini = menu_text_fini; - + data->menu = menu; data->offset = entry; @@ -477,5 +481,6 @@ grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested) grub_menu_init_page (nested, 0, data->term); print_entries (menu, data->first, data->offset, data->term); grub_term_refresh (data->term); + grub_menu_register_viewer (instance); } } From ca04c7a550d7309ede0e91a5debb44544207719f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 01:20:44 +0100 Subject: [PATCH 085/208] Colin Watson's request --- commands/keystatus.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/commands/keystatus.c b/commands/keystatus.c index 1bb22bde3..580e25f5d 100644 --- a/commands/keystatus.c +++ b/commands/keystatus.c @@ -55,12 +55,16 @@ grub_cmd_keystatus (grub_extcmd_t cmd, if (expect_mods == 0) { grub_term_input_t term; + int nterms = 0; FOR_ACTIVE_TERM_INPUTS (term) - if (term->getkeystatus) - return 0; - - return grub_error (GRUB_ERR_TEST_FAILURE, "false"); + if (!term->getkeystatus) + return grub_error (GRUB_ERR_TEST_FAILURE, "false"); + else + nterms++; + if (!nterms) + return grub_error (GRUB_ERR_TEST_FAILURE, "false"); + return 0; } mods = grub_getkeystatus (); From bf2ebfbe0299b984979c05c714b6ef9f412cbfb6 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 03:36:42 +0100 Subject: [PATCH 086/208] Lost hunk --- conf/common.rmk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conf/common.rmk b/conf/common.rmk index 83168557d..caad3c571 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -644,6 +644,11 @@ charset_mod_SOURCES = lib/charset.c charset_mod_CFLAGS = $(COMMON_CFLAGS) charset_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += terminal.mod +terminal_mod_SOURCES = commands/terminal.c +terminal_mod_CFLAGS = $(COMMON_CFLAGS) +terminal_mod_LDFLAGS = $(COMMON_LDFLAGS) + pkglib_MODULES += crypto.mod crypto_mod_SOURCES = lib/crypto.c crypto_mod_CFLAGS = $(COMMON_CFLAGS) From 33c1ed4c8d1ef6bfa463a9f51fa709b72fb9b71d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 03:37:20 +0100 Subject: [PATCH 087/208] terminal modules autoloading --- Makefile.in | 5 +- commands/terminal.c | 109 ++++++++++++++++++++++++++++++------- genmk.rb | 7 +++ genterminallist.sh | 22 ++++++++ include/grub/normal.h | 2 + include/grub/term.h | 10 ++++ normal/main.c | 1 + normal/term.c | 123 ++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 260 insertions(+), 19 deletions(-) create mode 100644 genterminallist.sh diff --git a/Makefile.in b/Makefile.in index b28b660da..413c6a59d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -169,7 +169,7 @@ endif ### General targets. CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo -pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst +pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk cat $(DEFSYMFILES) /dev/null \ | $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \ @@ -187,6 +187,9 @@ partmap.lst: $(PARTMAPFILES) handler.lst: $(HANDLERFILES) cat $^ /dev/null | sort > $@ +terminal.lst: $(TERMINALFILES) + cat $^ /dev/null | sort > $@ + parttool.lst: $(PARTTOOLFILES) cat $^ /dev/null | sort | uniq > $@ diff --git a/commands/terminal.c b/commands/terminal.c index a667825f4..5befecd31 100644 --- a/commands/terminal.c +++ b/commands/terminal.c @@ -23,12 +23,16 @@ #include #include +struct grub_term_autoload *grub_term_input_autoload = NULL; +struct grub_term_autoload *grub_term_output_autoload = NULL; + grub_err_t grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) { int i; grub_term_input_t term; + struct grub_term_autoload *aut; if (argc == 0) { @@ -39,6 +43,20 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)), grub_puts_ (N_ ("Available input terminals:")); FOR_DISABLED_TERM_INPUTS(term) grub_printf ("%s ", term->name); + /* This is quadratic but we don't expect mode than 30 terminal + modules ever. */ + for (aut = grub_term_input_autoload; aut; aut = aut->next) + { + FOR_DISABLED_TERM_INPUTS(term) + if (grub_strcmp (term->name, aut->name) == 0) + break; + if (!term) + FOR_ACTIVE_TERM_INPUTS(term) + if (grub_strcmp (term->name, aut->name) == 0) + break; + if (!term) + grub_printf ("%s ", aut->name); + } grub_printf ("\n"); return GRUB_ERR_NONE; } @@ -53,16 +71,36 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)), for (; i < argc; i++) { - FOR_DISABLED_TERM_INPUTS(term) - if (grub_strcmp (args[i], term->name) == 0) - break; - if (term == 0) - FOR_ACTIVE_TERM_INPUTS(term) - if (grub_strcmp (args[i], term->name) == 0) + int again = 0; + while (1) + { + FOR_DISABLED_TERM_INPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term == 0) + FOR_ACTIVE_TERM_INPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term) break; - if (term == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n", - args[i]); + if (again) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n", + args[i]); + for (aut = grub_term_input_autoload; aut; aut = aut->next) + if (grub_strcmp (args[i], aut->name) == 0) + { + grub_dl_t mod; + mod = grub_dl_load (aut->modname); + if (mod) + grub_dl_ref (mod); + grub_errno = GRUB_ERR_NONE; + break; + } + if (!aut) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n", + args[i]); + again = 1; + } } if (grub_strcmp (args[0], "--append") == 0) @@ -151,6 +189,7 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)), { int i; grub_term_output_t term; + struct grub_term_autoload *aut; if (argc == 0) { @@ -161,6 +200,20 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)), grub_puts_ (N_ ("Available output terminals:")); FOR_DISABLED_TERM_OUTPUTS(term) grub_printf ("%s ", term->name); + /* This is quadratic but we don't expect mode than 30 terminal + modules ever. */ + for (aut = grub_term_output_autoload; aut; aut = aut->next) + { + FOR_DISABLED_TERM_OUTPUTS(term) + if (grub_strcmp (term->name, aut->name) == 0) + break; + if (!term) + FOR_ACTIVE_TERM_OUTPUTS(term) + if (grub_strcmp (term->name, aut->name) == 0) + break; + if (!term) + grub_printf ("%s ", aut->name); + } grub_printf ("\n"); return GRUB_ERR_NONE; } @@ -175,16 +228,36 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)), for (; i < argc; i++) { - FOR_DISABLED_TERM_OUTPUTS(term) - if (grub_strcmp (args[i], term->name) == 0) - break; - if (term == 0) - FOR_ACTIVE_TERM_OUTPUTS(term) - if (grub_strcmp (args[i], term->name) == 0) + int again = 0; + while (1) + { + FOR_DISABLED_TERM_OUTPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term == 0) + FOR_ACTIVE_TERM_OUTPUTS(term) + if (grub_strcmp (args[i], term->name) == 0) + break; + if (term) break; - if (term == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n", - args[i]); + if (again) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n", + args[i]); + for (aut = grub_term_output_autoload; aut; aut = aut->next) + if (grub_strcmp (args[i], aut->name) == 0) + { + grub_dl_t mod; + mod = grub_dl_load (aut->modname); + if (mod) + grub_dl_ref (mod); + grub_errno = GRUB_ERR_NONE; + break; + } + if (!aut) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n", + args[i]); + again = 1; + } } if (grub_strcmp (args[0], "--append") == 0) diff --git a/genmk.rb b/genmk.rb index b3dbe8678..43eaef150 100644 --- a/genmk.rb +++ b/genmk.rb @@ -192,6 +192,7 @@ endif fs = 'fs-' + obj.suffix('lst') partmap = 'partmap-' + obj.suffix('lst') handler = 'handler-' + obj.suffix('lst') + terminal = 'terminal-' + obj.suffix('lst') parttool = 'parttool-' + obj.suffix('lst') video = 'video-' + obj.suffix('lst') dep = deps[i] @@ -213,6 +214,7 @@ FSFILES += #{fs} PARTTOOLFILES += #{parttool} PARTMAPFILES += #{partmap} HANDLERFILES += #{handler} +TERMINALFILES += #{terminal} VIDEOFILES += #{video} #{command}: #{src} $(#{src}_DEPENDENCIES) gencmdlist.sh @@ -240,6 +242,11 @@ VIDEOFILES += #{video} $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \ | sh $(srcdir)/genhandlerlist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1) +#{terminal}: #{src} $(#{src}_DEPENDENCIES) genterminlist.sh + set -e; \ + $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \ + | sh $(srcdir)/genterminallist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1) + #{video}: #{src} $(#{src}_DEPENDENCIES) genvideolist.sh set -e; \ $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \ diff --git a/genterminallist.sh b/genterminallist.sh new file mode 100644 index 000000000..eb0de0c32 --- /dev/null +++ b/genterminallist.sh @@ -0,0 +1,22 @@ +#! /bin/sh +# +# Copyright (C) 2009 Free Software Foundation, Inc. +# +# This script is free software; the author +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# Read source code from stdin and detect command names. + +module=$1 + +grep -v "^#" | sed -n \ + -e "/grub_term_register_input *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $module/;p;}" \ + -e "/grub_term_register_input_active *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $module/;p;}" \ + -e "/grub_term_register_output *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $module/;p;}" \ + -e "/grub_term_register_output_active *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $module/;p;}" diff --git a/include/grub/normal.h b/include/grub/normal.h index 91457fc09..af8e00a71 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -103,6 +103,8 @@ void read_fs_list (void); void read_crypto_list (void); +void read_terminal_list (void); + void grub_set_more (int onoff); #ifdef GRUB_UTIL diff --git a/include/grub/term.h b/include/grub/term.h index e8cf727be..922ccb2d2 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -395,6 +395,16 @@ grub_term_getcolor (struct grub_term_output *term, extern void (*EXPORT_VAR (grub_newline_hook)) (void); +struct grub_term_autoload +{ + struct grub_term_autoload *next; + char *name; + char *modname; +}; + +extern struct grub_term_autoload *grub_term_input_autoload; +extern struct grub_term_autoload *grub_term_output_autoload; + /* For convenience. */ #define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff) diff --git a/normal/main.c b/normal/main.c index b4af09be9..3ee4d295d 100644 --- a/normal/main.c +++ b/normal/main.c @@ -443,6 +443,7 @@ grub_normal_execute (const char *config, int nested, int batch) read_fs_list (); read_handler_list (); read_crypto_list (); + read_terminal_list (); grub_command_execute ("parser.grub", 0, 0); reader_nested = nested; diff --git a/normal/term.c b/normal/term.c index 5a8e9cffc..b099ae84c 100644 --- a/normal/term.c +++ b/normal/term.c @@ -19,6 +19,10 @@ #include #include #include +#include +#include +#include +#include /* The amount of lines counted by the pager. */ static unsigned grub_more_lines; @@ -127,3 +131,122 @@ grub_term_restore_pos (grub_uint16_t *pos) ptr++; } } + +static void +grub_terminal_autoload_free (void) +{ + struct grub_term_autoload *cur, *next; + unsigned i; + for (i = 0; i < 2; i++) + for (cur = i ? grub_term_input_autoload : grub_term_output_autoload; + cur; cur = next) + { + next = cur->next; + grub_free (cur->name); + grub_free (cur->modname); + grub_free (cur); + } + grub_term_input_autoload = NULL; + grub_term_output_autoload = NULL; +} + + +/* Read the file terminal.lst for auto-loading. */ +void +read_terminal_list (void) +{ + const char *prefix; + char *filename; + grub_file_t file; + char *buf = NULL; + + prefix = grub_env_get ("prefix"); + if (!prefix) + { + grub_errno = GRUB_ERR_NONE; + return; + } + + filename = grub_malloc (grub_strlen (prefix) + sizeof ("/crypto.lst")); + if (!filename) + { + grub_errno = GRUB_ERR_NONE; + return; + } + + grub_sprintf (filename, "%s/terminal.lst", prefix); + file = grub_file_open (filename); + if (!file) + { + grub_errno = GRUB_ERR_NONE; + return; + } + + /* Override previous terminal.lst. */ + grub_terminal_autoload_free (); + + for (;; grub_free (buf)) + { + char *p, *name; + struct grub_term_autoload *cur; + struct grub_term_autoload **target = NULL; + + buf = grub_file_getline (file); + + if (! buf) + break; + + switch (buf[0]) + { + case 'i': + target = &grub_term_input_autoload; + break; + + case 'o': + target = &grub_term_output_autoload; + break; + } + if (!target) + continue; + + name = buf + 1; + + p = grub_strchr (name, ':'); + if (! p) + continue; + + *p = '\0'; + while (*++p == ' ') + ; + + cur = grub_malloc (sizeof (*cur)); + if (!cur) + { + grub_errno = GRUB_ERR_NONE; + continue; + } + + cur->name = grub_strdup (name); + if (! name) + { + grub_errno = GRUB_ERR_NONE; + grub_free (cur); + continue; + } + + cur->modname = grub_strdup (p); + if (! cur->modname) + { + grub_errno = GRUB_ERR_NONE; + grub_free (cur); + grub_free (cur->name); + continue; + } + cur->next = *target; + *target = cur; + } + + grub_file_close (file); + + grub_errno = GRUB_ERR_NONE; +} From 2e5b307c47308b92a0c94ab4702ba348a8495e26 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 04:12:29 +0100 Subject: [PATCH 088/208] Make menu editor work --- normal/menu.c | 2 ++ normal/menu_entry.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/normal/menu.c b/normal/menu.c index b64213185..8cf0e158d 100644 --- a/normal/menu.c +++ b/normal/menu.c @@ -435,10 +435,12 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) break; case 'c': + menu_fini (); grub_cmdline_run (1); goto refresh; case 'e': + menu_fini (); { grub_menu_entry_t e = grub_menu_get_entry (menu, current_entry); if (e) diff --git a/normal/menu_entry.c b/normal/menu_entry.c index da4eff496..8caba4336 100644 --- a/normal/menu_entry.c +++ b/normal/menu_entry.c @@ -135,8 +135,16 @@ print_line (struct line *linep, int offset, int start, int y, else { int i; + char *p, c; + + p = linep->buf + linep->len; + c = *p; + *p = 0; + grub_puts_terminal (linep->buf + offset + start, term_screen->term); + *p = c; + for (i = 0; - i <= grub_term_entry_width (term_screen->term) - linep->len + offset; + i < grub_term_entry_width (term_screen->term) - linep->len + offset; i++) grub_putcode (' ', term_screen->term); } @@ -1208,6 +1216,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) int prev_c; grub_err_t err = GRUB_ERR_NONE; unsigned i; + grub_term_output_t term; err = grub_auth_check_authentication (NULL); @@ -1222,7 +1231,27 @@ grub_menu_entry_run (grub_menu_entry_t entry) if (! screen) return; + screen->terms = NULL; + refresh: + grub_free (screen->terms); + screen->nterms = 0; + FOR_ACTIVE_TERM_OUTPUTS(term) + screen->nterms++; + screen->terms = grub_malloc (screen->nterms * sizeof (screen->terms[0])); + if (!screen->terms) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + return; + } + i = 0; + FOR_ACTIVE_TERM_OUTPUTS(term) + { + screen->terms[i].term = term; + screen->terms[i].x = 0; + screen->terms[i].y = 0; + } /* Draw the screen. */ for (i = 0; i < screen->nterms; i++) grub_menu_init_page (0, 1, screen->terms[i].term); From a999b9d96538f0e868bab734980370026bcb607d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 13:17:27 +0100 Subject: [PATCH 089/208] Fix refresh in cmdline --- normal/cmdline.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/normal/cmdline.c b/normal/cmdline.c index d7f41c7e3..3521c3cbd 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -306,8 +306,6 @@ grub_cmdline_get (const char *prompt) cl_print_all (lpos - len, 0); cl_set_pos_all (); } - - grub_refresh (); } void cl_delete (unsigned len) @@ -328,8 +326,6 @@ grub_cmdline_get (const char *prompt) cl_print_all (lpos, 0); cl_set_pos_all (); } - - grub_refresh (); } void init_clterm (struct cmdline_term *cl_term_cur) @@ -596,6 +592,7 @@ grub_cmdline_get (const char *prompt) } break; } + grub_refresh (); } grub_putchar ('\n'); From 0e76d18c5b1cae408f7440da730e1808fe85a7b8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 13:18:08 +0100 Subject: [PATCH 090/208] Fix various issues in menu editor --- normal/menu_entry.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/normal/menu_entry.c b/normal/menu_entry.c index 8caba4336..9599abd97 100644 --- a/normal/menu_entry.c +++ b/normal/menu_entry.c @@ -124,8 +124,7 @@ print_line (struct line *linep, int offset, int start, int y, if (linep->len >= offset + grub_term_entry_width (term_screen->term)) { char *p, c; - p = linep->buf + offset + start - + grub_term_entry_width (term_screen->term); + p = linep->buf + offset + grub_term_entry_width (term_screen->term); c = *p; *p = 0; grub_puts_terminal (linep->buf + offset + start, term_screen->term); @@ -144,7 +143,7 @@ print_line (struct line *linep, int offset, int start, int y, *p = c; for (i = 0; - i < grub_term_entry_width (term_screen->term) - linep->len + offset; + i <= grub_term_entry_width (term_screen->term) - linep->len + offset; i++) grub_putcode (' ', term_screen->term); } @@ -1251,6 +1250,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) screen->terms[i].term = term; screen->terms[i].x = 0; screen->terms[i].y = 0; + i++; } /* Draw the screen. */ for (i = 0; i < screen->nterms; i++) From 6066889c88dd92fba5a9e845a8215ab115a96726 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 16:28:31 +0100 Subject: [PATCH 091/208] normal_exit command --- include/grub/normal.h | 2 +- normal/main.c | 55 ++++++++++++++++++++++++++++++++----------- normal/menu.c | 6 +++++ normal/menu_entry.c | 6 +++++ 4 files changed, 54 insertions(+), 15 deletions(-) diff --git a/include/grub/normal.h b/include/grub/normal.h index af8e00a71..58b2c7966 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -46,7 +46,7 @@ enum grub_completion_type typedef enum grub_completion_type grub_completion_type_t; extern struct grub_menu_viewer grub_normal_text_menu_viewer; - +extern int grub_normal_exit_level; /* Defined in `main.c'. */ void grub_enter_normal_mode (const char *config); diff --git a/normal/main.c b/normal/main.c index 3ee4d295d..14e8971b0 100644 --- a/normal/main.c +++ b/normal/main.c @@ -34,6 +34,9 @@ #define GRUB_DEFAULT_HISTORY_SIZE 50 +static int nested_level = 0; +int grub_normal_exit_level = 0; + /* Read a line from the file FILE. */ char * grub_file_getline (grub_file_t file) @@ -430,8 +433,6 @@ grub_normal_init_page (struct grub_term_output *term) grub_free (unicode_msg); } -static int reader_nested; - /* Read the config file CONFIG and execute the menu interface or the command line interface if BATCH is false. */ void @@ -446,8 +447,6 @@ grub_normal_execute (const char *config, int nested, int batch) read_terminal_list (); grub_command_execute ("parser.grub", 0, 0); - reader_nested = nested; - if (config) { menu = read_config_file (config); @@ -471,8 +470,12 @@ grub_normal_execute (const char *config, int nested, int batch) void grub_enter_normal_mode (const char *config) { + nested_level++; grub_normal_execute (config, 0, 0); - grub_cmdline_run (1); + grub_cmdline_run (0); + nested_level--; + if (grub_normal_exit_level) + grub_normal_exit_level--; } /* Enter normal mode from rescue mode. */ @@ -508,8 +511,20 @@ quit: return 0; } +/* Exit from normal mode to rescue mode. */ static grub_err_t -grub_normal_reader_init (void) +grub_cmd_normal_exit (struct grub_command *cmd __attribute__ ((unused)), + int argc __attribute__ ((unused)), + char *argv[] __attribute__ ((unused))) +{ + if (nested_level <= grub_normal_exit_level) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "not in normal environment"); + grub_normal_exit_level++; + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_normal_reader_init (int nested) { struct grub_term_output *term; const char *msg = _("Minimal BASH-like line editing is supported. For " @@ -519,7 +534,7 @@ grub_normal_reader_init (void) char *msg_formatted = grub_malloc (sizeof (char) * (grub_strlen (msg) + grub_strlen(msg_esc) + 1)); - grub_sprintf (msg_formatted, msg, reader_nested ? msg_esc : ""); + grub_sprintf (msg_formatted, msg, nested ? msg_esc : ""); FOR_ACTIVE_TERM_OUTPUTS(term) { @@ -536,12 +551,15 @@ grub_normal_reader_init (void) static grub_err_t -grub_normal_read_line (char **line, int cont) +grub_normal_read_line_real (char **line, int cont, int nested) { grub_parser_t parser = grub_parser_get_current (); char prompt[sizeof("> ") + grub_strlen (parser->name)]; - grub_sprintf (prompt, "%s> ", parser->name); + if (cont) + grub_sprintf (prompt, "> "); + else + grub_sprintf (prompt, "%s> ", parser->name); while (1) { @@ -549,7 +567,7 @@ grub_normal_read_line (char **line, int cont) if (*line) break; - if ((reader_nested) || (cont)) + if (cont || nested) { grub_free (*line); *line = 0; @@ -560,6 +578,12 @@ grub_normal_read_line (char **line, int cont) return 0; } +static grub_err_t +grub_normal_read_line (char **line, int cont) +{ + return grub_normal_read_line_real (line, cont, 0); +} + void grub_cmdline_run (int nested) { @@ -574,19 +598,20 @@ grub_cmdline_run (int nested) return; } - reader_nested = nested; - - grub_normal_reader_init (); + grub_normal_reader_init (nested); while (1) { char *line; + if (grub_normal_exit_level) + break; + /* Print an error, if any. */ grub_print_error (); grub_errno = GRUB_ERR_NONE; - grub_normal_read_line (&line, 0); + grub_normal_read_line_real (&line, 0, nested); if (! line) break; @@ -623,6 +648,8 @@ GRUB_MOD_INIT(normal) /* Register a command "normal" for the rescue mode. */ grub_register_command ("normal", grub_cmd_normal, 0, "Enter normal mode"); + grub_register_command ("normal_exit", grub_cmd_normal_exit, + 0, "Exit from normal mode"); /* Reload terminal colors when these variables are written to. */ grub_register_variable_hook ("color_normal", NULL, grub_env_write_color_normal); diff --git a/normal/menu.c b/normal/menu.c index 8cf0e158d..62f33b61b 100644 --- a/normal/menu.c +++ b/normal/menu.c @@ -344,6 +344,9 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) int c; timeout = grub_menu_get_timeout (); + if (grub_normal_exit_level) + return -1; + if (timeout > 0) { grub_uint64_t current_time; @@ -554,6 +557,9 @@ grub_show_menu (grub_menu_t menu, int nested) err1 = show_menu (menu, nested); grub_print_error (); + if (grub_normal_exit_level) + break; + err2 = grub_auth_check_authentication (NULL); if (err2) { diff --git a/normal/menu_entry.c b/normal/menu_entry.c index 9599abd97..7236f78e1 100644 --- a/normal/menu_entry.c +++ b/normal/menu_entry.c @@ -1270,6 +1270,12 @@ grub_menu_entry_run (grub_menu_entry_t entry) screen->completion_shown = 0; } + if (grub_normal_exit_level) + { + destroy_screen (screen); + return; + } + switch (c) { case 16: /* C-p */ From d75d75d93b4ddc291bb1085756bee26acd6d49f4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 25 Dec 2009 16:53:54 +0100 Subject: [PATCH 092/208] Fix glitch with escape message --- normal/menu_text.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/normal/menu_text.c b/normal/menu_text.c index 71bd104aa..791f831a0 100644 --- a/normal/menu_text.c +++ b/normal/menu_text.c @@ -196,15 +196,22 @@ entry is highlighted.\n"); grub_free (msg_translated); - grub_print_message_indented (_("Press enter to boot the selected OS, \ -\'e\' to edit the commands before booting or \'c\' for a command-line.\n"), - STANDARD_MARGIN, STANDARD_MARGIN, term); - if (nested) - { - grub_puts_terminal ("\n ", term); - grub_puts_terminal (_("ESC to return previous menu."), term); - } + { + grub_print_message_indented + (_("Press enter to boot the selected OS, " + "\'e\' to edit the commands before booting " + "or \'c\' for a command-line. ESC to return previous menu.\n"), + STANDARD_MARGIN, STANDARD_MARGIN, term); + } + else + { + grub_print_message_indented + (_("Press enter to boot the selected OS, " + "\'e\' to edit the commands before booting " + "or \'c\' for a command-line.\n"), + STANDARD_MARGIN, STANDARD_MARGIN, term); + } } } From 0ad46fd77185e5ed26016917a01e31488fd36382 Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Fri, 25 Dec 2009 18:29:17 +0100 Subject: [PATCH 093/208] 2009-12-25 Felix Zielcke * util/hostdisk.c (open_device): Fix a comment. --- ChangeLog | 30 +++++++++++++++++------------- util/hostdisk.c | 3 ++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 10b83e3c1..ee1141d57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-12-25 Felix Zielcke + + * util/hostdisk.c (open_device): Fix a comment. + 2009-12-24 Robert Millan * util/grub-install.in (host_os): New variable. @@ -153,7 +157,7 @@ * video/readers/tga.c: Likewise. * video/video.c: Likewise. -2009-12-23 Felix Zielcke +2009-12-23 Felix Zielcke * commands/i386/pc/drivemap.c: Remove all trailing whitespace. * commands/lspci.c: Likewise. @@ -206,7 +210,7 @@ * video/efi_gop.c (grub_video_gop_get_bitmask): Fix off-by-one in mask size counting. -2009-12-22 Felix Zielcke +2009-12-22 Felix Zielcke * util/grub-mkrescue.in (pkglib_DATA): Set to @pkglib_DATA@. * genmk.rb (class SCRIPT): Modify the target file instead of source. @@ -224,11 +228,11 @@ (grub_cmd_read): Restructure for readability. Support "-v" option. (grub_cmd_write): Restructure for readability. -2009-12-22 Felix Zielcke +2009-12-22 Felix Zielcke * genmk.rb (class SCRIPT): Prepend #{src} path with $(srcdir). -2009-12-22 Felix Zielcke +2009-12-22 Felix Zielcke * genmk.rb (class SCRIPT): Use sed to substitute @pkglib_DATA@ with the actual contents of the correspondending make variable. @@ -236,7 +240,7 @@ (process_input_dir): Copy all $pkglib_DATA files instead of explicitly specifying `*.lst' and `efiemu??.o' -2009-12-22 Felix Zielcke +2009-12-22 Felix Zielcke * util/grub.d/30_os-prober.in (osx_entry): Add round brackets after function name. @@ -252,7 +256,7 @@ (GRUB_MOD_INIT(lspci)): Use extcmd. (GRUB_MOD_FINI(lspci)): Likewise. -2009-12-22 Felix Zielcke +2009-12-22 Felix Zielcke * util/grub.d/30_os-prober.in (osx_entry): Remove non POSIX compliant `function' keyword. @@ -312,7 +316,7 @@ `$(XGETTEXT)'. * po/POTFILES: Add `commands/loadenv.c'. -2009-12-21 Felix Zielcke +2009-12-21 Felix Zielcke * util/grub-mkrescue.in (process_input_dir): Copy `*.lst' files instead of specifying them explicit. @@ -625,7 +629,7 @@ (grub_vbe_get_video_mode): Use 'last_set_mode' if get_mode fails. (grub_video_vbe_setup): Don't check for reserved flag. -2009-12-17 Felix Zielcke +2009-12-17 Felix Zielcke * gendistlist.sh: Use POSIX compliant `!' instead of `-not' in the `find' command. @@ -638,7 +642,7 @@ (grub_hfs_fs): New value .uuid. * include/grub/hfs.h (grub_hfs_sblock): New field 'num_serial'. -2009-12-14 Felix Zielcke +2009-12-14 Felix Zielcke Fix a segfault with parsing unknown long options. @@ -787,11 +791,11 @@ * include/grub/pciutils.h: New file. * util/pci.c: Likewise. -2009-12-11 Felix Zielcke +2009-12-11 Felix Zielcke * util/misc.c: Don't include twice. -2009-12-10 Felix Zielcke +2009-12-10 Felix Zielcke * disk/i386/pc/biosdisk.c (grub_biosdisk_open): Show the disk name in an error message. @@ -887,7 +891,7 @@ * disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Recognize anything even prefixed with 'cdrom' as a cdrom. -2009-12-06 Felix Zielcke +2009-12-06 Felix Zielcke * util/misc.c (make_system_path_relative_to_its_root): Correctly cope with mount points. @@ -1103,7 +1107,7 @@ ($(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po)): Rewrite as ... (po/%.po): ... this. -2009-11-26 Felix Zielcke +2009-11-26 Felix Zielcke * util/i386/efi/grub-mkimage.c: Include "progname.h". (main): Use `program_name' instead of nonexistent `progname'. diff --git a/util/hostdisk.c b/util/hostdisk.c index 11caaf407..c94f4237e 100644 --- a/util/hostdisk.c +++ b/util/hostdisk.c @@ -348,7 +348,8 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags) return -1; } - /* Make the buffer cache consistent with the physical disk. */ + /* Flush the buffer cache to the physical disk. + XXX: This also empties the buffer cache. */ ioctl (fd, BLKFLSBUF, 0); if (is_partition) From a22008a64f144faf994409ff283ae4b3c89fd831 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 25 Dec 2009 20:36:42 +0100 Subject: [PATCH 094/208] Fix typo in old changelog entry --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ee1141d57..84c5e3956 100644 --- a/ChangeLog +++ b/ChangeLog @@ -652,7 +652,7 @@ * include/grub/misc.h (grub_puts): New declaration. (grub_puts_): Likewise. - * kern/mis.c (grub_puts): New definition. + * kern/misc.c (grub_puts): New definition. (grub_puts_): Likewise. 2009-12-13 Robert Millan From 22815526305f9ffb2a7898216475558b597b3658 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 25 Dec 2009 20:33:41 +0000 Subject: [PATCH 095/208] 2009-12-25 Robert Millan * include/grub/i386/at_keyboard.h (NUM_LOCK, SCROLL_LOCK): New macros. * term/i386/pc/at_keyboard.c (KEYBOARD_STATUS_NUM_LOCK) (KEYBOARD_LED_SCROLL, KEYBOARD_LED_NUM, KEYBOARD_LED_CAPS): New macros. (led_status): New variable. (keyboard_controller_led): New function. (grub_at_keyboard_getkey_noblock): Handle num lock and scroll lock, update led status for caps lock, num lock and scroll lock. --- ChangeLog | 10 ++++++++ include/grub/i386/at_keyboard.h | 2 ++ term/i386/pc/at_keyboard.c | 41 ++++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 84c5e3956..9c34faa9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-12-25 Robert Millan + + * include/grub/i386/at_keyboard.h (NUM_LOCK, SCROLL_LOCK): New macros. + * term/i386/pc/at_keyboard.c (KEYBOARD_STATUS_NUM_LOCK) + (KEYBOARD_LED_SCROLL, KEYBOARD_LED_NUM, KEYBOARD_LED_CAPS): New macros. + (led_status): New variable. + (keyboard_controller_led): New function. + (grub_at_keyboard_getkey_noblock): Handle num lock and scroll lock, + update led status for caps lock, num lock and scroll lock. + 2009-12-25 Felix Zielcke * util/hostdisk.c (open_device): Fix a comment. diff --git a/include/grub/i386/at_keyboard.h b/include/grub/i386/at_keyboard.h index 12d61608e..017b58a62 100644 --- a/include/grub/i386/at_keyboard.h +++ b/include/grub/i386/at_keyboard.h @@ -25,6 +25,8 @@ #define CTRL 0x1d #define ALT 0x38 #define CAPS_LOCK 0x3a +#define NUM_LOCK 0x45 +#define SCROLL_LOCK 0x46 #define KEYBOARD_REG_DATA 0x60 #define KEYBOARD_REG_STATUS 0x64 diff --git a/term/i386/pc/at_keyboard.c b/term/i386/pc/at_keyboard.c index cf30e7242..dfa06ab4e 100644 --- a/term/i386/pc/at_keyboard.c +++ b/term/i386/pc/at_keyboard.c @@ -32,6 +32,13 @@ static short at_keyboard_status = 0; #define KEYBOARD_STATUS_CTRL_L (1 << 4) #define KEYBOARD_STATUS_CTRL_R (1 << 5) #define KEYBOARD_STATUS_CAPS_LOCK (1 << 6) +#define KEYBOARD_STATUS_NUM_LOCK (1 << 7) + +static grub_uint8_t led_status; + +#define KEYBOARD_LED_SCROLL (1 << 0) +#define KEYBOARD_LED_NUM (1 << 1) +#define KEYBOARD_LED_CAPS (1 << 2) static char keyboard_map[128] = { @@ -80,6 +87,15 @@ grub_keyboard_controller_read (void) return grub_inb (KEYBOARD_REG_DATA); } +static void +keyboard_controller_led (grub_uint8_t led_status) +{ + while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))); + grub_outb (0xed, KEYBOARD_REG_DATA); + while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))); + grub_outb (led_status & 0x7, KEYBOARD_REG_DATA); +} + /* FIXME: This should become an interrupt service routine. For now it's just used to catch events from control keys. */ static void @@ -158,14 +174,37 @@ grub_at_keyboard_getkey_noblock (void) switch (code) { case CAPS_LOCK: - at_keyboard_status ^= KEYBOARD_STATUS_CAPS_LOCK; /* Caps lock sends scan code twice. Get the second one and discard it. */ while (grub_keyboard_getkey () == -1); + + at_keyboard_status ^= KEYBOARD_STATUS_CAPS_LOCK; + led_status ^= KEYBOARD_LED_CAPS; + keyboard_controller_led (led_status); + #ifdef DEBUG_AT_KEYBOARD grub_dprintf ("atkeyb", "caps_lock = %d\n", !!(at_keyboard_status & KEYBOARD_STATUS_CAPS_LOCK)); #endif key = -1; break; + case NUM_LOCK: + /* Num lock sends scan code twice. Get the second one and discard it. */ + while (grub_keyboard_getkey () == -1); + + at_keyboard_status ^= KEYBOARD_STATUS_NUM_LOCK; + led_status ^= KEYBOARD_LED_NUM; + keyboard_controller_led (led_status); + +#ifdef DEBUG_AT_KEYBOARD + grub_dprintf ("atkeyb", "num_lock = %d\n", !!(at_keyboard_status & KEYBOARD_STATUS_NUM_LOCK)); +#endif + key = -1; + break; + case SCROLL_LOCK: + /* For scroll lock we don't keep track of status. Only update its led. */ + led_status ^= KEYBOARD_LED_SCROLL; + keyboard_controller_led (led_status); + key = -1; + break; default: if (at_keyboard_status & (KEYBOARD_STATUS_CTRL_L | KEYBOARD_STATUS_CTRL_R)) key = keyboard_map[code] - 'a' + 1; From ec5f98abda671278cba6304b4956d578714f79eb Mon Sep 17 00:00:00 2001 From: carles Date: Fri, 25 Dec 2009 21:51:05 +0100 Subject: [PATCH 096/208] 2009-12-25 Carles Pina i Estany * commands/help.c: Include `'. (grub_cmd_help): Gettextizze. (GRUB_MOD_INIT): Likewise. * commands/i386/pc/play.c: Include `'. (GRUB_MOD_INIT): Gettextizze. * commands/search.c: Include `'. (options): Gettextizze. (GRUB_MOD_INIT): Gettextizze. * lib/arg.c: Include `'. (help_options): Gettextizze. (find_long): Likewise. (grub_arg_show_help): Likewise. * normal/dyncmd.c: Include `'. (read_command_list): Gettextizze. * po/POTFILES: Add `commands/i386/pc/play.c', `commands/search.c', `commands/help.c', `lib/arg.c' and `normal/dyncmd.c'. --- ChangeLog | 19 +++++++++++++++++++ commands/help.c | 14 ++++++++------ commands/i386/pc/play.c | 3 ++- commands/search.c | 17 +++++++++-------- lib/arg.c | 11 ++++++----- normal/dyncmd.c | 3 ++- po/POTFILES | 7 +++++++ 7 files changed, 53 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c34faa9f..a8e29c808 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2009-12-25 Carles Pina i Estany + + * commands/help.c: Include `'. + (grub_cmd_help): Gettextizze. + (GRUB_MOD_INIT): Likewise. + * commands/i386/pc/play.c: Include `'. + (GRUB_MOD_INIT): Gettextizze. + * commands/search.c: Include `'. + (options): Gettextizze. + (GRUB_MOD_INIT): Gettextizze. + * lib/arg.c: Include `'. + (help_options): Gettextizze. + (find_long): Likewise. + (grub_arg_show_help): Likewise. + * normal/dyncmd.c: Include `'. + (read_command_list): Gettextizze. + * po/POTFILES: Add `commands/i386/pc/play.c', `commands/search.c', + `commands/help.c', `lib/arg.c' and `normal/dyncmd.c'. + 2009-12-25 Robert Millan * include/grub/i386/at_keyboard.h (NUM_LOCK, SCROLL_LOCK): New macros. diff --git a/commands/help.c b/commands/help.c index c18ec6b83..c24540cef 100644 --- a/commands/help.c +++ b/commands/help.c @@ -21,6 +21,7 @@ #include #include #include +#include static grub_err_t grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, @@ -38,13 +39,14 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE)) { char description[GRUB_TERM_WIDTH / 2]; - int desclen = grub_strlen (cmd->summary); + const char* summary_translated = _(cmd->summary); + int desclen = grub_strlen (summary_translated); /* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled with the description followed by spaces. */ grub_memset (description, ' ', GRUB_TERM_WIDTH / 2 - 1); description[GRUB_TERM_WIDTH / 2 - 1] = '\0'; - grub_memcpy (description, cmd->summary, + grub_memcpy (description, summary_translated, (desclen < GRUB_TERM_WIDTH / 2 - 1 ? desclen : GRUB_TERM_WIDTH / 2 - 1)); @@ -65,8 +67,8 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD) grub_arg_show_help ((grub_extcmd_t) cmd->data); else - grub_printf ("Usage: %s\n%s\b", cmd->summary, - cmd->description); + grub_printf ("%s %s\n%s\b", _("Usage:"), _(cmd->summary), + _(cmd->description)); } } return 0; @@ -94,8 +96,8 @@ GRUB_MOD_INIT(help) { cmd = grub_register_extcmd ("help", grub_cmd_help, GRUB_COMMAND_FLAG_CMDLINE, - "help [PATTERN ...]", - "Show a help message.", 0); + N_("help [PATTERN ...]"), + N_("Show a help message."), 0); } GRUB_MOD_FINI(help) diff --git a/commands/i386/pc/play.c b/commands/i386/pc/play.c index 6020b825a..86c0674a4 100644 --- a/commands/i386/pc/play.c +++ b/commands/i386/pc/play.c @@ -27,6 +27,7 @@ #include #include #include +#include #define BASE_TEMPO 120 @@ -207,7 +208,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(play) { cmd = grub_register_command ("play", grub_cmd_play, - "play FILE", "Play a tune."); + N_("play FILE"), N_("Play a tune.")); } GRUB_MOD_FINI(play) diff --git a/commands/search.c b/commands/search.c index 2907daa9f..b89295921 100644 --- a/commands/search.c +++ b/commands/search.c @@ -26,14 +26,15 @@ #include #include #include +#include static const struct grub_arg_option options[] = { - {"file", 'f', 0, "Search devices by a file.", 0, 0}, - {"label", 'l', 0, "Search devices by a filesystem label.", 0, 0}, - {"fs-uuid", 'u', 0, "Search devices by a filesystem UUID.", 0, 0}, - {"set", 's', GRUB_ARG_OPTION_OPTIONAL, "Set a variable to the first device found.", "VAR", ARG_TYPE_STRING}, - {"no-floppy", 'n', 0, "Do not probe any floppy drive.", 0, 0}, + {"file", 'f', 0, N_("Search devices by a file."), 0, 0}, + {"label", 'l', 0, N_("Search devices by a filesystem label."), 0, 0}, + {"fs-uuid", 'u', 0, N_("Search devices by a filesystem UUID."), 0, 0}, + {"set", 's', GRUB_ARG_OPTION_OPTIONAL, N_("Set a variable to the first device found."), "VAR", ARG_TYPE_STRING}, + {"no-floppy", 'n', 0, N_("Do not probe any floppy drive."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -186,11 +187,11 @@ GRUB_MOD_INIT(search) cmd = grub_register_extcmd ("search", grub_cmd_search, GRUB_COMMAND_FLAG_BOTH, - "search [-f|-l|-u|-s|-n] NAME", - "Search devices by file, filesystem label or filesystem UUID." + N_("search [-f|-l|-u|-s|-n] NAME"), + N_("Search devices by file, filesystem label or filesystem UUID." " If --set is specified, the first device found is" " set to a variable. If no variable name is" - " specified, \"root\" is used.", + " specified, \"root\" is used."), options); } diff --git a/lib/arg.c b/lib/arg.c index c40731368..bc1af1938 100644 --- a/lib/arg.c +++ b/lib/arg.c @@ -22,6 +22,7 @@ #include #include #include +#include /* Built-in parser for default options. */ #define SHORT_ARG_HELP -100 @@ -30,9 +31,9 @@ static const struct grub_arg_option help_options[] = { {"help", SHORT_ARG_HELP, 0, - "Display this help and exit.", 0, ARG_TYPE_NONE}, + N_("Display this help and exit."), 0, ARG_TYPE_NONE}, {"usage", SHORT_ARG_USAGE, 0, - "Display the usage of this command and exit.", 0, ARG_TYPE_NONE}, + N_("Display the usage of this command and exit."), 0, ARG_TYPE_NONE}, {0, 0, 0, 0, 0, 0} }; @@ -106,7 +107,7 @@ find_long (const struct grub_arg_option *options, const char *s, int len) static void show_usage (grub_extcmd_t cmd) { - grub_printf ("Usage: %s\n", cmd->cmd->summary); + grub_printf ("%s %s\n", _("Usage:"), _(cmd->cmd->summary)); } void @@ -143,7 +144,7 @@ grub_arg_show_help (grub_extcmd_t cmd) } } - const char *doc = opt->doc; + const char *doc = _(opt->doc); for (;;) { while (spacing-- > 0) @@ -176,7 +177,7 @@ grub_arg_show_help (grub_extcmd_t cmd) } show_usage (cmd); - grub_printf ("%s\n\n", cmd->cmd->description); + grub_printf ("%s\n\n", _(cmd->cmd->description)); if (cmd->options) showargs (cmd->options); showargs (help_options); diff --git a/normal/dyncmd.c b/normal/dyncmd.c index dc530b07b..04f1945dc 100644 --- a/normal/dyncmd.c +++ b/normal/dyncmd.c @@ -23,6 +23,7 @@ #include #include #include +#include static grub_err_t grub_dyncmd_dispatcher (struct grub_command *cmd, @@ -132,7 +133,7 @@ read_command_list (void) cmd = grub_register_command_prio (name, grub_dyncmd_dispatcher, - 0, "not loaded", prio); + 0, N_("not loaded"), prio); if (! cmd) { grub_free (name); diff --git a/po/POTFILES b/po/POTFILES index c214eb968..6efa12219 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -1,5 +1,12 @@ # List of files which contain translatable strings. +commands/i386/pc/play.c commands/loadenv.c +commands/search.c +commands/help.c + +lib/arg.c + +normal/dyncmd.c util/i386/pc/grub-mkimage.c util/i386/pc/grub-setup.c From 3fdae612d9da5ee35b1f1a860f530b52614e1050 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 25 Dec 2009 21:38:09 +0000 Subject: [PATCH 097/208] 2009-12-25 Robert Millan * term/i386/pc/at_keyboard.c (keyboard_controller_wait_untill_ready): New function. (grub_keyboard_controller_write, grub_keyboard_controller_read) (keyboard_controller_led): Use keyboard_controller_wait_untill_ready() for keyboard polling, rather than duplicate the same loop. This saves a few bytes in code size. --- ChangeLog | 9 +++++++++ term/i386/pc/at_keyboard.c | 14 ++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 46e06b255..9cef9c96d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-12-25 Robert Millan + + * term/i386/pc/at_keyboard.c + (keyboard_controller_wait_untill_ready): New function. + (grub_keyboard_controller_write, grub_keyboard_controller_read) + (keyboard_controller_led): Use keyboard_controller_wait_untill_ready() + for keyboard polling, rather than duplicate the same loop. This + saves a few bytes in code size. + 2009-12-25 Vladimir Serbinenko Support for (pxe[:server[:gateway]]) syntax and diff --git a/term/i386/pc/at_keyboard.c b/term/i386/pc/at_keyboard.c index dfa06ab4e..a53dbfa2d 100644 --- a/term/i386/pc/at_keyboard.c +++ b/term/i386/pc/at_keyboard.c @@ -72,9 +72,15 @@ static char keyboard_map_shift[128] = static grub_uint8_t grub_keyboard_controller_orig; static void -grub_keyboard_controller_write (grub_uint8_t c) +keyboard_controller_wait_untill_ready () { while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))); +} + +static void +grub_keyboard_controller_write (grub_uint8_t c) +{ + keyboard_controller_wait_untill_ready (); grub_outb (KEYBOARD_COMMAND_WRITE, KEYBOARD_REG_STATUS); grub_outb (c, KEYBOARD_REG_DATA); } @@ -82,7 +88,7 @@ grub_keyboard_controller_write (grub_uint8_t c) static grub_uint8_t grub_keyboard_controller_read (void) { - while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))); + keyboard_controller_wait_untill_ready (); grub_outb (KEYBOARD_COMMAND_READ, KEYBOARD_REG_STATUS); return grub_inb (KEYBOARD_REG_DATA); } @@ -90,9 +96,9 @@ grub_keyboard_controller_read (void) static void keyboard_controller_led (grub_uint8_t led_status) { - while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))); + keyboard_controller_wait_untill_ready (); grub_outb (0xed, KEYBOARD_REG_DATA); - while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))); + keyboard_controller_wait_untill_ready (); grub_outb (led_status & 0x7, KEYBOARD_REG_DATA); } From fdcdbb6633160bffffd65679dd7dbf2f19ff8e91 Mon Sep 17 00:00:00 2001 From: carles Date: Sat, 26 Dec 2009 00:50:59 +0100 Subject: [PATCH 098/208] 2009-12-26 Carles Pina i Estany * commands/help.c (grub_cmd_help): Print the command name before the summary. (GRUB_MOD_INIT): Remove command name from the summary. * kern/command.c (GRUB_MOD_INIT): If summary is null assign an empty strig as summary. * lib/arg.c (find_long): Print the command name before the summary. * commands/acpi.c (GRUB_MOD_INIT): Remove command name from the summary. * commands/blocklist.c (GRUB_MOD_INIT): Likewise. * commands/cat.c (GRUB_MOD_INIT): Likewise. * commands/cmp.c (GRUB_MOD_INIT): Likewise. * commands/configfile.c (GRUB_MOD_INIT): Likewise. * commands/crc.c (GRUB_MOD_INIT): Likewise. * commands/date.c (GRUB_MOD_INIT): Likewise. * commands/echo.c (GRUB_MOD_INIT): Likewise. * commands/efi/loadbios.c (GRUB_MOD_INIT): Likewise. * commands/gptsync.c (GRUB_MOD_INIT): Likewise. * commands/handler.c (GRUB_MOD_INIT): Likewise. * commands/hdparm.c (GRUB_MOD_INIT): Likewise. * commands/hexdump.c (GRUB_MOD_INIT): Likewise. * commands/i386/cpuid.c (GRUB_MOD_INIT): Likewise. * commands/i386/pc/halt.c (GRUB_MOD_INIT): Likewise. * commands/i386/pc/play.c (GRUB_MOD_INIT): Likewise. * commands/i386/pc/pxecmd.c (GRUB_MOD_INIT): Likewise. * commands/keystatus.c (GRUB_MOD_INIT): Likewise. * commands/loadenv.c (GRUB_MOD_INIT): Likewise. * commands/ls.c (GRUB_MOD_INIT): Likewise. * commands/lspci.c (GRUB_MOD_INIT): Likewise. * commands/memrw.c (GRUB_MOD_INIT): Likewise. * commands/minicmd.c (GRUB_MOD_INIT): Likewise. * commands/parttool.c (GRUB_MOD_INIT): Likewise. * commands/password.c (GRUB_MOD_INIT): Likewise. * commands/probe.c (GRUB_MOD_INIT): Likewise. * commands/read.c (GRUB_MOD_INIT): Likewise. * commands/search.c (GRUB_MOD_INIT): Likewise. * commands/sleep.c (GRUB_MOD_INIT): Likewise. * commands/test.c (GRUB_MOD_INIT): Likewise. * commands/xnu_uuid.c (GRUB_MOD_INIT): Likewise. * efiemu/main.c (GRUB_MOD_INIT): Likewise. * font/font_cmd.c (GRUB_MOD_INIT): Likewise. * gettext/gettext.c (GRUB_MOD_INIT): Likewise. * kern/corecmd.c (GRUB_MOD_INIT): Likewise. * lib/arg.c (GRUB_MOD_INIT): Likewise. * loader/efi/appleloader.c (GRUB_MOD_INIT): Likewise. * loader/i386/bsd.c (GRUB_MOD_INIT): Likewise. * loader/xnu.c (GRUB_MOD_INIT): Likewise. * mmap/mmap.c (GRUB_MOD_INIT): Likewise. * term/terminfo.c (GRUB_MOD_INIT): Likewise. * video/readers/jpeg.c (GRUB_MOD_INIT): Likewise. * video/readers/png.c (GRUB_MOD_INIT): Likewise. * video/readers/tga.c (GRUB_MOD_INIT): Likewise. --- ChangeLog | 54 +++++++++++++++++++++++++++++++++++++++ commands/acpi.c | 2 +- commands/blocklist.c | 2 +- commands/cat.c | 2 +- commands/cmp.c | 2 +- commands/configfile.c | 6 ++--- commands/crc.c | 2 +- commands/date.c | 2 +- commands/echo.c | 2 +- commands/efi/loadbios.c | 2 +- commands/gptsync.c | 2 +- commands/handler.c | 6 ++--- commands/hdparm.c | 2 +- commands/help.c | 4 +-- commands/hexdump.c | 2 +- commands/i386/cpuid.c | 2 +- commands/i386/pc/halt.c | 2 +- commands/i386/pc/play.c | 2 +- commands/i386/pc/pxecmd.c | 2 +- commands/keystatus.c | 2 +- commands/loadenv.c | 2 +- commands/ls.c | 2 +- commands/lspci.c | 2 +- commands/memrw.c | 12 ++++----- commands/minicmd.c | 8 +++--- commands/parttool.c | 2 +- commands/password.c | 2 +- commands/probe.c | 2 +- commands/read.c | 2 +- commands/search.c | 2 +- commands/sleep.c | 2 +- commands/test.c | 4 +-- commands/xnu_uuid.c | 2 +- efiemu/main.c | 6 ++--- font/font_cmd.c | 2 +- gettext/gettext.c | 2 +- kern/command.c | 2 +- kern/corecmd.c | 10 ++++---- lib/arg.c | 2 +- loader/efi/appleloader.c | 2 +- loader/i386/bsd.c | 6 ++--- loader/xnu.c | 2 +- mmap/mmap.c | 2 +- term/terminfo.c | 2 +- video/readers/jpeg.c | 2 +- video/readers/png.c | 2 +- video/readers/tga.c | 2 +- 47 files changed, 122 insertions(+), 68 deletions(-) diff --git a/ChangeLog b/ChangeLog index c10251569..82b2ab6ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,57 @@ +2009-12-26 Carles Pina i Estany + + * commands/help.c (grub_cmd_help): Print the command name before the + summary. + (GRUB_MOD_INIT): Remove command name from the summary. + * kern/command.c (GRUB_MOD_INIT): If summary is null assign an empty + strig as summary. + * lib/arg.c (find_long): Print the command name before the summary. + * commands/acpi.c (GRUB_MOD_INIT): Remove command name from the + summary. + * commands/blocklist.c (GRUB_MOD_INIT): Likewise. + * commands/cat.c (GRUB_MOD_INIT): Likewise. + * commands/cmp.c (GRUB_MOD_INIT): Likewise. + * commands/configfile.c (GRUB_MOD_INIT): Likewise. + * commands/crc.c (GRUB_MOD_INIT): Likewise. + * commands/date.c (GRUB_MOD_INIT): Likewise. + * commands/echo.c (GRUB_MOD_INIT): Likewise. + * commands/efi/loadbios.c (GRUB_MOD_INIT): Likewise. + * commands/gptsync.c (GRUB_MOD_INIT): Likewise. + * commands/handler.c (GRUB_MOD_INIT): Likewise. + * commands/hdparm.c (GRUB_MOD_INIT): Likewise. + * commands/hexdump.c (GRUB_MOD_INIT): Likewise. + * commands/i386/cpuid.c (GRUB_MOD_INIT): Likewise. + * commands/i386/pc/halt.c (GRUB_MOD_INIT): Likewise. + * commands/i386/pc/play.c (GRUB_MOD_INIT): Likewise. + * commands/i386/pc/pxecmd.c (GRUB_MOD_INIT): Likewise. + * commands/keystatus.c (GRUB_MOD_INIT): Likewise. + * commands/loadenv.c (GRUB_MOD_INIT): Likewise. + * commands/ls.c (GRUB_MOD_INIT): Likewise. + * commands/lspci.c (GRUB_MOD_INIT): Likewise. + * commands/memrw.c (GRUB_MOD_INIT): Likewise. + * commands/minicmd.c (GRUB_MOD_INIT): Likewise. + * commands/parttool.c (GRUB_MOD_INIT): Likewise. + * commands/password.c (GRUB_MOD_INIT): Likewise. + * commands/probe.c (GRUB_MOD_INIT): Likewise. + * commands/read.c (GRUB_MOD_INIT): Likewise. + * commands/search.c (GRUB_MOD_INIT): Likewise. + * commands/sleep.c (GRUB_MOD_INIT): Likewise. + * commands/test.c (GRUB_MOD_INIT): Likewise. + * commands/xnu_uuid.c (GRUB_MOD_INIT): Likewise. + * efiemu/main.c (GRUB_MOD_INIT): Likewise. + * font/font_cmd.c (GRUB_MOD_INIT): Likewise. + * gettext/gettext.c (GRUB_MOD_INIT): Likewise. + * kern/corecmd.c (GRUB_MOD_INIT): Likewise. + * lib/arg.c (GRUB_MOD_INIT): Likewise. + * loader/efi/appleloader.c (GRUB_MOD_INIT): Likewise. + * loader/i386/bsd.c (GRUB_MOD_INIT): Likewise. + * loader/xnu.c (GRUB_MOD_INIT): Likewise. + * mmap/mmap.c (GRUB_MOD_INIT): Likewise. + * term/terminfo.c (GRUB_MOD_INIT): Likewise. + * video/readers/jpeg.c (GRUB_MOD_INIT): Likewise. + * video/readers/png.c (GRUB_MOD_INIT): Likewise. + * video/readers/tga.c (GRUB_MOD_INIT): Likewise. + 2009-12-25 Vladimir Serbinenko Use search command for preliminar UUID search. diff --git a/commands/acpi.c b/commands/acpi.c index 6bf9f696b..ce4e2db36 100644 --- a/commands/acpi.c +++ b/commands/acpi.c @@ -759,7 +759,7 @@ GRUB_MOD_INIT(acpi) { cmd = grub_register_extcmd ("acpi", grub_cmd_acpi, GRUB_COMMAND_FLAG_BOTH, - "acpi [-1|-2] [--exclude=table1,table2|" + "[-1|-2] [--exclude=table1,table2|" "--load-only=table1,table2] filename1 " " [filename2] [...]", "Load host acpi tables and tables " diff --git a/commands/blocklist.c b/commands/blocklist.c index 51a91e2d7..3c9ef3a58 100644 --- a/commands/blocklist.c +++ b/commands/blocklist.c @@ -110,7 +110,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(blocklist) { cmd = grub_register_command ("blocklist", grub_cmd_blocklist, - "blocklist FILE", "Print a block list."); + "FILE", "Print a block list."); } GRUB_MOD_FINI(blocklist) diff --git a/commands/cat.c b/commands/cat.c index 1a2374360..9d0373b3a 100644 --- a/commands/cat.c +++ b/commands/cat.c @@ -78,7 +78,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(cat) { cmd = grub_register_command_p1 ("cat", grub_cmd_cat, - "cat FILE", "Show the contents of a file."); + "FILE", "Show the contents of a file."); } GRUB_MOD_FINI(cat) diff --git a/commands/cmp.c b/commands/cmp.c index 8a4b4158b..bdd8ff82d 100644 --- a/commands/cmp.c +++ b/commands/cmp.c @@ -109,7 +109,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(cmp) { cmd = grub_register_command ("cmp", grub_cmd_cmp, - "cmp FILE1 FILE2", "Compare two files."); + "FILE1 FILE2", "Compare two files."); } GRUB_MOD_FINI(cmp) diff --git a/commands/configfile.c b/commands/configfile.c index 852932216..d1fe9169e 100644 --- a/commands/configfile.c +++ b/commands/configfile.c @@ -53,15 +53,15 @@ GRUB_MOD_INIT(configfile) { cmd_configfile = grub_register_command ("configfile", grub_cmd_source, - "configfile FILE", "Load another config file."); + "FILE", "Load another config file."); cmd_source = grub_register_command ("source", grub_cmd_source, - "source FILE", + "FILE", "Load another config file without changing context." ); cmd_dot = grub_register_command (".", grub_cmd_source, - ". FILE", + "FILE", "Load another config file without changing context." ); } diff --git a/commands/crc.c b/commands/crc.c index 6b4b1d1b5..a6c17caf0 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -57,7 +57,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(crc) { cmd = grub_register_command ("crc", grub_cmd_crc, - "crc FILE", + "FILE", "Calculate the crc32 checksum of a file."); } diff --git a/commands/date.c b/commands/date.c index 1d609642e..7197b066e 100644 --- a/commands/date.c +++ b/commands/date.c @@ -135,7 +135,7 @@ GRUB_MOD_INIT(date) { cmd = grub_register_command ("date", grub_cmd_date, - "date [[year-]month-day] [hour:minute[:second]]", + "[[year-]month-day] [hour:minute[:second]]", "Command to display/set current datetime."); } diff --git a/commands/echo.c b/commands/echo.c index c9daf62f1..4d5a59df3 100644 --- a/commands/echo.c +++ b/commands/echo.c @@ -113,7 +113,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(echo) { cmd = grub_register_extcmd ("echo", grub_cmd_echo, GRUB_COMMAND_FLAG_BOTH, - "echo [-e|-n] STRING", "Display a line of text.", + "[-e|-n] STRING", "Display a line of text.", options); } diff --git a/commands/efi/loadbios.c b/commands/efi/loadbios.c index 877b5da17..de975c724 100644 --- a/commands/efi/loadbios.c +++ b/commands/efi/loadbios.c @@ -204,7 +204,7 @@ GRUB_MOD_INIT(loadbios) 0, "Fake bios."); cmd_loadbios = grub_register_command ("loadbios", grub_cmd_loadbios, - "loadbios BIOS_DUMP [INT10_DUMP]", + "BIOS_DUMP [INT10_DUMP]", "Load bios dump."); } diff --git a/commands/gptsync.c b/commands/gptsync.c index 8315faa53..b5fe0b8ed 100644 --- a/commands/gptsync.c +++ b/commands/gptsync.c @@ -240,7 +240,7 @@ GRUB_MOD_INIT(gptsync) { (void) mod; /* To stop warning. */ cmd = grub_register_command ("gptsync", grub_cmd_gptsync, - "gptsync DEVICE [PARTITION[+/-[TYPE]]] ...", + "DEVICE [PARTITION[+/-[TYPE]]] ...", "Fill hybrid MBR of GPT drive DEVICE. " "specified partitions will be a part " "of hybrid mbr. Up to 3 partitions are " diff --git a/commands/handler.c b/commands/handler.c index d65a703e4..09b8ff5d0 100644 --- a/commands/handler.c +++ b/commands/handler.c @@ -95,15 +95,15 @@ GRUB_MOD_INIT(handler) { cmd_handler = grub_register_command ("handler", grub_cmd_handler, - "handler [class [handler]]", + "[class [handler]]", "List or select a handler."); cmd_terminal_input = grub_register_command ("terminal_input", grub_cmd_handler, - "terminal_input [handler]", + "[handler]", "List or select an input terminal."); cmd_terminal_output = grub_register_command ("terminal_output", grub_cmd_handler, - "terminal_output [handler]", + "[handler]", "List or select an output terminal."); } diff --git a/commands/hdparm.c b/commands/hdparm.c index 458a447c7..fbcd7f6a8 100644 --- a/commands/hdparm.c +++ b/commands/hdparm.c @@ -410,7 +410,7 @@ GRUB_MOD_INIT(hdparm) { cmd = grub_register_extcmd ("hdparm", grub_cmd_hdparm, GRUB_COMMAND_FLAG_BOTH, - "hdparm [OPTIONS] DISK", + "[OPTIONS] DISK", "Get/set ATA disk parameters.", options); } diff --git a/commands/help.c b/commands/help.c index c24540cef..9f0ee7528 100644 --- a/commands/help.c +++ b/commands/help.c @@ -67,7 +67,7 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD) grub_arg_show_help ((grub_extcmd_t) cmd->data); else - grub_printf ("%s %s\n%s\b", _("Usage:"), _(cmd->summary), + grub_printf ("%s %s %s\n%s\b", _("Usage:"), cmd->name, _(cmd->summary), _(cmd->description)); } } @@ -96,7 +96,7 @@ GRUB_MOD_INIT(help) { cmd = grub_register_extcmd ("help", grub_cmd_help, GRUB_COMMAND_FLAG_CMDLINE, - N_("help [PATTERN ...]"), + N_("[PATTERN ...]"), N_("Show a help message."), 0); } diff --git a/commands/hexdump.c b/commands/hexdump.c index 727deecbf..771cde34d 100644 --- a/commands/hexdump.c +++ b/commands/hexdump.c @@ -121,7 +121,7 @@ GRUB_MOD_INIT (hexdump) { cmd = grub_register_extcmd ("hexdump", grub_cmd_hexdump, GRUB_COMMAND_FLAG_BOTH, - "hexdump [OPTIONS] FILE_OR_DEVICE", + "[OPTIONS] FILE_OR_DEVICE", "Dump the contents of a file or memory.", options); } diff --git a/commands/i386/cpuid.c b/commands/i386/cpuid.c index 8097e7372..b1752ca89 100644 --- a/commands/i386/cpuid.c +++ b/commands/i386/cpuid.c @@ -88,7 +88,7 @@ done: #endif cmd = grub_register_extcmd ("cpuid", grub_cmd_cpuid, GRUB_COMMAND_FLAG_BOTH, - "cpuid [-l]", "Check for CPU features.", options); + "[-l]", "Check for CPU features.", options); } GRUB_MOD_FINI(cpuid) diff --git a/commands/i386/pc/halt.c b/commands/i386/pc/halt.c index befd58804..c2e22882f 100644 --- a/commands/i386/pc/halt.c +++ b/commands/i386/pc/halt.c @@ -46,7 +46,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(halt) { cmd = grub_register_extcmd ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH, - "halt [-n]", + "[-n]", "Halt the system, if possible using APM.", options); } diff --git a/commands/i386/pc/play.c b/commands/i386/pc/play.c index 86c0674a4..96d9f6df5 100644 --- a/commands/i386/pc/play.c +++ b/commands/i386/pc/play.c @@ -208,7 +208,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(play) { cmd = grub_register_command ("play", grub_cmd_play, - N_("play FILE"), N_("Play a tune.")); + N_("FILE"), N_("Play a tune.")); } GRUB_MOD_FINI(play) diff --git a/commands/i386/pc/pxecmd.c b/commands/i386/pc/pxecmd.c index b2c99c4e2..1d4fb6a4d 100644 --- a/commands/i386/pc/pxecmd.c +++ b/commands/i386/pc/pxecmd.c @@ -41,7 +41,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(pxecmd) { cmd = grub_register_command ("pxe_unload", grub_cmd_pxe_unload, - "pxe_unload", + 0, "Unload PXE environment."); } diff --git a/commands/keystatus.c b/commands/keystatus.c index 0a4667645..4f82550be 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]", + "[--shift] [--ctrl] [--alt]", "Check key modifier status.", options); } diff --git a/commands/loadenv.c b/commands/loadenv.c index ac5064df9..6ee4d204a 100644 --- a/commands/loadenv.c +++ b/commands/loadenv.c @@ -396,7 +396,7 @@ GRUB_MOD_INIT(loadenv) cmd_save = grub_register_extcmd ("save_env", grub_cmd_save_env, GRUB_COMMAND_FLAG_BOTH, - "save_env [-f FILE] variable_name [...]", + "[-f FILE] variable_name [...]", "Save variables to environment block file.", options); } diff --git a/commands/ls.c b/commands/ls.c index 6eaa1d59e..4b1500398 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -260,7 +260,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(ls) { cmd = grub_register_extcmd ("ls", grub_cmd_ls, GRUB_COMMAND_FLAG_BOTH, - "ls [-l|-h|-a] [FILE]", + "[-l|-h|-a] [FILE]", "List devices and files.", options); } diff --git a/commands/lspci.c b/commands/lspci.c index fbade98c1..63e60abe0 100644 --- a/commands/lspci.c +++ b/commands/lspci.c @@ -218,7 +218,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(lspci) { cmd = grub_register_extcmd ("lspci", grub_cmd_lspci, GRUB_COMMAND_FLAG_BOTH, - "lspci [-i]", "List PCI devices.", options); + "[-i]", "List PCI devices.", options); } GRUB_MOD_FINI(lspci) diff --git a/commands/memrw.c b/commands/memrw.c index de3ac38e1..8e9c3db11 100644 --- a/commands/memrw.c +++ b/commands/memrw.c @@ -119,22 +119,22 @@ GRUB_MOD_INIT(memrw) { cmd_read_byte = grub_register_extcmd ("read_byte", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, - "read_byte ADDR", "Read byte from ADDR.", options); + "ADDR", "Read byte from ADDR.", options); cmd_read_word = grub_register_extcmd ("read_word", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, - "read_word ADDR", "Read word from ADDR.", options); + "ADDR", "Read word from ADDR.", options); cmd_read_dword = grub_register_extcmd ("read_dword", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, - "read_dword ADDR", "Read dword from ADDR.", options); + "ADDR", "Read dword from ADDR.", options); cmd_write_byte = grub_register_command ("write_byte", grub_cmd_write, - "write_byte ADDR VALUE [MASK]", "Write byte VALUE to ADDR."); + "ADDR VALUE [MASK]", "Write byte VALUE to ADDR."); cmd_write_word = grub_register_command ("write_word", grub_cmd_write, - "write_word ADDR VALUE [MASK]", "Write word VALUE to ADDR."); + "ADDR VALUE [MASK]", "Write word VALUE to ADDR."); cmd_write_dword = grub_register_command ("write_dword", grub_cmd_write, - "write_dword ADDR VALUE [MASK]", "Write dword VALUE to ADDR."); + "ADDR VALUE [MASK]", "Write dword VALUE to ADDR."); } GRUB_MOD_FINI(memrw) diff --git a/commands/minicmd.c b/commands/minicmd.c index 9e06fa5de..47b57e3ed 100644 --- a/commands/minicmd.c +++ b/commands/minicmd.c @@ -354,19 +354,19 @@ GRUB_MOD_INIT(minicmd) { cmd_cat = grub_register_command ("cat", grub_mini_cmd_cat, - "cat FILE", "Show the contents of a file."); + "FILE", "Show the contents of a file."); cmd_help = grub_register_command ("help", grub_mini_cmd_help, 0, "Show this message."); cmd_root = grub_register_command ("root", grub_mini_cmd_root, - "root [DEVICE]", "Set the root device."); + "[DEVICE]", "Set the root device."); cmd_dump = grub_register_command ("dump", grub_mini_cmd_dump, - "dump ADDR", "Dump memory."); + "ADDR", "Dump memory."); cmd_rmmod = grub_register_command ("rmmod", grub_mini_cmd_rmmod, - "rmmod MODULE", "Remove a module."); + "MODULE", "Remove a module."); cmd_lsmod = grub_register_command ("lsmod", grub_mini_cmd_lsmod, 0, "Show loaded modules."); diff --git a/commands/parttool.c b/commands/parttool.c index 473652cec..62fe5ad2b 100644 --- a/commands/parttool.c +++ b/commands/parttool.c @@ -322,7 +322,7 @@ GRUB_MOD_INIT(parttool) { mymod = mod; cmd = grub_register_command ("parttool", grub_cmd_parttool, - "parttool PARTITION COMMANDS", + "PARTITION COMMANDS", helpmsg); } diff --git a/commands/password.c b/commands/password.c index 710283b3d..d9b31f962 100644 --- a/commands/password.c +++ b/commands/password.c @@ -75,7 +75,7 @@ GRUB_MOD_INIT(password) { my_mod = mod; cmd = grub_register_command ("password", grub_cmd_password, - "password USER PASSWORD", + "USER PASSWORD", "Set user password (plaintext). " "Unrecommended and insecure."); } diff --git a/commands/probe.c b/commands/probe.c index fb196275f..7de1c1d34 100644 --- a/commands/probe.c +++ b/commands/probe.c @@ -150,7 +150,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT (probe) { cmd = grub_register_extcmd ("probe", grub_cmd_probe, GRUB_COMMAND_FLAG_BOTH, - "probe [DEVICE]", + "[DEVICE]", "Retrieve device info.", options); } diff --git a/commands/read.c b/commands/read.c index 270b7bd77..5f4451a72 100644 --- a/commands/read.c +++ b/commands/read.c @@ -79,7 +79,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(read) { cmd = grub_register_command ("read", grub_cmd_read, - "read [ENVVAR]", + "[ENVVAR]", "Set variable with user input."); } diff --git a/commands/search.c b/commands/search.c index 33102da89..01e83739b 100644 --- a/commands/search.c +++ b/commands/search.c @@ -165,7 +165,7 @@ GRUB_MOD_INIT(search_fs_label) { cmd = grub_register_command (COMMAND_NAME, grub_cmd_do_search, - COMMAND_NAME " NAME [VARIABLE]", + "NAME [VARIABLE]", "Search devices by " SEARCH_TARGET "." " If VARIABLE is specified, " "the first device found is set to a variable."); diff --git a/commands/sleep.c b/commands/sleep.c index 9207b60a7..eb9aeb510 100644 --- a/commands/sleep.c +++ b/commands/sleep.c @@ -105,7 +105,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(sleep) { cmd = grub_register_extcmd ("sleep", grub_cmd_sleep, GRUB_COMMAND_FLAG_BOTH, - "sleep NUMBER_OF_SECONDS", + "NUMBER_OF_SECONDS", "Wait for a specified number of seconds.", options); } diff --git a/commands/test.c b/commands/test.c index 84b4279ea..8d1e24859 100644 --- a/commands/test.c +++ b/commands/test.c @@ -420,9 +420,9 @@ static grub_command_t cmd_1, cmd_2; GRUB_MOD_INIT(test) { cmd_1 = grub_register_command ("[", grub_cmd_test, - "[ EXPRESSION ]", "Evaluate an expression."); + "EXPRESSION ]", "Evaluate an expression."); cmd_2 = grub_register_command ("test", grub_cmd_test, - "test EXPRESSION", "Evaluate an expression."); + "EXPRESSION", "Evaluate an expression."); } GRUB_MOD_FINI(test) diff --git a/commands/xnu_uuid.c b/commands/xnu_uuid.c index 85c0e9ce4..31e69ad13 100644 --- a/commands/xnu_uuid.c +++ b/commands/xnu_uuid.c @@ -377,7 +377,7 @@ static grub_command_t cmd; GRUB_MOD_INIT (xnu_uuid) { cmd = grub_register_command ("xnu_uuid", grub_cmd_xnu_uuid, - "xnu_uuid GRUBUUID [VARNAME]", + "GRUBUUID [VARNAME]", "Transform 64-bit UUID to format " "suitable for xnu."); } diff --git a/efiemu/main.c b/efiemu/main.c index f6d7b2e4c..3ec707ef3 100644 --- a/efiemu/main.c +++ b/efiemu/main.c @@ -328,14 +328,14 @@ GRUB_MOD_INIT(efiemu) { cmd_loadcore = grub_register_command ("efiemu_loadcore", grub_cmd_efiemu_load, - "efiemu_loadcore FILE", + "FILE", "Load and initialize EFI emulator"); cmd_prepare = grub_register_command ("efiemu_prepare", grub_cmd_efiemu_prepare, - "efiemu_prepare", + 0, "Finalize loading of EFI emulator"); cmd_unload = grub_register_command ("efiemu_unload", grub_cmd_efiemu_unload, - "efiemu_unload", + 0, "Unload EFI emulator"); } diff --git a/font/font_cmd.c b/font/font_cmd.c index 0402b8d77..98216ae44 100644 --- a/font/font_cmd.c +++ b/font/font_cmd.c @@ -62,7 +62,7 @@ GRUB_MOD_INIT(font_manager) cmd_loadfont = grub_register_command ("loadfont", loadfont_command, - "loadfont FILE...", + "FILE...", "Specify one or more font files to load."); cmd_lsfonts = grub_register_command ("lsfonts", lsfonts_command, diff --git a/gettext/gettext.c b/gettext/gettext.c index c48b5fd95..3472b2fb8 100644 --- a/gettext/gettext.c +++ b/gettext/gettext.c @@ -347,7 +347,7 @@ GRUB_MOD_INIT (gettext) grub_gettext_init_ext (lang); grub_register_command_p1 ("gettext", grub_cmd_translate, - "gettext STRING", + "STRING", "Translates the string with the current settings."); /* Reload .mo file information if lang changes. */ diff --git a/kern/command.c b/kern/command.c index 9b3c92b9b..477240d57 100644 --- a/kern/command.c +++ b/kern/command.c @@ -37,7 +37,7 @@ grub_register_command_prio (const char *name, cmd->name = name; cmd->func = func; - cmd->summary = (summary) ? summary : name; + cmd->summary = (summary) ? summary : ""; cmd->description = description; cmd->flags = GRUB_COMMAND_FLAG_BOTH; diff --git a/kern/corecmd.c b/kern/corecmd.c index 03944f2df..5ea052d38 100644 --- a/kern/corecmd.c +++ b/kern/corecmd.c @@ -190,13 +190,13 @@ void grub_register_core_commands (void) { grub_register_command ("set", grub_core_cmd_set, - "set [ENVVAR=VALUE]", "set an environment variable"); + "[ENVVAR=VALUE]", "set an environment variable"); grub_register_command ("unset", grub_core_cmd_unset, - "unset ENVVAR", "remove an environment variable"); + "ENVVAR", "remove an environment variable"); grub_register_command ("export", grub_core_cmd_export, - "export ENVVAR", "Export a variable."); + "ENVVAR", "Export a variable."); grub_register_command ("ls", grub_core_cmd_ls, - "ls [ARG]", "list devices or files"); + "[ARG]", "list devices or files"); grub_register_command ("insmod", grub_core_cmd_insmod, - "insmod MODULE", "insert a module"); + "MODULE", "insert a module"); } diff --git a/lib/arg.c b/lib/arg.c index bc1af1938..6a7bb8beb 100644 --- a/lib/arg.c +++ b/lib/arg.c @@ -107,7 +107,7 @@ find_long (const struct grub_arg_option *options, const char *s, int len) static void show_usage (grub_extcmd_t cmd) { - grub_printf ("%s %s\n", _("Usage:"), _(cmd->cmd->summary)); + grub_printf ("%s %s %s\n", _("Usage:"), cmd->cmd->name, _(cmd->cmd->summary)); } void diff --git a/loader/efi/appleloader.c b/loader/efi/appleloader.c index 94d501bcf..a7c2183ab 100644 --- a/loader/efi/appleloader.c +++ b/loader/efi/appleloader.c @@ -208,7 +208,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(appleloader) { cmd = grub_register_command ("appleloader", grub_cmd_appleloader, - "appleloader [OPTS]", "Boot legacy system."); + "[OPTS]", "Boot legacy system."); my_mod = mod; } diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 620c4bbf3..ead7ed1f8 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -1280,15 +1280,15 @@ GRUB_MOD_INIT (bsd) { cmd_freebsd = grub_register_extcmd ("kfreebsd", grub_cmd_freebsd, GRUB_COMMAND_FLAG_BOTH, - "kfreebsd FILE", "Load kernel of FreeBSD.", + "FILE", "Load kernel of FreeBSD.", freebsd_opts); cmd_openbsd = grub_register_extcmd ("kopenbsd", grub_cmd_openbsd, GRUB_COMMAND_FLAG_BOTH, - "kopenbsd FILE", "Load kernel of OpenBSD.", + "FILE", "Load kernel of OpenBSD.", openbsd_opts); cmd_netbsd = grub_register_extcmd ("knetbsd", grub_cmd_netbsd, GRUB_COMMAND_FLAG_BOTH, - "knetbsd FILE", "Load kernel of NetBSD.", + "FILE", "Load kernel of NetBSD.", netbsd_opts); cmd_freebsd_loadenv = grub_register_command ("kfreebsd_loadenv", grub_cmd_freebsd_loadenv, diff --git a/loader/xnu.c b/loader/xnu.c index 85d2882b6..1954d4b65 100644 --- a/loader/xnu.c +++ b/loader/xnu.c @@ -1412,7 +1412,7 @@ GRUB_MOD_INIT(xnu) cmd_kext = grub_register_command ("xnu_kext", grub_cmd_xnu_kext, 0, "Load XNU extension."); cmd_kextdir = grub_register_command ("xnu_kextdir", grub_cmd_xnu_kextdir, - "xnu_kextdir DIRECTORY [OSBundleRequired]", + "DIRECTORY [OSBundleRequired]", "Load XNU extension directory"); cmd_ramdisk = grub_register_command ("xnu_ramdisk", grub_cmd_xnu_ramdisk, 0, "Load XNU ramdisk. " diff --git a/mmap/mmap.c b/mmap/mmap.c index 7598cf501..3dc44c24e 100644 --- a/mmap/mmap.c +++ b/mmap/mmap.c @@ -414,7 +414,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(mmap) { cmd = grub_register_command ("badram", grub_cmd_badram, - "badram ADDR1,MASK1[,ADDR2,MASK2[,...]]", + "ADDR1,MASK1[,ADDR2,MASK2[,...]]", "declare memory regions as badram"); } diff --git a/term/terminfo.c b/term/terminfo.c index e5328d06b..fc22fe850 100644 --- a/term/terminfo.c +++ b/term/terminfo.c @@ -178,7 +178,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(terminfo) { cmd = grub_register_command ("terminfo", grub_cmd_terminfo, - "terminfo [TERM]", "Set terminfo type."); + "[TERM]", "Set terminfo type."); grub_terminfo_set_current ("vt100"); } diff --git a/video/readers/jpeg.c b/video/readers/jpeg.c index 460a52872..0c3d00bef 100644 --- a/video/readers/jpeg.c +++ b/video/readers/jpeg.c @@ -731,7 +731,7 @@ GRUB_MOD_INIT (video_reader_jpeg) grub_video_bitmap_reader_register (&jpeg_reader); #if defined(JPEG_DEBUG) grub_register_command ("jpegtest", grub_cmd_jpegtest, - GRUB_COMMAND_FLAG_BOTH, "jpegtest FILE", + GRUB_COMMAND_FLAG_BOTH, "FILE", "Tests loading of JPEG bitmap.", 0); #endif } diff --git a/video/readers/png.c b/video/readers/png.c index c2008aeb2..908672a2e 100644 --- a/video/readers/png.c +++ b/video/readers/png.c @@ -895,7 +895,7 @@ GRUB_MOD_INIT (video_reader_png) grub_video_bitmap_reader_register (&png_reader); #if defined(PNG_DEBUG) grub_register_command ("pngtest", grub_cmd_pngtest, - GRUB_COMMAND_FLAG_BOTH, "pngtest FILE", + GRUB_COMMAND_FLAG_BOTH, "FILE", "Tests loading of PNG bitmap.", 0); #endif } diff --git a/video/readers/tga.c b/video/readers/tga.c index 277458fa8..c5ff99cfe 100644 --- a/video/readers/tga.c +++ b/video/readers/tga.c @@ -481,7 +481,7 @@ GRUB_MOD_INIT(video_reader_tga) grub_video_bitmap_reader_register (&tga_reader); #if defined(TGA_DEBUG) grub_register_command ("tgatest", grub_cmd_tgatest, GRUB_COMMAND_FLAG_BOTH, - "tgatest FILE", "Tests loading of TGA bitmap.", 0); + "FILE", "Tests loading of TGA bitmap.", 0); #endif } From 864ba2bbca2b52675e24f77ec026222ec19887e5 Mon Sep 17 00:00:00 2001 From: carles Date: Sat, 26 Dec 2009 11:01:33 +0100 Subject: [PATCH 099/208] 2009-12-27 Carles Pina i Estany * efiemu/main.c (GRUB_MOD_INIT): Fix capitalizations and/or full stops. * kern/corecmd.c (grub_register_core_commands): Likewise. * loader/efi/chainloader.c (GRUB_MOD_INIT): Likewise. * loader/i386/bsd.c (GRUB_MOD_INIT): Likewise. * loader/i386/efi/linux.c (GRUB_MOD_INIT): Likewise. * loader/i386/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. * loader/i386/linux.c (GRUB_MOD_INIT): Likewise. * loader/i386/pc/chainloader.c (GRUB_MOD_INIT): Likewise. * loader/i386/pc/linux.c (GRUB_MOD_INIT): Likewise. * loader/multiboot_loader.c (GRUB_MOD_INIT): Likewise. * loader/powerpc/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. * loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. * loader/xnu.c (GRUB_MOD_INIT): Likewise. * mmap/mmap.c (GRUB_MOD_INIT): Likewise. * normal/handler.c (insert_handler): Likewise. * normal/main.c (GRUB_MOD_INIT): Likewise. * term/gfxterm.c (GRUB_MOD_INIT): Likewise. --- ChangeLog | 21 +++++++++++++++++++++ efiemu/main.c | 6 +++--- kern/corecmd.c | 8 ++++---- loader/efi/chainloader.c | 2 +- loader/i386/bsd.c | 6 +++--- loader/i386/efi/linux.c | 4 ++-- loader/i386/ieee1275/linux.c | 4 ++-- loader/i386/linux.c | 4 ++-- loader/i386/pc/chainloader.c | 2 +- loader/i386/pc/linux.c | 4 ++-- loader/multiboot_loader.c | 4 ++-- loader/powerpc/ieee1275/linux.c | 4 ++-- loader/sparc64/ieee1275/linux.c | 4 ++-- loader/xnu.c | 10 +++++----- mmap/mmap.c | 2 +- normal/handler.c | 2 +- normal/main.c | 2 +- term/gfxterm.c | 2 +- 18 files changed, 56 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 82b2ab6ac..f309d3cb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2009-12-27 Carles Pina i Estany + + * efiemu/main.c (GRUB_MOD_INIT): Fix capitalizations and/or full + stops. + * kern/corecmd.c (grub_register_core_commands): Likewise. + * loader/efi/chainloader.c (GRUB_MOD_INIT): Likewise. + * loader/i386/bsd.c (GRUB_MOD_INIT): Likewise. + * loader/i386/efi/linux.c (GRUB_MOD_INIT): Likewise. + * loader/i386/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/i386/linux.c (GRUB_MOD_INIT): Likewise. + * loader/i386/pc/chainloader.c (GRUB_MOD_INIT): Likewise. + * loader/i386/pc/linux.c (GRUB_MOD_INIT): Likewise. + * loader/multiboot_loader.c (GRUB_MOD_INIT): Likewise. + * loader/powerpc/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/xnu.c (GRUB_MOD_INIT): Likewise. + * mmap/mmap.c (GRUB_MOD_INIT): Likewise. + * normal/handler.c (insert_handler): Likewise. + * normal/main.c (GRUB_MOD_INIT): Likewise. + * term/gfxterm.c (GRUB_MOD_INIT): Likewise. + 2009-12-26 Carles Pina i Estany * commands/help.c (grub_cmd_help): Print the command name before the diff --git a/efiemu/main.c b/efiemu/main.c index 3ec707ef3..a3cfdb5b5 100644 --- a/efiemu/main.c +++ b/efiemu/main.c @@ -329,14 +329,14 @@ GRUB_MOD_INIT(efiemu) cmd_loadcore = grub_register_command ("efiemu_loadcore", grub_cmd_efiemu_load, "FILE", - "Load and initialize EFI emulator"); + "Load and initialize EFI emulator."); cmd_prepare = grub_register_command ("efiemu_prepare", grub_cmd_efiemu_prepare, 0, - "Finalize loading of EFI emulator"); + "Finalize loading of EFI emulator."); cmd_unload = grub_register_command ("efiemu_unload", grub_cmd_efiemu_unload, 0, - "Unload EFI emulator"); + "Unload EFI emulator."); } GRUB_MOD_FINI(efiemu) diff --git a/kern/corecmd.c b/kern/corecmd.c index 5ea052d38..3e508cd2c 100644 --- a/kern/corecmd.c +++ b/kern/corecmd.c @@ -190,13 +190,13 @@ void grub_register_core_commands (void) { grub_register_command ("set", grub_core_cmd_set, - "[ENVVAR=VALUE]", "set an environment variable"); + "[ENVVAR=VALUE]", "Set an environment variable."); grub_register_command ("unset", grub_core_cmd_unset, - "ENVVAR", "remove an environment variable"); + "ENVVAR", "Remove an environment variable."); grub_register_command ("export", grub_core_cmd_export, "ENVVAR", "Export a variable."); grub_register_command ("ls", grub_core_cmd_ls, - "[ARG]", "list devices or files"); + "[ARG]", "List devices or files."); grub_register_command ("insmod", grub_core_cmd_insmod, - "MODULE", "insert a module"); + "MODULE", "Insert a module."); } diff --git a/loader/efi/chainloader.c b/loader/efi/chainloader.c index 9c833e9b9..559c3f52a 100644 --- a/loader/efi/chainloader.c +++ b/loader/efi/chainloader.c @@ -336,7 +336,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(chainloader) { cmd = grub_register_command ("chainloader", grub_cmd_chainloader, - 0, "load another boot loader"); + 0, "Load another boot loader."); my_mod = mod; } diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index ead7ed1f8..ca60b0be9 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -1292,13 +1292,13 @@ GRUB_MOD_INIT (bsd) netbsd_opts); cmd_freebsd_loadenv = grub_register_command ("kfreebsd_loadenv", grub_cmd_freebsd_loadenv, - 0, "load FreeBSD env"); + 0, "Load FreeBSD env."); cmd_freebsd_module = grub_register_command ("kfreebsd_module", grub_cmd_freebsd_module, - 0, "load FreeBSD kernel module"); + 0, "Load FreeBSD kernel module."); cmd_freebsd_module_elf = grub_register_command ("kfreebsd_module_elf", grub_cmd_freebsd_module_elf, - 0, "load FreeBSD kernel module (ELF)"); + 0, "Load FreeBSD kernel module (ELF)."); my_mod = mod; } diff --git a/loader/i386/efi/linux.c b/loader/i386/efi/linux.c index d0b218b08..0b82ff807 100644 --- a/loader/i386/efi/linux.c +++ b/loader/i386/efi/linux.c @@ -989,9 +989,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "load linux"); + 0, "Load linux."); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "load initrd"); + 0, "Load initrd."); my_mod = mod; } diff --git a/loader/i386/ieee1275/linux.c b/loader/i386/ieee1275/linux.c index 97f9a8216..0a76a67b0 100644 --- a/loader/i386/ieee1275/linux.c +++ b/loader/i386/ieee1275/linux.c @@ -276,9 +276,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "load linux"); + 0, "Load linux."); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "load initrd"); + 0, "Load initrd."); my_mod = mod; } diff --git a/loader/i386/linux.c b/loader/i386/linux.c index 805ec7962..9ea456b0d 100644 --- a/loader/i386/linux.c +++ b/loader/i386/linux.c @@ -982,9 +982,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "load linux"); + 0, "Load linux."); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "load initrd"); + 0, "Load initrd."); my_mod = mod; } diff --git a/loader/i386/pc/chainloader.c b/loader/i386/pc/chainloader.c index 2e3b24fee..27dda4f4f 100644 --- a/loader/i386/pc/chainloader.c +++ b/loader/i386/pc/chainloader.c @@ -146,7 +146,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(chainloader) { cmd = grub_register_command ("chainloader", grub_cmd_chainloader, - 0, "load another boot loader"); + 0, "Load another boot loader."); my_mod = mod; } diff --git a/loader/i386/pc/linux.c b/loader/i386/pc/linux.c index 9e2543e62..0e7336214 100644 --- a/loader/i386/pc/linux.c +++ b/loader/i386/pc/linux.c @@ -383,10 +383,10 @@ GRUB_MOD_INIT(linux16) { cmd_linux = grub_register_command ("linux16", grub_cmd_linux, - 0, "load linux"); + 0, "Load linux."); cmd_initrd = grub_register_command ("initrd16", grub_cmd_initrd, - 0, "load initrd"); + 0, "Load initrd."); my_mod = mod; } diff --git a/loader/multiboot_loader.c b/loader/multiboot_loader.c index 37b33302a..24c0c5eac 100644 --- a/loader/multiboot_loader.c +++ b/loader/multiboot_loader.c @@ -197,10 +197,10 @@ GRUB_MOD_INIT(multiboot) { cmd_multiboot = grub_register_command ("multiboot", grub_cmd_multiboot_loader, - 0, "load a multiboot kernel"); + 0, "Load a multiboot kernel."); cmd_module = grub_register_command ("module", grub_cmd_module_loader, - 0, "load a multiboot module"); + 0, "Load a multiboot module."); my_mod = mod; } diff --git a/loader/powerpc/ieee1275/linux.c b/loader/powerpc/ieee1275/linux.c index 9d755450e..f03c10ad8 100644 --- a/loader/powerpc/ieee1275/linux.c +++ b/loader/powerpc/ieee1275/linux.c @@ -349,9 +349,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "load a linux kernel"); + 0, "Load a linux kernel."); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "load an initrd"); + 0, "Load an initrd."); my_mod = mod; } diff --git a/loader/sparc64/ieee1275/linux.c b/loader/sparc64/ieee1275/linux.c index 820110847..92836e7eb 100644 --- a/loader/sparc64/ieee1275/linux.c +++ b/loader/sparc64/ieee1275/linux.c @@ -516,9 +516,9 @@ GRUB_MOD_INIT(linux) fetch_translations (); cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "load a linux kernel"); + 0, "Load a linux kernel."); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "load an initrd"); + 0, "Load an initrd".); my_mod = mod; } diff --git a/loader/xnu.c b/loader/xnu.c index 1954d4b65..114f3f213 100644 --- a/loader/xnu.c +++ b/loader/xnu.c @@ -1404,21 +1404,21 @@ static grub_command_t cmd_kextdir, cmd_ramdisk, cmd_resume, cmd_splash; GRUB_MOD_INIT(xnu) { cmd_kernel = grub_register_command ("xnu_kernel", grub_cmd_xnu_kernel, 0, - "load a xnu kernel"); + "Load a xnu kernel."); cmd_kernel64 = grub_register_command ("xnu_kernel64", grub_cmd_xnu_kernel64, - 0, "load a 64-bit xnu kernel"); + 0, "Load a 64-bit xnu kernel."); cmd_mkext = grub_register_command ("xnu_mkext", grub_cmd_xnu_mkext, 0, "Load XNU extension package."); cmd_kext = grub_register_command ("xnu_kext", grub_cmd_xnu_kext, 0, "Load XNU extension."); cmd_kextdir = grub_register_command ("xnu_kextdir", grub_cmd_xnu_kextdir, "DIRECTORY [OSBundleRequired]", - "Load XNU extension directory"); + "Load XNU extension directory."); cmd_ramdisk = grub_register_command ("xnu_ramdisk", grub_cmd_xnu_ramdisk, 0, "Load XNU ramdisk. " - "It will be seen as md0"); + "It will be seen as md0."); cmd_splash = grub_register_command ("xnu_splash", grub_cmd_xnu_splash, 0, - "Load a splash image for XNU"); + "Load a splash image for XNU."); #ifndef GRUB_UTIL cmd_resume = grub_register_command ("xnu_resume", grub_cmd_xnu_resume, diff --git a/mmap/mmap.c b/mmap/mmap.c index 3dc44c24e..874a238b2 100644 --- a/mmap/mmap.c +++ b/mmap/mmap.c @@ -415,7 +415,7 @@ GRUB_MOD_INIT(mmap) { cmd = grub_register_command ("badram", grub_cmd_badram, "ADDR1,MASK1[,ADDR2,MASK2[,...]]", - "declare memory regions as badram"); + "Declare memory regions as badram."); } GRUB_MOD_FINI(mmap) diff --git a/normal/handler.c b/normal/handler.c index eb19f912f..b44dc7a68 100644 --- a/normal/handler.c +++ b/normal/handler.c @@ -117,7 +117,7 @@ insert_handler (char *name, char *module) data = 0; item->cmd = grub_register_command (item->name, grub_handler_cmd, 0, - "Set active handler"); + "Set active handler."); if (! item->cmd) { grub_free (data); diff --git a/normal/main.c b/normal/main.c index e8dfb182b..17e21566d 100644 --- a/normal/main.c +++ b/normal/main.c @@ -598,7 +598,7 @@ GRUB_MOD_INIT(normal) /* Register a command "normal" for the rescue mode. */ grub_register_command_prio ("normal", grub_cmd_normal, - 0, "Enter normal mode", 0); + 0, "Enter normal mode.", 0); /* Reload terminal colors when these variables are written to. */ grub_register_variable_hook ("color_normal", NULL, grub_env_write_color_normal); diff --git a/term/gfxterm.c b/term/gfxterm.c index 3e8a081fc..fa19a5d85 100644 --- a/term/gfxterm.c +++ b/term/gfxterm.c @@ -956,7 +956,7 @@ GRUB_MOD_INIT(term_gfxterm) grub_term_register_output ("gfxterm", &grub_video_term); cmd = grub_register_command ("background_image", grub_gfxterm_background_image_cmd, - 0, "Load background image for active terminal"); + 0, "Load background image for active terminal."); } GRUB_MOD_FINI(term_gfxterm) From c541b01a66f9f46dbed815154f4dcdf25781db3d Mon Sep 17 00:00:00 2001 From: carles Date: Sat, 26 Dec 2009 12:06:35 +0100 Subject: [PATCH 100/208] 2009-12-27 Carles Pina i Estany * video/readers/jpeg.c (cmd): Declare. (grub_cmd_jpegtest): Use `grub_command_t' type. (GRUB_MOD_INIT): Fix arguments passed to `grub_register_command'. Assign to `cmd'. (GRUB_MOD_FINI): Use `cmd' to unregister. * video/readers/png.c (cmd): Declare. (grub_cmd_pngtest): Use `grub_command_t' type. (GRUB_MOD_INIT): Fix arguments passed to `grub_register_command'. Assign to `cmd'. (GRUB_MOD_FINI): Use `cmd' to unregister. * video/readers/tga.c (cmd): Declare. (grub_cmd_tgatest): Use `grub_command_t' type. (GRUB_MOD_INIT): Fix arguments passed to `grub_register_command'. Assign to `cmd'. (GRUB_MOD_FINI): Use `cmd' to unregister. --- ChangeLog | 18 ++++++++++++++++++ video/readers/jpeg.c | 18 +++++++++++------- video/readers/png.c | 14 +++++++++----- video/readers/tga.c | 9 +++++---- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index f309d3cb0..8f44663a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2009-12-27 Carles Pina i Estany + + * video/readers/jpeg.c (cmd): Declare. + (grub_cmd_jpegtest): Use `grub_command_t' type. + (GRUB_MOD_INIT): Fix arguments passed to `grub_register_command'. + Assign to `cmd'. + (GRUB_MOD_FINI): Use `cmd' to unregister. + * video/readers/png.c (cmd): Declare. + (grub_cmd_pngtest): Use `grub_command_t' type. + (GRUB_MOD_INIT): Fix arguments passed to `grub_register_command'. + Assign to `cmd'. + (GRUB_MOD_FINI): Use `cmd' to unregister. + * video/readers/tga.c (cmd): Declare. + (grub_cmd_tgatest): Use `grub_command_t' type. + (GRUB_MOD_INIT): Fix arguments passed to `grub_register_command'. + Assign to `cmd'. + (GRUB_MOD_FINI): Use `cmd' to unregister. + 2009-12-27 Carles Pina i Estany * efiemu/main.c (GRUB_MOD_INIT): Fix capitalizations and/or full diff --git a/video/readers/jpeg.c b/video/readers/jpeg.c index 0c3d00bef..e7b69a208 100644 --- a/video/readers/jpeg.c +++ b/video/readers/jpeg.c @@ -54,6 +54,10 @@ static const grub_uint8_t jpeg_zigzag_order[64] = { 53, 60, 61, 54, 47, 55, 62, 63 }; +#ifdef JPEG_DEBUG +static grub_command_t cmd; +#endif + typedef int jpeg_data_unit_t[64]; struct grub_jpeg_data @@ -695,8 +699,8 @@ grub_video_reader_jpeg (struct grub_video_bitmap **bitmap, #if defined(JPEG_DEBUG) static grub_err_t -grub_cmd_jpegtest (struct grub_arg_list *state __attribute__ ((unused)), - int argc, char **args) +grub_cmd_jpegtest (grub_command_t cmd __attribute__ ((unused)), + int argc, char **args) { struct grub_video_bitmap *bitmap = 0; @@ -730,16 +734,16 @@ GRUB_MOD_INIT (video_reader_jpeg) grub_video_bitmap_reader_register (&jpg_reader); grub_video_bitmap_reader_register (&jpeg_reader); #if defined(JPEG_DEBUG) - grub_register_command ("jpegtest", grub_cmd_jpegtest, - GRUB_COMMAND_FLAG_BOTH, "FILE", - "Tests loading of JPEG bitmap.", 0); + cmd = grub_register_command ("jpegtest", grub_cmd_jpegtest, + "FILE", + "Tests loading of JPEG bitmap."); #endif } -GRUB_MOD_FINI (video_reader_jpeg) +GRUB_MOD_FINI (grub_cmd_jpegtest) { #if defined(JPEG_DEBUG) - grub_unregister_command ("jpegtest"); + grub_unregister_command (cmd); #endif grub_video_bitmap_reader_unregister (&jpeg_reader); grub_video_bitmap_reader_unregister (&jpg_reader); diff --git a/video/readers/png.c b/video/readers/png.c index 908672a2e..4e16bf27e 100644 --- a/video/readers/png.c +++ b/video/readers/png.c @@ -73,6 +73,10 @@ #define DEFLATE_HUFF_LEN 16 +#ifdef PNG_DEBUG +static grub_command_t cmd; +#endif + struct huff_table { int *values, *maxval, *offset; @@ -866,7 +870,7 @@ grub_video_reader_png (struct grub_video_bitmap **bitmap, #if defined(PNG_DEBUG) static grub_err_t -grub_cmd_pngtest (struct grub_arg_list *state __attribute__ ((unused)), +grub_cmd_pngtest (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) { struct grub_video_bitmap *bitmap = 0; @@ -894,16 +898,16 @@ GRUB_MOD_INIT (video_reader_png) { grub_video_bitmap_reader_register (&png_reader); #if defined(PNG_DEBUG) - grub_register_command ("pngtest", grub_cmd_pngtest, - GRUB_COMMAND_FLAG_BOTH, "FILE", - "Tests loading of PNG bitmap.", 0); + cmd = grub_register_command ("pngtest", grub_cmd_pngtest, + "FILE", + "Tests loading of PNG bitmap."); #endif } GRUB_MOD_FINI (video_reader_png) { #if defined(PNG_DEBUG) - grub_unregister_command ("pngtest"); + grub_unregister_command (cmd); #endif grub_video_bitmap_reader_unregister (&png_reader); } diff --git a/video/readers/tga.c b/video/readers/tga.c index c5ff99cfe..d720141e1 100644 --- a/video/readers/tga.c +++ b/video/readers/tga.c @@ -29,6 +29,7 @@ #if defined(TGA_DEBUG) #define dump_int_field(x) grub_printf( #x " = %d (0x%04x)\n", x, x); +static grub_command_t cmd; #endif enum @@ -452,7 +453,7 @@ grub_video_reader_tga (struct grub_video_bitmap **bitmap, #if defined(TGA_DEBUG) static grub_err_t -grub_cmd_tgatest (struct grub_arg_list *state __attribute__ ((unused)), +grub_cmd_tgatest (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) { struct grub_video_bitmap *bitmap = 0; @@ -480,15 +481,15 @@ GRUB_MOD_INIT(video_reader_tga) { grub_video_bitmap_reader_register (&tga_reader); #if defined(TGA_DEBUG) - grub_register_command ("tgatest", grub_cmd_tgatest, GRUB_COMMAND_FLAG_BOTH, - "FILE", "Tests loading of TGA bitmap.", 0); + cmd = grub_register_command ("tgatest", grub_cmd_tgatest, + "FILE", "Tests loading of TGA bitmap."); #endif } GRUB_MOD_FINI(video_reader_tga) { #if defined(TGA_DEBUG) - grub_unregister_command ("tgatest"); + grub_unregister_command (cmd); #endif grub_video_bitmap_reader_unregister (&tga_reader); } From 82f3e4125fdcd611689e4e3bd51e5967524bc373 Mon Sep 17 00:00:00 2001 From: carles Date: Sat, 26 Dec 2009 12:08:22 +0100 Subject: [PATCH 101/208] Fix two dates and one typo in ChangeLog. --- ChangeLog | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f44663a0..08f7bfb3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2009-12-27 Carles Pina i Estany +2009-12-26 Carles Pina i Estany * video/readers/jpeg.c (cmd): Declare. (grub_cmd_jpegtest): Use `grub_command_t' type. @@ -16,7 +16,7 @@ Assign to `cmd'. (GRUB_MOD_FINI): Use `cmd' to unregister. -2009-12-27 Carles Pina i Estany +2009-12-26 Carles Pina i Estany * efiemu/main.c (GRUB_MOD_INIT): Fix capitalizations and/or full stops. @@ -43,7 +43,7 @@ summary. (GRUB_MOD_INIT): Remove command name from the summary. * kern/command.c (GRUB_MOD_INIT): If summary is null assign an empty - strig as summary. + string as summary. * lib/arg.c (find_long): Print the command name before the summary. * commands/acpi.c (GRUB_MOD_INIT): Remove command name from the summary. From 27a8ee52b4a624071d70c40ff78d0f575388d289 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 26 Dec 2009 16:39:16 +0100 Subject: [PATCH 102/208] Remove menu init hooks. They are useless --- genmk.rb | 2 +- include/grub/menu_viewer.h | 10 +++-- normal/main.c | 7 ---- normal/menu.c | 48 ++++++++++++------------ normal/menu_text.c | 76 ++++++++++++++++++-------------------- 5 files changed, 67 insertions(+), 76 deletions(-) diff --git a/genmk.rb b/genmk.rb index 43eaef150..6cb7b5a89 100644 --- a/genmk.rb +++ b/genmk.rb @@ -242,7 +242,7 @@ VIDEOFILES += #{video} $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \ | sh $(srcdir)/genhandlerlist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1) -#{terminal}: #{src} $(#{src}_DEPENDENCIES) genterminlist.sh +#{terminal}: #{src} $(#{src}_DEPENDENCIES) genterminallist.sh set -e; \ $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -E $< \ | sh $(srcdir)/genterminallist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1) diff --git a/include/grub/menu_viewer.h b/include/grub/menu_viewer.h index 3821219a3..c6513c4e8 100644 --- a/include/grub/menu_viewer.h +++ b/include/grub/menu_viewer.h @@ -24,6 +24,7 @@ #include #include #include +#include struct grub_menu_viewer { @@ -37,8 +38,11 @@ struct grub_menu_viewer void grub_menu_register_viewer (struct grub_menu_viewer *viewer); -grub_err_t grub_menu_register_viewer_init (void (*callback) (int entry, - grub_menu_t menu, - int nested)); +grub_err_t +grub_menu_try_text (struct grub_term_output *term, + int entry, grub_menu_t menu, int nested); + +extern grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu, + int nested); #endif /* GRUB_MENU_VIEWER_HEADER */ diff --git a/normal/main.c b/normal/main.c index 14e8971b0..6d7a558f3 100644 --- a/normal/main.c +++ b/normal/main.c @@ -636,13 +636,6 @@ GRUB_MOD_INIT(normal) grub_set_history (GRUB_DEFAULT_HISTORY_SIZE); - grub_menu_register_viewer_init (grub_menu_text_register_instances); - if (grub_errno) - { - grub_print_error (); - grub_errno = GRUB_ERR_NONE; - } - grub_register_variable_hook ("pager", 0, grub_env_write_pager); /* Register a command "normal" for the rescue mode. */ diff --git a/normal/menu.c b/normal/menu.c index 62f33b61b..24c1588d8 100644 --- a/normal/menu.c +++ b/normal/menu.c @@ -28,18 +28,14 @@ #include #include #include +#include /* Time to delay after displaying an error message about a default/fallback entry failing to boot. */ #define DEFAULT_ENTRY_ERROR_DELAY_MS 2500 -struct menu_run_callback -{ - struct menu_run_callback *next; - void (*hook) (int entry, grub_menu_t menu, int nested); -}; - -struct menu_run_callback *callbacks = NULL; +grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu, + int nested) = NULL; /* Wait until the user pushes any key so that the user can see what happened. */ @@ -237,9 +233,27 @@ menu_fini (void) static void menu_init (int entry, grub_menu_t menu, int nested) { - struct menu_run_callback *cb; - for (cb = callbacks; cb; cb = cb->next) - cb->hook (entry, menu, nested); + struct grub_term_output *term; + + FOR_ACTIVE_TERM_OUTPUTS(term) + { + grub_err_t err; + + if (grub_gfxmenu_try_hook && grub_strcmp (term->name, "gfxterm") == 0) + { + err = grub_gfxmenu_try_hook (entry, menu, nested); + if(!err) + continue; + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + } + + err = grub_menu_try_text (term, entry, menu, nested); + if(!err) + continue; + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + } } static void @@ -257,20 +271,6 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer) viewers = viewer; } -grub_err_t -grub_menu_register_viewer_init (void (*callback) (int entry, grub_menu_t menu, - int nested)) -{ - struct menu_run_callback *cb; - cb = grub_malloc (sizeof (*cb)); - if (!cb) - return grub_errno; - cb->hook = callback; - cb->next = callbacks; - callbacks = cb; - return GRUB_ERR_NONE; -} - /* Get the entry number from the variable NAME. */ static int get_entry_number (const char *name) diff --git a/normal/menu_text.c b/normal/menu_text.c index 791f831a0..91000c1d4 100644 --- a/normal/menu_text.c +++ b/normal/menu_text.c @@ -442,52 +442,46 @@ menu_text_clear_timeout (void *dataptr) grub_term_refresh (data->term); } -void -grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested) +grub_err_t +grub_menu_try_text (struct grub_term_output *term, + int entry, grub_menu_t menu, int nested) { struct menu_viewer_data *data; struct grub_menu_viewer *instance; - struct grub_term_output *term; - FOR_ACTIVE_TERM_OUTPUTS(term) - { - instance = grub_zalloc (sizeof (*instance)); - if (!instance) - { - grub_print_error (); - grub_errno = GRUB_ERR_NONE; - continue; - } - data = grub_zalloc (sizeof (*data)); - if (!data) - { - grub_free (instance); - grub_print_error (); - grub_errno = GRUB_ERR_NONE; - continue; - } + instance = grub_zalloc (sizeof (*instance)); + if (!instance) + return grub_errno; - data->term = term; - instance->data = data; - instance->set_chosen_entry = menu_text_set_chosen_entry; - instance->print_timeout = menu_text_print_timeout; - instance->clear_timeout = menu_text_clear_timeout; - instance->fini = menu_text_fini; + data = grub_zalloc (sizeof (*data)); + if (!data) + { + grub_free (instance); + return grub_errno; + } - data->menu = menu; - - data->offset = entry; - data->first = 0; - if (data->offset > grub_term_num_entries (data->term) - 1) - { - data->first = data->offset - (grub_term_num_entries (data->term) - 1); - data->offset = grub_term_num_entries (data->term) - 1; - } + data->term = term; + instance->data = data; + instance->set_chosen_entry = menu_text_set_chosen_entry; + instance->print_timeout = menu_text_print_timeout; + instance->clear_timeout = menu_text_clear_timeout; + instance->fini = menu_text_fini; - grub_term_setcursor (data->term, 0); - grub_menu_init_page (nested, 0, data->term); - print_entries (menu, data->first, data->offset, data->term); - grub_term_refresh (data->term); - grub_menu_register_viewer (instance); - } + data->menu = menu; + + data->offset = entry; + data->first = 0; + if (data->offset > grub_term_num_entries (data->term) - 1) + { + data->first = data->offset - (grub_term_num_entries (data->term) - 1); + data->offset = grub_term_num_entries (data->term) - 1; + } + + grub_term_setcursor (data->term, 0); + grub_menu_init_page (nested, 0, data->term); + print_entries (menu, data->first, data->offset, data->term); + grub_term_refresh (data->term); + grub_menu_register_viewer (instance); + + return GRUB_ERR_NONE; } From 731ffd8773c9e6c09b675289cb932f1a286e9ce4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 26 Dec 2009 22:16:14 +0100 Subject: [PATCH 103/208] Fix EFI compilation --- loader/i386/efi/linux.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/loader/i386/efi/linux.c b/loader/i386/efi/linux.c index 8cd4d23f2..a869ca71a 100644 --- a/loader/i386/efi/linux.c +++ b/loader/i386/efi/linux.c @@ -693,13 +693,41 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), params->ext_mem = ((32 * 0x100000) >> 10); params->alt_mem = ((32 * 0x100000) >> 10); - params->video_cursor_x = grub_getxy () >> 8; - params->video_cursor_y = grub_getxy () & 0xff; + { + grub_term_output_t term; + int found = 0; + FOR_ACTIVE_TERM_OUTPUTS(term) + if (grub_strcmp (term->name, "vga_text") == 0) + { + grub_uint16_t pos = grub_term_getxy (term); + params->video_cursor_x = pos >> 8; + params->video_cursor_y = pos & 0xff; + params->video_width = grub_term_width (term); + params->video_height = grub_term_height (term); + found = 1; + } + if (!found) + FOR_ACTIVE_TERM_OUTPUTS(term) + if (grub_strcmp (term->name, "console") == 0) + { + grub_uint16_t pos = grub_term_getxy (term); + params->video_cursor_x = pos >> 8; + params->video_cursor_y = pos & 0xff; + params->video_width = grub_term_width (term); + params->video_height = grub_term_height (term); + found = 1; + } + if (!found) + { + params->video_cursor_x = 0; + params->video_cursor_y = 0; + params->video_width = 80; + params->video_height = 25; + } + } params->video_page = 0; /* ??? */ params->video_mode = grub_efi_system_table->con_out->mode->mode; - params->video_width = (grub_getwh () >> 8); params->video_ega_bx = 0; - params->video_height = (grub_getwh () & 0xff); params->have_vga = 0; params->font_size = 16; /* XXX */ From 714af9b9e4d5a0ff99325d58b414438e670c42d2 Mon Sep 17 00:00:00 2001 From: carles Date: Sun, 27 Dec 2009 00:36:59 +0100 Subject: [PATCH 104/208] 2009-12-27 Carles Pina i Estany * loader/i386/efi/linux.c (GRUB_MOD_INIT): Improve command summary. * loader/i386/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. * loader/i386/linux.c (GRUB_MOD_INIT): Likewise. * loader/i386/pc/linux.c (GRUB_MOD_INIT): Likewise. * loader/powerpc/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. * loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. * loader/xnu.c (GRUB_MOD_INIT): Likewise. --- ChangeLog | 10 ++++++++++ loader/i386/efi/linux.c | 2 +- loader/i386/ieee1275/linux.c | 2 +- loader/i386/linux.c | 2 +- loader/i386/pc/linux.c | 2 +- loader/powerpc/ieee1275/linux.c | 4 ++-- loader/sparc64/ieee1275/linux.c | 4 ++-- loader/xnu.c | 4 ++-- 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08f7bfb3c..07dbb52fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-12-27 Carles Pina i Estany + + * loader/i386/efi/linux.c (GRUB_MOD_INIT): Improve command summary. + * loader/i386/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/i386/linux.c (GRUB_MOD_INIT): Likewise. + * loader/i386/pc/linux.c (GRUB_MOD_INIT): Likewise. + * loader/powerpc/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT): Likewise. + * loader/xnu.c (GRUB_MOD_INIT): Likewise. + 2009-12-26 Carles Pina i Estany * video/readers/jpeg.c (cmd): Declare. diff --git a/loader/i386/efi/linux.c b/loader/i386/efi/linux.c index 0b82ff807..1c256e377 100644 --- a/loader/i386/efi/linux.c +++ b/loader/i386/efi/linux.c @@ -989,7 +989,7 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "Load linux."); + 0, "Load Linux."); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0, "Load initrd."); my_mod = mod; diff --git a/loader/i386/ieee1275/linux.c b/loader/i386/ieee1275/linux.c index 0a76a67b0..b577de964 100644 --- a/loader/i386/ieee1275/linux.c +++ b/loader/i386/ieee1275/linux.c @@ -276,7 +276,7 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "Load linux."); + 0, "Load Linux."); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0, "Load initrd."); my_mod = mod; diff --git a/loader/i386/linux.c b/loader/i386/linux.c index 9ea456b0d..899216783 100644 --- a/loader/i386/linux.c +++ b/loader/i386/linux.c @@ -982,7 +982,7 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "Load linux."); + 0, "Load Linux."); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0, "Load initrd."); my_mod = mod; diff --git a/loader/i386/pc/linux.c b/loader/i386/pc/linux.c index 0e7336214..b93754559 100644 --- a/loader/i386/pc/linux.c +++ b/loader/i386/pc/linux.c @@ -383,7 +383,7 @@ GRUB_MOD_INIT(linux16) { cmd_linux = grub_register_command ("linux16", grub_cmd_linux, - 0, "Load linux."); + 0, "Load Linux."); cmd_initrd = grub_register_command ("initrd16", grub_cmd_initrd, 0, "Load initrd."); diff --git a/loader/powerpc/ieee1275/linux.c b/loader/powerpc/ieee1275/linux.c index f03c10ad8..7996a22f6 100644 --- a/loader/powerpc/ieee1275/linux.c +++ b/loader/powerpc/ieee1275/linux.c @@ -349,9 +349,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "Load a linux kernel."); + 0, "Load Linux."); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "Load an initrd."); + 0, "Load initrd."); my_mod = mod; } diff --git a/loader/sparc64/ieee1275/linux.c b/loader/sparc64/ieee1275/linux.c index 92836e7eb..3af93df7d 100644 --- a/loader/sparc64/ieee1275/linux.c +++ b/loader/sparc64/ieee1275/linux.c @@ -516,9 +516,9 @@ GRUB_MOD_INIT(linux) fetch_translations (); cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "Load a linux kernel."); + 0, "Load Linux."); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "Load an initrd".); + 0, "Load initrd".); my_mod = mod; } diff --git a/loader/xnu.c b/loader/xnu.c index 114f3f213..f3ae3888a 100644 --- a/loader/xnu.c +++ b/loader/xnu.c @@ -1404,9 +1404,9 @@ static grub_command_t cmd_kextdir, cmd_ramdisk, cmd_resume, cmd_splash; GRUB_MOD_INIT(xnu) { cmd_kernel = grub_register_command ("xnu_kernel", grub_cmd_xnu_kernel, 0, - "Load a xnu kernel."); + "Load XNU image."); cmd_kernel64 = grub_register_command ("xnu_kernel64", grub_cmd_xnu_kernel64, - 0, "Load a 64-bit xnu kernel."); + 0, "Load 64-bit XNU image."); cmd_mkext = grub_register_command ("xnu_mkext", grub_cmd_xnu_mkext, 0, "Load XNU extension package."); cmd_kext = grub_register_command ("xnu_kext", grub_cmd_xnu_kext, 0, From 64fd18edbc8b10be53dd4fe2462bf29cb8b1e18e Mon Sep 17 00:00:00 2001 From: carles Date: Sun, 27 Dec 2009 00:43:21 +0100 Subject: [PATCH 105/208] 2009-12-27 Carles Pina i Estany * normal/cmdline.c (grub_cmdline_get): Print a space after prompt. * normal/main.c (grub_normal_read_line): Remove a space from the default prompt. --- ChangeLog | 6 ++++++ normal/cmdline.c | 4 ++-- normal/main.c | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 07dbb52fe..ebeb7ca93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-12-27 Carles Pina i Estany + + * normal/cmdline.c (grub_cmdline_get): Print a space after prompt. + * normal/main.c (grub_normal_read_line): Remove a space from the + default prompt. + 2009-12-27 Carles Pina i Estany * loader/i386/efi/linux.c (GRUB_MOD_INIT): Improve command summary. diff --git a/normal/cmdline.c b/normal/cmdline.c index 6d74e6e69..19b83951a 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -268,14 +268,14 @@ grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, grub_refresh (); } - plen = grub_strlen (prompt_translated); + plen = grub_strlen (prompt_translated) + sizeof (" ") - 1; lpos = llen = 0; buf[0] = '\0'; if ((grub_getxy () >> 8) != 0) grub_putchar ('\n'); - grub_printf ("%s", prompt_translated); + grub_printf ("%s ", prompt_translated); xpos = plen; ystart = ypos = (grub_getxy () & 0xFF); diff --git a/normal/main.c b/normal/main.c index 17e21566d..23de7e238 100644 --- a/normal/main.c +++ b/normal/main.c @@ -546,9 +546,9 @@ static grub_err_t grub_normal_read_line (char **line, int cont) { grub_parser_t parser = grub_parser_get_current (); - char prompt[sizeof("> ") + grub_strlen (parser->name)]; + char prompt[sizeof(">") + grub_strlen (parser->name)]; - grub_sprintf (prompt, "%s> ", parser->name); + grub_sprintf (prompt, "%s>", parser->name); while (1) { From 562e438b775b204ef0ab4aeb0128a91571c2c413 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 27 Dec 2009 17:21:49 +0100 Subject: [PATCH 106/208] Add defines for yeeloong --- term/gfxterm.c | 4 ++++ term/i386/pc/at_keyboard.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/term/gfxterm.c b/term/gfxterm.c index f161499e6..2a22b9168 100644 --- a/term/gfxterm.c +++ b/term/gfxterm.c @@ -953,7 +953,11 @@ static grub_command_t cmd; GRUB_MOD_INIT(term_gfxterm) { +#ifdef GRUB_MACHINE_MIPS_YEELOONG + grub_term_register_output_active ("gfxterm", &grub_video_term); +#else grub_term_register_output ("gfxterm", &grub_video_term); +#endif cmd = grub_register_command ("background_image", grub_gfxterm_background_image_cmd, 0, "Load background image for active terminal"); diff --git a/term/i386/pc/at_keyboard.c b/term/i386/pc/at_keyboard.c index 379cb3a4b..fd9767736 100644 --- a/term/i386/pc/at_keyboard.c +++ b/term/i386/pc/at_keyboard.c @@ -233,7 +233,7 @@ static struct grub_term_input grub_at_keyboard_term = GRUB_MOD_INIT(at_keyboard) { -#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) +#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_MIPS_YEELOONG) grub_term_register_input_active ("at_keyboard", &grub_at_keyboard_term); #else grub_term_register_input ("at_keyboard", &grub_at_keyboard_term); From 1975ecdc59b51e2b52a1457c7325333ecd77b4f8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 27 Dec 2009 17:40:36 +0100 Subject: [PATCH 107/208] Fix include in kern/term.c --- kern/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/term.c b/kern/term.c index b76771d86..3d8777133 100644 --- a/kern/term.c +++ b/kern/term.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include struct grub_term_output *grub_term_outputs_disabled; struct grub_term_input *grub_term_inputs_disabled; From 3e74249c4c98463dac5541c232e8864bbc6ee11a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 27 Dec 2009 22:21:48 +0100 Subject: [PATCH 108/208] 2009-12-27 Vladimir Serbinenko * video/readers/jpeg.c (GRUB_MOD_FINI (grub_cmd_jpegtest)): Rename to .. (GRUB_MOD_FINI (video_reader_jpeg)): ...this --- ChangeLog | 5 +++++ video/readers/jpeg.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ebeb7ca93..68be8cfe6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-27 Vladimir Serbinenko + + * video/readers/jpeg.c (GRUB_MOD_FINI (grub_cmd_jpegtest)): Rename to .. + (GRUB_MOD_FINI (video_reader_jpeg)): ...this + 2009-12-27 Carles Pina i Estany * normal/cmdline.c (grub_cmdline_get): Print a space after prompt. diff --git a/video/readers/jpeg.c b/video/readers/jpeg.c index e7b69a208..3c3ac33bb 100644 --- a/video/readers/jpeg.c +++ b/video/readers/jpeg.c @@ -740,7 +740,7 @@ GRUB_MOD_INIT (video_reader_jpeg) #endif } -GRUB_MOD_FINI (grub_cmd_jpegtest) +GRUB_MOD_FINI (video_reader_jpeg) { #if defined(JPEG_DEBUG) grub_unregister_command (cmd); From 3851cc386e1d98f5407fadc2932815f0f6831205 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 27 Dec 2009 22:29:22 +0100 Subject: [PATCH 109/208] Prevent NULL dereferencing when unregistering ciphers --- lib/crypto.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/crypto.c b/lib/crypto.c index 021560d6c..d11f0994f 100644 --- a/lib/crypto.c +++ b/lib/crypto.c @@ -59,7 +59,10 @@ grub_cipher_unregister (gcry_cipher_spec_t *cipher) gcry_cipher_spec_t **ciph; for (ciph = &grub_ciphers; *ciph; ciph = &((*ciph)->next)) if (*ciph == cipher) - *ciph = (*ciph)->next; + { + *ciph = (*ciph)->next; + break; + } } void @@ -75,7 +78,10 @@ grub_md_unregister (gcry_md_spec_t *cipher) gcry_md_spec_t **ciph; for (ciph = &grub_digests; *ciph; ciph = &((*ciph)->next)) if (*ciph == cipher) - *ciph = (*ciph)->next; + { + *ciph = (*ciph)->next; + break; + } } void From 9c8739a456e7031a605f19ef0504687d853b894c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 27 Dec 2009 22:32:52 +0100 Subject: [PATCH 110/208] 2009-12-27 Vladimir Serbinenko * normal/menu_text.c (grub_print_message_indented): Prevent past-the-end-of-array dereference. --- ChangeLog | 5 +++++ normal/menu_text.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 68be8cfe6..b6d1f02cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-27 Vladimir Serbinenko + + * normal/menu_text.c (grub_print_message_indented): Prevent + past-the-end-of-array dereference. + 2009-12-27 Vladimir Serbinenko * video/readers/jpeg.c (GRUB_MOD_FINI (grub_cmd_jpegtest)): Rename to .. diff --git a/normal/menu_text.c b/normal/menu_text.c index 4f2dfb78e..bac15f32b 100644 --- a/normal/menu_text.c +++ b/normal/menu_text.c @@ -137,8 +137,8 @@ grub_print_message_indented (const char *msg, int margin_left, int margin_right) next_new_line = (grub_uint32_t *) last_position; while (grub_getstringwidth (current_position, next_new_line) > line_len - || (*next_new_line != ' ' && next_new_line > current_position && - next_new_line != last_position)) + || (next_new_line != last_position && *next_new_line != ' ' + && next_new_line > current_position)) { next_new_line--; } From f45e1a9fb790237b066d2f1e706e896fcc5a9e15 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 27 Dec 2009 22:34:49 +0100 Subject: [PATCH 111/208] Allocate correct size --- normal/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/normal/term.c b/normal/term.c index b099ae84c..667d27ee9 100644 --- a/normal/term.c +++ b/normal/term.c @@ -167,7 +167,7 @@ read_terminal_list (void) return; } - filename = grub_malloc (grub_strlen (prefix) + sizeof ("/crypto.lst")); + filename = grub_malloc (grub_strlen (prefix) + sizeof ("/terminal.lst")); if (!filename) { grub_errno = GRUB_ERR_NONE; From dc71441293ffa0682ee2fc1f759c34bb772bb8d2 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 27 Dec 2009 22:35:40 +0100 Subject: [PATCH 112/208] Output \n\r like it was done previously because ncurses is confused by \r\n --- kern/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/term.c b/kern/term.c index 3d8777133..50fbbf302 100644 --- a/kern/term.c +++ b/kern/term.c @@ -45,9 +45,9 @@ grub_putcode (grub_uint32_t code, struct grub_term_output *term) return; } + (term->putchar) (code); if (code == '\n') (term->putchar) ('\r'); - (term->putchar) (code); } /* Put a character. C is one byte of a UTF-8 stream. From 13d1f24696a905e83c4edd7c96fafbc2081554dc Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 27 Dec 2009 22:36:09 +0100 Subject: [PATCH 113/208] Fix grub-emu compilation --- conf/any-emu.rmk | 1 + util/console.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index bbc564c80..85ff972ab 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -28,6 +28,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.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 normal/crypto.c normal/term.c \ + commands/terminal.c lib/charset.c \ script/main.c script/execute.c script/function.c \ script/lexer.c script/script.c grub_script.tab.c \ partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \ diff --git a/util/console.c b/util/console.c index 40ee3a638..73195765e 100644 --- a/util/console.c +++ b/util/console.c @@ -19,14 +19,6 @@ #include -#if defined(HAVE_NCURSES_CURSES_H) -# include -#elif defined(HAVE_NCURSES_H) -# include -#elif defined(HAVE_CURSES_H) -# include -#endif - /* For compatibility. */ #ifndef A_NORMAL # define A_NORMAL 0 @@ -39,6 +31,14 @@ #include #include +#if defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + static int grub_console_attr = A_NORMAL; grub_uint8_t grub_console_cur_color = 7; From c181849b95d42134d9bcb08ade43525ed58024cc Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 28 Dec 2009 01:02:21 +0100 Subject: [PATCH 114/208] 2009-12-27 Vladimir Serbinenko * kern/parser.c (grub_parser_split_cmdline): Don't dereference NULL. --- ChangeLog | 4 ++++ kern/parser.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b6d1f02cc..70e24ef15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-12-27 Vladimir Serbinenko + + * kern/parser.c (grub_parser_split_cmdline): Don't dereference NULL. + 2009-12-27 Vladimir Serbinenko * normal/menu_text.c (grub_print_message_indented): Prevent diff --git a/kern/parser.c b/kern/parser.c index 006d67da7..dd4608ba9 100644 --- a/kern/parser.c +++ b/kern/parser.c @@ -145,13 +145,16 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline, *argc = 0; do { - if (! *rd) + if (! rd || !*rd) { if (getline) getline (&rd, 1); else break; } + if (!rd) + break; + for (; *rd; rd++) { grub_parser_state_t newstate; From 465b5a81300851f72ad9e5dc4b2fe261dac371b4 Mon Sep 17 00:00:00 2001 From: carles Date: Mon, 28 Dec 2009 19:11:59 +0100 Subject: [PATCH 115/208] 2009-12-28 Carles Pina i Estany * normal/misc.c (grub_normal_print_device_info): Add spaces and double quotes. --- ChangeLog | 5 +++++ normal/misc.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 70e24ef15..38ee89b04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-28 Carles Pina i Estany + + * normal/misc.c (grub_normal_print_device_info): Add spaces and double + quotes. + 2009-12-27 Vladimir Serbinenko * kern/parser.c (grub_parser_split_cmdline): Don't dereference NULL. diff --git a/normal/misc.c b/normal/misc.c index 18e20d2fc..17ba372ce 100644 --- a/normal/misc.c +++ b/normal/misc.c @@ -68,7 +68,10 @@ grub_normal_print_device_info (const char *name) if (grub_errno == GRUB_ERR_NONE) { if (label && grub_strlen (label)) - grub_printf_ (N_("- Label %s"), label); + { + grub_putchar (' '); + grub_printf_ (N_("- Label \"%s\""), label); + } grub_free (label); } grub_errno = GRUB_ERR_NONE; @@ -81,6 +84,7 @@ grub_normal_print_device_info (const char *name) if (grub_errno == GRUB_ERR_NONE) { grub_unixtime2datetime (tm, &datetime); + grub_putchar (' '); grub_printf_ (N_("- Last modification time %d-%02d-%02d " "%02d:%02d:%02d %s"), datetime.year, datetime.month, datetime.day, From a6f106ce3780a76d6b9fd4199c8774bd07ad77ed Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 28 Dec 2009 22:06:30 +0100 Subject: [PATCH 116/208] Fix i386-ieee1275 compilation --- loader/i386/ieee1275/linux.c | 34 ++++++++++++++++++++++++++++++++-- term/ieee1275/ofconsole.c | 4 ++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/loader/i386/ieee1275/linux.c b/loader/i386/ieee1275/linux.c index 529d1590a..33488d443 100644 --- a/loader/i386/ieee1275/linux.c +++ b/loader/i386/ieee1275/linux.c @@ -109,8 +109,38 @@ grub_linux_boot (void) params->cl_magic = GRUB_LINUX_CL_MAGIC; params->cl_offset = GRUB_OFW_LINUX_CL_OFFSET; - params->video_width = (grub_getwh () >> 8); - params->video_height = (grub_getwh () & 0xff); + { + grub_term_output_t term; + int found = 0; + FOR_ACTIVE_TERM_OUTPUTS(term) + if (grub_strcmp (term->name, "vga_text") == 0) + { + grub_uint16_t pos = grub_term_getxy (term); + params->video_cursor_x = pos >> 8; + params->video_cursor_y = pos & 0xff; + params->video_width = grub_term_width (term); + params->video_height = grub_term_height (term); + found = 1; + } + if (!found) + FOR_ACTIVE_TERM_OUTPUTS(term) + if (grub_strcmp (term->name, "console") == 0) + { + grub_uint16_t pos = grub_term_getxy (term); + params->video_cursor_x = pos >> 8; + params->video_cursor_y = pos & 0xff; + params->video_width = grub_term_width (term); + params->video_height = grub_term_height (term); + found = 1; + } + if (!found) + { + params->video_cursor_x = 0; + params->video_cursor_y = 0; + params->video_width = 80; + params->video_height = 25; + } + } params->font_size = 16; params->ofw_signature = GRUB_LINUX_OFW_SIGNATURE; diff --git a/term/ieee1275/ofconsole.c b/term/ieee1275/ofconsole.c index f5db7c146..4b9c9060e 100644 --- a/term/ieee1275/ofconsole.c +++ b/term/ieee1275/ofconsole.c @@ -88,7 +88,7 @@ grub_ofconsole_putchar (grub_uint32_t c) grub_curr_x++; if (grub_curr_x > grub_ofconsole_width) { - grub_putcode ('\n'); + grub_ofconsole_putchar ('\n'); grub_curr_x++; } } @@ -319,7 +319,7 @@ grub_ofconsole_cls (void) * ANSI escape sequence. Using video console, Apple Open Firmware (version * 3.1.1) only recognizes the literal ^L. So use both. */ grub_ofconsole_writeesc (" \e[2J"); - grub_gotoxy (0, 0); + grub_ofconsole_gotoxy (0, 0); } static void From bd2b242ea20d6c696f7f737ae56056c60b281a18 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Dec 2009 10:24:10 +0100 Subject: [PATCH 117/208] Fix space after completion --- normal/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/normal/cmdline.c b/normal/cmdline.c index 3521c3cbd..317f63fe3 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -436,7 +436,7 @@ grub_cmdline_get (const char *prompt) if (restore) { /* Restore the prompt. */ - grub_printf ("\n%s", prompt_translated); + grub_printf ("\n%s ", prompt_translated); init_clterm_all (); cl_print_all (0, 0); } From 37f7fb26a379f3ea88bc30107ae371a70e85e0e8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Dec 2009 13:03:22 +0100 Subject: [PATCH 118/208] always_inline cl_print to avoid regparm=3 bug --- normal/cmdline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/normal/cmdline.c b/normal/cmdline.c index 317f63fe3..a0e678778 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -222,7 +222,8 @@ grub_cmdline_get (const char *prompt) int histpos = 0; auto void cl_insert (const grub_uint32_t *str); auto void cl_delete (unsigned len); - auto void cl_print (struct cmdline_term *cl_term, int pos, grub_uint32_t c); + auto inline void __attribute__ ((always_inline)) cl_print (struct cmdline_term *cl_term, int pos, + grub_uint32_t c); auto void cl_set_pos (struct cmdline_term *cl_term); auto void cl_print_all (int pos, grub_uint32_t c); auto void cl_set_pos_all (void); @@ -245,7 +246,7 @@ grub_cmdline_get (const char *prompt) cl_set_pos (&cl_terms[i]); } - void cl_print (struct cmdline_term *cl_term, int pos, grub_uint32_t c) + inline void __attribute__ ((always_inline)) cl_print (struct cmdline_term *cl_term, int pos, grub_uint32_t c) { grub_uint32_t *p; From 90d1e8797a459950943da91dbcd3712893e195f3 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 29 Dec 2009 14:04:18 +0000 Subject: [PATCH 119/208] 2009-12-29 Robert Millan * configure.ac: Check for TARGET_CFLAGS initialization before we initialize it ourselves (sigh). Move a few modifications to TARGET_CFLAGS to be unconditional (extra warning flags, loop alignment, i386 CPU extensions, GCC 4.4 eh_frame) * gettext/gettext.c (grub_gettext_delete_list): Add `void' argument. * term/i386/pc/at_keyboard.c (keyboard_controller_wait_untill_ready): Likewise. (keyboard_controller_led): Rename `led_status' paramter to avoid name conflict. --- ChangeLog | 14 +++++++ configure.ac | 82 +++++++++++++++++--------------------- gettext/gettext.c | 2 +- term/i386/pc/at_keyboard.c | 6 +-- 4 files changed, 54 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 38ee89b04..588c035ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2009-12-29 Robert Millan + + * configure.ac: Check for TARGET_CFLAGS initialization before we + initialize it ourselves (sigh). + Move a few modifications to TARGET_CFLAGS to be unconditional + (extra warning flags, loop alignment, i386 CPU extensions, GCC 4.4 + eh_frame) + + * gettext/gettext.c (grub_gettext_delete_list): Add `void' argument. + * term/i386/pc/at_keyboard.c + (keyboard_controller_wait_untill_ready): Likewise. + (keyboard_controller_led): Rename `led_status' paramter to avoid + name conflict. + 2009-12-28 Carles Pina i Estany * normal/misc.c (grub_normal_print_device_info): Add spaces and double diff --git a/configure.ac b/configure.ac index 6560d3e31..3cac421e8 100644 --- a/configure.ac +++ b/configure.ac @@ -44,6 +44,11 @@ AC_CANONICAL_TARGET # Program name transformations AC_ARG_PROGRAM +# Optimization flag. Allow user to override. +if test "x$TARGET_CFLAGS" = x; then + TARGET_CFLAGS="$TARGET_CFLAGS -Os" +fi + case "$target_cpu" in i[[3456]]86) target_cpu=i386 ;; sparc) target_cpu=sparc64 ;; @@ -242,60 +247,45 @@ CPPFLAGS="$TARGET_CPPFLAGS" LDFLAGS="$TARGET_LDFLAGS" LIBS="" -if test "x$TARGET_CFLAGS" = x; then - # debug flags. - TARGET_CFLAGS="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \ - -Wundef -Wstrict-prototypes -g" +# debug flags. +TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \ + -Wundef -Wstrict-prototypes -g" - # optimization flags. - AC_CACHE_CHECK([whether optimization for size works], grub_cv_cc_Os, [ - CFLAGS=-Os +# Force no alignment to save space on i386. +if test "x$target_cpu" = xi386; then + AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ + CFLAGS="$CFLAGS -falign-loops=1" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], - [grub_cv_cc_Os=yes], - [grub_cv_cc_Os=no]) + [grub_cv_cc_falign_loop=yes], + [grub_cv_cc_falign_loop=no]) ]) - if test "x$grub_cv_cc_Os" = xyes; then - TARGET_CFLAGS="$TARGET_CFLAGS -Os" + + if test "x$grub_cv_cc_falign_loop" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1" else - TARGET_CFLAGS="$TARGET_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops" + TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" fi - # Force no alignment to save space on i386. - if test "x$target_cpu" = xi386; then - AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ - CFLAGS="$CFLAGS -falign-loops=1" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], - [grub_cv_cc_falign_loop=yes], - [grub_cv_cc_falign_loop=no]) - ]) + # Some toolchains enable these features by default, but they need + # registers that aren't set up properly in GRUB. + TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow" +fi - if test "x$grub_cv_cc_falign_loop" = xyes; then - TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1" - else - TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" - 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" +]) - # Some toolchains enable these features by default, but they need - # registers that aren't set up properly in GRUB. - TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow" - 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 +if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm" fi grub_apple_target_cc diff --git a/gettext/gettext.c b/gettext/gettext.c index 3472b2fb8..165feb332 100644 --- a/gettext/gettext.c +++ b/gettext/gettext.c @@ -298,7 +298,7 @@ grub_gettext_init_ext (const char *lang) } static void -grub_gettext_delete_list () +grub_gettext_delete_list (void) { struct grub_gettext_msg *item; diff --git a/term/i386/pc/at_keyboard.c b/term/i386/pc/at_keyboard.c index a53dbfa2d..4ad60c65c 100644 --- a/term/i386/pc/at_keyboard.c +++ b/term/i386/pc/at_keyboard.c @@ -72,7 +72,7 @@ static char keyboard_map_shift[128] = static grub_uint8_t grub_keyboard_controller_orig; static void -keyboard_controller_wait_untill_ready () +keyboard_controller_wait_untill_ready (void) { while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))); } @@ -94,12 +94,12 @@ grub_keyboard_controller_read (void) } static void -keyboard_controller_led (grub_uint8_t led_status) +keyboard_controller_led (grub_uint8_t leds) { keyboard_controller_wait_untill_ready (); grub_outb (0xed, KEYBOARD_REG_DATA); keyboard_controller_wait_untill_ready (); - grub_outb (led_status & 0x7, KEYBOARD_REG_DATA); + grub_outb (leds & 0x7, KEYBOARD_REG_DATA); } /* FIXME: This should become an interrupt service routine. For now From d8a1cbbd0b3a9e31d064d25ba193b1bcdb685404 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Dec 2009 17:54:27 +0100 Subject: [PATCH 120/208] Fix compilation warning --- commands/terminal.c | 4 ++-- normal/cmdline.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/terminal.c b/commands/terminal.c index 5befecd31..0fff70a69 100644 --- a/commands/terminal.c +++ b/commands/terminal.c @@ -26,7 +26,7 @@ struct grub_term_autoload *grub_term_input_autoload = NULL; struct grub_term_autoload *grub_term_output_autoload = NULL; -grub_err_t +static grub_err_t grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) { @@ -183,7 +183,7 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)), return GRUB_ERR_NONE; } -grub_err_t +static grub_err_t grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) { diff --git a/normal/cmdline.c b/normal/cmdline.c index a0e678778..f2c2edf9b 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -227,6 +227,8 @@ grub_cmdline_get (const char *prompt) auto void cl_set_pos (struct cmdline_term *cl_term); auto void cl_print_all (int pos, grub_uint32_t c); auto void cl_set_pos_all (void); + auto void init_clterm (struct cmdline_term *cl_term_cur); + auto void init_clterm_all (void); const char *prompt_translated = _(prompt); struct cmdline_term *cl_terms; char *ret; From f5a513064cf4e68cdd77cb885d5409c92d0a5403 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Dec 2009 19:06:04 +0100 Subject: [PATCH 121/208] 2009-12-29 Vladimir Serbinenko * loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT (linux)): Fix syntax error. --- ChangeLog | 5 +++++ loader/sparc64/ieee1275/linux.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 588c035ad..c9a5d4eb2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-29 Vladimir Serbinenko + + * loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT (linux)): + Fix syntax error. + 2009-12-29 Robert Millan * configure.ac: Check for TARGET_CFLAGS initialization before we diff --git a/loader/sparc64/ieee1275/linux.c b/loader/sparc64/ieee1275/linux.c index 3af93df7d..6ffad202e 100644 --- a/loader/sparc64/ieee1275/linux.c +++ b/loader/sparc64/ieee1275/linux.c @@ -518,7 +518,7 @@ GRUB_MOD_INIT(linux) cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0, "Load Linux."); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "Load initrd".); + 0, "Load initrd."); my_mod = mod; } From 33433555f30fa99eda7ceed7ce7d6f0d202c22c7 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 31 Dec 2009 15:03:09 +0100 Subject: [PATCH 122/208] 2009-12-31 BVK Chaitanya * include/grub/list.h (grub_assert_fail): Removed. (grub_bad_type_cast_real): New function. (grub_bad_type_cast): New macro. (GRUB_AS_LIST): Use grub_bad_type_cast. (GRUB_AS_LIST_P): Likewise. (GRUB_AS_NAMED_LIST): Likewise. (GRUB_AS_NAMED_LIST_P): Likewise. (GRUB_AS_PRIO_LIST): Likewise. (GRUB_AS_PRIO_LIST_P): Likewise. * include/grub/handler.h (GRUB_AS_HANDLER): Likewise. --- ChangeLog | 13 +++++++++++++ include/grub/handler.h | 2 +- include/grub/list.h | 34 +++++++++++++++++----------------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9a5d4eb2..64ebf0e78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-12-31 BVK Chaitanya + + * include/grub/list.h (grub_assert_fail): Removed. + (grub_bad_type_cast_real): New function. + (grub_bad_type_cast): New macro. + (GRUB_AS_LIST): Use grub_bad_type_cast. + (GRUB_AS_LIST_P): Likewise. + (GRUB_AS_NAMED_LIST): Likewise, + (GRUB_AS_NAMED_LIST_P): Likewise. + (GRUB_AS_PRIO_LIST): Likewise, + (GRUB_AS_PRIO_LIST_P): Likewise. + * include/grub/handler.h (GRUB_AS_HANDLER): Likewise, + 2009-12-29 Vladimir Serbinenko * loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT (linux)): diff --git a/include/grub/handler.h b/include/grub/handler.h index 3331bb417..77dd7d9c1 100644 --- a/include/grub/handler.h +++ b/include/grub/handler.h @@ -55,6 +55,6 @@ grub_err_t EXPORT_FUNC(grub_handler_set_current) (grub_handler_class_t class, GRUB_FIELD_MATCH (ptr, grub_handler_t, name) && \ GRUB_FIELD_MATCH (ptr, grub_handler_t, init) && \ GRUB_FIELD_MATCH (ptr, grub_handler_t, fini)) ? \ - (grub_handler_t) ptr : grub_assert_fail ()) + (grub_handler_t) ptr : grub_bad_type_cast ()) #endif /* ! GRUB_HANDLER_HEADER */ diff --git a/include/grub/list.h b/include/grub/list.h index 2dffdc08d..86a5381cd 100644 --- a/include/grub/list.h +++ b/include/grub/list.h @@ -22,6 +22,7 @@ #include #include +#include struct grub_list { @@ -39,31 +40,30 @@ int EXPORT_FUNC(grub_list_iterate) (grub_list_t head, grub_list_hook_t hook); void EXPORT_FUNC(grub_list_insert) (grub_list_t *head, grub_list_t item, grub_list_test_t test); -/* This function doesn't exist, so if assertion is false for some reason, the - linker would fail. */ -#ifdef APPLE_CC -/* This approach fails with Apple's gcc. Use grub_abort. */ -#include static inline void * -grub_assert_fail (void) +grub_bad_type_cast_real (int line, const char *file) + __attribute__ ((error ("bad type cast between incompatible grub types"))); + +static inline void * +grub_bad_type_cast_real (int line, const char *file) { - grub_abort (); - return 0; + grub_fatal ("error:%s:%u: bad type cast between incompatible grub types", + file, line); + return 0; } -#else -extern void* grub_assert_fail (void); -#endif + +#define grub_bad_type_cast() grub_bad_type_cast_real(__LINE__, __FILE__) #define GRUB_FIELD_MATCH(ptr, type, field) \ ((char *) &(ptr)->field == (char *) &((type) (ptr))->field) #define GRUB_AS_LIST(ptr) \ (GRUB_FIELD_MATCH (ptr, grub_list_t, next) ? \ - (grub_list_t) ptr : grub_assert_fail ()) + (grub_list_t) ptr : grub_bad_type_cast ()) #define GRUB_AS_LIST_P(pptr) \ (GRUB_FIELD_MATCH (*pptr, grub_list_t, next) ? \ - (grub_list_t *) (void *) pptr : grub_assert_fail ()) + (grub_list_t *) (void *) pptr : grub_bad_type_cast ()) struct grub_named_list { @@ -78,12 +78,12 @@ void * EXPORT_FUNC(grub_named_list_find) (grub_named_list_t head, #define GRUB_AS_NAMED_LIST(ptr) \ ((GRUB_FIELD_MATCH (ptr, grub_named_list_t, next) && \ GRUB_FIELD_MATCH (ptr, grub_named_list_t, name))? \ - (grub_named_list_t) ptr : grub_assert_fail ()) + (grub_named_list_t) ptr : grub_bad_type_cast ()) #define GRUB_AS_NAMED_LIST_P(pptr) \ ((GRUB_FIELD_MATCH (*pptr, grub_named_list_t, next) && \ GRUB_FIELD_MATCH (*pptr, grub_named_list_t, name))? \ - (grub_named_list_t *) (void *) pptr : grub_assert_fail ()) + (grub_named_list_t *) (void *) pptr : grub_bad_type_cast ()) #define GRUB_PRIO_LIST_PRIO_MASK 0xff #define GRUB_PRIO_LIST_FLAG_ACTIVE 0x100 @@ -111,12 +111,12 @@ grub_prio_list_remove (grub_prio_list_t *head, grub_prio_list_t item) ((GRUB_FIELD_MATCH (ptr, grub_prio_list_t, next) && \ GRUB_FIELD_MATCH (ptr, grub_prio_list_t, name) && \ GRUB_FIELD_MATCH (ptr, grub_prio_list_t, prio))? \ - (grub_prio_list_t) ptr : grub_assert_fail ()) + (grub_prio_list_t) ptr : grub_bad_type_cast ()) #define GRUB_AS_PRIO_LIST_P(pptr) \ ((GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, next) && \ GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, name) && \ GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, prio))? \ - (grub_prio_list_t *) (void *) pptr : grub_assert_fail ()) + (grub_prio_list_t *) (void *) pptr : grub_bad_type_cast ()) #endif /* ! GRUB_LIST_HEADER */ From e44721e811e42f4a3d6135ab052615150699f5d1 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 31 Dec 2009 15:05:12 +0100 Subject: [PATCH 123/208] Fix punctuation in ChangeLog --- ChangeLog | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 64ebf0e78..b7734a5f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,11 +5,11 @@ (grub_bad_type_cast): New macro. (GRUB_AS_LIST): Use grub_bad_type_cast. (GRUB_AS_LIST_P): Likewise. - (GRUB_AS_NAMED_LIST): Likewise, + (GRUB_AS_NAMED_LIST): Likewise. (GRUB_AS_NAMED_LIST_P): Likewise. - (GRUB_AS_PRIO_LIST): Likewise, + (GRUB_AS_PRIO_LIST): Likewise. (GRUB_AS_PRIO_LIST_P): Likewise. - * include/grub/handler.h (GRUB_AS_HANDLER): Likewise, + * include/grub/handler.h (GRUB_AS_HANDLER): Likewise. 2009-12-29 Vladimir Serbinenko From 3fd3b8d81a7a0b8db4e655b93e72779007b18c06 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 1 Jan 2010 12:33:45 +0000 Subject: [PATCH 124/208] 2010-01-01 Robert Millan Import from Gnulib. * gnulib/getdelim.c: New file. * gnulib/getline.c: Likewise. --- ChangeLog | 7 +++ gnulib/getdelim.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++ gnulib/getline.c | 30 +++++++++++ 3 files changed, 170 insertions(+) create mode 100644 gnulib/getdelim.c create mode 100644 gnulib/getline.c diff --git a/ChangeLog b/ChangeLog index b7734a5f4..17ddc35d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-01-01 Robert Millan + + Import from Gnulib. + + * gnulib/getdelim.c: New file. + * gnulib/getline.c: Likewise. + 2009-12-31 BVK Chaitanya * include/grub/list.h (grub_assert_fail): Removed. diff --git a/gnulib/getdelim.c b/gnulib/getdelim.c new file mode 100644 index 000000000..12f2167c9 --- /dev/null +++ b/gnulib/getdelim.c @@ -0,0 +1,133 @@ +/* getdelim.c --- Implementation of replacement getdelim function. + Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007, + 2008, 2009 Free Software Foundation, Inc. + + This program 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 2, or (at + your option) any later version. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Ported from glibc by Simon Josefsson. */ + +#include + +#include + +#include +#include +#include +#include + +#ifndef SSIZE_MAX +# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) +#endif + +#if USE_UNLOCKED_IO +# include "unlocked-io.h" +# define getc_maybe_unlocked(fp) getc(fp) +#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED +# undef flockfile +# undef funlockfile +# define flockfile(x) ((void) 0) +# define funlockfile(x) ((void) 0) +# define getc_maybe_unlocked(fp) getc(fp) +#else +# define getc_maybe_unlocked(fp) getc_unlocked(fp) +#endif + +/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and + NUL-terminate it). *LINEPTR is a pointer returned from malloc (or + NULL), pointing to *N characters of space. It is realloc'ed as + necessary. Returns the number of characters read (not including + the null terminator), or -1 on error or EOF. */ + +ssize_t +getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) +{ + ssize_t result; + size_t cur_len = 0; + + if (lineptr == NULL || n == NULL || fp == NULL) + { + errno = EINVAL; + return -1; + } + + flockfile (fp); + + if (*lineptr == NULL || *n == 0) + { + char *new_lineptr; + *n = 120; + new_lineptr = (char *) realloc (*lineptr, *n); + if (new_lineptr == NULL) + { + result = -1; + goto unlock_return; + } + *lineptr = new_lineptr; + } + + for (;;) + { + int i; + + i = getc_maybe_unlocked (fp); + if (i == EOF) + { + result = -1; + break; + } + + /* Make enough space for len+1 (for final NUL) bytes. */ + if (cur_len + 1 >= *n) + { + size_t needed_max = + SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; + size_t needed = 2 * *n + 1; /* Be generous. */ + char *new_lineptr; + + if (needed_max < needed) + needed = needed_max; + if (cur_len + 1 >= needed) + { + result = -1; + errno = EOVERFLOW; + goto unlock_return; + } + + new_lineptr = (char *) realloc (*lineptr, needed); + if (new_lineptr == NULL) + { + result = -1; + goto unlock_return; + } + + *lineptr = new_lineptr; + *n = needed; + } + + (*lineptr)[cur_len] = i; + cur_len++; + + if (i == delimiter) + break; + } + (*lineptr)[cur_len] = '\0'; + result = cur_len ? cur_len : result; + + unlock_return: + funlockfile (fp); /* doesn't set errno */ + + return result; +} diff --git a/gnulib/getline.c b/gnulib/getline.c new file mode 100644 index 000000000..eb8f055a8 --- /dev/null +++ b/gnulib/getline.c @@ -0,0 +1,30 @@ +/* getline.c --- Implementation of replacement getline function. + Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. + + This program 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 2, or (at + your option) any later version. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Written by Simon Josefsson. */ + +#include + +#include +#include + +ssize_t +getline (char **lineptr, size_t *n, FILE *stream) +{ + return getdelim (lineptr, n, '\n', stream); +} From 3393790450750da09ac9eaa34c10065f68a485a8 Mon Sep 17 00:00:00 2001 From: carles Date: Fri, 1 Jan 2010 18:58:00 +0100 Subject: [PATCH 125/208] 2010-01-01 Carles Pina i Estany * commands/help.c: Include `grub/mm.h' and `grub/normal.h'. (grub_cmd_help): Print the cmd->name before the cmd->summary. Cut the string using string width. * normal/menu_text.c (grub_print_message_indented): Use grub_print_spaces and not print_spaces. (print_timeout): Likewise. (print_spaces): Move to... * include/grub/term.h: ... here. Change the name to grub_print_spaces. --- ChangeLog | 11 ++++++++++ commands/help.c | 51 +++++++++++++++++++++++++++++++++++---------- include/grub/term.h | 8 +++++++ normal/menu_text.c | 14 +++---------- 4 files changed, 62 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17ddc35d7..634e8aad0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-01-01 Carles Pina i Estany + + * commands/help.c: Include `grub/mm.h' and `grub/normal.h'. + (grub_cmd_help): Print the cmd->name before the cmd->summary. Cut the + string using string width. + * normal/menu_text.c (grub_print_message_indented): Use + grub_print_spaces and not print_spaces. + (print_timeout): Likewise. + (print_spaces): Move to... + * include/grub/term.h: ... here. Change the name to grub_print_spaces. + 2010-01-01 Robert Millan Import from Gnulib. diff --git a/commands/help.c b/commands/help.c index 9f0ee7528..8ca2a5b1f 100644 --- a/commands/help.c +++ b/commands/help.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include static grub_err_t grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, @@ -38,19 +40,46 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc, if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) && (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE)) { - char description[GRUB_TERM_WIDTH / 2]; - const char* summary_translated = _(cmd->summary); - int desclen = grub_strlen (summary_translated); + char *command_help; + int stringwidth; + grub_uint32_t *unicode_command_help; + grub_uint32_t *unicode_last_position; + grub_uint32_t *unicode_last_screen_position; + const char *summary_translated = _(cmd->summary); - /* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled - with the description followed by spaces. */ - grub_memset (description, ' ', GRUB_TERM_WIDTH / 2 - 1); - description[GRUB_TERM_WIDTH / 2 - 1] = '\0'; - grub_memcpy (description, summary_translated, - (desclen < GRUB_TERM_WIDTH / 2 - 1 - ? desclen : GRUB_TERM_WIDTH / 2 - 1)); + command_help = grub_malloc (grub_strlen (cmd->name) + + sizeof (" ") - 1 + + grub_strlen (summary_translated)); + + grub_sprintf(command_help, "%s %s", cmd->name, summary_translated); - grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " "); + grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help, + &unicode_last_position); + + unicode_last_screen_position = unicode_command_help; + + stringwidth = 0; + + while (unicode_last_screen_position < unicode_last_position && + stringwidth < ((GRUB_TERM_WIDTH / 2) - 2)) + { + stringwidth += grub_getcharwidth (*unicode_last_screen_position); + unicode_last_screen_position++; + } + + grub_print_ucs4 (unicode_command_help, unicode_last_screen_position); + + if ((cnt++) % 2) + { + grub_putchar ('\n'); + } + else + { + grub_print_spaces (GRUB_TERM_WIDTH / 2 - stringwidth); + } + + grub_free (command_help); + grub_free (unicode_command_help); } return 0; } diff --git a/include/grub/term.h b/include/grub/term.h index 316d75390..ec158353d 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -299,6 +299,14 @@ int EXPORT_FUNC(grub_getcursor) (void); void EXPORT_FUNC(grub_refresh) (void); void EXPORT_FUNC(grub_set_more) (int onoff); +static inline void +grub_print_spaces (int number_spaces) +{ + while (--number_spaces >= 0) + grub_putchar (' '); +} + + /* For convenience. */ #define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff) diff --git a/normal/menu_text.c b/normal/menu_text.c index bac15f32b..5c985fa6f 100644 --- a/normal/menu_text.c +++ b/normal/menu_text.c @@ -45,14 +45,6 @@ grub_wait_after_message (void) grub_putchar ('\n'); } -static void -print_spaces (int number_spaces) -{ - int i; - for (i = 0; i < number_spaces; i++) - grub_putchar (' '); -} - void grub_print_ucs4 (const grub_uint32_t * str, const grub_uint32_t * last_position) @@ -149,7 +141,7 @@ grub_print_message_indented (const char *msg, int margin_left, int margin_right) (grub_uint32_t *) last_position : next_new_line + line_len; } - print_spaces (margin_left); + grub_print_spaces (margin_left); grub_print_ucs4 (current_position, next_new_line); next_new_line++; @@ -405,7 +397,7 @@ print_timeout (int timeout, int offset) int posx; posx = grub_getxy() >> 8; - print_spaces (GRUB_TERM_WIDTH - posx - 1); + grub_print_spaces (GRUB_TERM_WIDTH - posx - 1); grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset); grub_refresh (); @@ -495,7 +487,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) if (timeout >= 0) { grub_gotoxy (0, GRUB_TERM_HEIGHT - 3); - print_spaces (GRUB_TERM_WIDTH - 1); + grub_print_spaces (GRUB_TERM_WIDTH - 1); grub_env_unset ("timeout"); grub_env_unset ("fallback"); From cec573c894e79f5d55697ff6722f4e148962aac2 Mon Sep 17 00:00:00 2001 From: Yves Blusseau Date: Fri, 1 Jan 2010 20:33:15 +0100 Subject: [PATCH 126/208] 2009-01-01 Yves Blusseau * config.rpath: new file used to configure compilation with NLS --- config.rpath | 666 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 666 insertions(+) create mode 100755 config.rpath diff --git a/config.rpath b/config.rpath new file mode 100755 index 000000000..c547c6882 --- /dev/null +++ b/config.rpath @@ -0,0 +1,666 @@ +#! /bin/sh +# Output a system dependent set of variables, describing how to set the +# run time search path of shared libraries in an executable. +# +# Copyright 1996-2007 Free Software Foundation, Inc. +# Taken from GNU libtool, 2001 +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's _LT_CC_BASENAME. + +for cc_temp in $CC""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + darwin*) + case $cc_basename in + xlc*) + wl='-Wl,' + ;; + esac + ;; + mingw* | cygwin* | pw32* | os2*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + newsos6) + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + icc* | ecc*) + wl='-Wl,' + ;; + pgcc | pgf77 | pgf90) + wl='-Wl,' + ;; + ccc*) + wl='-Wl,' + ;; + como) + wl='-lopt=' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + wl='-Wl,' + ;; + esac + ;; + esac + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + rdos*) + ;; + solaris*) + wl='-Wl,' + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; + unicos*) + wl='-Wl,' + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +case "$host_os" in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + case "$host_os" in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we cannot use + # them. + ld_shlibs=no + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + interix[3-9]*) + hardcode_direct=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + gnu* | linux* | k*bsd*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + else + ld_shlibs=no + fi + ;; + esac + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = no; then + hardcode_libdir_flag_spec= + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + else + aix_use_runtimelinking=no + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + fi + if test -z "$aix_libpath"; then + aix_libpath="/usr/lib:/lib" + fi + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + bsdi[45]*) + ;; + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + hardcode_direct=no + if test "$GCC" = yes ; then + : + else + case $cc_basename in + xlc*) + ;; + *) + ld_shlibs=no + ;; + esac + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd1*) + ld_shlibs=no + ;; + freebsd2.2*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + freebsd2*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd* | dragonfly*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + hpux11*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + ;; + *) + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + ;; + sysv5* | sco3.2v5* | sco5v6*) + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. +# Unlike libtool.m4, here we don't care about _all_ names of the library, but +# only about the one the linker finds when passed -lNAME. This is the last +# element of library_names_spec in libtool.m4, or possibly two of them if the +# linker has special search rules. +library_names_spec= # the last element of library_names_spec in libtool.m4 +libname_spec='lib$name' +case "$host_os" in + aix3*) + library_names_spec='$libname.a' + ;; + aix4* | aix5*) + library_names_spec='$libname$shrext' + ;; + amigaos*) + library_names_spec='$libname.a' + ;; + beos*) + library_names_spec='$libname$shrext' + ;; + bsdi[45]*) + library_names_spec='$libname$shrext' + ;; + cygwin* | mingw* | pw32*) + shrext=.dll + library_names_spec='$libname.dll.a $libname.lib' + ;; + darwin* | rhapsody*) + shrext=.dylib + library_names_spec='$libname$shrext' + ;; + dgux*) + library_names_spec='$libname$shrext' + ;; + freebsd1*) + ;; + freebsd* | dragonfly*) + case "$host_os" in + freebsd[123]*) + library_names_spec='$libname$shrext$versuffix' ;; + *) + library_names_spec='$libname$shrext' ;; + esac + ;; + gnu*) + library_names_spec='$libname$shrext' + ;; + hpux9* | hpux10* | hpux11*) + case $host_cpu in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + library_names_spec='$libname$shrext' + ;; + interix[3-9]*) + library_names_spec='$libname$shrext' + ;; + irix5* | irix6* | nonstopux*) + library_names_spec='$libname$shrext' + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux* | k*bsd*-gnu) + library_names_spec='$libname$shrext' + ;; + knetbsd*-gnu) + library_names_spec='$libname$shrext' + ;; + netbsd*) + library_names_spec='$libname$shrext' + ;; + newsos6) + library_names_spec='$libname$shrext' + ;; + nto-qnx*) + library_names_spec='$libname$shrext' + ;; + openbsd*) + library_names_spec='$libname$shrext$versuffix' + ;; + os2*) + libname_spec='$name' + shrext=.dll + library_names_spec='$libname.a' + ;; + osf3* | osf4* | osf5*) + library_names_spec='$libname$shrext' + ;; + rdos*) + ;; + solaris*) + library_names_spec='$libname$shrext' + ;; + sunos4*) + library_names_spec='$libname$shrext$versuffix' + ;; + sysv4 | sysv4.3*) + library_names_spec='$libname$shrext' + ;; + sysv4*MP*) + library_names_spec='$libname$shrext' + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + library_names_spec='$libname$shrext' + ;; + uts4*) + library_names_spec='$libname$shrext' + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' < Date: Fri, 1 Jan 2010 21:32:30 +0100 Subject: [PATCH 127/208] 2009-01-01 Yves Blusseau * configure.ac: check external intl library * Makefile.in: add compiler and linker flags to properly compile with intl library * include/grub/i18n.h: add a check to disable NLS * util/misc.c (grub_util_init_nls): new function * include/grub/util/misc.h: likewise * util/elf/grub-mkimage.c: use the new function below to initialize NLS * util/grub-editenv.c: likewise * util/grub-emu.c: likewise * util/grub-fstest.c: likewise * util/grub-mkdevicemap.c: likewise * util/grub-mkfont.c: likewise * util/grub-mkrelpath.c: likewise * util/grub-probe.c: likewise * util/i386/pc/grub-mkimage.c: likewise * util/i386/pc/grub-setup.c: likewise * util/sparc64/ieee1275/grub-mkimage.c: likewise * util/sparc64/ieee1275/grub-ofpathname.c: likewise * util/sparc64/ieee1275/grub-setup.c: likewise * util/mkisofs/mkisofs.h: add a check to disable NLS * util/mkisofs/mkisofs.c: likewise --- Makefile.in | 9 ++++-- configure.ac | 4 +-- include/grub/i18n.h | 41 ++++++++++++++++++++----- include/grub/util/misc.h | 4 ++- util/elf/grub-mkimage.c | 7 ++--- util/grub-editenv.c | 7 ++--- util/grub-emu.c | 7 ++--- util/grub-fstest.c | 7 ++--- util/grub-mkdevicemap.c | 7 ++--- util/grub-mkfont.c | 7 ++--- util/grub-mkrelpath.c | 7 ++--- util/grub-probe.c | 7 ++--- util/i386/pc/grub-mkimage.c | 7 ++--- util/i386/pc/grub-setup.c | 7 ++--- util/misc.c | 13 +++++++- util/mkisofs/mkisofs.c | 4 ++- util/mkisofs/mkisofs.h | 19 ++++++++++-- util/sparc64/ieee1275/grub-mkimage.c | 7 ++--- util/sparc64/ieee1275/grub-ofpathname.c | 7 ++--- util/sparc64/ieee1275/grub-setup.c | 7 ++--- 20 files changed, 115 insertions(+), 70 deletions(-) diff --git a/Makefile.in b/Makefile.in index 46b380cd5..927db2cee 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,6 @@ # -*- makefile -*- # -# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2002,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. +# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2002,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. # # This Makefile.in is free software; the author # gives unlimited permission to copy and/or distribute it, @@ -41,6 +41,9 @@ includedir = @includedir@ pkgdatadir = $(datadir)/`echo @PACKAGE_TARNAME@ | sed '$(transform)'` pkglibdir = $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed '$(transform)'` +# Internationalization library. +LIBINTL = @LIBINTL@ + XGETTEXT = @XGETTEXT@ MSGMERGE = @MSGMERGE@ MSGFMT = @MSGFMT@ @@ -72,10 +75,12 @@ MKDIR_P = @MKDIR_P@ mkinstalldirs = $(srcdir)/mkinstalldirs +LIBS = @LIBS@ $(LIBINTL) + CC = @CC@ CFLAGS = @CFLAGS@ ASFLAGS = @ASFLAGS@ -LDFLAGS = @LDFLAGS@ +LDFLAGS = @LDFLAGS@ $(LIBS) CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \ -DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\" TARGET_CC = @TARGET_CC@ diff --git a/configure.ac b/configure.ac index 3cac421e8..4b5b5dd5a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # Process this file with autoconf to produce a configure script. -# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. +# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. # # This configure.ac is free software; the author # gives unlimited permission to copy and/or distribute it, @@ -178,7 +178,7 @@ AC_PROG_CC test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required]) AC_GNU_SOURCE -AM_GNU_GETTEXT +AM_GNU_GETTEXT([external]) AC_SYS_LARGEFILE # Identify characteristics of the host architecture. diff --git a/include/grub/i18n.h b/include/grub/i18n.h index f6f468744..4d4a0b7bd 100644 --- a/include/grub/i18n.h +++ b/include/grub/i18n.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2009 Free Software Foundation, Inc. + * Copyright (C) 2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,17 +19,42 @@ #ifndef GRUB_I18N_H #define GRUB_I18N_H 1 -#ifdef GRUB_UTIL -# include -# include -# define _(str) gettext(str) -#else -# define _(str) grub_gettext(str) +#include +#include const char *EXPORT_FUNC(grub_gettext_dummy) (const char *s); extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s); -#endif +/* NLS can be disabled through the configure --disable-nls option. */ +#if ENABLE_NLS + +# ifdef GRUB_UTIL + +# include +# include + +# endif /* GRUB_UTIL */ + +#else /* ! ENABLE_NLS */ + +/* Disabled NLS. + The casts to 'const char *' serve the purpose of producing warnings + for invalid uses of the value returned from these functions. + On pre-ANSI systems without 'const', the config.h file is supposed to + contain "#define const". */ +# ifdef GRUB_UTIL +# define gettext(Msgid) ((const char *) (Msgid)) +# else +# define grub_gettext(str) ((const char *) (str)) +# endif /* GRUB_UTIL */ + +#endif /* ENABLE_NLS */ + +#ifdef GRUB_UTIL +# define _(str) gettext(str) +#else +# define _(str) grub_gettext(str) +#endif /* GRUB_UTIL */ #define N_(str) str diff --git a/include/grub/util/misc.h b/include/grub/util/misc.h index 09108547c..373fff8bb 100644 --- a/include/grub/util/misc.h +++ b/include/grub/util/misc.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -88,4 +88,6 @@ grub_int64_t grub_util_get_disk_size (char *name); char *make_system_path_relative_to_its_root (const char *path); +void grub_util_init_nls (void); + #endif /* ! GRUB_UTIL_MISC_HEADER */ diff --git a/util/elf/grub-mkimage.c b/util/elf/grub-mkimage.c index 5750543ad..6ba8b1ae2 100644 --- a/util/elf/grub-mkimage.c +++ b/util/elf/grub-mkimage.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -361,9 +361,8 @@ main (int argc, char *argv[]) int chrp = 0; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); while (1) { diff --git a/util/grub-editenv.c b/util/grub-editenv.c index 68fb23b15..b6b731549 100644 --- a/util/grub-editenv.c +++ b/util/grub-editenv.c @@ -1,7 +1,7 @@ /* grub-editenv.c - tool to edit environment block. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -256,9 +256,8 @@ main (int argc, char *argv[]) char *command; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); /* Check for options. */ while (1) diff --git a/util/grub-emu.c b/util/grub-emu.c index e65c8585e..3f2acaaec 100644 --- a/util/grub-emu.c +++ b/util/grub-emu.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -159,9 +159,8 @@ main (int argc, char *argv[]) int opt; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); while ((opt = getopt_long (argc, argv, "r:d:m:vH:hV", options, 0)) != -1) switch (opt) diff --git a/util/grub-fstest.c b/util/grub-fstest.c index fa54fe414..586dda0f9 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -1,7 +1,7 @@ /* grub-fstest.c - debug tool for filesystem driver */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -384,9 +384,8 @@ main (int argc, char *argv[]) int i, cmd, num_opts, image_index, num_disks = 1; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); /* Find the first non option entry. */ for (num_opts = 1; num_opts < argc; num_opts++) diff --git a/util/grub-mkdevicemap.c b/util/grub-mkdevicemap.c index 2b69f905e..b4febbb8d 100644 --- a/util/grub-mkdevicemap.c +++ b/util/grub-mkdevicemap.c @@ -1,7 +1,7 @@ /* grub-mkdevicemap.c - make a device map file automatically */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -112,9 +112,8 @@ main (int argc, char *argv[]) int floppy_disks = 1; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); /* Check for options. */ while (1) diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index 9775e0803..a358ba5b0 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2009 Free Software Foundation, Inc. + * Copyright (C) 2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -476,9 +476,8 @@ main (int argc, char *argv[]) memset (&font_info, 0, sizeof (font_info)); set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); /* Check for options. */ while (1) diff --git a/util/grub-mkrelpath.c b/util/grub-mkrelpath.c index 956e52ed7..62e400814 100644 --- a/util/grub-mkrelpath.c +++ b/util/grub-mkrelpath.c @@ -1,7 +1,7 @@ /* grub-mkrelpath.c - make a system path relative to its root */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2009 Free Software Foundation, Inc. + * Copyright (C) 2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,9 +56,8 @@ main (int argc, char *argv[]) char *argument, *relpath; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); /* Check for options. */ while (1) diff --git a/util/grub-probe.c b/util/grub-probe.c index ebf5142d4..4ba8a98e5 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -1,7 +1,7 @@ /* grub-probe.c - probe device information for a given path */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -338,9 +338,8 @@ main (int argc, char *argv[]) char *argument; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); /* Check for options. */ while (1) diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index 3c2cb7549..aaa1a13db 100644 --- a/util/i386/pc/grub-mkimage.c +++ b/util/i386/pc/grub-mkimage.c @@ -1,7 +1,7 @@ /* grub-mkimage.c - make a bootable image */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -351,9 +351,8 @@ main (int argc, char *argv[]) FILE *fp = stdout; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); while (1) { diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c index c2b9b9268..5a1cbb27a 100644 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@ -1,7 +1,7 @@ /* grub-setup.c - make GRUB usable */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -641,9 +641,8 @@ main (int argc, char *argv[]) int must_embed = 0, force = 0, fs_probe = 1; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); /* Check for options. */ while (1) diff --git a/util/misc.c b/util/misc.c index 6aa92fb64..d8aa041be 100644 --- a/util/misc.c +++ b/util/misc.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +38,7 @@ #include #include #include +#include #include "progname.h" @@ -566,3 +567,13 @@ make_system_path_relative_to_its_root (const char *path) return buf3; } + +void +grub_util_init_nls (void) +{ +#if ENABLE_NLS + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); +#endif /* ENABLE_NLS */ +} diff --git a/util/mkisofs/mkisofs.c b/util/mkisofs/mkisofs.c index 8e99d5c18..dffe4f703 100644 --- a/util/mkisofs/mkisofs.c +++ b/util/mkisofs/mkisofs.c @@ -6,7 +6,7 @@ Copyright 1993 Yggdrasil Computing, Incorporated - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009,2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -645,9 +645,11 @@ int FDECL2(main, int, argc, char **, argv){ char *log_file = 0; set_program_name (argv[0]); +#if ENABLE_NLS setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); +#endif /* ENABLE_NLS */ if (argc < 2) usage(); diff --git a/util/mkisofs/mkisofs.h b/util/mkisofs/mkisofs.h index 79ae50251..482db6ceb 100644 --- a/util/mkisofs/mkisofs.h +++ b/util/mkisofs/mkisofs.h @@ -5,7 +5,7 @@ Copyright 1993 Yggdrasil Computing, Incorporated - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009,2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,8 +30,21 @@ #include #include -#include -#include +#if ENABLE_NLS + +# include +# include + +#else /* ! ENABLE_NLS */ + +/* Disabled NLS. + The casts to 'const char *' serve the purpose of producing warnings + for invalid uses of the value returned from these functions. + On pre-ANSI systems without 'const', the config.h file is supposed to + contain "#define const". */ +# define gettext(Msgid) ((const char *) (Msgid)) +#endif /* ENABLE_NLS */ + #define _(str) gettext(str) #define N_(str) str diff --git a/util/sparc64/ieee1275/grub-mkimage.c b/util/sparc64/ieee1275/grub-mkimage.c index d756586af..b79bbeb41 100644 --- a/util/sparc64/ieee1275/grub-mkimage.c +++ b/util/sparc64/ieee1275/grub-mkimage.c @@ -1,7 +1,7 @@ /* grub-mkimage.c - make a bootable image */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -222,9 +222,8 @@ main (int argc, char *argv[]) FILE *fp = stdout; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_ls (); while (1) { diff --git a/util/sparc64/ieee1275/grub-ofpathname.c b/util/sparc64/ieee1275/grub-ofpathname.c index 166ce4cbe..3ac6fce8b 100644 --- a/util/sparc64/ieee1275/grub-ofpathname.c +++ b/util/sparc64/ieee1275/grub-ofpathname.c @@ -1,7 +1,7 @@ /* grub-ofpathname.c - Find OpenBOOT path for a given device */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2009 Free Software Foundation, Inc. + * Copyright (C) 2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,9 +29,8 @@ int main(int argc, char **argv) char *of_path; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); if (argc != 2) { diff --git a/util/sparc64/ieee1275/grub-setup.c b/util/sparc64/ieee1275/grub-setup.c index ade1bd595..9d8e67562 100644 --- a/util/sparc64/ieee1275/grub-setup.c +++ b/util/sparc64/ieee1275/grub-setup.c @@ -1,7 +1,7 @@ /* grub-setup.c - make GRUB usable */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -620,9 +620,8 @@ main (int argc, char *argv[]) struct grub_setup_info ginfo; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); init_info (&ginfo); if (!parse_options (&ginfo, argc, argv)) From b1c10d44120800299ca43c0757943e305a56f813 Mon Sep 17 00:00:00 2001 From: Yves Blusseau Date: Fri, 1 Jan 2010 21:41:59 +0100 Subject: [PATCH 128/208] 2009-01-01 Yves Blusseau * util/mkisofs/mkisofs.c: fix a warning about a bad cast when NLS is disabled --- util/mkisofs/mkisofs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/mkisofs/mkisofs.c b/util/mkisofs/mkisofs.c index dffe4f703..588345232 100644 --- a/util/mkisofs/mkisofs.c +++ b/util/mkisofs/mkisofs.c @@ -490,7 +490,7 @@ void usage(){ int comma; int len; unsigned int j; - char *arg; + const char *arg; printf (" "); From 18f81dfc029736979a16b2cdea80aa29abfb2937 Mon Sep 17 00:00:00 2001 From: Yves Blusseau Date: Fri, 1 Jan 2010 22:48:52 +0100 Subject: [PATCH 129/208] 2010-01-01 Yves Blusseau * kern/misc.c (memcmp): add missing memcmp "alias" function for Apple platforms (memset): add missing memset "alias" function for Apple platforms --- kern/misc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kern/misc.c b/kern/misc.c index f6d189e94..63007510e 100644 --- a/kern/misc.c +++ b/kern/misc.c @@ -1,7 +1,7 @@ /* misc.c - definitions of misc functions */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -227,6 +227,11 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n) #ifndef APPLE_CC int memcmp (const void *s1, const void *s2, grub_size_t n) __attribute__ ((alias ("grub_memcmp"))); +#else +int memcmp (const void *s1, const void *s2, grub_size_t n) +{ + return grub_memcmp (s1, s2, n); +} #endif int @@ -512,6 +517,11 @@ grub_memset (void *s, int c, grub_size_t n) #ifndef APPLE_CC void *memset (void *s, int c, grub_size_t n) __attribute__ ((alias ("grub_memset"))); +#else +void *memset (void *s, int c, grub_size_t n) +{ + return grub_memset (s, c, n); +} #endif grub_size_t From da8d5c53e9f0fa207c259e7713518aa6a21119a5 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 2 Jan 2010 15:19:57 +0000 Subject: [PATCH 130/208] 2010-01-02 Colin Watson * term/i386/pc/at_keyboard.c (keyboard_controller_wait_untill_ready): Rename to ... (keyboard_controller_wait_until_ready): ... this. Update all users. --- ChangeLog | 6 ++++++ term/i386/pc/at_keyboard.c | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 634e8aad0..3b7ccab32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-02 Colin Watson + + * term/i386/pc/at_keyboard.c + (keyboard_controller_wait_untill_ready): Rename to ... + (keyboard_controller_wait_until_ready): ... this. Update all users. + 2010-01-01 Carles Pina i Estany * commands/help.c: Include `grub/mm.h' and `grub/normal.h'. diff --git a/term/i386/pc/at_keyboard.c b/term/i386/pc/at_keyboard.c index 4ad60c65c..6382c954a 100644 --- a/term/i386/pc/at_keyboard.c +++ b/term/i386/pc/at_keyboard.c @@ -72,7 +72,7 @@ static char keyboard_map_shift[128] = static grub_uint8_t grub_keyboard_controller_orig; static void -keyboard_controller_wait_untill_ready (void) +keyboard_controller_wait_until_ready (void) { while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))); } @@ -80,7 +80,7 @@ keyboard_controller_wait_untill_ready (void) static void grub_keyboard_controller_write (grub_uint8_t c) { - keyboard_controller_wait_untill_ready (); + keyboard_controller_wait_until_ready (); grub_outb (KEYBOARD_COMMAND_WRITE, KEYBOARD_REG_STATUS); grub_outb (c, KEYBOARD_REG_DATA); } @@ -88,7 +88,7 @@ grub_keyboard_controller_write (grub_uint8_t c) static grub_uint8_t grub_keyboard_controller_read (void) { - keyboard_controller_wait_untill_ready (); + keyboard_controller_wait_until_ready (); grub_outb (KEYBOARD_COMMAND_READ, KEYBOARD_REG_STATUS); return grub_inb (KEYBOARD_REG_DATA); } @@ -96,9 +96,9 @@ grub_keyboard_controller_read (void) static void keyboard_controller_led (grub_uint8_t leds) { - keyboard_controller_wait_untill_ready (); + keyboard_controller_wait_until_ready (); grub_outb (0xed, KEYBOARD_REG_DATA); - keyboard_controller_wait_untill_ready (); + keyboard_controller_wait_until_ready (); grub_outb (leds & 0x7, KEYBOARD_REG_DATA); } From 77a795923bd2fdde4b27233c0d7a918d46ce68ed Mon Sep 17 00:00:00 2001 From: carles Date: Sun, 3 Jan 2010 19:24:22 +0100 Subject: [PATCH 131/208] 2010-01-03 Carles Pina i Estany * commands/acpi.c: Gettextizze help strings and/or options. Include `grub/i18n.h' if needed. * commands/blocklist.c: Likewise. * commands/boot.c: Likewise. * commands/cat.c: Likewise. * commands/cmp.c: Likewise. * commands/configfile.c: Likewise. * commands/crc.c: Likewise. * commands/date.c: Likewise. * commands/echo.c: Likewise. * commands/efi/fixvideo.c: Likewise. * commands/efi/loadbios.c: Likewise. * commands/gptsync.c: Likewise. * commands/halt.c: Likewise. * commands/handler.c: Likewise. * commands/hdparm.c: Likewise. * commands/hexdump.c: Likewise. * commands/i386/cpuid.c: Likewise. * commands/i386/pc/drivemap.c: Likewise. * commands/i386/pc/halt.c: Likewise. * commands/i386/pc/pxecmd.c: Likewise. * commands/i386/pc/vbeinfo.c: Likewise. * commands/i386/pc/vbetest.c: Likewise. * commands/ieee1275/suspend.c: Likewise. * commands/keystatus.c: Likewise. * commands/loadenv.c: Likewise. * commands/ls.c: Likewise. * commands/lsmmap.c: Likewise. * commands/lspci.c: Likewise. * commands/memrw.c: Likewise. * commands/minicmd.c: Likewise. * commands/parttool.c: Likewise. * commands/password.c: Likewise. * commands/probe.c: Likewise. * commands/read.c: Likewise. * commands/reboot.c: Likewise. * commands/search.c: Likewise. * commands/sleep.c: Likewise. * commands/test.c: Likewise. * commands/true.c: Likewise. * commands/usbtest.c: Likewise. * commands/videotest.c: Likewise. * commands/xnu_uuid.c: Likewise. * disk/loopback.c: Likewise. * hello/hello.c: Likewise. * loader/i386/bsd.c: Likewise. * term/i386/pc/serial.c: Likewise. * po/POTFILES: Add new files. --- ChangeLog | 51 ++++++++++++++++++++++++++ commands/acpi.c | 31 ++++++++-------- commands/blocklist.c | 3 +- commands/boot.c | 3 +- commands/cat.c | 3 +- commands/cmp.c | 3 +- commands/configfile.c | 11 +++--- commands/crc.c | 5 ++- commands/date.c | 5 ++- commands/echo.c | 7 ++-- commands/efi/fixvideo.c | 3 +- commands/efi/loadbios.c | 5 ++- commands/gptsync.c | 7 ++-- commands/halt.c | 5 ++- commands/handler.c | 13 ++++--- commands/hdparm.c | 35 +++++++++--------- commands/hexdump.c | 9 +++-- commands/i386/cpuid.c | 5 ++- commands/i386/pc/drivemap.c | 11 +++--- commands/i386/pc/halt.c | 5 ++- commands/i386/pc/pxecmd.c | 3 +- commands/i386/pc/vbeinfo.c | 3 +- commands/i386/pc/vbetest.c | 3 +- commands/ieee1275/suspend.c | 3 +- commands/keystatus.c | 11 +++--- commands/loadenv.c | 3 +- commands/ls.c | 11 +++--- commands/lsmmap.c | 3 +- commands/lspci.c | 3 +- commands/memrw.c | 15 ++++---- commands/minicmd.c | 17 +++++---- commands/parttool.c | 3 +- commands/password.c | 7 ++-- commands/probe.c | 17 +++++---- commands/read.c | 5 ++- commands/reboot.c | 3 +- commands/search.c | 2 +- commands/sleep.c | 9 +++-- commands/test.c | 5 ++- commands/true.c | 5 ++- commands/usbtest.c | 3 +- commands/videotest.c | 3 +- commands/xnu_uuid.c | 7 ++-- disk/loopback.c | 9 +++-- hello/hello.c | 3 +- loader/i386/bsd.c | 73 +++++++++++++++++++------------------ po/POTFILES | 55 ++++++++++++++++++++++++++-- term/i386/pc/serial.c | 17 +++++---- 48 files changed, 333 insertions(+), 188 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3b7ccab32..7da0c929e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,54 @@ +2010-01-03 Carles Pina i Estany + + * commands/acpi.c: Gettextizze help strings and/or options. Include + `grub/i18n.h' if needed. + * commands/blocklist.c: Likewise. + * commands/boot.c: Likewise. + * commands/cat.c: Likewise. + * commands/cmp.c: Likewise. + * commands/configfile.c: Likewise. + * commands/crc.c: Likewise. + * commands/date.c: Likewise. + * commands/echo.c: Likewise. + * commands/efi/fixvideo.c: Likewise. + * commands/efi/loadbios.c: Likewise. + * commands/gptsync.c: Likewise. + * commands/halt.c: Likewise. + * commands/handler.c: Likewise. + * commands/hdparm.c: Likewise. + * commands/hexdump.c: Likewise. + * commands/i386/cpuid.c: Likewise. + * commands/i386/pc/drivemap.c: Likewise. + * commands/i386/pc/halt.c: Likewise. + * commands/i386/pc/pxecmd.c: Likewise. + * commands/i386/pc/vbeinfo.c: Likewise. + * commands/i386/pc/vbetest.c: Likewise. + * commands/ieee1275/suspend.c: Likewise. + * commands/keystatus.c: Likewise. + * commands/loadenv.c: Likewise. + * commands/ls.c: Likewise. + * commands/lsmmap.c: Likewise. + * commands/lspci.c: Likewise. + * commands/memrw.c: Likewise. + * commands/minicmd.c: Likewise. + * commands/parttool.c: Likewise. + * commands/password.c: Likewise. + * commands/probe.c: Likewise. + * commands/read.c: Likewise. + * commands/reboot.c: Likewise. + * commands/search.c: Likewise. + * commands/sleep.c: Likewise. + * commands/test.c: Likewise. + * commands/true.c: Likewise. + * commands/usbtest.c: Likewise. + * commands/videotest.c: Likewise. + * commands/xnu_uuid.c: Likewise. + * disk/loopback.c: Likewise. + * hello/hello.c: Likewise. + * loader/i386/bsd.c: Likewise. + * term/i386/pc/serial.c: Likewise. + * po/POTFILES: Add new files. + 2010-01-02 Colin Watson * term/i386/pc/at_keyboard.c diff --git a/commands/acpi.c b/commands/acpi.c index ce4e2db36..4d54539fd 100644 --- a/commands/acpi.c +++ b/commands/acpi.c @@ -28,6 +28,7 @@ #include #include #include +#include #ifdef GRUB_MACHINE_EFI #include @@ -36,23 +37,23 @@ static const struct grub_arg_option options[] = { {"exclude", 'x', 0, - "Don't load host tables specified by comma-separated list.", + N_("Don't load host tables specified by comma-separated list."), 0, ARG_TYPE_STRING}, {"load-only", 'n', 0, - "Load only tables specified by comma-separated list.", 0, ARG_TYPE_STRING}, - {"v1", '1', 0, "Expose v1 tables.", 0, ARG_TYPE_NONE}, - {"v2", '2', 0, "Expose v2 and v3 tables.", 0, ARG_TYPE_NONE}, - {"oemid", 'o', 0, "Set OEMID of RSDP, XSDT and RSDT.", 0, ARG_TYPE_STRING}, + N_("Load only tables specified by comma-separated list."), 0, ARG_TYPE_STRING}, + {"v1", '1', 0, N_("Expose v1 tables."), 0, ARG_TYPE_NONE}, + {"v2", '2', 0, N_("Expose v2 and v3 tables."), 0, ARG_TYPE_NONE}, + {"oemid", 'o', 0, N_("Set OEMID of RSDP, XSDT and RSDT."), 0, ARG_TYPE_STRING}, {"oemtable", 't', 0, - "Set OEMTABLE ID of RSDP, XSDT and RSDT.", 0, ARG_TYPE_STRING}, + N_("Set OEMTABLE ID of RSDP, XSDT and RSDT."), 0, ARG_TYPE_STRING}, {"oemtablerev", 'r', 0, - "Set OEMTABLE revision of RSDP, XSDT and RSDT.", 0, ARG_TYPE_INT}, + N_("Set OEMTABLE revision of RSDP, XSDT and RSDT."), 0, ARG_TYPE_INT}, {"oemtablecreator", 'c', 0, - "Set creator field of RSDP, XSDT and RSDT.", 0, ARG_TYPE_STRING}, + N_("Set creator field of RSDP, XSDT and RSDT."), 0, ARG_TYPE_STRING}, {"oemtablecreatorrev", 'd', 0, - "Set creator revision of RSDP, XSDT and RSDT.", 0, ARG_TYPE_INT}, - {"no-ebda", 'e', 0, "Don't update EBDA. May fix failures or hangs on some." - " BIOSes but makes it ineffective with OS not receiving RSDP from GRUB.", + N_("Set creator revision of RSDP, XSDT and RSDT."), 0, ARG_TYPE_INT}, + {"no-ebda", 'e', 0, N_("Don't update EBDA. May fix failures or hangs on some." + " BIOSes but makes it ineffective with OS not receiving RSDP from GRUB."), 0, ARG_TYPE_NONE}, {0, 0, 0, 0, 0, 0} }; @@ -759,11 +760,11 @@ GRUB_MOD_INIT(acpi) { cmd = grub_register_extcmd ("acpi", grub_cmd_acpi, GRUB_COMMAND_FLAG_BOTH, - "[-1|-2] [--exclude=table1,table2|" + N_("[-1|-2] [--exclude=table1,table2|" "--load-only=table1,table2] filename1 " - " [filename2] [...]", - "Load host acpi tables and tables " - "specified by arguments.", + " [filename2] [...]"), + N_("Load host acpi tables and tables " + "specified by arguments."), options); } diff --git a/commands/blocklist.c b/commands/blocklist.c index 3c9ef3a58..fec59a828 100644 --- a/commands/blocklist.c +++ b/commands/blocklist.c @@ -24,6 +24,7 @@ #include #include #include +#include static grub_err_t grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)), @@ -110,7 +111,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(blocklist) { cmd = grub_register_command ("blocklist", grub_cmd_blocklist, - "FILE", "Print a block list."); + N_("FILE"), N_("Print a block list.")); } GRUB_MOD_FINI(blocklist) diff --git a/commands/boot.c b/commands/boot.c index fe0453b8a..1ec1e6f77 100644 --- a/commands/boot.c +++ b/commands/boot.c @@ -23,6 +23,7 @@ #include #include #include +#include static grub_err_t (*grub_loader_boot_func) (void); static grub_err_t (*grub_loader_unload_func) (void); @@ -186,7 +187,7 @@ GRUB_MOD_INIT(boot) { cmd_boot = grub_register_command ("boot", grub_cmd_boot, - 0, "Boot an operating system."); + 0, N_("Boot an operating system.")); } GRUB_MOD_FINI(boot) diff --git a/commands/cat.c b/commands/cat.c index 9d0373b3a..844034777 100644 --- a/commands/cat.c +++ b/commands/cat.c @@ -24,6 +24,7 @@ #include #include #include +#include static grub_err_t grub_cmd_cat (grub_command_t cmd __attribute__ ((unused)), @@ -78,7 +79,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(cat) { cmd = grub_register_command_p1 ("cat", grub_cmd_cat, - "FILE", "Show the contents of a file."); + N_("FILE"), N_("Show the contents of a file.")); } GRUB_MOD_FINI(cat) diff --git a/commands/cmp.c b/commands/cmp.c index bdd8ff82d..8fd939640 100644 --- a/commands/cmp.c +++ b/commands/cmp.c @@ -23,6 +23,7 @@ #include #include #include +#include #define BUFFER_SIZE 512 @@ -109,7 +110,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(cmp) { cmd = grub_register_command ("cmp", grub_cmd_cmp, - "FILE1 FILE2", "Compare two files."); + N_("FILE1 FILE2"), N_("Compare two files.")); } GRUB_MOD_FINI(cmp) diff --git a/commands/configfile.c b/commands/configfile.c index d1fe9169e..469447711 100644 --- a/commands/configfile.c +++ b/commands/configfile.c @@ -22,6 +22,7 @@ #include #include #include +#include static grub_err_t grub_cmd_source (grub_command_t cmd, int argc, char **args) @@ -53,16 +54,16 @@ GRUB_MOD_INIT(configfile) { cmd_configfile = grub_register_command ("configfile", grub_cmd_source, - "FILE", "Load another config file."); + N_("FILE"), N_("Load another config file.")); cmd_source = grub_register_command ("source", grub_cmd_source, - "FILE", - "Load another config file without changing context." + N_("FILE"), + N_("Load another config file without changing context.") ); cmd_dot = grub_register_command (".", grub_cmd_source, - "FILE", - "Load another config file without changing context." + N_("FILE"), + N_("Load another config file without changing context.") ); } diff --git a/commands/crc.c b/commands/crc.c index a6c17caf0..dff9fd55c 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -23,6 +23,7 @@ #include #include #include +#include static grub_err_t grub_cmd_crc (grub_command_t cmd __attribute__ ((unused)), @@ -57,8 +58,8 @@ static grub_command_t cmd; GRUB_MOD_INIT(crc) { cmd = grub_register_command ("crc", grub_cmd_crc, - "FILE", - "Calculate the crc32 checksum of a file."); + N_("FILE"), + N_("Calculate the crc32 checksum of a file.")); } GRUB_MOD_FINI(crc) diff --git a/commands/date.c b/commands/date.c index 7197b066e..623db4943 100644 --- a/commands/date.c +++ b/commands/date.c @@ -22,6 +22,7 @@ #include #include #include +#include #define GRUB_DATETIME_SET_YEAR 1 #define GRUB_DATETIME_SET_MONTH 2 @@ -135,8 +136,8 @@ GRUB_MOD_INIT(date) { cmd = grub_register_command ("date", grub_cmd_date, - "[[year-]month-day] [hour:minute[:second]]", - "Command to display/set current datetime."); + N_("[[year-]month-day] [hour:minute[:second]]"), + N_("Command to display/set current datetime.")); } GRUB_MOD_FINI(date) diff --git a/commands/echo.c b/commands/echo.c index 4d5a59df3..4fea091cb 100644 --- a/commands/echo.c +++ b/commands/echo.c @@ -20,11 +20,12 @@ #include #include #include +#include static const struct grub_arg_option options[] = { - {0, 'n', 0, "Do not output the trailing newline.", 0, 0}, - {0, 'e', 0, "Enable interpretation of backslash escapes.", 0, 0}, + {0, 'n', 0, N_("Do not output the trailing newline."), 0, 0}, + {0, 'e', 0, N_("Enable interpretation of backslash escapes."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -113,7 +114,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(echo) { cmd = grub_register_extcmd ("echo", grub_cmd_echo, GRUB_COMMAND_FLAG_BOTH, - "[-e|-n] STRING", "Display a line of text.", + N_("[-e|-n] STRING"), N_("Display a line of text."), options); } diff --git a/commands/efi/fixvideo.c b/commands/efi/fixvideo.c index 685662237..0f821b7a2 100644 --- a/commands/efi/fixvideo.c +++ b/commands/efi/fixvideo.c @@ -22,6 +22,7 @@ #include #include #include +#include static struct grub_video_patch { @@ -99,7 +100,7 @@ static grub_command_t cmd_fixvideo; GRUB_MOD_INIT(fixvideo) { cmd_fixvideo = grub_register_command ("fix_video", grub_cmd_fixvideo, - 0, "Fix video problem."); + 0, N_("Fix video problem.")); } diff --git a/commands/efi/loadbios.c b/commands/efi/loadbios.c index de975c724..0f0d7bc10 100644 --- a/commands/efi/loadbios.c +++ b/commands/efi/loadbios.c @@ -23,6 +23,7 @@ #include #include #include +#include static grub_efi_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID; static grub_efi_guid_t acpi2_guid = GRUB_EFI_ACPI_20_TABLE_GUID; @@ -201,11 +202,11 @@ static grub_command_t cmd_fakebios, cmd_loadbios; GRUB_MOD_INIT(loadbios) { cmd_fakebios = grub_register_command ("fakebios", grub_cmd_fakebios, - 0, "Fake bios."); + 0, N_("Fake bios.")); cmd_loadbios = grub_register_command ("loadbios", grub_cmd_loadbios, "BIOS_DUMP [INT10_DUMP]", - "Load bios dump."); + N_("Load bios dump.")); } GRUB_MOD_FINI(loadbios) diff --git a/commands/gptsync.c b/commands/gptsync.c index b5fe0b8ed..d217b5d5c 100644 --- a/commands/gptsync.c +++ b/commands/gptsync.c @@ -27,6 +27,7 @@ #include #include #include +#include /* Convert a LBA address to a CHS address in the INT 13 format. */ /* Taken from grub1. */ @@ -240,13 +241,13 @@ GRUB_MOD_INIT(gptsync) { (void) mod; /* To stop warning. */ cmd = grub_register_command ("gptsync", grub_cmd_gptsync, - "DEVICE [PARTITION[+/-[TYPE]]] ...", - "Fill hybrid MBR of GPT drive DEVICE. " + N_("DEVICE [PARTITION[+/-[TYPE]]] ..."), + N_("Fill hybrid MBR of GPT drive DEVICE. " "specified partitions will be a part " "of hybrid mbr. Up to 3 partitions are " "allowed. TYPE is an MBR type. " "+ means that partition is active. " - "Only one partition can be active."); + "Only one partition can be active.")); } GRUB_MOD_FINI(gptsync) diff --git a/commands/halt.c b/commands/halt.c index 09431d3cb..3400115a0 100644 --- a/commands/halt.c +++ b/commands/halt.c @@ -20,6 +20,7 @@ #include #include #include +#include static grub_err_t grub_cmd_halt (grub_command_t cmd __attribute__ ((unused)), @@ -35,8 +36,8 @@ static grub_command_t cmd; GRUB_MOD_INIT(halt) { cmd = grub_register_command ("halt", grub_cmd_halt, - 0, "Halts the computer. This command does not" - " work on all firmware implementations."); + 0, N_("Halts the computer. This command does" + " not work on all firmware implementations.")); } GRUB_MOD_FINI(halt) diff --git a/commands/handler.c b/commands/handler.c index 09b8ff5d0..7316db304 100644 --- a/commands/handler.c +++ b/commands/handler.c @@ -23,6 +23,7 @@ #include #include #include +#include static grub_err_t grub_cmd_handler (struct grub_command *cmd, @@ -95,16 +96,16 @@ GRUB_MOD_INIT(handler) { cmd_handler = grub_register_command ("handler", grub_cmd_handler, - "[class [handler]]", - "List or select a handler."); + N_("[class [handler]]"), + N_("List or select a handler.")); cmd_terminal_input = grub_register_command ("terminal_input", grub_cmd_handler, - "[handler]", - "List or select an input terminal."); + N_("[handler]"), + N_("List or select an input terminal.")); cmd_terminal_output = grub_register_command ("terminal_output", grub_cmd_handler, - "[handler]", - "List or select an output terminal."); + N_("[handler]"), + N_("List or select an output terminal.")); } GRUB_MOD_FINI(handler) diff --git a/commands/hdparm.c b/commands/hdparm.c index fbcd7f6a8..a3f8bbff0 100644 --- a/commands/hdparm.c +++ b/commands/hdparm.c @@ -24,29 +24,30 @@ #include #include #include +#include static const struct grub_arg_option options[] = { - {"apm", 'B', 0, "Set Advanced Power Management\n" - "(1=low, ..., 254=high, 255=off).", + {"apm", 'B', 0, N_("Set Advanced Power Management\n" + "(1=low, ..., 254=high, 255=off)."), 0, ARG_TYPE_INT}, - {"power", 'C', 0, "Check power mode.", 0, ARG_TYPE_NONE}, - {"security-freeze", 'F', 0, "Freeze ATA security settings until reset.", + {"power", 'C', 0, N_("Check power mode."), 0, ARG_TYPE_NONE}, + {"security-freeze", 'F', 0, N_("Freeze ATA security settings until reset."), 0, ARG_TYPE_NONE}, - {"health", 'H', 0, "Check SMART health status.", 0, ARG_TYPE_NONE}, - {"aam", 'M', 0, "Set Automatic Acoustic Management\n" - "(0=off, 128=quiet, ..., 254=fast).", + {"health", 'H', 0, N_("Check SMART health status."), 0, ARG_TYPE_NONE}, + {"aam", 'M', 0, N_("Set Automatic Acoustic Management\n" + "(0=off, 128=quiet, ..., 254=fast)."), 0, ARG_TYPE_INT}, - {"standby-timeout", 'S', 0, "Set standby timeout\n" - "(0=off, 1=5s, 2=10s, ..., 240=20m, 241=30m, ...).", + {"standby-timeout", 'S', 0, N_("Set standby timeout\n" + "(0=off, 1=5s, 2=10s, ..., 240=20m, 241=30m, ...)."), 0, ARG_TYPE_INT}, - {"standby", 'y', 0, "Set drive to standby mode.", 0, ARG_TYPE_NONE}, - {"sleep", 'Y', 0, "Set drive to sleep mode.", 0, ARG_TYPE_NONE}, - {"identify", 'i', 0, "Print drive identity and settings.", + {"standby", 'y', 0, N_("Set drive to standby mode."), 0, ARG_TYPE_NONE}, + {"sleep", 'Y', 0, N_("Set drive to sleep mode."), 0, ARG_TYPE_NONE}, + {"identify", 'i', 0, N_("Print drive identity and settings."), 0, ARG_TYPE_NONE}, - {"dumpid", 'I', 0, "Dump contents of ATA IDENTIFY sector.", + {"dumpid", 'I', 0, N_("Dump contents of ATA IDENTIFY sector."), 0, ARG_TYPE_NONE}, - {"smart", -1, 0, "Disable/enable SMART (0/1).", 0, ARG_TYPE_INT}, - {"quiet", 'q', 0, "Do not print messages.", 0, ARG_TYPE_NONE}, + {"smart", -1, 0, N_("Disable/enable SMART (0/1)."), 0, ARG_TYPE_INT}, + {"quiet", 'q', 0, N_("Do not print messages."), 0, ARG_TYPE_NONE}, {0, 0, 0, 0, 0, 0} }; @@ -410,8 +411,8 @@ GRUB_MOD_INIT(hdparm) { cmd = grub_register_extcmd ("hdparm", grub_cmd_hdparm, GRUB_COMMAND_FLAG_BOTH, - "[OPTIONS] DISK", - "Get/set ATA disk parameters.", options); + N_("[OPTIONS] DISK"), + N_("Get/set ATA disk parameters."), options); } GRUB_MOD_FINI(hdparm) diff --git a/commands/hexdump.c b/commands/hexdump.c index 771cde34d..5bdbb1f76 100644 --- a/commands/hexdump.c +++ b/commands/hexdump.c @@ -24,11 +24,12 @@ #include #include #include +#include static const struct grub_arg_option options[] = { - {"skip", 's', 0, "Skip offset bytes from the beginning of file.", 0, + {"skip", 's', 0, N_("Skip offset bytes from the beginning of file."), 0, ARG_TYPE_INT}, - {"length", 'n', 0, "Read only LENGTH bytes.", 0, ARG_TYPE_INT}, + {"length", 'n', 0, N_("Read only LENGTH bytes."), 0, ARG_TYPE_INT}, {0, 0, 0, 0, 0, 0} }; @@ -121,8 +122,8 @@ GRUB_MOD_INIT (hexdump) { cmd = grub_register_extcmd ("hexdump", grub_cmd_hexdump, GRUB_COMMAND_FLAG_BOTH, - "[OPTIONS] FILE_OR_DEVICE", - "Dump the contents of a file or memory.", + N_("[OPTIONS] FILE_OR_DEVICE"), + N_("Dump the contents of a file or memory."), options); } diff --git a/commands/i386/cpuid.c b/commands/i386/cpuid.c index b1752ca89..6eebf91a1 100644 --- a/commands/i386/cpuid.c +++ b/commands/i386/cpuid.c @@ -25,6 +25,7 @@ #include #include #include +#include #define cpuid(num,a,b,c,d) \ asm volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1" \ @@ -33,7 +34,7 @@ static const struct grub_arg_option options[] = { - {"long-mode", 'l', 0, "Check for long mode flag (default).", 0, 0}, + {"long-mode", 'l', 0, N_("Check for long mode flag (default)."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -88,7 +89,7 @@ done: #endif cmd = grub_register_extcmd ("cpuid", grub_cmd_cpuid, GRUB_COMMAND_FLAG_BOTH, - "[-l]", "Check for CPU features.", options); + "[-l]", N_("Check for CPU features."), options); } GRUB_MOD_FINI(cpuid) diff --git a/commands/i386/pc/drivemap.c b/commands/i386/pc/drivemap.c index adef57576..3d1dcf614 100644 --- a/commands/i386/pc/drivemap.c +++ b/commands/i386/pc/drivemap.c @@ -26,6 +26,7 @@ #include #include #include +#include /* Real mode IVT slot (seg:off far pointer) for interrupt 0x13. */ @@ -33,9 +34,9 @@ static grub_uint32_t *const int13slot = UINT_TO_PTR (4 * 0x13); /* Remember to update enum opt_idxs accordingly. */ static const struct grub_arg_option options[] = { - {"list", 'l', 0, "Show the current mappings.", 0, 0}, - {"reset", 'r', 0, "Reset all mappings to the default values.", 0, 0}, - {"swap", 's', 0, "Perform both direct and reverse mappings.", 0, 0}, + {"list", 'l', 0, N_("Show the current mappings."), 0, 0}, + {"reset", 'r', 0, N_("Reset all mappings to the default values."), 0, 0}, + {"swap", 's', 0, N_("Perform both direct and reverse mappings."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -403,8 +404,8 @@ GRUB_MOD_INIT (drivemap) cmd = grub_register_extcmd ("drivemap", grub_cmd_drivemap, GRUB_COMMAND_FLAG_BOTH, "drivemap" - " -l | -r | [-s] grubdev osdisk", - "Manage the BIOS drive mappings.", + N_(" -l | -r | [-s] grubdev osdisk"), + N_("Manage the BIOS drive mappings."), options); drivemap_hook = grub_loader_register_preboot_hook (&install_int13_handler, diff --git a/commands/i386/pc/halt.c b/commands/i386/pc/halt.c index c2e22882f..73c3a2e11 100644 --- a/commands/i386/pc/halt.c +++ b/commands/i386/pc/halt.c @@ -20,10 +20,11 @@ #include #include #include +#include static const struct grub_arg_option options[] = { - {"no-apm", 'n', 0, "Do not use APM to halt the computer.", 0, 0}, + {"no-apm", 'n', 0, N_("Do not use APM to halt the computer."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -47,7 +48,7 @@ GRUB_MOD_INIT(halt) { cmd = grub_register_extcmd ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH, "[-n]", - "Halt the system, if possible using APM.", + N_("Halt the system, if possible using APM."), options); } diff --git a/commands/i386/pc/pxecmd.c b/commands/i386/pc/pxecmd.c index 1d4fb6a4d..b576a8ea4 100644 --- a/commands/i386/pc/pxecmd.c +++ b/commands/i386/pc/pxecmd.c @@ -22,6 +22,7 @@ #include #include #include +#include static grub_err_t grub_cmd_pxe_unload (grub_command_t cmd __attribute__ ((unused)), @@ -42,7 +43,7 @@ GRUB_MOD_INIT(pxecmd) { cmd = grub_register_command ("pxe_unload", grub_cmd_pxe_unload, 0, - "Unload PXE environment."); + N_("Unload PXE environment.")); } GRUB_MOD_FINI(pxecmd) diff --git a/commands/i386/pc/vbeinfo.c b/commands/i386/pc/vbeinfo.c index ee9f3c186..14f03846e 100644 --- a/commands/i386/pc/vbeinfo.c +++ b/commands/i386/pc/vbeinfo.c @@ -24,6 +24,7 @@ #include #include #include +#include static void * real2pm (grub_vbe_farptr_t ptr) @@ -175,7 +176,7 @@ GRUB_MOD_INIT(vbeinfo) { cmd = grub_register_command ("vbeinfo", grub_cmd_vbeinfo, 0, - "List compatible VESA BIOS extension video modes."); + N_("List compatible VESA BIOS extension video modes.")); } GRUB_MOD_FINI(vbeinfo) diff --git a/commands/i386/pc/vbetest.c b/commands/i386/pc/vbetest.c index 4050c869e..d97323087 100644 --- a/commands/i386/pc/vbetest.c +++ b/commands/i386/pc/vbetest.c @@ -25,6 +25,7 @@ #include #include #include +#include static grub_err_t grub_cmd_vbetest (grub_command_t cmd __attribute__ ((unused)), @@ -168,7 +169,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(vbetest) { cmd = grub_register_command ("vbetest", grub_cmd_vbetest, - 0, "Test VESA BIOS Extension 2.0+ support."); + 0, N_("Test VESA BIOS Extension 2.0+ support.")); } GRUB_MOD_FINI(vbetest) diff --git a/commands/ieee1275/suspend.c b/commands/ieee1275/suspend.c index fd538f8ea..f096cc9ba 100644 --- a/commands/ieee1275/suspend.c +++ b/commands/ieee1275/suspend.c @@ -22,6 +22,7 @@ #include #include #include +#include static grub_err_t grub_cmd_suspend (grub_command_t cmd __attribute__ ((unused)), @@ -39,7 +40,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(ieee1275_suspend) { cmd = grub_register_command ("suspend", grub_cmd_suspend, - 0, "Return to Open Firmware prompt."); + 0, N_("Return to Open Firmware prompt.")); } GRUB_MOD_FINI(ieee1275_suspend) diff --git a/commands/keystatus.c b/commands/keystatus.c index 4f82550be..a0a429284 100644 --- a/commands/keystatus.c +++ b/commands/keystatus.c @@ -21,12 +21,13 @@ #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}, + {"shift", 's', 0, N_("Check Shift key."), 0, 0}, + {"ctrl", 'c', 0, N_("Check Control key."), 0, 0}, + {"alt", 'a', 0, N_("Check Alt key."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -70,8 +71,8 @@ GRUB_MOD_INIT(keystatus) { cmd = grub_register_extcmd ("keystatus", grub_cmd_keystatus, GRUB_COMMAND_FLAG_BOTH, - "[--shift] [--ctrl] [--alt]", - "Check key modifier status.", + N_("[--shift] [--ctrl] [--alt]"), + N_("Check key modifier status."), options); } diff --git a/commands/loadenv.c b/commands/loadenv.c index 6ee4d204a..6f8714411 100644 --- a/commands/loadenv.c +++ b/commands/loadenv.c @@ -26,10 +26,11 @@ #include #include #include +#include static const struct grub_arg_option options[] = { - {"file", 'f', 0, "Specify filename.", 0, ARG_TYPE_PATHNAME}, + {"file", 'f', 0, N_("Specify filename."), 0, ARG_TYPE_PATHNAME}, {0, 0, 0, 0, 0, 0} }; diff --git a/commands/ls.c b/commands/ls.c index 4b1500398..9afca7907 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -30,12 +30,13 @@ #include #include #include +#include static const struct grub_arg_option options[] = { - {"long", 'l', 0, "Show a long list with more detailed information.", 0, 0}, - {"human-readable", 'h', 0, "Print sizes in a human readable format.", 0, 0}, - {"all", 'a', 0, "List all files.", 0, 0}, + {"long", 'l', 0, N_("Show a long list with more detailed information."), 0, 0}, + {"human-readable", 'h', 0, N_("Print sizes in a human readable format."), 0, 0}, + {"all", 'a', 0, N_("List all files."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -260,8 +261,8 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(ls) { cmd = grub_register_extcmd ("ls", grub_cmd_ls, GRUB_COMMAND_FLAG_BOTH, - "[-l|-h|-a] [FILE]", - "List devices and files.", options); + N_("[-l|-h|-a] [FILE]"), + N_("List devices and files."), options); } GRUB_MOD_FINI(ls) diff --git a/commands/lsmmap.c b/commands/lsmmap.c index 09f141ea0..d5eef1ce9 100644 --- a/commands/lsmmap.c +++ b/commands/lsmmap.c @@ -20,6 +20,7 @@ #include #include #include +#include static grub_err_t grub_cmd_lsmmap (grub_command_t cmd __attribute__ ((unused)), @@ -43,7 +44,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(lsmmap) { cmd = grub_register_command ("lsmmap", grub_cmd_lsmmap, - 0, "List memory map provided by firmware."); + 0, N_("List memory map provided by firmware.")); } GRUB_MOD_FINI(lsmmap) diff --git a/commands/lspci.c b/commands/lspci.c index 63e60abe0..c2abd8736 100644 --- a/commands/lspci.c +++ b/commands/lspci.c @@ -21,6 +21,7 @@ #include #include #include +#include struct grub_pci_classname { @@ -218,7 +219,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(lspci) { cmd = grub_register_extcmd ("lspci", grub_cmd_lspci, GRUB_COMMAND_FLAG_BOTH, - "[-i]", "List PCI devices.", options); + "[-i]", N_("List PCI devices."), options); } GRUB_MOD_FINI(lspci) diff --git a/commands/memrw.c b/commands/memrw.c index 8e9c3db11..d0908a237 100644 --- a/commands/memrw.c +++ b/commands/memrw.c @@ -21,13 +21,14 @@ #include #include #include +#include static grub_extcmd_t cmd_read_byte, cmd_read_word, cmd_read_dword; static grub_command_t cmd_write_byte, cmd_write_word, cmd_write_dword; static const struct grub_arg_option options[] = { - {0, 'v', 0, "Save read value into variable VARNAME.", + {0, 'v', 0, N_("Save read value into variable VARNAME."), "VARNAME", ARG_TYPE_STRING}, {0, 0, 0, 0, 0, 0} }; @@ -119,22 +120,22 @@ GRUB_MOD_INIT(memrw) { cmd_read_byte = grub_register_extcmd ("read_byte", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, - "ADDR", "Read byte from ADDR.", options); + N_("ADDR"), N_("Read byte from ADDR."), options); cmd_read_word = grub_register_extcmd ("read_word", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, - "ADDR", "Read word from ADDR.", options); + N_("ADDR"), N_("Read word from ADDR."), options); cmd_read_dword = grub_register_extcmd ("read_dword", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH, - "ADDR", "Read dword from ADDR.", options); + N_("ADDR"), N_("Read dword from ADDR."), options); cmd_write_byte = grub_register_command ("write_byte", grub_cmd_write, - "ADDR VALUE [MASK]", "Write byte VALUE to ADDR."); + N_("ADDR VALUE [MASK]"), N_("Write byte VALUE to ADDR.")); cmd_write_word = grub_register_command ("write_word", grub_cmd_write, - "ADDR VALUE [MASK]", "Write word VALUE to ADDR."); + N_("ADDR VALUE [MASK]"), N_("Write word VALUE to ADDR.")); cmd_write_dword = grub_register_command ("write_dword", grub_cmd_write, - "ADDR VALUE [MASK]", "Write dword VALUE to ADDR."); + N_("ADDR VALUE [MASK]"), N_("Write dword VALUE to ADDR.")); } GRUB_MOD_FINI(memrw) diff --git a/commands/minicmd.c b/commands/minicmd.c index 47b57e3ed..72e855faf 100644 --- a/commands/minicmd.c +++ b/commands/minicmd.c @@ -27,6 +27,7 @@ #include #include #include +#include /* cat FILE */ static grub_err_t @@ -354,28 +355,28 @@ GRUB_MOD_INIT(minicmd) { cmd_cat = grub_register_command ("cat", grub_mini_cmd_cat, - "FILE", "Show the contents of a file."); + N_("FILE"), N_("Show the contents of a file.")); cmd_help = grub_register_command ("help", grub_mini_cmd_help, - 0, "Show this message."); + 0, N_("Show this message.")); cmd_root = grub_register_command ("root", grub_mini_cmd_root, - "[DEVICE]", "Set the root device."); + N_("[DEVICE]"), N_("Set the root device.")); cmd_dump = grub_register_command ("dump", grub_mini_cmd_dump, - "ADDR", "Dump memory."); + N_("ADDR"), N_("Dump memory.")); cmd_rmmod = grub_register_command ("rmmod", grub_mini_cmd_rmmod, - "MODULE", "Remove a module."); + N_("MODULE"), N_("Remove a module.")); cmd_lsmod = grub_register_command ("lsmod", grub_mini_cmd_lsmod, - 0, "Show loaded modules."); + 0, N_("Show loaded modules.")); cmd_exit = grub_register_command ("exit", grub_mini_cmd_exit, - 0, "Exit from GRUB."); + 0, N_("Exit from GRUB.")); cmd_clear = grub_register_command ("clear", grub_mini_cmd_clear, - 0, "Clear the screen."); + 0, N_("Clear the screen.")); } GRUB_MOD_FINI(minicmd) diff --git a/commands/parttool.c b/commands/parttool.c index 62fe5ad2b..3f69d5525 100644 --- a/commands/parttool.c +++ b/commands/parttool.c @@ -29,6 +29,7 @@ #include #include #include +#include static struct grub_parttool *parts = 0; static int curhandle = 0; @@ -322,7 +323,7 @@ GRUB_MOD_INIT(parttool) { mymod = mod; cmd = grub_register_command ("parttool", grub_cmd_parttool, - "PARTITION COMMANDS", + N_("PARTITION COMMANDS"), helpmsg); } diff --git a/commands/password.c b/commands/password.c index d9b31f962..2869ffc53 100644 --- a/commands/password.c +++ b/commands/password.c @@ -23,6 +23,7 @@ #include #include #include +#include static grub_dl_t my_mod; @@ -75,9 +76,9 @@ GRUB_MOD_INIT(password) { my_mod = mod; cmd = grub_register_command ("password", grub_cmd_password, - "USER PASSWORD", - "Set user password (plaintext). " - "Unrecommended and insecure."); + N_("USER PASSWORD"), + N_("Set user password (plaintext). " + "Unrecommended and insecure.")); } GRUB_MOD_FINI(password) diff --git a/commands/probe.c b/commands/probe.c index 7de1c1d34..c2cc599e9 100644 --- a/commands/probe.c +++ b/commands/probe.c @@ -30,16 +30,17 @@ #include #include #include +#include static const struct grub_arg_option options[] = { {"set", 's', GRUB_ARG_OPTION_OPTIONAL, - "Set a variable to return value.", "VAR", ARG_TYPE_STRING}, - {"driver", 'd', 0, "Determine driver.", 0, 0}, - {"partmap", 'p', 0, "Determine partition map type.", 0, 0}, - {"fs", 'f', 0, "Determine filesystem type.", 0, 0}, - {"fs-uuid", 'u', 0, "Determine filesystem UUID.", 0, 0}, - {"label", 'l', 0, "Determine filesystem label.", 0, 0}, + N_("Set a variable to return value."), "VAR", ARG_TYPE_STRING}, + {"driver", 'd', 0, N_("Determine driver."), 0, 0}, + {"partmap", 'p', 0, N_("Determine partition map type."), 0, 0}, + {"fs", 'f', 0, N_("Determine filesystem type."), 0, 0}, + {"fs-uuid", 'u', 0, N_("Determine filesystem UUID."), 0, 0}, + {"label", 'l', 0, N_("Determine filesystem label."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -150,8 +151,8 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT (probe) { cmd = grub_register_extcmd ("probe", grub_cmd_probe, GRUB_COMMAND_FLAG_BOTH, - "[DEVICE]", - "Retrieve device info.", options); + N_("[DEVICE]"), + N_("Retrieve device info."), options); } GRUB_MOD_FINI (probe) diff --git a/commands/read.c b/commands/read.c index 5f4451a72..8a7c4a01f 100644 --- a/commands/read.c +++ b/commands/read.c @@ -24,6 +24,7 @@ #include #include #include +#include static char * grub_getline (void) @@ -79,8 +80,8 @@ static grub_command_t cmd; GRUB_MOD_INIT(read) { cmd = grub_register_command ("read", grub_cmd_read, - "[ENVVAR]", - "Set variable with user input."); + N_("[ENVVAR]"), + N_("Set variable with user input.")); } GRUB_MOD_FINI(read) diff --git a/commands/reboot.c b/commands/reboot.c index 2add295ef..eedd53c91 100644 --- a/commands/reboot.c +++ b/commands/reboot.c @@ -20,6 +20,7 @@ #include #include #include +#include static grub_err_t grub_cmd_reboot (grub_command_t cmd __attribute__ ((unused)), @@ -35,7 +36,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(reboot) { cmd = grub_register_command ("reboot", grub_cmd_reboot, - 0, "Reboot the computer."); + 0, N_("Reboot the computer.")); } GRUB_MOD_FINI(reboot) diff --git a/commands/search.c b/commands/search.c index 01e83739b..2f0cef8aa 100644 --- a/commands/search.c +++ b/commands/search.c @@ -165,7 +165,7 @@ GRUB_MOD_INIT(search_fs_label) { cmd = grub_register_command (COMMAND_NAME, grub_cmd_do_search, - "NAME [VARIABLE]", + N_("NAME [VARIABLE]"), "Search devices by " SEARCH_TARGET "." " If VARIABLE is specified, " "the first device found is set to a variable."); diff --git a/commands/sleep.c b/commands/sleep.c index eb9aeb510..a2caad89a 100644 --- a/commands/sleep.c +++ b/commands/sleep.c @@ -24,11 +24,12 @@ #include #include #include +#include static const struct grub_arg_option options[] = { - {"verbose", 'v', 0, "Verbose countdown.", 0, 0}, - {"interruptible", 'i', 0, "Interruptible with ESC.", 0, 0}, + {"verbose", 'v', 0, N_("Verbose countdown."), 0, 0}, + {"interruptible", 'i', 0, N_("Interruptible with ESC."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -105,8 +106,8 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(sleep) { cmd = grub_register_extcmd ("sleep", grub_cmd_sleep, GRUB_COMMAND_FLAG_BOTH, - "NUMBER_OF_SECONDS", - "Wait for a specified number of seconds.", + N_("NUMBER_OF_SECONDS"), + N_("Wait for a specified number of seconds."), options); } diff --git a/commands/test.c b/commands/test.c index 8d1e24859..318a42264 100644 --- a/commands/test.c +++ b/commands/test.c @@ -25,6 +25,7 @@ #include #include #include +#include /* A simple implementation for signed numbers. */ static int @@ -420,9 +421,9 @@ static grub_command_t cmd_1, cmd_2; GRUB_MOD_INIT(test) { cmd_1 = grub_register_command ("[", grub_cmd_test, - "EXPRESSION ]", "Evaluate an expression."); + N_("EXPRESSION ]"), N_("Evaluate an expression.")); cmd_2 = grub_register_command ("test", grub_cmd_test, - "EXPRESSION", "Evaluate an expression."); + N_("EXPRESSION"), N_("Evaluate an expression.")); } GRUB_MOD_FINI(test) diff --git a/commands/true.c b/commands/true.c index ef9f65889..aa8125853 100644 --- a/commands/true.c +++ b/commands/true.c @@ -19,6 +19,7 @@ #include #include +#include static grub_err_t grub_cmd_true (struct grub_command *cmd __attribute__ ((unused)), @@ -43,10 +44,10 @@ GRUB_MOD_INIT(true) { cmd_true = grub_register_command ("true", grub_cmd_true, - 0, "Do nothing, successfully."); + 0, N_("Do nothing, successfully.")); cmd_false = grub_register_command ("false", grub_cmd_false, - 0, "Do nothing, unsuccessfully."); + 0, N_("Do nothing, unsuccessfully.")); } GRUB_MOD_FINI(true) diff --git a/commands/usbtest.c b/commands/usbtest.c index df124ca18..b884a93f1 100644 --- a/commands/usbtest.c +++ b/commands/usbtest.c @@ -25,6 +25,7 @@ #include #include #include +#include static const char *usb_classes[] = { @@ -195,7 +196,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(usbtest) { cmd = grub_register_command ("usb", grub_cmd_usbtest, - 0, "Test USB support."); + 0, N_("Test USB support.")); } GRUB_MOD_FINI(usbtest) diff --git a/commands/videotest.c b/commands/videotest.c index e27552510..850639bd9 100644 --- a/commands/videotest.c +++ b/commands/videotest.c @@ -24,6 +24,7 @@ #include #include #include +#include static grub_err_t grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)), @@ -178,7 +179,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(videotest) { cmd = grub_register_command ("videotest", grub_cmd_videotest, - 0, "Test video subsystem."); + 0, N_("Test video subsystem.")); } GRUB_MOD_FINI(videotest) diff --git a/commands/xnu_uuid.c b/commands/xnu_uuid.c index 31e69ad13..32288636b 100644 --- a/commands/xnu_uuid.c +++ b/commands/xnu_uuid.c @@ -31,6 +31,7 @@ #include #include #include +#include struct tohash { @@ -377,9 +378,9 @@ static grub_command_t cmd; GRUB_MOD_INIT (xnu_uuid) { cmd = grub_register_command ("xnu_uuid", grub_cmd_xnu_uuid, - "GRUBUUID [VARNAME]", - "Transform 64-bit UUID to format " - "suitable for xnu."); + N_("GRUBUUID [VARNAME]"), + N_("Transform 64-bit UUID to format " + "suitable for xnu.")); } GRUB_MOD_FINI (xnu_uuid) diff --git a/disk/loopback.c b/disk/loopback.c index c877dd8af..fbec0426f 100644 --- a/disk/loopback.c +++ b/disk/loopback.c @@ -23,6 +23,7 @@ #include #include #include +#include struct grub_loopback { @@ -36,8 +37,8 @@ static struct grub_loopback *loopback_list; static const struct grub_arg_option options[] = { - {"delete", 'd', 0, "delete the loopback device entry", 0, 0}, - {"partitions", 'p', 0, "simulate a hard drive with partitions", 0, 0}, + {"delete", 'd', 0, N_("delete the loopback device entry"), 0, 0}, + {"partitions", 'p', 0, N_("simulate a hard drive with partitions"), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -245,8 +246,8 @@ GRUB_MOD_INIT(loop) { cmd = grub_register_extcmd ("loopback", grub_cmd_loopback, GRUB_COMMAND_FLAG_BOTH, - "loopback [-d|-p] DEVICENAME FILE", - "Make a device of a file.", options); + N_("loopback [-d|-p] DEVICENAME FILE"), + N_("Make a device of a file."), options); grub_disk_dev_register (&grub_loopback_dev); } diff --git a/hello/hello.c b/hello/hello.c index be60761ec..1e2a4ba7f 100644 --- a/hello/hello.c +++ b/hello/hello.c @@ -24,6 +24,7 @@ #include #include #include +#include static grub_err_t grub_cmd_hello (struct grub_extcmd *cmd __attribute__ ((unused)), @@ -39,7 +40,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(hello) { cmd = grub_register_extcmd ("hello", grub_cmd_hello, GRUB_COMMAND_FLAG_BOTH, - "hello", "Say hello", 0); + "hello", N_("Say hello"), 0); } GRUB_MOD_FINI(hello) diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index ca60b0be9..a7a860bb2 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -34,6 +34,7 @@ #include #include #include +#include #ifdef GRUB_MACHINE_PCBIOS #include @@ -61,20 +62,20 @@ static grub_uint32_t openbsd_root; 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}, + {"dual", 'D', 0, N_("Display output on all consoles."), 0, 0}, + {"serial", 'h', 0, N_("Use serial console."), 0, 0}, + {"askname", 'a', 0, N_("Ask for file name to reboot from."), 0, 0}, + {"cdrom", 'C', 0, N_("Use cdrom as root."), 0, 0}, + {"config", 'c', 0, N_("Invoke user configuration routing."), 0, 0}, + {"kdb", 'd', 0, N_("Enter in KDB on boot."), 0, 0}, + {"gdb", 'g', 0, N_("Use GDB remote debugger instead of DDB."), 0, 0}, + {"mute", 'm', 0, N_("Disable all boot output."), 0, 0}, {"nointr", 'n', 0, "", 0, 0}, - {"pause", 'p', 0, "Wait for keypress after every line of output.", 0, 0}, + {"pause", 'p', 0, N_("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}, + {"dfltroot", 'r', 0, N_("Use compiled-in rootdev."), 0, 0}, + {"single", 's', 0, N_("Boot into single mode."), 0, 0}, + {"verbose", 'v', 0, N_("Boot with verbose messages."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -89,12 +90,12 @@ static const grub_uint32_t freebsd_flags[] = 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}, - {"root", 'r', 0, "Set root device.", "wdXY", ARG_TYPE_STRING}, + {"askname", 'a', 0, N_("Ask for file name to reboot from."), 0, 0}, + {"halt", 'b', 0, N_("Don't reboot, just halt."), 0, 0}, + {"config", 'c', 0, N_("Change configured devices."), 0, 0}, + {"single", 's', 0, N_("Boot into single mode."), 0, 0}, + {"kdb", 'd', 0, N_("Enter in KDB on boot."), 0, 0}, + {"root", 'r', 0, N_("Set root device."), "wdXY", ARG_TYPE_STRING}, {0, 0, 0, 0, 0, 0} }; @@ -108,19 +109,19 @@ 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}, - {"kdb", 'd', 0, "Enter in KDB on boot.", 0, 0}, + {"no-smp", '1', 0, N_("Disable SMP."), 0, 0}, + {"no-acpi", '2', 0, N_("Disable ACPI."), 0, 0}, + {"askname", 'a', 0, N_("Ask for file name to reboot from."), 0, 0}, + {"halt", 'b', 0, N_("Don't reboot, just halt."), 0, 0}, + {"config", 'c', 0, N_("Change configured devices."), 0, 0}, + {"kdb", 'd', 0, N_("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}, - {"root", 'r', 0, "Set root device.", "DEVICE", ARG_TYPE_STRING}, + {"quiet", 'q', 0, N_("Don't display boot diagnostic messages."), 0, 0}, + {"single", 's', 0, N_("Boot into single mode."), 0, 0}, + {"verbose", 'v', 0, N_("Boot with verbose messages."), 0, 0}, + {"debug", 'x', 0, N_("Boot with debug messages."), 0, 0}, + {"silent", 'z', 0, N_("Supress normal output (warnings remain)."), 0, 0}, + {"root", 'r', 0, N_("Set root device."), N_("DEVICE"), ARG_TYPE_STRING}, {0, 0, 0, 0, 0, 0} }; @@ -1280,25 +1281,25 @@ GRUB_MOD_INIT (bsd) { cmd_freebsd = grub_register_extcmd ("kfreebsd", grub_cmd_freebsd, GRUB_COMMAND_FLAG_BOTH, - "FILE", "Load kernel of FreeBSD.", + N_("FILE"), N_("Load kernel of FreeBSD."), freebsd_opts); cmd_openbsd = grub_register_extcmd ("kopenbsd", grub_cmd_openbsd, GRUB_COMMAND_FLAG_BOTH, - "FILE", "Load kernel of OpenBSD.", + N_("FILE"), N_("Load kernel of OpenBSD."), openbsd_opts); cmd_netbsd = grub_register_extcmd ("knetbsd", grub_cmd_netbsd, GRUB_COMMAND_FLAG_BOTH, - "FILE", "Load kernel of NetBSD.", + N_("FILE"), N_("Load kernel of NetBSD."), netbsd_opts); cmd_freebsd_loadenv = grub_register_command ("kfreebsd_loadenv", grub_cmd_freebsd_loadenv, - 0, "Load FreeBSD env."); + 0, N_("Load FreeBSD env.")); cmd_freebsd_module = grub_register_command ("kfreebsd_module", grub_cmd_freebsd_module, - 0, "Load FreeBSD kernel module."); + 0, N_("Load FreeBSD kernel module.")); cmd_freebsd_module_elf = grub_register_command ("kfreebsd_module_elf", grub_cmd_freebsd_module_elf, - 0, "Load FreeBSD kernel module (ELF)."); + 0, N_("Load FreeBSD kernel module (ELF).")); my_mod = mod; } diff --git a/po/POTFILES b/po/POTFILES index 6efa12219..4e7e032ec 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -1,13 +1,62 @@ # List of files which contain translatable strings. -commands/i386/pc/play.c -commands/loadenv.c -commands/search.c +commands/acpi.c +commands/blocklist.c +commands/boot.c +commands/cat.c +commands/cmp.c +commands/configfile.c +commands/crc.c +commands/date.c +commands/echo.c +commands/efi/fixvideo.c +commands/efi/loadbios.c +commands/gptsync.c +commands/halt.c +commands/handler.c +commands/hdparm.c commands/help.c +commands/hexdump.c +commands/i386/cpuid.c +commands/i386/pc/drivemap.c +commands/i386/pc/halt.c +commands/i386/pc/play.c +commands/i386/pc/pxecmd.c +commands/i386/pc/vbeinfo.c +commands/i386/pc/vbetest.c +commands/ieee1275/suspend.c +commands/keystatus.c +commands/loadenv.c +commands/ls.c +commands/lsmmap.c +commands/lspci.c +commands/memrw.c +commands/minicmd.c +commands/parttool.c +commands/password.c +commands/probe.c +commands/read.c +commands/reboot.c +commands/search.c +commands/search.c +commands/sleep.c +commands/test.c +commands/true.c +commands/usbtest.c +commands/videotest.c +commands/xnu_uuid.c + +disk/loopback.c + +hello/hello.c lib/arg.c +loader/i386/bsd.c + normal/dyncmd.c +term/i386/pc/serial.c + util/i386/pc/grub-mkimage.c util/i386/pc/grub-setup.c diff --git a/term/i386/pc/serial.c b/term/i386/pc/serial.c index 1c68f9bfc..e4e3c2755 100644 --- a/term/i386/pc/serial.c +++ b/term/i386/pc/serial.c @@ -26,6 +26,7 @@ #include #include #include +#include #define TEXT_WIDTH 80 #define TEXT_HEIGHT 25 @@ -41,12 +42,12 @@ static unsigned int npending = 0; /* Argument options. */ static const struct grub_arg_option options[] = { - {"unit", 'u', 0, "Set the serial unit", 0, ARG_TYPE_INT}, - {"port", 'p', 0, "Set the serial port address", 0, ARG_TYPE_STRING}, - {"speed", 's', 0, "Set the serial port speed", 0, ARG_TYPE_INT}, - {"word", 'w', 0, "Set the serial port word length", 0, ARG_TYPE_INT}, - {"parity", 'r', 0, "Set the serial port parity", 0, ARG_TYPE_STRING}, - {"stop", 't', 0, "Set the serial port stop bits", 0, ARG_TYPE_INT}, + {"unit", 'u', 0, N_("Set the serial unit"), 0, ARG_TYPE_INT}, + {"port", 'p', 0, N_("Set the serial port address"), 0, ARG_TYPE_STRING}, + {"speed", 's', 0, N_("Set the serial port speed"), 0, ARG_TYPE_INT}, + {"word", 'w', 0, N_("Set the serial port word length"), 0, ARG_TYPE_INT}, + {"parity", 'r', 0, N_("Set the serial port parity"), 0, ARG_TYPE_STRING}, + {"stop", 't', 0, N_("Set the serial port stop bits"), 0, ARG_TYPE_INT}, {0, 0, 0, 0, 0, 0} }; @@ -602,8 +603,8 @@ GRUB_MOD_INIT(serial) { cmd = grub_register_extcmd ("serial", grub_cmd_serial, GRUB_COMMAND_FLAG_BOTH, - "serial [OPTIONS...]", - "Configure serial port.", options); + N_("serial [OPTIONS...]"), + N_("Configure serial port."), options); /* Set default settings. */ serial_settings.port = serial_hw_get_port (0); From 29c44ad156207a17b8825e7dbc7b192ba3e571c7 Mon Sep 17 00:00:00 2001 From: carles Date: Sun, 3 Jan 2010 19:50:51 +0100 Subject: [PATCH 132/208] 2010-01-03 Carles Pina i Estany * commands/acpi.c (GRUB_MOD_INIT): Capitalise some words from help. * commands/efi/loadbios.c (GRUB_MOD_INIT): Capitalise BIOS. * commands/i386/pc/drivemap.c (GRUB_MOD_INIT): Remove space. Add full stop. * commands/loadenv.c (GRUB_MOD_INIT): Remove command name from summary. Gettextizze the strings. * commands/probe.c (grub_cmd_probe): Capitalise UUID and FS. * commands/xnu_uuid.c (GRUB_MOD_INIT): Capitalise XNU. * disk/loopback.c (grub_arg_options): Capitalise first letter. Add full stop. (GRUB_MOD_INIT): Remove command name from summary. * hello/hello.c (GRUD_MOT_INIT): Add missing full stop. Improve the summary. * loader/i386/bsd.c (grub_arg_option): Capitalise CDROM. * term/i386/pc/serial.c (options): Add full stops. (GRUB_MOD_INIT): Remove command name from the summary. --- ChangeLog | 19 +++++++++++++++++++ commands/acpi.c | 8 ++++---- commands/efi/loadbios.c | 4 ++-- commands/i386/pc/drivemap.c | 2 +- commands/loadenv.c | 12 ++++++------ commands/xnu_uuid.c | 2 +- disk/loopback.c | 6 +++--- hello/hello.c | 2 +- loader/i386/bsd.c | 2 +- term/i386/pc/serial.c | 14 +++++++------- 10 files changed, 45 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7da0c929e..d90116d4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2010-01-03 Carles Pina i Estany + + * commands/acpi.c (GRUB_MOD_INIT): Capitalise some words from help. + * commands/efi/loadbios.c (GRUB_MOD_INIT): Capitalise BIOS. + * commands/i386/pc/drivemap.c (GRUB_MOD_INIT): Remove space. Add + full stop. + * commands/loadenv.c (GRUB_MOD_INIT): Remove command name from + summary. Gettextizze the strings. + * commands/probe.c (grub_cmd_probe): Capitalise UUID and FS. + * commands/xnu_uuid.c (GRUB_MOD_INIT): Capitalise XNU. + * disk/loopback.c (grub_arg_options): Capitalise first letter. Add + full stop. + (GRUB_MOD_INIT): Remove command name from summary. + * hello/hello.c (GRUD_MOT_INIT): Add missing full stop. Improve the + summary. + * loader/i386/bsd.c (grub_arg_option): Capitalise CDROM. + * term/i386/pc/serial.c (options): Add full stops. + (GRUB_MOD_INIT): Remove command name from the summary. + 2010-01-03 Carles Pina i Estany * commands/acpi.c: Gettextizze help strings and/or options. Include diff --git a/commands/acpi.c b/commands/acpi.c index 4d54539fd..f62592115 100644 --- a/commands/acpi.c +++ b/commands/acpi.c @@ -760,10 +760,10 @@ GRUB_MOD_INIT(acpi) { cmd = grub_register_extcmd ("acpi", grub_cmd_acpi, GRUB_COMMAND_FLAG_BOTH, - N_("[-1|-2] [--exclude=table1,table2|" - "--load-only=table1,table2] filename1 " - " [filename2] [...]"), - N_("Load host acpi tables and tables " + N_("[-1|-2] [--exclude=TABLE1,TABLE2|" + "--load-only=table1,table2] FILE1" + " [FILE2] [...]"), + N_("Load host ACPI tables and tables " "specified by arguments."), options); } diff --git a/commands/efi/loadbios.c b/commands/efi/loadbios.c index 0f0d7bc10..653327d6c 100644 --- a/commands/efi/loadbios.c +++ b/commands/efi/loadbios.c @@ -202,11 +202,11 @@ static grub_command_t cmd_fakebios, cmd_loadbios; GRUB_MOD_INIT(loadbios) { cmd_fakebios = grub_register_command ("fakebios", grub_cmd_fakebios, - 0, N_("Fake bios.")); + 0, N_("Fake BIOS.")); cmd_loadbios = grub_register_command ("loadbios", grub_cmd_loadbios, "BIOS_DUMP [INT10_DUMP]", - N_("Load bios dump.")); + N_("Load BIOS dump.")); } GRUB_MOD_FINI(loadbios) diff --git a/commands/i386/pc/drivemap.c b/commands/i386/pc/drivemap.c index 3d1dcf614..3baacba49 100644 --- a/commands/i386/pc/drivemap.c +++ b/commands/i386/pc/drivemap.c @@ -404,7 +404,7 @@ GRUB_MOD_INIT (drivemap) cmd = grub_register_extcmd ("drivemap", grub_cmd_drivemap, GRUB_COMMAND_FLAG_BOTH, "drivemap" - N_(" -l | -r | [-s] grubdev osdisk"), + N_("-l | -r | [-s] grubdev osdisk."), N_("Manage the BIOS drive mappings."), options); drivemap_hook = diff --git a/commands/loadenv.c b/commands/loadenv.c index 6f8714411..910392614 100644 --- a/commands/loadenv.c +++ b/commands/loadenv.c @@ -385,20 +385,20 @@ GRUB_MOD_INIT(loadenv) cmd_load = grub_register_extcmd ("load_env", grub_cmd_load_env, GRUB_COMMAND_FLAG_BOTH, - "load_env [-f FILE]", - "Load variables from environment block file.", + N_("[-f FILE]"), + N_("Load variables from environment block file."), options); cmd_list = grub_register_extcmd ("list_env", grub_cmd_list_env, GRUB_COMMAND_FLAG_BOTH, - "list_env [-f FILE]", - "List variables from environment block file.", + N_("[-f FILE]"), + N_("List variables from environment block file."), options); cmd_save = grub_register_extcmd ("save_env", grub_cmd_save_env, GRUB_COMMAND_FLAG_BOTH, - "[-f FILE] variable_name [...]", - "Save variables to environment block file.", + N_("[-f FILE] variable_name [...]"), + N_("Save variables to environment block file."), options); } diff --git a/commands/xnu_uuid.c b/commands/xnu_uuid.c index 32288636b..b94dc0dc7 100644 --- a/commands/xnu_uuid.c +++ b/commands/xnu_uuid.c @@ -380,7 +380,7 @@ GRUB_MOD_INIT (xnu_uuid) cmd = grub_register_command ("xnu_uuid", grub_cmd_xnu_uuid, N_("GRUBUUID [VARNAME]"), N_("Transform 64-bit UUID to format " - "suitable for xnu.")); + "suitable for XNU.")); } GRUB_MOD_FINI (xnu_uuid) diff --git a/disk/loopback.c b/disk/loopback.c index fbec0426f..a8b7cf5d7 100644 --- a/disk/loopback.c +++ b/disk/loopback.c @@ -37,8 +37,8 @@ static struct grub_loopback *loopback_list; static const struct grub_arg_option options[] = { - {"delete", 'd', 0, N_("delete the loopback device entry"), 0, 0}, - {"partitions", 'p', 0, N_("simulate a hard drive with partitions"), 0, 0}, + {"delete", 'd', 0, N_("Delete the loopback device entry."), 0, 0}, + {"partitions", 'p', 0, N_("Simulate a hard drive with partitions."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -246,7 +246,7 @@ GRUB_MOD_INIT(loop) { cmd = grub_register_extcmd ("loopback", grub_cmd_loopback, GRUB_COMMAND_FLAG_BOTH, - N_("loopback [-d|-p] DEVICENAME FILE"), + N_("[-d|-p] DEVICENAME FILE."), N_("Make a device of a file."), options); grub_disk_dev_register (&grub_loopback_dev); } diff --git a/hello/hello.c b/hello/hello.c index 1e2a4ba7f..eff07d941 100644 --- a/hello/hello.c +++ b/hello/hello.c @@ -40,7 +40,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(hello) { cmd = grub_register_extcmd ("hello", grub_cmd_hello, GRUB_COMMAND_FLAG_BOTH, - "hello", N_("Say hello"), 0); + 0, N_("Say \"Hello World\"."), 0); } GRUB_MOD_FINI(hello) diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index a7a860bb2..d0f0c464b 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -65,7 +65,7 @@ static const struct grub_arg_option freebsd_opts[] = {"dual", 'D', 0, N_("Display output on all consoles."), 0, 0}, {"serial", 'h', 0, N_("Use serial console."), 0, 0}, {"askname", 'a', 0, N_("Ask for file name to reboot from."), 0, 0}, - {"cdrom", 'C', 0, N_("Use cdrom as root."), 0, 0}, + {"cdrom", 'C', 0, N_("Use CDROM as root."), 0, 0}, {"config", 'c', 0, N_("Invoke user configuration routing."), 0, 0}, {"kdb", 'd', 0, N_("Enter in KDB on boot."), 0, 0}, {"gdb", 'g', 0, N_("Use GDB remote debugger instead of DDB."), 0, 0}, diff --git a/term/i386/pc/serial.c b/term/i386/pc/serial.c index e4e3c2755..0f4749eae 100644 --- a/term/i386/pc/serial.c +++ b/term/i386/pc/serial.c @@ -42,12 +42,12 @@ static unsigned int npending = 0; /* Argument options. */ static const struct grub_arg_option options[] = { - {"unit", 'u', 0, N_("Set the serial unit"), 0, ARG_TYPE_INT}, - {"port", 'p', 0, N_("Set the serial port address"), 0, ARG_TYPE_STRING}, - {"speed", 's', 0, N_("Set the serial port speed"), 0, ARG_TYPE_INT}, - {"word", 'w', 0, N_("Set the serial port word length"), 0, ARG_TYPE_INT}, - {"parity", 'r', 0, N_("Set the serial port parity"), 0, ARG_TYPE_STRING}, - {"stop", 't', 0, N_("Set the serial port stop bits"), 0, ARG_TYPE_INT}, + {"unit", 'u', 0, N_("Set the serial unit."), 0, ARG_TYPE_INT}, + {"port", 'p', 0, N_("Set the serial port address."), 0, ARG_TYPE_STRING}, + {"speed", 's', 0, N_("Set the serial port speed."), 0, ARG_TYPE_INT}, + {"word", 'w', 0, N_("Set the serial port word length."), 0, ARG_TYPE_INT}, + {"parity", 'r', 0, N_("Set the serial port parity."), 0, ARG_TYPE_STRING}, + {"stop", 't', 0, N_("Set the serial port stop bits."), 0, ARG_TYPE_INT}, {0, 0, 0, 0, 0, 0} }; @@ -603,7 +603,7 @@ GRUB_MOD_INIT(serial) { cmd = grub_register_extcmd ("serial", grub_cmd_serial, GRUB_COMMAND_FLAG_BOTH, - N_("serial [OPTIONS...]"), + N_("[OPTIONS...]"), N_("Configure serial port."), options); /* Set default settings. */ From f936862eda35bf430e9d1c135fdbc37cb1a2c358 Mon Sep 17 00:00:00 2001 From: carles Date: Sun, 3 Jan 2010 20:41:26 +0100 Subject: [PATCH 133/208] 2010-01-03 Carles Pina i Estany * po/POTFILES: Sort correctly. --- ChangeLog | 4 ++++ po/POTFILES | 13 ++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index d90116d4d..6cdfd57d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-03 Carles Pina i Estany + + * po/POTFILES: Sort correctly. + 2010-01-03 Carles Pina i Estany * commands/acpi.c (GRUB_MOD_INIT): Capitalise some words from help. diff --git a/po/POTFILES b/po/POTFILES index 4e7e032ec..cecf8a049 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -53,7 +53,13 @@ lib/arg.c loader/i386/bsd.c +normal/auth.c +normal/color.c normal/dyncmd.c +normal/main.c +normal/menu_entry.c +normal/menu_text.c +normal/misc.c term/i386/pc/serial.c @@ -68,10 +74,3 @@ util/mkisofs/multi.c util/mkisofs/rock.c util/mkisofs/tree.c util/mkisofs/write.c - -normal/auth.c -normal/color.c -normal/main.c -normal/menu_entry.c -normal/menu_text.c -normal/misc.c From 136d24f6433f82ec261654c6a395107268087614 Mon Sep 17 00:00:00 2001 From: carles Date: Sun, 3 Jan 2010 21:08:51 +0100 Subject: [PATCH 134/208] 2010-01-03 Carles Pina i Estany * kern/env.c (grub_env_unset): Set the variable to "" if has hooks. --- ChangeLog | 4 ++++ kern/env.c | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6cdfd57d7..4b5080ebf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-03 Carles Pina i Estany + + * kern/env.c (grub_env_unset): Set the variable to "" if has hooks. + 2010-01-03 Carles Pina i Estany * po/POTFILES: Sort correctly. diff --git a/kern/env.c b/kern/env.c index 969227dec..8f94e891e 100644 --- a/kern/env.c +++ b/kern/env.c @@ -264,10 +264,11 @@ grub_env_unset (const char *name) if (! var) return; - /* XXX: It is not possible to unset variables with a read or write - hook. */ if (var->read_hook || var->write_hook) - return; + { + grub_env_set (name, ""); + return; + } grub_env_remove (var); From 7fa7ff743964bdcf0c12743835382fbe2cbb66f0 Mon Sep 17 00:00:00 2001 From: carles Date: Sun, 3 Jan 2010 21:30:04 +0100 Subject: [PATCH 135/208] 2010-01-03 Carles Pina i Estany * normal/menu_entry.c (store_completion): Gettextizze. --- ChangeLog | 4 ++++ normal/menu_entry.c | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b5080ebf..ce81611c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-03 Carles Pina i Estany + + * normal/menu_entry.c (store_completion): Gettextizze. + 2010-01-03 Carles Pina i Estany * kern/env.c (grub_env_unset): Set the variable to "" if has hooks. diff --git a/normal/menu_entry.c b/normal/menu_entry.c index 7a31c27af..bd97d17d7 100644 --- a/normal/menu_entry.c +++ b/normal/menu_entry.c @@ -816,28 +816,28 @@ store_completion (const char *item, grub_completion_type_t type, int count) switch (type) { case GRUB_COMPLETION_TYPE_COMMAND: - what = "commands"; + what = N_("commands"); break; case GRUB_COMPLETION_TYPE_DEVICE: - what = "devices"; + what = N_("devices"); break; case GRUB_COMPLETION_TYPE_FILE: - what = "files"; + what = N_("files"); break; case GRUB_COMPLETION_TYPE_PARTITION: - what = "partitions"; + what = N_("partitions"); break; case GRUB_COMPLETION_TYPE_ARGUMENT: - what = "arguments"; + what = N_("arguments"); break; default: - what = "things"; + what = N_("things"); break; } grub_gotoxy (0, GRUB_TERM_HEIGHT - 3); grub_printf (" "); - grub_printf_ (N_("Possible %s are:"), what); + grub_printf_ (N_("Possible %s are:"), _(what)); grub_printf ("\n "); } From a173283f78235489c0004c35ba1e1790cc6c4fc5 Mon Sep 17 00:00:00 2001 From: carles Date: Sun, 3 Jan 2010 21:48:09 +0100 Subject: [PATCH 136/208] 2010-01-03 Carles Pina i Estany * normal/menu_text.c (print_message): Change messages. --- ChangeLog | 4 ++++ normal/menu_text.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ce81611c9..916e2bc1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-03 Carles Pina i Estany + + * normal/menu_text.c (print_message): Change messages. + 2010-01-03 Carles Pina i Estany * normal/menu_entry.c (store_completion): Gettextizze. diff --git a/normal/menu_text.c b/normal/menu_text.c index 5c985fa6f..8ab67a35c 100644 --- a/normal/menu_text.c +++ b/normal/menu_text.c @@ -214,8 +214,8 @@ entry is highlighted.\n"); grub_free (msg_translated); - grub_print_message_indented (_("Press enter to boot the selected OS, \ -\'e\' to edit the commands before booting or \'c\' for a command-line.\n"), STANDARD_MARGIN, STANDARD_MARGIN); + grub_print_message_indented (_("Press enter to execute the selected \ +entry, \'e\' to edit the commands before booting or \'c\' for a command-line.\n"), STANDARD_MARGIN, STANDARD_MARGIN); if (nested) { @@ -385,7 +385,7 @@ static void print_timeout (int timeout, int offset) { const char *msg = - _("The highlighted entry will be booted automatically in %ds."); + _("The highlighted entry will be executed automatically in %ds."); grub_gotoxy (0, GRUB_TERM_HEIGHT - 3); From e2d70b5cea62f2b4c57a2fb8e1885d9b7569f741 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 3 Jan 2010 21:50:53 +0000 Subject: [PATCH 137/208] 2010-01-03 Colin Watson * include/grub/misc.h (GNUC_PREREQ): New macro. (ATTRIBUTE_ERROR): New macro. * include/grub/list.h (grub_bad_type_cast_real): Use ATTRIBUTE_ERROR. --- ChangeLog | 7 +++++++ include/grub/list.h | 2 +- include/grub/misc.h | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 916e2bc1e..e5e4f42ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-01-03 Colin Watson + + * include/grub/misc.h (GNUC_PREREQ): New macro. + (ATTRIBUTE_ERROR): New macro. + * include/grub/list.h (grub_bad_type_cast_real): Use + ATTRIBUTE_ERROR. + 2010-01-03 Carles Pina i Estany * normal/menu_text.c (print_message): Change messages. diff --git a/include/grub/list.h b/include/grub/list.h index 86a5381cd..b7703e214 100644 --- a/include/grub/list.h +++ b/include/grub/list.h @@ -42,7 +42,7 @@ void EXPORT_FUNC(grub_list_insert) (grub_list_t *head, grub_list_t item, static inline void * grub_bad_type_cast_real (int line, const char *file) - __attribute__ ((error ("bad type cast between incompatible grub types"))); + ATTRIBUTE_ERROR ("bad type cast between incompatible grub types"); static inline void * grub_bad_type_cast_real (int line, const char *file) diff --git a/include/grub/misc.h b/include/grub/misc.h index 92fb460cf..c5eb953e2 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -1,7 +1,7 @@ /* misc.h - prototypes for misc functions */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,22 @@ #include #include +/* GCC version checking borrowed from glibc. */ +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define GNUC_PREREQ(maj,min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define GNUC_PREREQ(maj,min) 0 +#endif + +/* Does this compiler support compile-time error attributes? */ +#if GNUC_PREREQ(4,3) +# define ATTRIBUTE_ERROR(msg) \ + __attribute__ ((__error__ (msg))) +#else +# define ATTRIBUTE_ERROR(msg) +#endif + #define ALIGN_UP(addr, align) \ ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1)) #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0])) From 58bc8bd5b146cfd5c9be6ed09693fcf73aebf768 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 3 Jan 2010 22:05:07 +0000 Subject: [PATCH 138/208] 2010-01-03 Robert Millan * boot/i386/pc/boot.S: Update copyright year. * boot/i386/pc/cdboot.S: Likewise. * boot/i386/pc/diskboot.S: Likewise. * boot/i386/pc/lnxboot.S: Likewise. * boot/i386/pc/pxeboot.S: Likewise. * bus/pci.c: Likewise. * commands/cmp.c: Likewise. * commands/help.c: Likewise. * commands/hexdump.c: Likewise. * commands/i386/pc/halt.c: Likewise. * commands/i386/pc/play.c: Likewise. * commands/i386/pc/vbeinfo.c: Likewise. * commands/ls.c: Likewise. * commands/test.c: Likewise. * disk/dmraid_nvidia.c: Likewise. * disk/i386/pc/biosdisk.c: Likewise. * disk/ieee1275/nand.c: Likewise. * disk/ieee1275/ofdisk.c: Likewise. * disk/lvm.c: Likewise. * disk/raid.c: Likewise. * disk/raid6_recover.c: Likewise. * disk/scsi.c: Likewise. * fs/affs.c: Likewise. * fs/cpio.c: Likewise. * fs/ext2.c: Likewise. * fs/hfs.c: Likewise. * fs/iso9660.c: Likewise. * fs/ntfs.c: Likewise. * fs/sfs.c: Likewise. * fs/udf.c: Likewise. * fs/ufs.c: Likewise. * fs/xfs.c: Likewise. * gencmdlist.sh: Likewise. * genmk.rb: Likewise. * include/grub/disk.h: Likewise. * include/grub/efi/api.h: Likewise. * include/grub/efi/efi.h: Likewise. * include/grub/efi/pe32.h: Likewise. * include/grub/elf.h: Likewise. * include/grub/fs.h: Likewise. * include/grub/i386/at_keyboard.h: Likewise. * include/grub/i386/pc/memory.h: Likewise. * include/grub/i386/pc/vbe.h: Likewise. * include/grub/i386/pci.h: Likewise. * include/grub/i386/tsc.h: Likewise. * include/grub/ieee1275/ieee1275.h: Likewise. * include/grub/ntfs.h: Likewise. * include/grub/sparc64/ieee1275/ieee1275.h: Likewise. * include/grub/sparc64/libgcc.h: Likewise. * include/grub/symbol.h: Likewise. * include/grub/types.h: Likewise. * include/multiboot2.h: Likewise. * io/gzio.c: Likewise. * kern/device.c: Likewise. * kern/disk.c: Likewise. * kern/efi/efi.c: Likewise. * kern/efi/mm.c: Likewise. * kern/elf.c: Likewise. * kern/file.c: Likewise. * kern/i386/dl.c: Likewise. * kern/i386/pc/init.c: Likewise. * kern/i386/pc/startup.S: Likewise. * kern/ieee1275/ieee1275.c: Likewise. * kern/ieee1275/init.c: Likewise. * kern/main.c: Likewise. * kern/mm.c: Likewise. * kern/powerpc/dl.c: Likewise. * kern/sparc64/dl.c: Likewise. * kern/x86_64/dl.c: Likewise. * lib/hexdump.c: Likewise. * loader/efi/appleloader.c: Likewise. * loader/i386/ieee1275/linux.c: Likewise. * loader/i386/pc/chainloader.c: Likewise. * loader/i386/pc/linux.c: Likewise. * loader/i386/pc/multiboot2.c: Likewise. * loader/ieee1275/multiboot2.c: Likewise. * loader/multiboot2.c: Likewise. * loader/multiboot_loader.c: Likewise. * loader/powerpc/ieee1275/linux.c: Likewise. * normal/completion.c: Likewise. * normal/menu_entry.c: Likewise. * partmap/apple.c: Likewise. * util/grub.d/10_hurd.in: Likewise. * util/hostfs.c: Likewise. * video/readers/png.c: Likewise. --- ChangeLog | 88 ++++++++++++++++++++++++ boot/i386/pc/boot.S | 2 +- boot/i386/pc/cdboot.S | 2 +- boot/i386/pc/diskboot.S | 2 +- boot/i386/pc/lnxboot.S | 2 +- boot/i386/pc/pxeboot.S | 2 +- bus/pci.c | 2 +- commands/cmp.c | 2 +- commands/help.c | 2 +- commands/hexdump.c | 2 +- commands/i386/pc/halt.c | 2 +- commands/i386/pc/play.c | 2 +- commands/i386/pc/vbeinfo.c | 2 +- commands/ls.c | 2 +- commands/test.c | 2 +- disk/dmraid_nvidia.c | 2 +- disk/i386/pc/biosdisk.c | 2 +- disk/ieee1275/nand.c | 2 +- disk/ieee1275/ofdisk.c | 2 +- disk/lvm.c | 2 +- disk/raid.c | 2 +- disk/raid6_recover.c | 2 +- disk/scsi.c | 2 +- fs/affs.c | 2 +- fs/cpio.c | 2 +- fs/ext2.c | 2 +- fs/hfs.c | 2 +- fs/iso9660.c | 2 +- fs/ntfs.c | 2 +- fs/sfs.c | 2 +- fs/udf.c | 2 +- fs/ufs.c | 2 +- fs/xfs.c | 2 +- gencmdlist.sh | 2 +- genmk.rb | 2 +- include/grub/disk.h | 2 +- include/grub/efi/api.h | 2 +- include/grub/efi/efi.h | 2 +- include/grub/efi/pe32.h | 2 +- include/grub/elf.h | 2 +- include/grub/fs.h | 2 +- include/grub/i386/at_keyboard.h | 2 +- include/grub/i386/pc/memory.h | 2 +- include/grub/i386/pc/vbe.h | 2 +- include/grub/i386/pci.h | 2 +- include/grub/i386/tsc.h | 2 +- include/grub/ieee1275/ieee1275.h | 2 +- include/grub/ntfs.h | 2 +- include/grub/sparc64/ieee1275/ieee1275.h | 2 +- include/grub/sparc64/libgcc.h | 2 +- include/grub/symbol.h | 2 +- include/grub/types.h | 2 +- include/multiboot2.h | 2 +- io/gzio.c | 2 +- kern/device.c | 2 +- kern/disk.c | 2 +- kern/efi/efi.c | 2 +- kern/efi/mm.c | 2 +- kern/elf.c | 2 +- kern/file.c | 2 +- kern/i386/dl.c | 2 +- kern/i386/pc/init.c | 2 +- kern/i386/pc/startup.S | 2 +- kern/ieee1275/ieee1275.c | 2 +- kern/ieee1275/init.c | 2 +- kern/main.c | 2 +- kern/mm.c | 2 +- kern/powerpc/dl.c | 2 +- kern/sparc64/dl.c | 2 +- kern/x86_64/dl.c | 2 +- lib/hexdump.c | 2 +- loader/efi/appleloader.c | 2 +- loader/i386/ieee1275/linux.c | 2 +- loader/i386/pc/chainloader.c | 2 +- loader/i386/pc/linux.c | 2 +- loader/i386/pc/multiboot2.c | 2 +- loader/ieee1275/multiboot2.c | 2 +- loader/multiboot2.c | 2 +- loader/multiboot_loader.c | 2 +- loader/powerpc/ieee1275/linux.c | 2 +- normal/completion.c | 2 +- normal/menu_entry.c | 2 +- partmap/apple.c | 2 +- util/grub.d/10_hurd.in | 2 +- util/hostfs.c | 2 +- video/readers/png.c | 2 +- 86 files changed, 173 insertions(+), 85 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5e4f42ca..db63c66f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,91 @@ +2010-01-03 Robert Millan + + * boot/i386/pc/boot.S: Update copyright year. + * boot/i386/pc/cdboot.S: Likewise. + * boot/i386/pc/diskboot.S: Likewise. + * boot/i386/pc/lnxboot.S: Likewise. + * boot/i386/pc/pxeboot.S: Likewise. + * bus/pci.c: Likewise. + * commands/cmp.c: Likewise. + * commands/help.c: Likewise. + * commands/hexdump.c: Likewise. + * commands/i386/pc/halt.c: Likewise. + * commands/i386/pc/play.c: Likewise. + * commands/i386/pc/vbeinfo.c: Likewise. + * commands/ls.c: Likewise. + * commands/test.c: Likewise. + * disk/dmraid_nvidia.c: Likewise. + * disk/i386/pc/biosdisk.c: Likewise. + * disk/ieee1275/nand.c: Likewise. + * disk/ieee1275/ofdisk.c: Likewise. + * disk/lvm.c: Likewise. + * disk/raid.c: Likewise. + * disk/raid6_recover.c: Likewise. + * disk/scsi.c: Likewise. + * fs/affs.c: Likewise. + * fs/cpio.c: Likewise. + * fs/ext2.c: Likewise. + * fs/hfs.c: Likewise. + * fs/iso9660.c: Likewise. + * fs/ntfs.c: Likewise. + * fs/sfs.c: Likewise. + * fs/udf.c: Likewise. + * fs/ufs.c: Likewise. + * fs/xfs.c: Likewise. + * gencmdlist.sh: Likewise. + * genmk.rb: Likewise. + * include/grub/disk.h: Likewise. + * include/grub/efi/api.h: Likewise. + * include/grub/efi/efi.h: Likewise. + * include/grub/efi/pe32.h: Likewise. + * include/grub/elf.h: Likewise. + * include/grub/fs.h: Likewise. + * include/grub/i386/at_keyboard.h: Likewise. + * include/grub/i386/pc/memory.h: Likewise. + * include/grub/i386/pc/vbe.h: Likewise. + * include/grub/i386/pci.h: Likewise. + * include/grub/i386/tsc.h: Likewise. + * include/grub/ieee1275/ieee1275.h: Likewise. + * include/grub/ntfs.h: Likewise. + * include/grub/sparc64/ieee1275/ieee1275.h: Likewise. + * include/grub/sparc64/libgcc.h: Likewise. + * include/grub/symbol.h: Likewise. + * include/grub/types.h: Likewise. + * include/multiboot2.h: Likewise. + * io/gzio.c: Likewise. + * kern/device.c: Likewise. + * kern/disk.c: Likewise. + * kern/efi/efi.c: Likewise. + * kern/efi/mm.c: Likewise. + * kern/elf.c: Likewise. + * kern/file.c: Likewise. + * kern/i386/dl.c: Likewise. + * kern/i386/pc/init.c: Likewise. + * kern/i386/pc/startup.S: Likewise. + * kern/ieee1275/ieee1275.c: Likewise. + * kern/ieee1275/init.c: Likewise. + * kern/main.c: Likewise. + * kern/mm.c: Likewise. + * kern/powerpc/dl.c: Likewise. + * kern/sparc64/dl.c: Likewise. + * kern/x86_64/dl.c: Likewise. + * lib/hexdump.c: Likewise. + * loader/efi/appleloader.c: Likewise. + * loader/i386/ieee1275/linux.c: Likewise. + * loader/i386/pc/chainloader.c: Likewise. + * loader/i386/pc/linux.c: Likewise. + * loader/i386/pc/multiboot2.c: Likewise. + * loader/ieee1275/multiboot2.c: Likewise. + * loader/multiboot2.c: Likewise. + * loader/multiboot_loader.c: Likewise. + * loader/powerpc/ieee1275/linux.c: Likewise. + * normal/completion.c: Likewise. + * normal/menu_entry.c: Likewise. + * partmap/apple.c: Likewise. + * util/grub.d/10_hurd.in: Likewise. + * util/hostfs.c: Likewise. + * video/readers/png.c: Likewise. + 2010-01-03 Colin Watson * include/grub/misc.h (GNUC_PREREQ): New macro. diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S index 865326ee2..257f9044e 100644 --- a/boot/i386/pc/boot.S +++ b/boot/i386/pc/boot.S @@ -1,7 +1,7 @@ /* -*-Asm-*- */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2005,2006,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 diff --git a/boot/i386/pc/cdboot.S b/boot/i386/pc/cdboot.S index ccc9d64de..33569ce9d 100644 --- a/boot/i386/pc/cdboot.S +++ b/boot/i386/pc/cdboot.S @@ -1,7 +1,7 @@ /* -*-Asm-*- */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/boot/i386/pc/diskboot.S b/boot/i386/pc/diskboot.S index e5e4a4ef3..6b621190d 100644 --- a/boot/i386/pc/diskboot.S +++ b/boot/i386/pc/diskboot.S @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2006,2007 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2006,2007,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 diff --git a/boot/i386/pc/lnxboot.S b/boot/i386/pc/lnxboot.S index 43d170c6e..b4f0030b8 100644 --- a/boot/i386/pc/lnxboot.S +++ b/boot/i386/pc/lnxboot.S @@ -1,7 +1,7 @@ /* -*-Asm-*- */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/boot/i386/pc/pxeboot.S b/boot/i386/pc/pxeboot.S index 2fc53bc81..28c90e29b 100644 --- a/boot/i386/pc/pxeboot.S +++ b/boot/i386/pc/pxeboot.S @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2000,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2000,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 diff --git a/bus/pci.c b/bus/pci.c index fe4cad181..65d848a18 100644 --- a/bus/pci.c +++ b/bus/pci.c @@ -1,7 +1,7 @@ /* pci.c - Generic PCI interfaces. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007 Free Software Foundation, Inc. + * Copyright (C) 2007,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 diff --git a/commands/cmp.c b/commands/cmp.c index 8fd939640..626e1d022 100644 --- a/commands/cmp.c +++ b/commands/cmp.c @@ -1,7 +1,7 @@ /* cmd.c - command to cmp an operating system */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2005,2006,2007 Free Software Foundation, Inc. + * Copyright (C) 2003,2005,2006,2007,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 diff --git a/commands/help.c b/commands/help.c index 8ca2a5b1f..7edc23563 100644 --- a/commands/help.c +++ b/commands/help.c @@ -1,7 +1,7 @@ /* help.c - command to show a help text. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/commands/hexdump.c b/commands/hexdump.c index 5bdbb1f76..c1d4ecba9 100644 --- a/commands/hexdump.c +++ b/commands/hexdump.c @@ -1,7 +1,7 @@ /* hexdump.c - command to dump the contents of a file or memory */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/commands/i386/pc/halt.c b/commands/i386/pc/halt.c index 73c3a2e11..4c39612ae 100644 --- a/commands/i386/pc/halt.c +++ b/commands/i386/pc/halt.c @@ -1,7 +1,7 @@ /* halt.c - command to halt the computer. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2005,2007,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 diff --git a/commands/i386/pc/play.c b/commands/i386/pc/play.c index 96d9f6df5..1151dddf4 100644 --- a/commands/i386/pc/play.c +++ b/commands/i386/pc/play.c @@ -1,7 +1,7 @@ /* play.c - command to play a tune */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2005,2007,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 diff --git a/commands/i386/pc/vbeinfo.c b/commands/i386/pc/vbeinfo.c index 14f03846e..c266bbfcb 100644 --- a/commands/i386/pc/vbeinfo.c +++ b/commands/i386/pc/vbeinfo.c @@ -1,7 +1,7 @@ /* vbeinfo.c - command to list compatible VBE video modes. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/commands/ls.c b/commands/ls.c index 9afca7907..57409c4f6 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -1,7 +1,7 @@ /* ls.c - command to list files and devices */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/commands/test.c b/commands/test.c index 318a42264..6995165cf 100644 --- a/commands/test.c +++ b/commands/test.c @@ -1,7 +1,7 @@ /* test.c -- The test command.. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2005,2007,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 diff --git a/disk/dmraid_nvidia.c b/disk/dmraid_nvidia.c index 46eac6ac5..c4e3922cf 100644 --- a/disk/dmraid_nvidia.c +++ b/disk/dmraid_nvidia.c @@ -1,7 +1,7 @@ /* dmraid_nvidia.c - module to handle Nvidia fakeraid. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2006,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 diff --git a/disk/i386/pc/biosdisk.c b/disk/i386/pc/biosdisk.c index af184b1ba..19ee3f981 100644 --- a/disk/i386/pc/biosdisk.c +++ b/disk/i386/pc/biosdisk.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,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 diff --git a/disk/ieee1275/nand.c b/disk/ieee1275/nand.c index a9ed553cf..df2ee81f3 100644 --- a/disk/ieee1275/nand.c +++ b/disk/ieee1275/nand.c @@ -1,7 +1,7 @@ /* nand.c - NAND flash disk access. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/disk/ieee1275/ofdisk.c b/disk/ieee1275/ofdisk.c index c2a3a2c3a..c8c4d1a4e 100644 --- a/disk/ieee1275/ofdisk.c +++ b/disk/ieee1275/ofdisk.c @@ -1,7 +1,7 @@ /* ofdisk.c - Open Firmware disk access. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2004,2006,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 diff --git a/disk/lvm.c b/disk/lvm.c index 8d0c75a6d..2c54ca3b3 100644 --- a/disk/lvm.c +++ b/disk/lvm.c @@ -1,7 +1,7 @@ /* lvm.c - module to read Logical Volumes. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2006,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 diff --git a/disk/raid.c b/disk/raid.c index c48a41d8d..5d2793a07 100644 --- a/disk/raid.c +++ b/disk/raid.c @@ -1,7 +1,7 @@ /* raid.c - module to read RAID arrays. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2006,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 diff --git a/disk/raid6_recover.c b/disk/raid6_recover.c index ed0e92523..550968ceb 100644 --- a/disk/raid6_recover.c +++ b/disk/raid6_recover.c @@ -1,7 +1,7 @@ /* raid6_recover.c - module to recover from faulty RAID6 arrays. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2006,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 diff --git a/disk/scsi.c b/disk/scsi.c index 21b888559..2a5e934f0 100644 --- a/disk/scsi.c +++ b/disk/scsi.c @@ -1,7 +1,7 @@ /* scsi.c - scsi support. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/fs/affs.c b/fs/affs.c index de20fbca1..3dc80752d 100644 --- a/fs/affs.c +++ b/fs/affs.c @@ -1,7 +1,7 @@ /* affs.c - Amiga Fast FileSystem. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2005,2006,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 diff --git a/fs/cpio.c b/fs/cpio.c index 852c4dcd8..17c37975d 100644 --- a/fs/cpio.c +++ b/fs/cpio.c @@ -1,7 +1,7 @@ /* cpio.c - cpio and tar filesystem. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/fs/ext2.c b/fs/ext2.c index e7a20a43b..58be3e6fc 100644 --- a/fs/ext2.c +++ b/fs/ext2.c @@ -1,7 +1,7 @@ /* ext2.c - Second Extended filesystem */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/fs/hfs.c b/fs/hfs.c index 4dd1e3131..f7dc2484f 100644 --- a/fs/hfs.c +++ b/fs/hfs.c @@ -1,7 +1,7 @@ /* hfs.c - HFS. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2004,2005,2006,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 diff --git a/fs/iso9660.c b/fs/iso9660.c index 2fb0ffb63..0647ca8fc 100644 --- a/fs/iso9660.c +++ b/fs/iso9660.c @@ -2,7 +2,7 @@ SUSP, Rock Ridge. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2004,2005,2006,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 diff --git a/fs/ntfs.c b/fs/ntfs.c index 87db1a561..c1b4b2fe1 100644 --- a/fs/ntfs.c +++ b/fs/ntfs.c @@ -1,7 +1,7 @@ /* ntfs.c - NTFS filesystem */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/fs/sfs.c b/fs/sfs.c index 4f70ad3ec..68f8b3a6e 100644 --- a/fs/sfs.c +++ b/fs/sfs.c @@ -1,7 +1,7 @@ /* sfs.c - Amiga Smart FileSystem. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2005,2006,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 diff --git a/fs/udf.c b/fs/udf.c index b44fa8a6d..cecb6eb78 100644 --- a/fs/udf.c +++ b/fs/udf.c @@ -1,7 +1,7 @@ /* udf.c - Universal Disk Format filesystem. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/fs/ufs.c b/fs/ufs.c index f95a6e12e..9f3743d8b 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -1,7 +1,7 @@ /* ufs.c - Unix File System */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/fs/xfs.c b/fs/xfs.c index c15ec7341..8b512de37 100644 --- a/fs/xfs.c +++ b/fs/xfs.c @@ -1,7 +1,7 @@ /* xfs.c - XFS. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2005,2006,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 diff --git a/gencmdlist.sh b/gencmdlist.sh index 7f2549099..ed5965f07 100644 --- a/gencmdlist.sh +++ b/gencmdlist.sh @@ -1,6 +1,6 @@ #! /bin/sh # -# Copyright (C) 2005 Free Software Foundation, Inc. +# Copyright (C) 2005,2009 Free Software Foundation, Inc. # # This gensymlist.sh is free software; the author # gives unlimited permission to copy and/or distribute it, diff --git a/genmk.rb b/genmk.rb index b3dbe8678..b1cce3831 100644 --- a/genmk.rb +++ b/genmk.rb @@ -1,6 +1,6 @@ #! /usr/bin/ruby -w # -# Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc. +# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. # # This genmk.rb is free software; the author # gives unlimited permission to copy and/or distribute it, diff --git a/include/grub/disk.h b/include/grub/disk.h index de71bb588..6efbfe58a 100644 --- a/include/grub/disk.h +++ b/include/grub/disk.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2004,2005,2006,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 diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 32904150e..4a81207c6 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -1,7 +1,7 @@ /* efi.h - declare EFI types and functions */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2006,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 diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index b12205ad3..5852a476f 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -1,7 +1,7 @@ /* efi.h - declare variables and functions for EFI support */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2006,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 diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h index 4fb8d098c..21b56ae27 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2006,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 diff --git a/include/grub/elf.h b/include/grub/elf.h index 1a1ec1310..e54989cde 100644 --- a/include/grub/elf.h +++ b/include/grub/elf.h @@ -1,5 +1,5 @@ /* This file defines standard ELF types, structures, and macros. - Copyright (C) 1995-1999, 2000, 2001, 2002,2008 Free Software Foundation, Inc. + Copyright (C) 1995-1999,2000,2001,2002,2008,2009 Free Software Foundation, Inc. This file was part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/include/grub/fs.h b/include/grub/fs.h index 132ab4755..45f515768 100644 --- a/include/grub/fs.h +++ b/include/grub/fs.h @@ -1,7 +1,7 @@ /* fs.h - filesystem manager */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2004,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2004,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 diff --git a/include/grub/i386/at_keyboard.h b/include/grub/i386/at_keyboard.h index 017b58a62..e6ee60d28 100644 --- a/include/grub/i386/at_keyboard.h +++ b/include/grub/i386/at_keyboard.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/include/grub/i386/pc/memory.h b/include/grub/i386/pc/memory.h index e14cc3e96..841b06164 100644 --- a/include/grub/i386/pc/memory.h +++ b/include/grub/i386/pc/memory.h @@ -1,7 +1,7 @@ /* memory.h - describe the memory map */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,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 diff --git a/include/grub/i386/pc/vbe.h b/include/grub/i386/pc/vbe.h index 32427679b..9c4c4dd3d 100644 --- a/include/grub/i386/pc/vbe.h +++ b/include/grub/i386/pc/vbe.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2005,2006,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 diff --git a/include/grub/i386/pci.h b/include/grub/i386/pci.h index 5b5f5f0df..31217d5f5 100644 --- a/include/grub/i386/pci.h +++ b/include/grub/i386/pci.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/include/grub/i386/tsc.h b/include/grub/i386/tsc.h index 46041c2b2..dad9d062d 100644 --- a/include/grub/i386/tsc.h +++ b/include/grub/i386/tsc.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 0e6aae548..8b31e32e2 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -1,7 +1,7 @@ /* ieee1275.h - Access the Open Firmware client interface. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/include/grub/ntfs.h b/include/grub/ntfs.h index 6f9d4ad6e..31b99398b 100644 --- a/include/grub/ntfs.h +++ b/include/grub/ntfs.h @@ -1,7 +1,7 @@ /* ntfs.h - header for the NTFS filesystem */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007 Free Software Foundation, Inc. + * Copyright (C) 2007,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 diff --git a/include/grub/sparc64/ieee1275/ieee1275.h b/include/grub/sparc64/ieee1275/ieee1275.h index 7626e93c1..b25e98a6d 100644 --- a/include/grub/sparc64/ieee1275/ieee1275.h +++ b/include/grub/sparc64/ieee1275/ieee1275.h @@ -1,7 +1,7 @@ /* ieee1275.h - Access the Open Firmware client interface. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2004,2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2003,2004,2005,2007,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 diff --git a/include/grub/sparc64/libgcc.h b/include/grub/sparc64/libgcc.h index 008821d81..e73abe29c 100644 --- a/include/grub/sparc64/libgcc.h +++ b/include/grub/sparc64/libgcc.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004,2007 Free Software Foundation, Inc. + * Copyright (C) 2004,2007,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 diff --git a/include/grub/symbol.h b/include/grub/symbol.h index 6bf512d12..63ed19436 100644 --- a/include/grub/symbol.h +++ b/include/grub/symbol.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2006,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 diff --git a/include/grub/types.h b/include/grub/types.h index 5f6b7ec62..93174b424 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,2005,2006,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 diff --git a/include/multiboot2.h b/include/multiboot2.h index e55af8392..275aa5a9b 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -1,7 +1,7 @@ /* multiboot2.h - multiboot 2 header file. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007 Free Software Foundation, Inc. + * Copyright (C) 2007,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 diff --git a/io/gzio.c b/io/gzio.c index a38bfb372..39f6d7b13 100644 --- a/io/gzio.c +++ b/io/gzio.c @@ -1,7 +1,7 @@ /* gzio.c - decompression support for gzip */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2005,2006,2007 Free Software Foundation, Inc. + * Copyright (C) 1999,2005,2006,2007,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 diff --git a/kern/device.c b/kern/device.c index 9f219949b..f519c63b2 100644 --- a/kern/device.c +++ b/kern/device.c @@ -1,7 +1,7 @@ /* device.c - device manager */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,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 diff --git a/kern/disk.c b/kern/disk.c index e463626fb..1f10c8731 100644 --- a/kern/disk.c +++ b/kern/disk.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2004,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2004,2006,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 diff --git a/kern/efi/efi.c b/kern/efi/efi.c index 501ab4578..c6ce04c5e 100644 --- a/kern/efi/efi.c +++ b/kern/efi/efi.c @@ -1,7 +1,7 @@ /* efi.c - generic EFI support */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2006,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 diff --git a/kern/efi/mm.c b/kern/efi/mm.c index e1fca81f3..ceb8fc9ba 100644 --- a/kern/efi/mm.c +++ b/kern/efi/mm.c @@ -1,7 +1,7 @@ /* mm.c - generic EFI memory management */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2006,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 diff --git a/kern/elf.c b/kern/elf.c index 10fe9c758..7625f6acd 100644 --- a/kern/elf.c +++ b/kern/elf.c @@ -1,7 +1,7 @@ /* elf.c - load ELF files */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2003,2004,2005,2006,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 diff --git a/kern/file.c b/kern/file.c index 4224cf910..e17c35f95 100644 --- a/kern/file.c +++ b/kern/file.c @@ -1,7 +1,7 @@ /* file.c - file I/O functions */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2006,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2006,2007,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 diff --git a/kern/i386/dl.c b/kern/i386/dl.c index 91121f614..57854964b 100644 --- a/kern/i386/dl.c +++ b/kern/i386/dl.c @@ -1,7 +1,7 @@ /* dl-386.c - arch-dependent part of loadable module support */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2005,2007,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 diff --git a/kern/i386/pc/init.c b/kern/i386/pc/init.c index ebe4bb6ea..0f2374c6d 100644 --- a/kern/i386/pc/init.c +++ b/kern/i386/pc/init.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2004,2005,2006,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 diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S index 06e26dea3..23f3f398e 100644 --- a/kern/i386/pc/startup.S +++ b/kern/i386/pc/startup.S @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,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 diff --git a/kern/ieee1275/ieee1275.c b/kern/ieee1275/ieee1275.c index 37a98071c..8a5773c23 100644 --- a/kern/ieee1275/ieee1275.c +++ b/kern/ieee1275/ieee1275.c @@ -1,7 +1,7 @@ /* of.c - Access the Open Firmware client interface. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/kern/ieee1275/init.c b/kern/ieee1275/init.c index f3305d71c..3e11d2369 100644 --- a/kern/ieee1275/init.c +++ b/kern/ieee1275/init.c @@ -1,7 +1,7 @@ /* init.c -- Initialize GRUB on the newworld mac (PPC). */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/kern/main.c b/kern/main.c index 9215d55e7..b3b33e93b 100644 --- a/kern/main.c +++ b/kern/main.c @@ -1,7 +1,7 @@ /* main.c - the kernel main routine */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2005,2006,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2005,2006,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 diff --git a/kern/mm.c b/kern/mm.c index cbcb99560..ef97b018e 100644 --- a/kern/mm.c +++ b/kern/mm.c @@ -1,7 +1,7 @@ /* mm.c - functions for memory manager */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,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 diff --git a/kern/powerpc/dl.c b/kern/powerpc/dl.c index fa112b16f..ad19e5600 100644 --- a/kern/powerpc/dl.c +++ b/kern/powerpc/dl.c @@ -1,7 +1,7 @@ /* dl.c - arch-dependent part of loadable module support */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2004,2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2004,2005,2007,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 diff --git a/kern/sparc64/dl.c b/kern/sparc64/dl.c index 7932b4969..7b6266cac 100644 --- a/kern/sparc64/dl.c +++ b/kern/sparc64/dl.c @@ -1,7 +1,7 @@ /* dl.c - arch-dependent part of loadable module support */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2004,2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2004,2005,2007,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 diff --git a/kern/x86_64/dl.c b/kern/x86_64/dl.c index 73a7337e7..090ad78b8 100644 --- a/kern/x86_64/dl.c +++ b/kern/x86_64/dl.c @@ -1,7 +1,7 @@ /* dl-x86_64.c - arch-dependent part of loadable module support */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2005,2007,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 diff --git a/lib/hexdump.c b/lib/hexdump.c index c69cb093b..800beb2ba 100644 --- a/lib/hexdump.c +++ b/lib/hexdump.c @@ -1,7 +1,7 @@ /* hexdump.c - hexdump function */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/loader/efi/appleloader.c b/loader/efi/appleloader.c index a7c2183ab..a64530748 100644 --- a/loader/efi/appleloader.c +++ b/loader/efi/appleloader.c @@ -1,7 +1,7 @@ /* appleloader.c - apple legacy boot loader. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/loader/i386/ieee1275/linux.c b/loader/i386/ieee1275/linux.c index b577de964..e8a6f1a52 100644 --- a/loader/i386/ieee1275/linux.c +++ b/loader/i386/ieee1275/linux.c @@ -1,7 +1,7 @@ /* linux.c - boot Linux zImage or bzImage */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 1999,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 diff --git a/loader/i386/pc/chainloader.c b/loader/i386/pc/chainloader.c index 27dda4f4f..a153d80a9 100644 --- a/loader/i386/pc/chainloader.c +++ b/loader/i386/pc/chainloader.c @@ -1,7 +1,7 @@ /* chainloader.c - boot another boot loader */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2004,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2004,2007,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 diff --git a/loader/i386/pc/linux.c b/loader/i386/pc/linux.c index b93754559..77b7966bf 100644 --- a/loader/i386/pc/linux.c +++ b/loader/i386/pc/linux.c @@ -1,7 +1,7 @@ /* linux.c - boot Linux zImage or bzImage */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 1999,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 diff --git a/loader/i386/pc/multiboot2.c b/loader/i386/pc/multiboot2.c index 9bfe5d248..005c8a823 100644 --- a/loader/i386/pc/multiboot2.c +++ b/loader/i386/pc/multiboot2.c @@ -1,7 +1,7 @@ /* multiboot2.c - boot a multiboot 2 OS image. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/loader/ieee1275/multiboot2.c b/loader/ieee1275/multiboot2.c index 8c0bc09ec..846550ee5 100644 --- a/loader/ieee1275/multiboot2.c +++ b/loader/ieee1275/multiboot2.c @@ -1,7 +1,7 @@ /* multiboot.c - boot a multiboot 2 OS image. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007 Free Software Foundation, Inc. + * Copyright (C) 2007,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 diff --git a/loader/multiboot2.c b/loader/multiboot2.c index dbdee9c87..cfc7b400c 100644 --- a/loader/multiboot2.c +++ b/loader/multiboot2.c @@ -1,7 +1,7 @@ /* multiboot2.c - boot a multiboot 2 OS image. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007 Free Software Foundation, Inc. + * Copyright (C) 2007,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 diff --git a/loader/multiboot_loader.c b/loader/multiboot_loader.c index 24c0c5eac..9e5cf1628 100644 --- a/loader/multiboot_loader.c +++ b/loader/multiboot_loader.c @@ -1,7 +1,7 @@ /* multiboot_loader.c - boot multiboot 1 or 2 OS image */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/loader/powerpc/ieee1275/linux.c b/loader/powerpc/ieee1275/linux.c index 7996a22f6..085f5c026 100644 --- a/loader/powerpc/ieee1275/linux.c +++ b/loader/powerpc/ieee1275/linux.c @@ -1,7 +1,7 @@ /* linux.c - boot Linux */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc. + * Copyright (C) 2003,2004,2005,2007,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 diff --git a/normal/completion.c b/normal/completion.c index d264028cc..f9d8307e8 100644 --- a/normal/completion.c +++ b/normal/completion.c @@ -1,7 +1,7 @@ /* completion.c - complete a command, a disk, a partition or a file */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 1999,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 diff --git a/normal/menu_entry.c b/normal/menu_entry.c index bd97d17d7..1b26be1fd 100644 --- a/normal/menu_entry.c +++ b/normal/menu_entry.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2005,2006,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 diff --git a/partmap/apple.c b/partmap/apple.c index 765912672..7934c90fd 100644 --- a/partmap/apple.c +++ b/partmap/apple.c @@ -1,7 +1,7 @@ /* apple.c - Read macintosh partition tables. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2004,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2002,2004,2005,2006,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 diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index e693c7dfa..19fd8ec27 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -1,7 +1,7 @@ #! /bin/sh -e # grub-mkconfig helper script. -# Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. +# Copyright (C) 2006,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 diff --git a/util/hostfs.c b/util/hostfs.c index 83db2f1a9..df930b42e 100644 --- a/util/hostfs.c +++ b/util/hostfs.c @@ -1,7 +1,7 @@ /* hostfs.c - Dummy filesystem to provide access to the hosts filesystem */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2008 Free Software Foundation, Inc. + * Copyright (C) 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 diff --git a/video/readers/png.c b/video/readers/png.c index 4e16bf27e..8eec421dd 100644 --- a/video/readers/png.c +++ b/video/readers/png.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 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 From ab0eeb0c33df3b11fb52397b8bd2595275eb2a8b Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 3 Jan 2010 22:15:44 +0000 Subject: [PATCH 139/208] 2010-01-03 Robert Millan * loader/efi/appleloader.c: Remove. Update all users. --- ChangeLog | 4 + conf/i386-efi.rmk | 7 +- conf/x86_64-efi.rmk | 7 +- loader/efi/appleloader.c | 218 --------------------------------------- 4 files changed, 6 insertions(+), 230 deletions(-) delete mode 100644 loader/efi/appleloader.c diff --git a/ChangeLog b/ChangeLog index db63c66f5..51c6a644e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-03 Robert Millan + + * loader/efi/appleloader.c: Remove. Update all users. + 2010-01-03 Robert Millan * boot/i386/pc/boot.S: Update copyright year. diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index 3a219e71b..df4768be1 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -30,7 +30,7 @@ sbin_SCRIPTS = grub-install grub_install_SOURCES = util/i386/efi/grub-install.in # Modules. -pkglib_MODULES = kernel.img chain.mod appleldr.mod \ +pkglib_MODULES = kernel.img chain.mod \ linux.mod halt.mod reboot.mod pci.mod lspci.mod \ datetime.mod date.mod datehook.mod loadbios.mod \ fixvideo.mod mmap.mod acpi.mod @@ -88,11 +88,6 @@ chain_mod_SOURCES = loader/efi/chainloader.c chain_mod_CFLAGS = $(COMMON_CFLAGS) chain_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For appleldr.mod. -appleldr_mod_SOURCES = loader/efi/appleloader.c -appleldr_mod_CFLAGS = $(COMMON_CFLAGS) -appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS) - # For linux.mod. linux_mod_SOURCES = loader/i386/efi/linux.c linux_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index a82b35222..c0d3c22c1 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -29,7 +29,7 @@ sbin_SCRIPTS = grub-install grub_install_SOURCES = util/i386/efi/grub-install.in # Modules. -pkglib_MODULES = kernel.img chain.mod appleldr.mod \ +pkglib_MODULES = kernel.img chain.mod \ halt.mod reboot.mod linux.mod pci.mod lspci.mod \ datetime.mod date.mod datehook.mod loadbios.mod \ fixvideo.mod mmap.mod acpi.mod ata.mod @@ -93,11 +93,6 @@ chain_mod_SOURCES = loader/efi/chainloader.c chain_mod_CFLAGS = $(COMMON_CFLAGS) chain_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For appleldr.mod. -appleldr_mod_SOURCES = loader/efi/appleloader.c -appleldr_mod_CFLAGS = $(COMMON_CFLAGS) -appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS) - # For linux.mod. linux_mod_SOURCES = loader/i386/efi/linux.c loader/i386/linux_trampoline.S linux_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/loader/efi/appleloader.c b/loader/efi/appleloader.c deleted file mode 100644 index a64530748..000000000 --- a/loader/efi/appleloader.c +++ /dev/null @@ -1,218 +0,0 @@ -/* appleloader.c - apple legacy boot loader. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 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 - * 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 -#include - -static grub_dl_t my_mod; - -static grub_efi_handle_t image_handle; -static grub_efi_char16_t *cmdline; - -static grub_err_t -grub_appleloader_unload (void) -{ - grub_efi_boot_services_t *b; - - b = grub_efi_system_table->boot_services; - efi_call_1 (b->unload_image, image_handle); - - grub_free (cmdline); - cmdline = 0; - - grub_dl_unref (my_mod); - return GRUB_ERR_NONE; -} - -static grub_err_t -grub_appleloader_boot (void) -{ - grub_efi_boot_services_t *b; - - b = grub_efi_system_table->boot_services; - efi_call_3 (b->start_image, image_handle, 0, 0); - - grub_appleloader_unload (); - - return grub_errno; -} - -/* early 2006 Core Duo / Core Solo models */ -static grub_uint8_t devpath_1[] = -{ - 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xF9, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, - 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, - 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, -}; - -/* mid-2006 Mac Pro (and probably other Core 2 models) */ -static grub_uint8_t devpath_2[] = -{ - 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xF7, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, - 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, - 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, -}; - -/* mid-2007 MBP ("Santa Rosa" based models) */ -static grub_uint8_t devpath_3[] = -{ - 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, - 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, - 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, -}; - -/* early-2008 MBA */ -static grub_uint8_t devpath_4[] = -{ - 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xC0, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, - 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, - 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, -}; - -/* late-2008 MB/MBP (NVidia chipset) */ -static grub_uint8_t devpath_5[] = { - 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, - 0x00, 0x40, 0xCB, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xBF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, - 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, - 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, -}; - -struct devdata -{ - char *model; - grub_efi_device_path_t *devpath; -}; - -struct devdata devs[] = -{ - {"Core Duo/Solo", (grub_efi_device_path_t *) devpath_1}, - {"Mac Pro", (grub_efi_device_path_t *) devpath_2}, - {"MBP", (grub_efi_device_path_t *) devpath_3}, - {"MBA", (grub_efi_device_path_t *) devpath_4}, - {"MB NV", (grub_efi_device_path_t *) devpath_5}, - {NULL, NULL}, -}; - -static grub_err_t -grub_cmd_appleloader (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) -{ - grub_efi_boot_services_t *b; - grub_efi_loaded_image_t *loaded_image; - struct devdata *pdev; - - grub_dl_ref (my_mod); - - /* Initialize some global variables. */ - image_handle = 0; - - b = grub_efi_system_table->boot_services; - - for (pdev = devs ; pdev->devpath ; pdev++) - if (efi_call_6 (b->load_image, 0, grub_efi_image_handle, pdev->devpath, - NULL, 0, &image_handle) == GRUB_EFI_SUCCESS) - break; - - if (! pdev->devpath) - { - grub_error (GRUB_ERR_BAD_OS, "can't find model"); - goto fail; - } - - grub_printf ("Model : %s\n", pdev->model); - - loaded_image = grub_efi_get_loaded_image (image_handle); - if (! loaded_image) - { - grub_error (GRUB_ERR_BAD_OS, "no loaded image available"); - goto fail; - } - - if (argc > 0) - { - int i, len; - grub_efi_char16_t *p16; - - for (i = 0, len = 0; i < argc; i++) - len += grub_strlen (argv[i]) + 1; - - len *= sizeof (grub_efi_char16_t); - cmdline = p16 = grub_malloc (len); - if (! cmdline) - goto fail; - - for (i = 0; i < argc; i++) - { - char *p8; - - p8 = argv[i]; - while (*p8) - *(p16++) = *(p8++); - - *(p16++) = ' '; - } - *(--p16) = 0; - - loaded_image->load_options = cmdline; - loaded_image->load_options_size = len; - } - - grub_loader_set (grub_appleloader_boot, grub_appleloader_unload, 0); - - return 0; - - fail: - - grub_dl_unref (my_mod); - return grub_errno; -} - -static grub_command_t cmd; - -GRUB_MOD_INIT(appleloader) -{ - cmd = grub_register_command ("appleloader", grub_cmd_appleloader, - "[OPTS]", "Boot legacy system."); - my_mod = mod; -} - -GRUB_MOD_FINI(appleloader) -{ - grub_unregister_command (cmd); -} From 3a73dcb6f5a2a6887752290602a3327c7bab3481 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 3 Jan 2010 22:34:03 +0000 Subject: [PATCH 140/208] 2010-01-03 Robert Millan * boot/i386/pc/diskboot.S: Fix inaccurate comment. * util/i386/pc/grub-setup.c: Include `'. (struct boot_blocklist): Move from here ... * include/grub/i386/pc/boot.h [ASM_FILE] (struct grub_boot_blocklist): ... to here. Update all users. (setup): Only initialize `start' member of `first_block' structure. Add assert() calls to verify the other members. * util/i386/pc/grub-mkimage.c: Include `'. (generate_image): Fix broken blocklist length initialization. Add assert() call to verify blocklist `segment' field. --- ChangeLog | 15 +++++++++++++++ boot/i386/pc/diskboot.S | 4 ++-- include/grub/i386/pc/boot.h | 14 +++++++++++++- util/i386/pc/grub-mkimage.c | 16 ++++++++++++---- util/i386/pc/grub-setup.c | 28 +++++++++++----------------- 5 files changed, 53 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 51c6a644e..ba26f07d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2010-01-03 Robert Millan + + * boot/i386/pc/diskboot.S: Fix inaccurate comment. + + * util/i386/pc/grub-setup.c: Include `'. + (struct boot_blocklist): Move from here ... + * include/grub/i386/pc/boot.h [ASM_FILE] + (struct grub_boot_blocklist): ... to here. Update all users. + (setup): Only initialize `start' member of `first_block' + structure. Add assert() calls to verify the other members. + + * util/i386/pc/grub-mkimage.c: Include `'. + (generate_image): Fix broken blocklist length initialization. + Add assert() call to verify blocklist `segment' field. + 2010-01-03 Robert Millan * loader/efi/appleloader.c: Remove. Update all users. diff --git a/boot/i386/pc/diskboot.S b/boot/i386/pc/diskboot.S index 6b621190d..92f223f0d 100644 --- a/boot/i386/pc/diskboot.S +++ b/boot/i386/pc/diskboot.S @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2006,2007,2009 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2006,2007,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -370,7 +370,7 @@ blocklist_default_start: the start of the disk, sector 0 */ .long 2, 0 blocklist_default_len: - /* this is the number of sectors to read the command "install" + /* this is the number of sectors to read. grub-mkimage will fill this up */ .word 0 blocklist_default_seg: diff --git a/include/grub/i386/pc/boot.h b/include/grub/i386/pc/boot.h index f45fe6da0..508b10742 100644 --- a/include/grub/i386/pc/boot.h +++ b/include/grub/i386/pc/boot.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2002,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2002,2005,2006,2007,2008,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -66,4 +66,16 @@ /* The size of a block list used in the kernel startup code. */ #define GRUB_BOOT_MACHINE_LIST_SIZE 12 +#ifndef ASM_FILE + +/* This is the blocklist used in the diskboot image. */ +struct grub_boot_blocklist +{ + grub_uint64_t start; + grub_uint16_t len; + grub_uint16_t segment; +} __attribute__ ((packed)); + +#endif /* ! ASM_FILE */ + #endif /* ! BOOT_MACHINE_HEADER */ diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index aaa1a13db..ebf1bc7ff 100644 --- a/util/i386/pc/grub-mkimage.c +++ b/util/i386/pc/grub-mkimage.c @@ -33,6 +33,7 @@ #include #include #include +#include #define _GNU_SOURCE 1 #include @@ -212,10 +213,17 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], boot_img = grub_util_read_image (boot_path); - /* i386 is a little endian architecture. */ - *((grub_uint16_t *) (boot_img + GRUB_DISK_SECTOR_SIZE - - GRUB_BOOT_MACHINE_LIST_SIZE + 8)) - = grub_cpu_to_le16 (num); + { + struct grub_boot_blocklist *block; + block = (struct grub_boot_blocklist *) (boot_img + + GRUB_DISK_SECTOR_SIZE + - sizeof (*block)); + block->len = grub_host_to_target16 (num); + + /* This is filled elsewhere. Verify it just in case. */ + assert (block->segment == grub_host_to_target16 (GRUB_BOOT_MACHINE_KERNEL_SEG + + (GRUB_DISK_SECTOR_SIZE >> 4))); + } grub_util_write_image (boot_img, boot_size, out); free (boot_img); diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c index 5a1cbb27a..909a521eb 100644 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@ -48,6 +48,7 @@ static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot = GRUB_GPT_P #include #include #include +#include #include "progname.h" #define _GNU_SOURCE 1 @@ -56,14 +57,6 @@ static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot = GRUB_GPT_P #define DEFAULT_BOOT_FILE "boot.img" #define DEFAULT_CORE_FILE "core.img" -/* This is the blocklist used in the diskboot image. */ -struct boot_blocklist -{ - grub_uint64_t start; - grub_uint16_t len; - grub_uint16_t segment; -} __attribute__ ((packed)); - void grub_putchar (int c) { @@ -99,7 +92,7 @@ setup (const char *dir, grub_uint8_t *boot_drive; grub_disk_addr_t *kernel_sector; grub_uint16_t *boot_drive_check; - struct boot_blocklist *first_block, *block; + struct grub_boot_blocklist *first_block, *block; grub_int32_t *install_dos_part, *install_bsd_part; grub_int32_t dos_part, bsd_part; char *tmp_img; @@ -171,7 +164,7 @@ setup (const char *dir, void NESTED_FUNC_ATTR save_blocklists (grub_disk_addr_t sector, unsigned offset, unsigned length) { - struct boot_blocklist *prev = block + 1; + struct grub_boot_blocklist *prev = block + 1; grub_util_info ("saving <%llu,%u,%u> with the segment 0x%x", sector, offset, length, (unsigned) current_segment); @@ -226,9 +219,9 @@ setup (const char *dir, core_img = grub_util_read_image (core_path); /* Have FIRST_BLOCK to point to the first blocklist. */ - first_block = (struct boot_blocklist *) (core_img - + GRUB_DISK_SECTOR_SIZE - - sizeof (*block)); + first_block = (struct grub_boot_blocklist *) (core_img + + GRUB_DISK_SECTOR_SIZE + - sizeof (*block)); install_dos_part = (grub_int32_t *) (core_img + GRUB_DISK_SECTOR_SIZE + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART); @@ -389,10 +382,11 @@ setup (const char *dir, /* The first blocklist contains the whole sectors. */ first_block->start = grub_cpu_to_le64 (embed_region.start + 1); - first_block->len = grub_cpu_to_le16 (core_sectors - 1); - first_block->segment - = grub_cpu_to_le16 (GRUB_BOOT_MACHINE_KERNEL_SEG - + (GRUB_DISK_SECTOR_SIZE >> 4)); + + /* These are filled elsewhere. Verify them just in case. */ + assert (first_block->len == grub_host_to_target16 (core_sectors - 1)); + assert (first_block->segment == grub_host_to_target16 (GRUB_BOOT_MACHINE_KERNEL_SEG + + (GRUB_DISK_SECTOR_SIZE >> 4))); /* Make sure that the second blocklist is a terminator. */ block = first_block - 1; From 98ff6a54de1223845d5a8a297015311256befe5e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 4 Jan 2010 14:53:15 +0100 Subject: [PATCH 141/208] 2010-01-04 Vladimir Serbinenko * loader/efi/appleloader.c: Restored. Update all users. --- ChangeLog | 4 + conf/i386-efi.rmk | 7 +- conf/x86_64-efi.rmk | 7 +- loader/efi/appleloader.c | 218 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 loader/efi/appleloader.c diff --git a/ChangeLog b/ChangeLog index ba26f07d7..db0c0d2f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-04 Vladimir Serbinenko + + * loader/efi/appleloader.c: Restored. Update all users. + 2010-01-03 Robert Millan * boot/i386/pc/diskboot.S: Fix inaccurate comment. diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index df4768be1..3a219e71b 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -30,7 +30,7 @@ sbin_SCRIPTS = grub-install grub_install_SOURCES = util/i386/efi/grub-install.in # Modules. -pkglib_MODULES = kernel.img chain.mod \ +pkglib_MODULES = kernel.img chain.mod appleldr.mod \ linux.mod halt.mod reboot.mod pci.mod lspci.mod \ datetime.mod date.mod datehook.mod loadbios.mod \ fixvideo.mod mmap.mod acpi.mod @@ -88,6 +88,11 @@ chain_mod_SOURCES = loader/efi/chainloader.c chain_mod_CFLAGS = $(COMMON_CFLAGS) chain_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For appleldr.mod. +appleldr_mod_SOURCES = loader/efi/appleloader.c +appleldr_mod_CFLAGS = $(COMMON_CFLAGS) +appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For linux.mod. linux_mod_SOURCES = loader/i386/efi/linux.c linux_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index c0d3c22c1..a82b35222 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -29,7 +29,7 @@ sbin_SCRIPTS = grub-install grub_install_SOURCES = util/i386/efi/grub-install.in # Modules. -pkglib_MODULES = kernel.img chain.mod \ +pkglib_MODULES = kernel.img chain.mod appleldr.mod \ halt.mod reboot.mod linux.mod pci.mod lspci.mod \ datetime.mod date.mod datehook.mod loadbios.mod \ fixvideo.mod mmap.mod acpi.mod ata.mod @@ -93,6 +93,11 @@ chain_mod_SOURCES = loader/efi/chainloader.c chain_mod_CFLAGS = $(COMMON_CFLAGS) chain_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For appleldr.mod. +appleldr_mod_SOURCES = loader/efi/appleloader.c +appleldr_mod_CFLAGS = $(COMMON_CFLAGS) +appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For linux.mod. linux_mod_SOURCES = loader/i386/efi/linux.c loader/i386/linux_trampoline.S linux_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/loader/efi/appleloader.c b/loader/efi/appleloader.c new file mode 100644 index 000000000..a64530748 --- /dev/null +++ b/loader/efi/appleloader.c @@ -0,0 +1,218 @@ +/* appleloader.c - apple legacy boot loader. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 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 + * 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 +#include + +static grub_dl_t my_mod; + +static grub_efi_handle_t image_handle; +static grub_efi_char16_t *cmdline; + +static grub_err_t +grub_appleloader_unload (void) +{ + grub_efi_boot_services_t *b; + + b = grub_efi_system_table->boot_services; + efi_call_1 (b->unload_image, image_handle); + + grub_free (cmdline); + cmdline = 0; + + grub_dl_unref (my_mod); + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_appleloader_boot (void) +{ + grub_efi_boot_services_t *b; + + b = grub_efi_system_table->boot_services; + efi_call_3 (b->start_image, image_handle, 0, 0); + + grub_appleloader_unload (); + + return grub_errno; +} + +/* early 2006 Core Duo / Core Solo models */ +static grub_uint8_t devpath_1[] = +{ + 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xF9, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, + 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, + 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, +}; + +/* mid-2006 Mac Pro (and probably other Core 2 models) */ +static grub_uint8_t devpath_2[] = +{ + 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xF7, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, + 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, + 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, +}; + +/* mid-2007 MBP ("Santa Rosa" based models) */ +static grub_uint8_t devpath_3[] = +{ + 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, + 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, + 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, +}; + +/* early-2008 MBA */ +static grub_uint8_t devpath_4[] = +{ + 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xC0, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, + 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, + 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, +}; + +/* late-2008 MB/MBP (NVidia chipset) */ +static grub_uint8_t devpath_5[] = { + 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, + 0x00, 0x40, 0xCB, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xBF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, + 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, + 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, +}; + +struct devdata +{ + char *model; + grub_efi_device_path_t *devpath; +}; + +struct devdata devs[] = +{ + {"Core Duo/Solo", (grub_efi_device_path_t *) devpath_1}, + {"Mac Pro", (grub_efi_device_path_t *) devpath_2}, + {"MBP", (grub_efi_device_path_t *) devpath_3}, + {"MBA", (grub_efi_device_path_t *) devpath_4}, + {"MB NV", (grub_efi_device_path_t *) devpath_5}, + {NULL, NULL}, +}; + +static grub_err_t +grub_cmd_appleloader (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) +{ + grub_efi_boot_services_t *b; + grub_efi_loaded_image_t *loaded_image; + struct devdata *pdev; + + grub_dl_ref (my_mod); + + /* Initialize some global variables. */ + image_handle = 0; + + b = grub_efi_system_table->boot_services; + + for (pdev = devs ; pdev->devpath ; pdev++) + if (efi_call_6 (b->load_image, 0, grub_efi_image_handle, pdev->devpath, + NULL, 0, &image_handle) == GRUB_EFI_SUCCESS) + break; + + if (! pdev->devpath) + { + grub_error (GRUB_ERR_BAD_OS, "can't find model"); + goto fail; + } + + grub_printf ("Model : %s\n", pdev->model); + + loaded_image = grub_efi_get_loaded_image (image_handle); + if (! loaded_image) + { + grub_error (GRUB_ERR_BAD_OS, "no loaded image available"); + goto fail; + } + + if (argc > 0) + { + int i, len; + grub_efi_char16_t *p16; + + for (i = 0, len = 0; i < argc; i++) + len += grub_strlen (argv[i]) + 1; + + len *= sizeof (grub_efi_char16_t); + cmdline = p16 = grub_malloc (len); + if (! cmdline) + goto fail; + + for (i = 0; i < argc; i++) + { + char *p8; + + p8 = argv[i]; + while (*p8) + *(p16++) = *(p8++); + + *(p16++) = ' '; + } + *(--p16) = 0; + + loaded_image->load_options = cmdline; + loaded_image->load_options_size = len; + } + + grub_loader_set (grub_appleloader_boot, grub_appleloader_unload, 0); + + return 0; + + fail: + + grub_dl_unref (my_mod); + return grub_errno; +} + +static grub_command_t cmd; + +GRUB_MOD_INIT(appleloader) +{ + cmd = grub_register_command ("appleloader", grub_cmd_appleloader, + "[OPTS]", "Boot legacy system."); + my_mod = mod; +} + +GRUB_MOD_FINI(appleloader) +{ + grub_unregister_command (cmd); +} From 52c2d97f266b37af831db945f9ad2900b7e358bc Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 4 Jan 2010 14:59:06 +0100 Subject: [PATCH 142/208] 2010-01-04 Vladimir Serbinenko * include/grub/efi/api.h (GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE): New constant. (grub_efi_piwg_device_path): New structure (grub_efi_piwg_device_path_t): New type. * loader/efi/appleloader.c (piwg_full_device_path): New structure. (devpath_1): Transform to a structure. All users updated. (devpath_2): Likewise. (devpath_3): Likewise. (devpath_4): Likewise. (devpath_5): Likewise. --- ChangeLog | 13 +++ include/grub/efi/api.h | 10 ++ loader/efi/appleloader.c | 195 +++++++++++++++++++++++++++++++-------- 3 files changed, 177 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index db0c0d2f2..c71862f78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2010-01-04 Vladimir Serbinenko + + * include/grub/efi/api.h (GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE): + New constant. + (grub_efi_piwg_device_path): New structure + (grub_efi_piwg_device_path_t): New type. + * loader/efi/appleloader.c (piwg_full_device_path): New structure. + (devpath_1): Transform to a structure. All users updated. + (devpath_2): Likewise. + (devpath_3): Likewise. + (devpath_4): Likewise. + (devpath_5): Likewise. + 2010-01-04 Vladimir Serbinenko * loader/efi/appleloader.c: Restored. Update all users. diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 4a81207c6..36363ae1e 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -584,6 +584,16 @@ struct grub_efi_protocol_device_path }; typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t; +#define GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE 6 + +struct grub_efi_piwg_device_path +{ + grub_efi_device_path_t header; + grub_efi_guid_t guid __attribute__ ((packed)); +}; +typedef struct grub_efi_piwg_device_path grub_efi_piwg_device_path_t; + + /* BIOS Boot Specification Device Path. */ #define GRUB_EFI_BIOS_DEVICE_PATH_TYPE 5 diff --git a/loader/efi/appleloader.c b/loader/efi/appleloader.c index a64530748..114a0a506 100644 --- a/loader/efi/appleloader.c +++ b/loader/efi/appleloader.c @@ -59,58 +59,171 @@ grub_appleloader_boot (void) return grub_errno; } -/* early 2006 Core Duo / Core Solo models */ -static grub_uint8_t devpath_1[] = +struct piwg_full_device_path { - 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xF9, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, - 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, - 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, + struct grub_efi_memory_mapped_device_path comp1; + struct grub_efi_piwg_device_path comp2; + struct grub_efi_device_path end; +}; + +/* early 2006 Core Duo / Core Solo models */ +static struct piwg_full_device_path devpath_1 = +{ + .comp1 = + { + .header = { + .type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_memory_mapped_device_path), 0} + }, + .memory_type = GRUB_EFI_MEMORY_MAPPED_IO, + .start_address = 0xffe00000, + .end_address = 0xfff9ffff + }, + .comp2 = + { + .header = { + .type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_piwg_device_path), 0} + }, + .guid = {0x2B0585EB, 0xD8B8, 0x49A9, {0x8B, 0x8C, 0xE2, 0x1B, + 0x01, 0xAE, 0xF2, 0xB7}} + }, + .end = + { + .type = GRUB_EFI_END_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_device_path), 0} + } }; /* mid-2006 Mac Pro (and probably other Core 2 models) */ -static grub_uint8_t devpath_2[] = +static struct piwg_full_device_path devpath_2 = { - 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xF7, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, - 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, - 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, + .comp1 = + { + .header = { + .type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_memory_mapped_device_path), 0} + }, + .memory_type = GRUB_EFI_MEMORY_MAPPED_IO, + .start_address = 0xffe00000, + .end_address = 0xfff7ffff + }, + .comp2 = + { + .header = { + .type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_piwg_device_path), 0} + }, + .guid = {0x2B0585EB, 0xD8B8, 0x49A9, {0x8B, 0x8C, 0xE2, 0x1B, + 0x01, 0xAE, 0xF2, 0xB7}} + }, + .end = + { + .type = GRUB_EFI_END_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_device_path), 0} + } }; /* mid-2007 MBP ("Santa Rosa" based models) */ -static grub_uint8_t devpath_3[] = +static struct piwg_full_device_path devpath_3 = { - 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, - 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, - 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, + .comp1 = + { + .header = { + .type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_memory_mapped_device_path), 0} + }, + .memory_type = GRUB_EFI_MEMORY_MAPPED_IO, + .start_address = 0xffe00000, + .end_address = 0xfff8ffff + }, + .comp2 = + { + .header = { + .type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_piwg_device_path), 0} + }, + .guid = {0x2B0585EB, 0xD8B8, 0x49A9, {0x8B, 0x8C, 0xE2, 0x1B, + 0x01, 0xAE, 0xF2, 0xB7}} + }, + .end = + { + .type = GRUB_EFI_END_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_device_path), 0} + } }; /* early-2008 MBA */ -static grub_uint8_t devpath_4[] = +static struct piwg_full_device_path devpath_4 = { - 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xC0, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, - 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, - 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, + .comp1 = + { + .header = { + .type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_memory_mapped_device_path), 0} + }, + .memory_type = GRUB_EFI_MEMORY_MAPPED_IO, + .start_address = 0xffc00000, + .end_address = 0xfff8ffff + }, + .comp2 = + { + .header = { + .type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_piwg_device_path), 0} + }, + .guid = {0x2B0585EB, 0xD8B8, 0x49A9, {0x8B, 0x8C, 0xE2, 0x1B, + 0x01, 0xAE, 0xF2, 0xB7}} + }, + .end = + { + .type = GRUB_EFI_END_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_device_path), 0} + } }; /* late-2008 MB/MBP (NVidia chipset) */ -static grub_uint8_t devpath_5[] = { - 0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00, - 0x00, 0x40, 0xCB, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xBF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, - 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, - 0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00, +static struct piwg_full_device_path devpath_5 = +{ + .comp1 = + { + .header = { + .type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_memory_mapped_device_path), 0} + }, + .memory_type = GRUB_EFI_MEMORY_MAPPED_IO, + .start_address = 0xffcb4000, + .end_address = 0xffffbfff + }, + .comp2 = + { + .header = { + .type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_piwg_device_path), 0} + }, + .guid = {0x2B0585EB, 0xD8B8, 0x49A9, {0x8B, 0x8C, 0xE2, 0x1B, + 0x01, 0xAE, 0xF2, 0xB7}} + }, + .end = + { + .type = GRUB_EFI_END_DEVICE_PATH_TYPE, + .subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE, + .length = {sizeof (struct grub_efi_device_path), 0} + } }; struct devdata @@ -121,11 +234,11 @@ struct devdata struct devdata devs[] = { - {"Core Duo/Solo", (grub_efi_device_path_t *) devpath_1}, - {"Mac Pro", (grub_efi_device_path_t *) devpath_2}, - {"MBP", (grub_efi_device_path_t *) devpath_3}, - {"MBA", (grub_efi_device_path_t *) devpath_4}, - {"MB NV", (grub_efi_device_path_t *) devpath_5}, + {"Core Duo/Solo", (grub_efi_device_path_t *) &devpath_1}, + {"Mac Pro", (grub_efi_device_path_t *) &devpath_2}, + {"MBP", (grub_efi_device_path_t *) &devpath_3}, + {"MBA", (grub_efi_device_path_t *) &devpath_4}, + {"MB NV", (grub_efi_device_path_t *) &devpath_5}, {NULL, NULL}, }; From 732c47f005838e6ea893ee374fd8e11113cd7bc0 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 4 Jan 2010 22:47:30 +0000 Subject: [PATCH 143/208] 2010-01-04 Robert Millan * commands/crc.c (grub_cmd_crc): Abort on read errors. * fs/iso9660.c (grub_iso9660_read): Check for read error and pass it to upper layer. --- commands/crc.c | 7 +++++-- fs/iso9660.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/commands/crc.c b/commands/crc.c index dff9fd55c..1c1a690aa 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -1,7 +1,7 @@ /* crc.c - command to calculate the crc32 checksum of a file */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 2008,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,10 +46,13 @@ grub_cmd_crc (grub_command_t cmd __attribute__ ((unused)), while ((size = grub_file_read (file, buf, sizeof (buf))) > 0) crc = grub_getcrc32 (crc, buf, size); - grub_file_close (file); + if (grub_errno) + goto fail; grub_printf ("%08x\n", crc); + fail: + grub_file_close (file); return 0; } diff --git a/fs/iso9660.c b/fs/iso9660.c index 0647ca8fc..1ab98be3f 100644 --- a/fs/iso9660.c +++ b/fs/iso9660.c @@ -2,7 +2,7 @@ SUSP, Rock Ridge. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -773,7 +773,10 @@ grub_iso9660_read (grub_file_t file, char *buf, grub_size_t len) data->first_sector << GRUB_ISO9660_LOG2_BLKSZ, file->offset, len, buf); - data->disk->read_hook = 0; + data->disk->read_hook = NULL; + + if (grub_errno) + return -1; return len; } From 4b856776a991f1b87f36a18653923d030f28ea11 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 4 Jan 2010 22:49:59 +0000 Subject: [PATCH 144/208] forgot to commit ChangeLog... --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index c71862f78..0bcb062fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-04 Robert Millan + + * commands/crc.c (grub_cmd_crc): Abort on read errors. + * fs/iso9660.c (grub_iso9660_read): Check for read error and pass + it to upper layer. + 2010-01-04 Vladimir Serbinenko * include/grub/efi/api.h (GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE): From e33ace066e186e6b3000b9c41dd2d3d574d6bc23 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 4 Jan 2010 23:30:27 +0000 Subject: [PATCH 145/208] 2010-01-04 Robert Millan * disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Use ALIGN_UP macro instead of manual alignment. * kern/disk.c (grub_disk_read): Remove grub_dprintf call (excessively verbose). Avoid attempts to read past end of the device (grub_disk_adjust_range() guarantees that we can read `size' bytes, but GRUB_DISK_CACHE_SIZE may exceed that). --- ChangeLog | 9 +++++++++ disk/i386/pc/biosdisk.c | 4 ++-- kern/disk.c | 9 ++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bcb062fb..df0eaad34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-01-04 Robert Millan + + * disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Use ALIGN_UP macro + instead of manual alignment. + * kern/disk.c (grub_disk_read): Remove grub_dprintf call (excessively + verbose). Avoid attempts to read past end of the device + (grub_disk_adjust_range() guarantees that we can read `size' bytes, + but GRUB_DISK_CACHE_SIZE may exceed that). + 2010-01-04 Robert Millan * commands/crc.c (grub_cmd_crc): Abort on read errors. diff --git a/disk/i386/pc/biosdisk.c b/disk/i386/pc/biosdisk.c index 19ee3f981..5f04ecc1e 100644 --- a/disk/i386/pc/biosdisk.c +++ b/disk/i386/pc/biosdisk.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -222,7 +222,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk, if (cmd) return grub_error (GRUB_ERR_WRITE_ERROR, "can\'t write to cdrom"); - dap->blocks = (dap->blocks + 3) >> 2; + dap->blocks = ALIGN_UP (dap->blocks, 4) >> 2; dap->block >>= 2; for (i = 0; i < GRUB_BIOSDISK_CDROM_RETRY_COUNT; i++) diff --git a/kern/disk.c b/kern/disk.c index 1f10c8731..544896f2f 100644 --- a/kern/disk.c +++ b/kern/disk.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2004,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2004,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -386,8 +386,6 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector, char *tmp_buf; unsigned real_offset; - grub_dprintf ("disk", "Reading `%s'...\n", disk->name); - /* First of all, check if the region is within the disk. */ if (grub_disk_adjust_range (disk, §or, &offset, size) != GRUB_ERR_NONE) { @@ -432,8 +430,9 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector, else { /* Otherwise read data from the disk actually. */ - if ((disk->dev->read) (disk, start_sector, - GRUB_DISK_CACHE_SIZE, tmp_buf) + if (start_sector + GRUB_DISK_CACHE_SIZE > disk->total_sectors + || (disk->dev->read) (disk, start_sector, + GRUB_DISK_CACHE_SIZE, tmp_buf) != GRUB_ERR_NONE) { /* Uggh... Failed. Instead, just read necessary data. */ From 7c302978579298a8bd0d8950790c3f2ac887b85b Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 5 Jan 2010 00:31:07 +0000 Subject: [PATCH 146/208] 2010-01-05 Robert Millan Remove grub-mkfloppy. Images produced by grub-mkrescue are valid floppy images now. * util/i386/pc/grub-mkfloppy.in: Remove. Update all users. --- ChangeLog | 7 ++ conf/i386-pc.rmk | 3 - util/i386/pc/grub-mkfloppy.in | 116 ---------------------------------- 3 files changed, 7 insertions(+), 119 deletions(-) delete mode 100644 util/i386/pc/grub-mkfloppy.in diff --git a/ChangeLog b/ChangeLog index df0eaad34..d9d327bac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-01-05 Robert Millan + + Remove grub-mkfloppy. Images produced by grub-mkrescue are valid + floppy images now. + + * util/i386/pc/grub-mkfloppy.in: Remove. Update all users. + 2010-01-04 Robert Millan * disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Use ALIGN_UP macro diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 4ae753776..afdf47e5a 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -115,9 +115,6 @@ grub_install_SOURCES = util/grub-install.in bin_SCRIPTS += grub-mkrescue grub_mkrescue_SOURCES = util/grub-mkrescue.in -bin_SCRIPTS += grub-mkfloppy -grub_mkfloppy_SOURCES = util/i386/pc/grub-mkfloppy.in - pkglib_MODULES = biosdisk.mod chain.mod \ multiboot.mod reboot.mod halt.mod \ vbe.mod vbetest.mod vbeinfo.mod play.mod serial.mod \ diff --git a/util/i386/pc/grub-mkfloppy.in b/util/i386/pc/grub-mkfloppy.in deleted file mode 100644 index 3b5518690..000000000 --- a/util/i386/pc/grub-mkfloppy.in +++ /dev/null @@ -1,116 +0,0 @@ -#! /bin/sh -e - -# Make GRUB rescue floppy -# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008 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 . - -# Initialize some variables. -transform="@program_transform_name@" - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libdir=@libdir@ -PACKAGE_NAME=@PACKAGE_NAME@ -PACKAGE_TARNAME=@PACKAGE_TARNAME@ -PACKAGE_VERSION=@PACKAGE_VERSION@ -target_cpu=@target_cpu@ -platform=@platform@ -pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` - -# Usage: usage -# Print the usage. -usage () { - cat <. -EOF -} - -input_dir=${pkglibdir} - -# Check the arguments. -for option in "$@"; do - case "$option" in - -h | --help) - usage - exit 0 ;; - -v | --version) - echo "$0 (GNU GRUB ${PACKAGE_VERSION})" - exit 0 ;; - --modules=*) - modules=`echo "$option" | sed 's/--modules=//'` ;; - --output=*) - output_image=`echo "$option" | sed 's/--output=//'` ;; - -*) - echo "Unrecognized option \`$option'" 1>&2 - usage - exit 1 - ;; - *) - if test "x$output_image" != x; then - echo "Unrecognized option \`$option'" 1>&2 - usage - exit 1 - fi - output_image="${option}" ;; - esac -done - -if test "x$output_image" = x; then - usage - exit 1 -fi - -aux_dir=`mktemp -d` -mkdir -p ${aux_dir}/boot/grub - -for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \ - ${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \ - ${input_dir}/handler.lst ${input_dir}/parttool.lst; do - if test -f "$file"; then - cp -f "$file" ${aux_dir}/boot/grub/ - fi -done - -modules="$(cat ${input_dir}/partmap.lst) ${modules}" -for i in ${modules} ; do - echo "insmod $i" -done > ${aux_dir}/boot/grub/grub.cfg - -# build memdisk -memdisk_img=`mktemp` -tar -C ${aux_dir} -cf ${memdisk_img} boot -rm -rf ${aux_dir} - -# build core.img -core_img=`mktemp` -grub-mkimage -d ${input_dir}/ -m ${memdisk_img} -o ${core_img} memdisk tar biosdisk -rm -f ${memdisk_img} - -# build floppy image -cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > ${output_image} -rm -f ${core_img} - -exit 0 From b445cfaa4dadc0ce15d9dddd9764e8db295feffb Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 5 Jan 2010 10:30:14 +0000 Subject: [PATCH 147/208] 2010-10-05 Jordan Uggla 2010-10-05 Colin Watson * util/grub-mkconfig_lib.in (save_default_entry): Only set saved_entry if boot_once is unset. * util/grub.d/00_header.in: Set boot_once to "true" if there was a previous saved entry (i.e. grub-reboot). --- ChangeLog.savedefault | 8 ++++++++ util/grub-mkconfig_lib.in | 8 ++++++-- util/grub.d/00_header.in | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog.savedefault b/ChangeLog.savedefault index 7457c3f71..f07bd6beb 100644 --- a/ChangeLog.savedefault +++ b/ChangeLog.savedefault @@ -1,3 +1,11 @@ +2010-10-05 Jordan Uggla +2010-10-05 Colin Watson + + * util/grub-mkconfig_lib.in (save_default_entry): Only set + saved_entry if boot_once is unset. + * util/grub.d/00_header.in: Set boot_once to "true" if there was a + previous saved entry (i.e. grub-reboot). + 2009-12-08 Colin Watson * util/grub.d/30_os-prober.in: Call save_default_entry for hurd. diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 95fd02ad9..acfc9f6ea 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -93,8 +93,12 @@ convert_system_path_to_grub_path () save_default_entry () { if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then - echo 'set saved_entry=${chosen}' - echo 'save_env saved_entry' + cat << EOF +if [ -z \${boot_once} ]; then + set saved_entry=${chosen} + save_env saved_entry +fi +EOF fi } diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 4cd8fd30c..85ce0d4a0 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -48,6 +48,7 @@ if [ \${prev_saved_entry} ]; then save_env saved_entry set prev_saved_entry= save_env prev_saved_entry + set boot_once=true fi EOF From fcab4f04e5e32cd2d3247e25d2c629085fcb23bf Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 5 Jan 2010 10:39:30 +0000 Subject: [PATCH 148/208] missing backslash --- util/grub-mkconfig_lib.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index acfc9f6ea..72e0e38f9 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -95,7 +95,7 @@ save_default_entry () if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then cat << EOF if [ -z \${boot_once} ]; then - set saved_entry=${chosen} + set saved_entry=\${chosen} save_env saved_entry fi EOF From 5c23bb0f529f6b3d1577dbfa405338e3ec81fbf3 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 5 Jan 2010 10:41:51 +0000 Subject: [PATCH 149/208] 2010-10-05 Jordan Uggla 2010-10-05 Colin Watson * util/grub.d/00_header.in: Define a "savedefault" function for use in menu entries. * util/grub-mkconfig_lib.in (save_default_entry): Use it. --- ChangeLog.savedefault | 7 +++++++ util/grub-mkconfig_lib.in | 5 +---- util/grub.d/00_header.in | 7 +++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog.savedefault b/ChangeLog.savedefault index f07bd6beb..90875588e 100644 --- a/ChangeLog.savedefault +++ b/ChangeLog.savedefault @@ -1,3 +1,10 @@ +2010-10-05 Jordan Uggla +2010-10-05 Colin Watson + + * util/grub.d/00_header.in: Define a "savedefault" function for use + in menu entries. + * util/grub-mkconfig_lib.in (save_default_entry): Use it. + 2010-10-05 Jordan Uggla 2010-10-05 Colin Watson diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 72e0e38f9..380ba1a48 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -94,10 +94,7 @@ save_default_entry () { if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then cat << EOF -if [ -z \${boot_once} ]; then - set saved_entry=\${chosen} - save_env saved_entry -fi +savedefault EOF fi } diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 85ce0d4a0..cfb8648ca 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -50,6 +50,13 @@ if [ \${prev_saved_entry} ]; then save_env prev_saved_entry set boot_once=true fi + +function savedefault { + if [ -z \${boot_once} ]; then + saved_entry=\${chosen} + save_env saved_entry + fi +} EOF case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in From cf2fd2a6d1a58ad0c47cf8b968ff695d0073b57a Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 5 Jan 2010 11:16:42 +0000 Subject: [PATCH 150/208] 2010-10-05 Jordan Uggla 2010-10-05 Colin Watson * util/grub-reboot.in: Make sure prev_saved_entry always gets a non-empty value. --- ChangeLog.savedefault | 6 ++++++ util/grub-reboot.in | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog.savedefault b/ChangeLog.savedefault index 90875588e..722769776 100644 --- a/ChangeLog.savedefault +++ b/ChangeLog.savedefault @@ -1,3 +1,9 @@ +2010-10-05 Jordan Uggla +2010-10-05 Colin Watson + + * util/grub-reboot.in: Make sure prev_saved_entry always gets a + non-empty value. + 2010-10-05 Jordan Uggla 2010-10-05 Colin Watson diff --git a/util/grub-reboot.in b/util/grub-reboot.in index 16abdf6f4..20f2b10bc 100644 --- a/util/grub-reboot.in +++ b/util/grub-reboot.in @@ -96,7 +96,11 @@ prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry if [ "$prev_saved_entry" ]; then $grub_editenv ${grubdir}/grubenv set prev_saved_entry="$prev_saved_entry" else - $grub_editenv ${grubdir}/grubenv unset prev_saved_entry + # We need some non-empty value for prev_saved_entry so that GRUB will + # recognise that grub-reboot has been used and restore the previous + # saved entry. "0" is the same as an empty value, i.e. the first menu + # entry. + $grub_editenv ${grubdir}/grubenv set prev_saved_entry=0 fi $grub_editenv ${grubdir}/grubenv set saved_entry="$entry" From a1368118864dea5cf293eb3e669a75cf6af14773 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 5 Jan 2010 12:40:30 +0000 Subject: [PATCH 151/208] 2010-01-05 Colin Watson * util/mkisofs/write.c (padblock_write): Check return value of fread. --- ChangeLog | 5 +++++ util/mkisofs/write.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d9d327bac..061fadc18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-05 Colin Watson + + * util/mkisofs/write.c (padblock_write): Check return value of + fread. + 2010-01-05 Robert Millan Remove grub-mkfloppy. Images produced by grub-mkrescue are valid diff --git a/util/mkisofs/write.c b/util/mkisofs/write.c index 896e2833b..d9b1fd05d 100644 --- a/util/mkisofs/write.c +++ b/util/mkisofs/write.c @@ -1437,7 +1437,9 @@ static int FDECL1(padblock_write, FILE *, outfile) if (! fp) error (1, errno, _("Unable to open %s"), boot_image_embed); - fread (buffer, 2048 * PADBLOCK_SIZE, 1, fp); + if (fread (buffer, 2048 * PADBLOCK_SIZE, 1, fp) == 0) + error (1, errno, _("cannot read %llu bytes from %s"), + (size_t) (2048 * PADBLOCK_SIZE), boot_image_embed); if (fgetc (fp) != EOF) error (1, 0, _("%s is too big for embed area"), boot_image_embed); } From 3bff18c5c6ebcd62c9e722f7e575cff1cff04e73 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 5 Jan 2010 16:09:02 +0000 Subject: [PATCH 152/208] 2010-01-05 Colin Watson * util/mkisofs/write.c (padblock_write): Switch size and nmemb arguments to fread so that we get a return value in bytes, rather than something that will normally be rounded down to 0. Adjust error handling to avoid producing garbage when size_t is not the same size as long long. --- ChangeLog | 8 ++++++++ util/mkisofs/write.c | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 061fadc18..bd32107f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-01-05 Colin Watson + + * util/mkisofs/write.c (padblock_write): Switch size and nmemb + arguments to fread so that we get a return value in bytes, rather + than something that will normally be rounded down to 0. + Adjust error handling to avoid producing garbage when size_t is not + the same size as long long. + 2010-01-05 Colin Watson * util/mkisofs/write.c (padblock_write): Check return value of diff --git a/util/mkisofs/write.c b/util/mkisofs/write.c index d9b1fd05d..5447229c8 100644 --- a/util/mkisofs/write.c +++ b/util/mkisofs/write.c @@ -1437,9 +1437,9 @@ static int FDECL1(padblock_write, FILE *, outfile) if (! fp) error (1, errno, _("Unable to open %s"), boot_image_embed); - if (fread (buffer, 2048 * PADBLOCK_SIZE, 1, fp) == 0) - error (1, errno, _("cannot read %llu bytes from %s"), - (size_t) (2048 * PADBLOCK_SIZE), boot_image_embed); + if (fread (buffer, 1, 2048 * PADBLOCK_SIZE, fp) == 0) + error (1, errno, _("cannot read %d bytes from %s"), + 2048 * PADBLOCK_SIZE, boot_image_embed); if (fgetc (fp) != EOF) error (1, 0, _("%s is too big for embed area"), boot_image_embed); } From 6581dd3a58f9a00fc342385d36bad6e8792de184 Mon Sep 17 00:00:00 2001 From: Yves Blusseau Date: Tue, 5 Jan 2010 18:24:10 +0100 Subject: [PATCH 153/208] 2010-01-05 Yves Blusseau * util/sparc64/ieee1275/grub-mkimage.c (main): Typo fix. --- ChangeLog | 4 ++++ util/sparc64/ieee1275/grub-mkimage.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bd32107f0..019049bb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-05 Yves Blusseau + + * util/sparc64/ieee1275/grub-mkimage.c (main): Typo fix. + 2010-01-05 Colin Watson * util/mkisofs/write.c (padblock_write): Switch size and nmemb diff --git a/util/sparc64/ieee1275/grub-mkimage.c b/util/sparc64/ieee1275/grub-mkimage.c index b79bbeb41..96ddfe3d7 100644 --- a/util/sparc64/ieee1275/grub-mkimage.c +++ b/util/sparc64/ieee1275/grub-mkimage.c @@ -223,7 +223,7 @@ main (int argc, char *argv[]) set_program_name (argv[0]); - grub_util_init_ls (); + grub_util_init_nls (); while (1) { From 465c787b508e940e8ef6c336aaf18b4d3f2e765f Mon Sep 17 00:00:00 2001 From: Yves Blusseau Date: Tue, 5 Jan 2010 22:04:15 +0100 Subject: [PATCH 154/208] 2010-01-05 Yves Blusseau * commands/acpi.c (grub_acpi_create_ebda): fix incorrect message. --- ChangeLog | 4 ++++ commands/acpi.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 019049bb0..ac66e6050 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-05 Yves Blusseau + + * commands/acpi.c (grub_acpi_create_ebda): fix incorrect message. + 2010-01-05 Yves Blusseau * util/sparc64/ieee1275/grub-mkimage.c (main): Typo fix. diff --git a/commands/acpi.c b/commands/acpi.c index f62592115..5bbfd008b 100644 --- a/commands/acpi.c +++ b/commands/acpi.c @@ -229,7 +229,7 @@ grub_acpi_create_ebda (void) sizeof (struct grub_acpi_rsdp_v10)) == 0) { grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10)); - grub_dprintf ("acpi", "Copying rsdpv2 to %p\n", target); + grub_dprintf ("acpi", "Copying rsdpv1 to %p\n", target); v1inebda = target; target += sizeof (struct grub_acpi_rsdp_v10); target = (grub_uint8_t *) ((((long) target - 1) | 0xf) + 1); From 83507e68bd6f2246b3d309f1650f3b7c8a171846 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 5 Jan 2010 22:44:00 +0000 Subject: [PATCH 155/208] 2010-01-05 Robert Millan * config.rpath: Update from Gnulib. --- ChangeLog | 4 ++++ config.rpath | 34 ++++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac66e6050..01483a3ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-05 Robert Millan + + * config.rpath: Update from Gnulib. + 2010-01-05 Yves Blusseau * commands/acpi.c (grub_acpi_create_ebda): fix incorrect message. diff --git a/config.rpath b/config.rpath index c547c6882..85c2f209b 100755 --- a/config.rpath +++ b/config.rpath @@ -2,7 +2,7 @@ # Output a system dependent set of variables, describing how to set the # run time search path of shared libraries in an executable. # -# Copyright 1996-2007 Free Software Foundation, Inc. +# Copyright 1996-2008 Free Software Foundation, Inc. # Taken from GNU libtool, 2001 # Originally by Gordon Matzigkeit , 1996 # @@ -47,7 +47,7 @@ for cc_temp in $CC""; do done cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` -# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. +# Code taken from libtool.m4's _LT_COMPILER_PIC. wl= if test "$GCC" = yes; then @@ -64,7 +64,7 @@ else ;; esac ;; - mingw* | cygwin* | pw32* | os2*) + mingw* | cygwin* | pw32* | os2* | cegcc*) ;; hpux9* | hpux10* | hpux11*) wl='-Wl,' @@ -76,7 +76,13 @@ else ;; linux* | k*bsd*-gnu) case $cc_basename in - icc* | ecc*) + ecc*) + wl='-Wl,' + ;; + icc* | ifort*) + wl='-Wl,' + ;; + lf95*) wl='-Wl,' ;; pgcc | pgf77 | pgf90) @@ -124,7 +130,7 @@ else esac fi -# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. +# Code taken from libtool.m4's _LT_LINKER_SHLIBS. hardcode_libdir_flag_spec= hardcode_libdir_separator= @@ -132,7 +138,7 @@ hardcode_direct=no hardcode_minus_L=no case "$host_os" in - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. @@ -158,7 +164,7 @@ if test "$with_gnu_ld" = yes; then # option of GNU ld is called -rpath, not --rpath. hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' case "$host_os" in - aix3* | aix4* | aix5*) + aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no @@ -182,7 +188,7 @@ if test "$with_gnu_ld" = yes; then ld_shlibs=no fi ;; - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' @@ -254,7 +260,7 @@ else hardcode_direct=unsupported fi ;; - aix4* | aix5*) + aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. @@ -264,7 +270,7 @@ else # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix5*) + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes @@ -326,7 +332,7 @@ else ;; bsdi[45]*) ;; - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is @@ -494,7 +500,7 @@ else fi # Check dynamic linker characteristics -# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. +# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. # Unlike libtool.m4, here we don't care about _all_ names of the library, but # only about the one the linker finds when passed -lNAME. This is the last # element of library_names_spec in libtool.m4, or possibly two of them if the @@ -505,7 +511,7 @@ case "$host_os" in aix3*) library_names_spec='$libname.a' ;; - aix4* | aix5*) + aix[4-9]*) library_names_spec='$libname$shrext' ;; amigaos*) @@ -517,7 +523,7 @@ case "$host_os" in bsdi[45]*) library_names_spec='$libname$shrext' ;; - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) shrext=.dll library_names_spec='$libname.dll.a $libname.lib' ;; From 40e3a41f854559d5faa08b4afe1d6e393442fb05 Mon Sep 17 00:00:00 2001 From: carles Date: Wed, 6 Jan 2010 21:36:34 +0000 Subject: [PATCH 156/208] 2010-01-06 Carles Pina i Estany * commands/search.c (GRUB_MOD_INIT): Use HELP_MESSAGE. * commands/search_file.c (HELP_MESSAGE): New macro. * commands/search_label.c (HELP_MESSAGE): Likewise. * commands/search_uuid.c (HELP_MESSAGE): Likewise. * po/POTFILES: Add `commands/search_file.c', `commands/search_label.c', `commands_uuid.c'. Remove duplicate `commands/search.c'. --- ChangeLog | 10 ++++++++++ commands/search.c | 4 +--- commands/search_file.c | 1 + commands/search_label.c | 1 + commands/search_uuid.c | 1 + po/POTFILES | 4 +++- 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01483a3ba..52cb5d401 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-01-06 Carles Pina i Estany + + * commands/search.c (GRUB_MOD_INIT): Use HELP_MESSAGE. + * commands/search_file.c (HELP_MESSAGE): New macro. + * commands/search_label.c (HELP_MESSAGE): Likewise. + * commands/search_uuid.c (HELP_MESSAGE): Likewise. + * po/POTFILES: Add `commands/search_file.c', + `commands/search_label.c', `commands_uuid.c'. Remove duplicate + `commands/search.c'. + 2010-01-05 Robert Millan * config.rpath: Update from Gnulib. diff --git a/commands/search.c b/commands/search.c index 2f0cef8aa..ec736de3c 100644 --- a/commands/search.c +++ b/commands/search.c @@ -166,9 +166,7 @@ GRUB_MOD_INIT(search_fs_label) cmd = grub_register_command (COMMAND_NAME, grub_cmd_do_search, N_("NAME [VARIABLE]"), - "Search devices by " SEARCH_TARGET "." - " If VARIABLE is specified, " - "the first device found is set to a variable."); + HELP_MESSAGE); } #ifdef DO_SEARCH_FILE diff --git a/commands/search_file.c b/commands/search_file.c index 265220001..73ce89ccc 100644 --- a/commands/search_file.c +++ b/commands/search_file.c @@ -2,4 +2,5 @@ #define FUNC_NAME grub_search_fs_file #define COMMAND_NAME "search.file" #define SEARCH_TARGET "file" +#define HELP_MESSAGE N_("Search devices by file. If VARIABLE is specified, the first device found is set to a variable.") #include "search.c" diff --git a/commands/search_label.c b/commands/search_label.c index 0047b0e8c..ee9c792be 100644 --- a/commands/search_label.c +++ b/commands/search_label.c @@ -2,4 +2,5 @@ #define FUNC_NAME grub_search_label #define COMMAND_NAME "search.fs_label" #define SEARCH_TARGET "filesystem label" +#define HELP_MESSAGE N_("Search devices by label. If VARIABLE is specified, the first device found is set to a variable.") #include "search.c" diff --git a/commands/search_uuid.c b/commands/search_uuid.c index 9767d6501..52f83812c 100644 --- a/commands/search_uuid.c +++ b/commands/search_uuid.c @@ -2,4 +2,5 @@ #define FUNC_NAME grub_search_fs_uuid #define COMMAND_NAME "search.fs_uuid" #define SEARCH_TARGET "filesystem UUID" +#define HELP_MESSAGE N_("Search devices by UUID. If VARIABLE is specified, the first device found is set to a variable.") #include "search.c" diff --git a/po/POTFILES b/po/POTFILES index cecf8a049..c4ae9d562 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -37,7 +37,9 @@ commands/probe.c commands/read.c commands/reboot.c commands/search.c -commands/search.c +commands/search_file.c +commands/search_label.c +commands/search_uuid.c commands/sleep.c commands/test.c commands/true.c From e7730de786199ba5ca7c962d018b9af92fd32122 Mon Sep 17 00:00:00 2001 From: carles Date: Wed, 6 Jan 2010 22:00:57 +0000 Subject: [PATCH 157/208] 2010-01-06 Carles Pina i Estany * kern/err.c: Include `'. (grub_print_error): Add full stop. Gettextizze. * loader/i386/bsd.c (grub_netbsd_boot): Change grub_error description. (grub_bsd_load_elf): Capitalise ELF. (grub_cmd_freebsd_loadenv): Add `s' in error string. (grub_cmd_freebsd_module): Likewise. (grub_cmd_freebsd_module_elf): Likewise. * loader/i386/bsdXX.c (SUFFIX): Capitalise ELF. --- ChangeLog | 11 +++++++++++ kern/err.c | 3 ++- loader/i386/bsd.c | 14 +++++++------- loader/i386/bsdXX.c | 4 ++-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 52cb5d401..3bd67bfba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-01-06 Carles Pina i Estany + + * kern/err.c: Include `'. + (grub_print_error): Add full stop. Gettextizze. + * loader/i386/bsd.c (grub_netbsd_boot): Change grub_error description. + (grub_bsd_load_elf): Capitalise ELF. + (grub_cmd_freebsd_loadenv): Add `s' in error string. + (grub_cmd_freebsd_module): Likewise. + (grub_cmd_freebsd_module_elf): Likewise. + * loader/i386/bsdXX.c (SUFFIX): Capitalise ELF. + 2010-01-06 Carles Pina i Estany * commands/search.c (GRUB_MOD_INIT): Use HELP_MESSAGE. diff --git a/kern/err.c b/kern/err.c index 311130154..02d7d879f 100644 --- a/kern/err.c +++ b/kern/err.c @@ -20,6 +20,7 @@ #include #include #include +#include #define GRUB_MAX_ERRMSG 256 #define GRUB_ERROR_STACK_SIZE 10 @@ -121,7 +122,7 @@ grub_print_error (void) do { if (grub_errno != GRUB_ERR_NONE) - grub_err_printf ("error: %s\n", grub_errmsg); + grub_err_printf (_("error: %s.\n"), grub_errmsg); } while (grub_error_pop ()); diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index d0f0c464b..0785a3fc1 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -680,7 +680,7 @@ grub_netbsd_boot (void) + 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"); + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory"); curarg = mmap = (struct grub_netbsd_btinfo_mmap_header *) kern_end; pm = (struct grub_netbsd_btinfo_mmap_entry *) (mmap + 1); @@ -888,7 +888,7 @@ grub_bsd_load_elf (grub_elf_t elf) return grub_elf64_load (elf, grub_bsd_elf64_hook, 0, 0); } else - return grub_error (GRUB_ERR_BAD_OS, "invalid elf"); + return grub_error (GRUB_ERR_BAD_OS, "invalid ELF"); } static grub_err_t @@ -1081,7 +1081,7 @@ grub_cmd_freebsd_loadenv (grub_command_t cmd __attribute__ ((unused)), if (kernel_type != KERNEL_TYPE_FREEBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "only FreeBSD support environment"); + "only FreeBSD supports environment"); if (argc == 0) { @@ -1175,11 +1175,11 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)), if (kernel_type != KERNEL_TYPE_FREEBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "only FreeBSD support module"); + "only FreeBSD supports module"); if (!is_elf_kernel) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "only ELF kernel support module"); + "only ELF kernel supports module"); /* List the current modules if no parameter. */ if (!argc) @@ -1241,11 +1241,11 @@ grub_cmd_freebsd_module_elf (grub_command_t cmd __attribute__ ((unused)), if (kernel_type != KERNEL_TYPE_FREEBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "only FreeBSD support module"); + "only FreeBSD supports module"); if (! is_elf_kernel) return grub_error (GRUB_ERR_BAD_ARGUMENT, - "only ELF kernel support module"); + "only ELF kernel supports module"); /* List the current modules if no parameter. */ if (! argc) diff --git a/loader/i386/bsdXX.c b/loader/i386/bsdXX.c index 4c1c035a9..b4d574821 100644 --- a/loader/i386/bsdXX.c +++ b/loader/i386/bsdXX.c @@ -271,7 +271,7 @@ SUFFIX (grub_freebsd_load_elf_meta) (grub_file_t file, grub_addr_t *kern_end) (grub_ssize_t) symsize) { if (! grub_errno) - return grub_error (GRUB_ERR_BAD_OS, "invalid elf"); + return grub_error (GRUB_ERR_BAD_OS, "invalid ELF"); return grub_errno; } curload += symsize; @@ -285,7 +285,7 @@ SUFFIX (grub_freebsd_load_elf_meta) (grub_file_t file, grub_addr_t *kern_end) != (grub_ssize_t) strsize) { if (! grub_errno) - return grub_error (GRUB_ERR_BAD_OS, "invalid elf"); + return grub_error (GRUB_ERR_BAD_OS, "invalid ELF"); return grub_errno; } curload += strsize; From 42841caa75a0ed911cbecee0c04bf340fdab9b56 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 6 Jan 2010 23:25:57 +0100 Subject: [PATCH 158/208] 2010-01-06 Vladimir Serbinenko Fix descent and ascent calculation. * util/grub-mkfont.c (grub_font_info): New fields 'asce' and 'max_y'. (options): New option "asce". (usage): Likewise. (add_char): Ignore invalid glyphs for descent calculation. Calculate ascent from actual content. (print_glyphs): Use 'asce'. (write_font): Likewise. Allow ascent override. (main): Handle "asce" option. --- ChangeLog | 13 +++++++++++++ util/grub-mkfont.c | 31 +++++++++++++++++++++++++------ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3bd67bfba..59f4e41f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2010-01-06 Vladimir Serbinenko + + Fix descent and ascent calculation. + + * util/grub-mkfont.c (grub_font_info): New fields 'asce' and 'max_y'. + (options): New option "asce". + (usage): Likewise. + (add_char): Ignore invalid glyphs for descent calculation. + Calculate ascent from actual content. + (print_glyphs): Use 'asce'. + (write_font): Likewise. Allow ascent override. + (main): Handle "asce" option. + 2010-01-06 Carles Pina i Estany * kern/err.c: Include `'. diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index a358ba5b0..3d1c6faac 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -59,10 +59,12 @@ struct grub_font_info char* name; int style; int desc; + int asce; int size; int max_width; int max_height; int min_y; + int max_y; int flags; int num_range; grub_uint32_t *ranges; @@ -77,6 +79,7 @@ static struct option options[] = {"range", required_argument, 0, 'r'}, {"size", required_argument, 0, 's'}, {"desc", required_argument, 0, 'd'}, + {"asce", required_argument, 0, 'c'}, {"bold", no_argument, 0, 'b'}, {"no-bitmap", no_argument, 0, 0x100}, {"no-hinting", no_argument, 0, 0x101}, @@ -104,6 +107,7 @@ Usage: %s [OPTIONS] FONT_FILES\n\ -n, --name=S set font family name\n\ -s, --size=N set font size\n\ -d, --desc=N set font descent\n\ + -c, --asce=N set font ascent\n\ -b, --bold convert to bold font\n\ -a, --force-autohint force autohint\n\ --no-hinting disable hinting\n\ @@ -193,9 +197,12 @@ add_char (struct grub_font_info *font_info, FT_Face face, if (height > font_info->max_height) font_info->max_height = height; - if (glyph_info->y_ofs < font_info->min_y) + if (glyph_info->y_ofs < font_info->min_y && glyph_info->y_ofs > -font_info->size) font_info->min_y = glyph_info->y_ofs; + if (glyph_info->y_ofs + height > font_info->max_y) + font_info->max_y = glyph_info->y_ofs + height; + mask = 0; data = &glyph_info->bitmap[0] - 1; for (j = 0; j < height; j++) @@ -284,8 +291,8 @@ print_glyphs (struct grub_font_info *font_info) xmin = 0; ymax = glyph->y_ofs + glyph->height; - if (ymax < font_info->size - font_info->desc) - ymax = font_info->size - font_info->desc; + if (ymax < font_info->asce) + ymax = font_info->asce; ymin = glyph->y_ofs; if (ymin > - font_info->desc) @@ -316,7 +323,7 @@ print_glyphs (struct grub_font_info *font_info) else if ((x >= 0) && (x < glyph->device_width) && (y >= - font_info->desc) && - (y < font_info->size - font_info->desc)) + (y < font_info->asce)) { line[line_pos++] = ((x == 0) || (y == 0)) ? '+' : '.'; } @@ -392,7 +399,15 @@ write_font (struct grub_font_info *font_info, char *output_file) font_info->desc = - font_info->min_y; } - write_be16_section ("ASCE", font_info->size - font_info->desc, &offset, file); + if (! font_info->asce) + { + if (font_info->max_y <= 0) + font_info->asce = 1; + else + font_info->asce = font_info->max_y; + } + + write_be16_section ("ASCE", font_info->asce, &offset, file); write_be16_section ("DESC", font_info->desc, &offset, file); if (font_verbosity > 0) @@ -400,7 +415,7 @@ write_font (struct grub_font_info *font_info, char *output_file) printf ("Font name: %s\n", font_name); printf ("Max width: %d\n", font_info->max_width); printf ("Max height: %d\n", font_info->max_height); - printf ("Font ascent: %d\n", font_info->size - font_info->desc); + printf ("Font ascent: %d\n", font_info->asce); printf ("Font descent: %d\n", font_info->desc); } @@ -560,6 +575,10 @@ main (int argc, char *argv[]) font_info.desc = strtoul (optarg, NULL, 0); break; + case 'e': + font_info.asce = strtoul (optarg, NULL, 0); + break; + case 'h': usage (0); break; From 5a1ed29ebd132255cd70c14fcd4e1838ac4c6717 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 7 Jan 2010 01:21:32 +0000 Subject: [PATCH 159/208] Simplify terminal check in loader/i386/efi/linux.c and loader/i386/linux.c Revert loader/i386/ieee1275/linux.c change --- loader/i386/efi/linux.c | 15 +++------------ loader/i386/ieee1275/linux.c | 34 ++-------------------------------- loader/i386/linux.c | 13 +++---------- 3 files changed, 8 insertions(+), 54 deletions(-) diff --git a/loader/i386/efi/linux.c b/loader/i386/efi/linux.c index c6acab641..a1d08b3d7 100644 --- a/loader/i386/efi/linux.c +++ b/loader/i386/efi/linux.c @@ -697,7 +697,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_term_output_t term; int found = 0; FOR_ACTIVE_TERM_OUTPUTS(term) - if (grub_strcmp (term->name, "vga_text") == 0) + if (grub_strcmp (term->name, "vga_text") == 0 + || grub_strcmp (term->name, "console") == 0) { grub_uint16_t pos = grub_term_getxy (term); params->video_cursor_x = pos >> 8; @@ -705,18 +706,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), params->video_width = grub_term_width (term); params->video_height = grub_term_height (term); found = 1; + break; } - if (!found) - FOR_ACTIVE_TERM_OUTPUTS(term) - if (grub_strcmp (term->name, "console") == 0) - { - grub_uint16_t pos = grub_term_getxy (term); - params->video_cursor_x = pos >> 8; - params->video_cursor_y = pos & 0xff; - params->video_width = grub_term_width (term); - params->video_height = grub_term_height (term); - found = 1; - } if (!found) { params->video_cursor_x = 0; diff --git a/loader/i386/ieee1275/linux.c b/loader/i386/ieee1275/linux.c index 33076ea5b..e8a6f1a52 100644 --- a/loader/i386/ieee1275/linux.c +++ b/loader/i386/ieee1275/linux.c @@ -109,38 +109,8 @@ grub_linux_boot (void) params->cl_magic = GRUB_LINUX_CL_MAGIC; params->cl_offset = GRUB_OFW_LINUX_CL_OFFSET; - { - grub_term_output_t term; - int found = 0; - FOR_ACTIVE_TERM_OUTPUTS(term) - if (grub_strcmp (term->name, "vga_text") == 0) - { - grub_uint16_t pos = grub_term_getxy (term); - params->video_cursor_x = pos >> 8; - params->video_cursor_y = pos & 0xff; - params->video_width = grub_term_width (term); - params->video_height = grub_term_height (term); - found = 1; - } - if (!found) - FOR_ACTIVE_TERM_OUTPUTS(term) - if (grub_strcmp (term->name, "console") == 0) - { - grub_uint16_t pos = grub_term_getxy (term); - params->video_cursor_x = pos >> 8; - params->video_cursor_y = pos & 0xff; - params->video_width = grub_term_width (term); - params->video_height = grub_term_height (term); - found = 1; - } - if (!found) - { - params->video_cursor_x = 0; - params->video_cursor_y = 0; - params->video_width = 80; - params->video_height = 25; - } - } + params->video_width = (grub_getwh () >> 8); + params->video_height = (grub_getwh () & 0xff); params->font_size = 16; params->ofw_signature = GRUB_LINUX_OFW_SIGNATURE; diff --git a/loader/i386/linux.c b/loader/i386/linux.c index c1649e9e6..863090025 100644 --- a/loader/i386/linux.c +++ b/loader/i386/linux.c @@ -551,21 +551,14 @@ grub_linux_boot (void) grub_term_output_t term; int found = 0; FOR_ACTIVE_TERM_OUTPUTS(term) - if (grub_strcmp (term->name, "vga_text") == 0) - { - grub_uint16_t pos = grub_term_getxy (term); - params->video_cursor_x = pos >> 8; - params->video_cursor_y = pos & 0xff; - found = 1; - } - if (!found) - FOR_ACTIVE_TERM_OUTPUTS(term) - if (grub_strcmp (term->name, "console") == 0) + if (grub_strcmp (term->name, "vga_text") == 0 + || grub_strcmp (term->name, "console") == 0) { grub_uint16_t pos = grub_term_getxy (term); params->video_cursor_x = pos >> 8; params->video_cursor_y = pos & 0xff; found = 1; + break; } if (!found) { From 5d2c52b8ca8c20cf527eaad3afc5e48e41ff8f6e Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 7 Jan 2010 19:55:16 +0000 Subject: [PATCH 160/208] 2010-01-07 Robert Millan * include/multiboot.h (MULTIBOOT_UNSUPPORTED): Moved from here ... * loader/i386/multiboot.c (UNSUPPORTED_FLAGS): ... to here. Update all users. --- ChangeLog | 6 ++++++ include/multiboot.h | 3 --- loader/i386/multiboot.c | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5823bd8f..d7b84f6b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-07 Robert Millan + + * include/multiboot.h (MULTIBOOT_UNSUPPORTED): Moved from here ... + * loader/i386/multiboot.c (UNSUPPORTED_FLAGS): ... to here. Update + all users. + 2010-01-07 Robert Millan 2010-01-07 Vladimir Serbinenko diff --git a/include/multiboot.h b/include/multiboot.h index 587f50832..da7afd9b3 100644 --- a/include/multiboot.h +++ b/include/multiboot.h @@ -31,9 +31,6 @@ /* This should be in %eax. */ #define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 -/* The bits in the required part of flags field we don't support. */ -#define MULTIBOOT_UNSUPPORTED 0x0000fffc - /* Alignment of multiboot modules. */ #define MULTIBOOT_MOD_ALIGN 0x00001000 diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index a52b8d5d6..f4869594e 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -27,6 +27,9 @@ * - APM table */ +/* The bits in the required part of flags field we don't support. */ +#define UNSUPPORTED_FLAGS 0x0000fffc + #include #include #include @@ -261,7 +264,7 @@ grub_multiboot (int argc, char *argv[]) goto fail; } - if (header->flags & MULTIBOOT_UNSUPPORTED) + if (header->flags & UNSUPPORTED_FLAGS) { grub_error (GRUB_ERR_UNKNOWN_OS, "unsupported flag: 0x%x", header->flags); From bc8b32b3ec017a72f96ccb428a7444d38edcc2f2 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 7 Jan 2010 21:05:25 +0000 Subject: [PATCH 161/208] 2010-01-07 Robert Millan Reset Multiboot 2 support. New loader implements the draft in /branches/multiboot2 and shares as much code as possible with the production Multiboot 1 implementation. * loader/ieee1275/multiboot2.c: Remove file. Update all users. * loader/multiboot2.c: Likewise. * loader/i386/multiboot_helper.S: Likewise. * include/multiboot2.h: Replace with latest version from the draft in /branches/multiboot2. * conf/i386-coreboot.rmk (multiboot_mod_SOURCES): Remove `loader/i386/multiboot_helper.S', `loader/i386/pc/multiboot2.c' and `loader/multiboot2.c'. (pkglib_MODULES): Add `multiboot2.mod'. (multiboot2_mod_SOURCES): New variable. (multiboot2_mod_LDFLAGS): Likewise. (multiboot2_mod_CFLAGS): Likewise. Define `GRUB_USE_MULTIBOOT2'. * conf/i386-pc.rmk: Likewise. * conf/powerpc-ieee1275.rmk (pkglib_MODULES): Remove `multiboot.mod'. (multiboot_mod_SOURCES): Remove variable. (multiboot_mod_LDFLAGS): Likewise. (multiboot_mod_CFLAGS): Likewise. * include/grub/multiboot.h [GRUB_USE_MULTIBOOT2]: Include `' instead of `'. [GRUB_USE_MULTIBOOT2] (MULTIBOOT_BOOTLOADER_MAGIC) (MULTIBOOT_HEADER_MAGIC): New macros. * loader/multiboot_loader.c (module_version_status): Remove variable. (find_multi_boot2_header): Remove function. (grub_cmd_multiboot_loader): Remove Multiboot 2 / Multiboot 1 selection logic. Always check for the Multiboot version we're compiling for. (grub_cmd_module_loader): Likewise. [GRUB_USE_MULTIBOOT2] (GRUB_MOD_INIT(multiboot)): Register `multiboot2' command instead of `multiboot'. --- ChangeLog | 40 +++ conf/i386-coreboot.rmk | 14 +- conf/i386-pc.rmk | 14 +- conf/powerpc-ieee1275.rmk | 8 - include/grub/multiboot.h | 9 +- include/multiboot2.h | 262 +++++++++++++------ loader/i386/multiboot_helper.S | 43 --- loader/ieee1275/multiboot2.c | 147 ----------- loader/multiboot2.c | 461 --------------------------------- loader/multiboot_loader.c | 91 +------ 10 files changed, 266 insertions(+), 823 deletions(-) delete mode 100644 loader/i386/multiboot_helper.S delete mode 100644 loader/ieee1275/multiboot2.c delete mode 100644 loader/multiboot2.c diff --git a/ChangeLog b/ChangeLog index d7b84f6b3..749b0e68c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,43 @@ +2010-01-07 Robert Millan + + Reset Multiboot 2 support. New loader implements the draft in + /branches/multiboot2 and shares as much code as possible with the + production Multiboot 1 implementation. + + * loader/ieee1275/multiboot2.c: Remove file. Update all users. + * loader/multiboot2.c: Likewise. + * loader/i386/multiboot_helper.S: Likewise. + * include/multiboot2.h: Replace with latest version from the draft + in /branches/multiboot2. + + * conf/i386-coreboot.rmk (multiboot_mod_SOURCES): Remove + `loader/i386/multiboot_helper.S', `loader/i386/pc/multiboot2.c' + and `loader/multiboot2.c'. + (pkglib_MODULES): Add `multiboot2.mod'. + (multiboot2_mod_SOURCES): New variable. + (multiboot2_mod_LDFLAGS): Likewise. + (multiboot2_mod_CFLAGS): Likewise. Define `GRUB_USE_MULTIBOOT2'. + + * conf/i386-pc.rmk: Likewise. + + * conf/powerpc-ieee1275.rmk (pkglib_MODULES): Remove `multiboot.mod'. + (multiboot_mod_SOURCES): Remove variable. + (multiboot_mod_LDFLAGS): Likewise. + (multiboot_mod_CFLAGS): Likewise. + + * include/grub/multiboot.h [GRUB_USE_MULTIBOOT2]: Include + `' instead of `'. + [GRUB_USE_MULTIBOOT2] (MULTIBOOT_BOOTLOADER_MAGIC) + (MULTIBOOT_HEADER_MAGIC): New macros. + + * loader/multiboot_loader.c (module_version_status): Remove variable. + (find_multi_boot2_header): Remove function. + (grub_cmd_multiboot_loader): Remove Multiboot 2 / Multiboot 1 selection + logic. Always check for the Multiboot version we're compiling for. + (grub_cmd_module_loader): Likewise. + [GRUB_USE_MULTIBOOT2] (GRUB_MOD_INIT(multiboot)): Register `multiboot2' + command instead of `multiboot'. + 2010-01-07 Robert Millan * include/multiboot.h (MULTIBOOT_UNSUPPORTED): Moved from here ... diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index 8b69f7796..797b29daf 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -102,7 +102,7 @@ bin_SCRIPTS += grub-mkrescue grub_mkrescue_SOURCES = util/grub-mkrescue.in # Modules. -pkglib_MODULES = linux.mod multiboot.mod \ +pkglib_MODULES = linux.mod \ aout.mod play.mod serial.mod \ memdisk.mod pci.mod lspci.mod reboot.mod \ halt.mod datetime.mod date.mod datehook.mod \ @@ -140,16 +140,20 @@ serial_mod_SOURCES = term/i386/pc/serial.c serial_mod_CFLAGS = $(COMMON_CFLAGS) serial_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For multiboot.mod. +pkglib_MODULES += multiboot.mod multiboot_mod_SOURCES = loader/i386/multiboot.c \ - loader/i386/multiboot_helper.S \ - loader/i386/pc/multiboot2.c \ - loader/multiboot2.c \ loader/multiboot_loader.c multiboot_mod_CFLAGS = $(COMMON_CFLAGS) multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS) +pkglib_MODULES += multiboot2.mod +multiboot2_mod_SOURCES = loader/i386/multiboot.c \ + loader/multiboot_loader.c +multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2 +multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS) +multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS) + # For aout.mod. aout_mod_SOURCES = loader/aout.c aout_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index afdf47e5a..e02ee4665 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -116,7 +116,7 @@ bin_SCRIPTS += grub-mkrescue grub_mkrescue_SOURCES = util/grub-mkrescue.in pkglib_MODULES = biosdisk.mod chain.mod \ - multiboot.mod reboot.mod halt.mod \ + reboot.mod halt.mod \ vbe.mod vbetest.mod vbeinfo.mod play.mod serial.mod \ vga.mod memdisk.mod pci.mod lspci.mod \ aout.mod bsd.mod pxe.mod pxecmd.mod datetime.mod date.mod \ @@ -201,16 +201,20 @@ serial_mod_SOURCES = term/i386/pc/serial.c serial_mod_CFLAGS = $(COMMON_CFLAGS) serial_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For multiboot.mod. +pkglib_MODULES += multiboot.mod multiboot_mod_SOURCES = loader/i386/multiboot.c \ - loader/i386/multiboot_helper.S \ - loader/i386/pc/multiboot2.c \ - loader/multiboot2.c \ loader/multiboot_loader.c multiboot_mod_CFLAGS = $(COMMON_CFLAGS) multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS) +pkglib_MODULES += multiboot2.mod +multiboot2_mod_SOURCES = loader/i386/multiboot.c \ + loader/multiboot_loader.c +multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2 +multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS) +multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS) + # For vbe.mod. vbe_mod_SOURCES = video/i386/pc/vbe.c vbe_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index 122455280..000434f33 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -61,7 +61,6 @@ pkglib_MODULES = halt.mod \ linux.mod \ reboot.mod \ suspend.mod \ - multiboot.mod \ memdisk.mod \ lsmmap.mod @@ -91,13 +90,6 @@ halt_mod_SOURCES = commands/halt.c halt_mod_CFLAGS = $(COMMON_CFLAGS) halt_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For multiboot.mod -multiboot_mod_SOURCES = loader/ieee1275/multiboot2.c \ - loader/multiboot2.c \ - loader/multiboot_loader.c -multiboot_mod_CFLAGS = $(COMMON_CFLAGS) -multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) - # For memdisk.mod. memdisk_mod_SOURCES = disk/memdisk.c memdisk_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/include/grub/multiboot.h b/include/grub/multiboot.h index c54874942..041ee1f18 100644 --- a/include/grub/multiboot.h +++ b/include/grub/multiboot.h @@ -1,7 +1,7 @@ /* multiboot.h - multiboot header file with grub definitions. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2003,2007,2008,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,14 @@ #ifndef GRUB_MULTIBOOT_HEADER #define GRUB_MULTIBOOT_HEADER 1 +#ifdef GRUB_USE_MULTIBOOT2 +#include +/* Same thing as far as our loader is concerned. */ +#define MULTIBOOT_BOOTLOADER_MAGIC MULTIBOOT2_BOOTLOADER_MAGIC +#define MULTIBOOT_HEADER_MAGIC MULTIBOOT2_HEADER_MAGIC +#else #include +#endif void grub_multiboot (int argc, char *argv[]); void grub_module (int argc, char *argv[]); diff --git a/include/multiboot2.h b/include/multiboot2.h index 275aa5a9b..0488849d7 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -1,110 +1,220 @@ -/* multiboot2.h - multiboot 2 header file. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2009 Free Software Foundation, Inc. +/* multiboot2.h - Multiboot 2 header file. */ +/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc. * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * 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. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY + * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR + * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef MULTIBOOT2_HEADER -#define MULTIBOOT2_HEADER 1 +#ifndef MULTIBOOT_HEADER +#define MULTIBOOT_HEADER 1 /* How many bytes from the start of the file we search for the header. */ -#define MULTIBOOT2_HEADER_SEARCH 8192 +#define MULTIBOOT_SEARCH 8192 /* The magic field should contain this. */ -#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 +#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 -/* Passed from the bootloader to the kernel. */ -#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 +/* This should be in %eax. */ +#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 /* Alignment of multiboot modules. */ -#define MULTIBOOT2_MOD_ALIGN 0x00001000 +#define MULTIBOOT_MOD_ALIGN 0x00001000 + +/* Alignment of the multiboot info structure. */ +#define MULTIBOOT_INFO_ALIGN 0x00000004 + +/* Flags set in the 'flags' member of the multiboot header. */ + +/* Align all boot modules on i386 page (4KB) boundaries. */ +#define MULTIBOOT_PAGE_ALIGN 0x00000001 + +/* Must pass memory information to OS. */ +#define MULTIBOOT_MEMORY_INFO 0x00000002 + +/* Must pass video information to OS. */ +#define MULTIBOOT_VIDEO_MODE 0x00000004 + +/* This flag indicates the use of the address fields in the header. */ +#define MULTIBOOT_AOUT_KLUDGE 0x00010000 + +/* Flags to be set in the 'flags' member of the multiboot info structure. */ + +/* is there basic lower/upper memory information? */ +#define MULTIBOOT_INFO_MEMORY 0x00000001 +/* is there a boot device set? */ +#define MULTIBOOT_INFO_BOOTDEV 0x00000002 +/* is the command-line defined? */ +#define MULTIBOOT_INFO_CMDLINE 0x00000004 +/* are there modules to do something with? */ +#define MULTIBOOT_INFO_MODS 0x00000008 + +/* These next two are mutually exclusive */ + +/* is there a symbol table loaded? */ +#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010 +/* is there an ELF section header table? */ +#define MULTIBOOT_INFO_ELF_SHDR 0X00000020 + +/* is there a full memory map? */ +#define MULTIBOOT_INFO_MEM_MAP 0x00000040 + +/* Is there drive info? */ +#define MULTIBOOT_INFO_DRIVE_INFO 0x00000080 + +/* Is there a config table? */ +#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100 + +/* Is there a boot loader name? */ +#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200 + +/* Is there a APM table? */ +#define MULTIBOOT_INFO_APM_TABLE 0x00000400 + +/* Is there video information? */ +#define MULTIBOOT_INFO_VIDEO_INFO 0x00000800 #ifndef ASM_FILE -#ifndef __WORDSIZE -#include -#endif +typedef unsigned short multiboot_uint16_t; +typedef unsigned int multiboot_uint32_t; +typedef unsigned long long multiboot_uint64_t; -/* XXX not portable? */ -#if __WORDSIZE == 64 -typedef uint64_t multiboot2_word; -#else -typedef uint32_t multiboot2_word; -#endif - -struct multiboot2_header +struct multiboot_header { - uint32_t magic; - uint32_t flags; + /* Must be MULTIBOOT_MAGIC - see above. */ + multiboot_uint32_t magic; + + /* Feature flags. */ + multiboot_uint32_t flags; + + /* The above fields plus this one must equal 0 mod 2^32. */ + multiboot_uint32_t checksum; + + /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ + multiboot_uint32_t header_addr; + multiboot_uint32_t load_addr; + multiboot_uint32_t load_end_addr; + multiboot_uint32_t bss_end_addr; + multiboot_uint32_t entry_addr; + + /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ + multiboot_uint32_t mode_type; + multiboot_uint32_t width; + multiboot_uint32_t height; + multiboot_uint32_t depth; }; -struct multiboot2_tag_header +/* The symbol table for a.out. */ +struct multiboot_aout_symbol_table { - uint32_t key; - uint32_t len; + multiboot_uint32_t tabsize; + multiboot_uint32_t strsize; + multiboot_uint32_t addr; + multiboot_uint32_t reserved; }; +typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t; -#define MULTIBOOT2_TAG_RESERVED1 0 -#define MULTIBOOT2_TAG_RESERVED2 (~0) - -#define MULTIBOOT2_TAG_START 1 -struct multiboot2_tag_start +/* The section header table for ELF. */ +struct multiboot_elf_section_header_table { - struct multiboot2_tag_header header; - multiboot2_word size; /* Total size of all multiboot tags. */ + multiboot_uint32_t num; + multiboot_uint32_t size; + multiboot_uint32_t addr; + multiboot_uint32_t shndx; }; +typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t; -#define MULTIBOOT2_TAG_NAME 2 -struct multiboot2_tag_name +struct multiboot_info { - struct multiboot2_tag_header header; - char name[1]; -}; + /* Multiboot info version number */ + multiboot_uint32_t flags; -#define MULTIBOOT2_TAG_MODULE 3 -struct multiboot2_tag_module -{ - struct multiboot2_tag_header header; - multiboot2_word addr; - multiboot2_word size; - char type[36]; - char cmdline[1]; -}; + /* Available memory from BIOS */ + multiboot_uint32_t mem_lower; + multiboot_uint32_t mem_upper; -#define MULTIBOOT2_TAG_MEMORY 4 -struct multiboot2_tag_memory -{ - struct multiboot2_tag_header header; - multiboot2_word addr; - multiboot2_word size; - multiboot2_word type; -}; + /* "root" partition */ + multiboot_uint32_t boot_device; -#define MULTIBOOT2_TAG_UNUSED 5 -struct multiboot2_tag_unused -{ - struct multiboot2_tag_header header; -}; + /* Kernel command line */ + multiboot_uint32_t cmdline; -#define MULTIBOOT2_TAG_END 0xffff -struct multiboot2_tag_end -{ - struct multiboot2_tag_header header; + /* Boot-Module list */ + multiboot_uint32_t mods_count; + multiboot_uint32_t mods_addr; + + union + { + multiboot_aout_symbol_table_t aout_sym; + multiboot_elf_section_header_table_t elf_sec; + } u; + + /* Memory Mapping buffer */ + multiboot_uint32_t mmap_length; + multiboot_uint32_t mmap_addr; + + /* Drive Info buffer */ + multiboot_uint32_t drives_length; + multiboot_uint32_t drives_addr; + + /* ROM configuration table */ + multiboot_uint32_t config_table; + + /* Boot Loader Name */ + multiboot_uint32_t boot_loader_name; + + /* APM table */ + multiboot_uint32_t apm_table; + + /* Video */ + multiboot_uint32_t vbe_control_info; + multiboot_uint32_t vbe_mode_info; + multiboot_uint16_t vbe_mode; + multiboot_uint16_t vbe_interface_seg; + multiboot_uint16_t vbe_interface_off; + multiboot_uint16_t vbe_interface_len; }; +typedef struct multiboot_info multiboot_info_t; + +struct multiboot_mmap_entry +{ + multiboot_uint32_t size; + multiboot_uint64_t addr; + multiboot_uint64_t len; +#define MULTIBOOT_MEMORY_AVAILABLE 1 +#define MULTIBOOT_MEMORY_RESERVED 2 + multiboot_uint32_t type; +} __attribute__((packed)); +typedef struct multiboot_mmap_entry multiboot_memory_map_t; + +struct multiboot_mod_list +{ + /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ + multiboot_uint32_t mod_start; + multiboot_uint32_t mod_end; + + /* Module command line */ + multiboot_uint32_t cmdline; + + /* padding to take it to 16 bytes (must be zero) */ + multiboot_uint32_t pad; +}; +typedef struct multiboot_mod_list multiboot_module_t; #endif /* ! ASM_FILE */ -#endif /* ! MULTIBOOT2_HEADER */ +#endif /* ! MULTIBOOT_HEADER */ diff --git a/loader/i386/multiboot_helper.S b/loader/i386/multiboot_helper.S deleted file mode 100644 index 2f9af778b..000000000 --- a/loader/i386/multiboot_helper.S +++ /dev/null @@ -1,43 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,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 - * 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 - - .p2align 2 /* force 4-byte alignment */ - -/* - * This starts the multiboot 2 kernel. - */ - -FUNCTION(grub_multiboot2_real_boot) - /* Push the entry address on the stack. */ - pushl %eax - /* Move the address of the multiboot information structure to ebx. */ - movl %edx,%ebx - - /* Interrupts should be disabled. */ - cli - - /* Move the magic value into eax and jump to the kernel. */ - movl $MULTIBOOT2_BOOTLOADER_MAGIC,%eax - popl %ecx - - cld - jmp *%ecx diff --git a/loader/ieee1275/multiboot2.c b/loader/ieee1275/multiboot2.c deleted file mode 100644 index 846550ee5..000000000 --- a/loader/ieee1275/multiboot2.c +++ /dev/null @@ -1,147 +0,0 @@ -/* multiboot.c - boot a multiboot 2 OS image. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,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 -#include -#include -#include -#ifdef __i386__ -#include -#endif - -typedef void (*kernel_entry_t) (unsigned long, void *, int (void *), - unsigned long, unsigned long); - -/* Claim the memory occupied by the multiboot kernel. */ -grub_err_t -grub_mb2_arch_elf32_hook (Elf32_Phdr *phdr, - grub_addr_t *addr __attribute__((unused)), - int *do_load) -{ - int rc; - - if (phdr->p_type != PT_LOAD) - { - *do_load = 0; - return 0; - } - *do_load = 1; - - rc = grub_claimmap (phdr->p_paddr, phdr->p_memsz); - if (rc) - return grub_error(GRUB_ERR_OUT_OF_MEMORY, "couldn't claim %x - %x", - phdr->p_paddr, phdr->p_paddr + phdr->p_memsz); - - grub_dprintf ("loader", "Loading segment at 0x%x - 0x%x\n", phdr->p_paddr, - phdr->p_paddr + phdr->p_memsz); - - return GRUB_ERR_NONE; -} - -/* Claim the memory occupied by the multiboot kernel. */ -grub_err_t -grub_mb2_arch_elf64_hook (Elf64_Phdr *phdr, - grub_addr_t *addr __attribute__((unused)), - int *do_load) -{ - int rc; - - if (phdr->p_type != PT_LOAD) - { - *do_load = 0; - return 0; - } - *do_load = 1; - - rc = grub_claimmap (phdr->p_paddr, phdr->p_memsz); - if (rc) - return grub_error(GRUB_ERR_OUT_OF_MEMORY, "couldn't claim 0x%lx - 0x%lx", - phdr->p_paddr, phdr->p_paddr + phdr->p_memsz); - - grub_dprintf ("loader", "Loading segment at 0x%lx - 0x%lx\n", - (unsigned long) phdr->p_paddr, - (unsigned long) (phdr->p_paddr + phdr->p_memsz)); - - return GRUB_ERR_NONE; -} - -grub_err_t -grub_mb2_arch_module_alloc (grub_size_t size, grub_addr_t *addr) -{ - int rc; - - /* XXX Will need to map on some firmwares. */ - rc = grub_ieee1275_claim (0, size, MULTIBOOT2_MOD_ALIGN, addr); - if (rc) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, - "firmware couldn't allocate memory (size 0x%lx)", size); - - return GRUB_ERR_NONE; -} - -grub_err_t -grub_mb2_arch_module_free (grub_addr_t addr, grub_size_t size) -{ - grub_ieee1275_release (addr, size); - return GRUB_ERR_NONE; -} - -grub_err_t -grub_mb2_tags_arch_create (void) -{ - /* Nothing special. */ - return GRUB_ERR_NONE; -} - -/* Release the memory we claimed from Open Firmware above. */ -void -grub_mb2_arch_unload (struct multiboot2_tag_header *tags) -{ - struct multiboot2_tag_header *tag; - - /* Free all module memory in the tag list. */ - for_each_tag (tag, tags) - { - if (tag->key == MULTIBOOT2_TAG_MODULE) - { - struct multiboot2_tag_module *module = - (struct multiboot2_tag_module *) tag; - grub_ieee1275_release (module->addr, module->size); - } - } -} - -void -grub_mb2_arch_boot (grub_addr_t entry_addr, void *tags) -{ -#if defined(__powerpc__) - kernel_entry_t entry = (kernel_entry_t) entry_addr; - entry (MULTIBOOT2_BOOTLOADER_MAGIC, tags, grub_ieee1275_entry_fn, 0, 0); -#elif defined(__i386__) - grub_multiboot2_real_boot (entry_addr, tags); -#else -#error -#endif -} diff --git a/loader/multiboot2.c b/loader/multiboot2.c deleted file mode 100644 index cfc7b400c..000000000 --- a/loader/multiboot2.c +++ /dev/null @@ -1,461 +0,0 @@ -/* multiboot2.c - boot a multiboot 2 OS image. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,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 -#include -#include -#include -#include - -static grub_addr_t entry; -extern grub_dl_t my_mod; - -static char *grub_mb2_tags; -static char *grub_mb2_tags_pos; -static grub_size_t grub_mb2_tags_len; -static int grub_mb2_tags_count; - -static void -grub_mb2_tags_free (void) -{ - grub_dprintf ("loader", "Freeing all tags...\n"); - grub_free (grub_mb2_tags); - grub_mb2_tags = 0; - grub_mb2_tags_pos = 0; - grub_mb2_tags_len = 0; - grub_mb2_tags_count = 0; -} - -grub_err_t -grub_mb2_tag_alloc (grub_addr_t *addr, int key, grub_size_t len) -{ - struct multiboot2_tag_header *tag; - grub_size_t used; - grub_size_t needed; - - grub_dprintf ("loader", "Allocating tag: key 0x%x, size 0x%lx.\n", - key, (unsigned long) len); - - used = grub_mb2_tags_pos - grub_mb2_tags; - len = ALIGN_UP (len, sizeof (multiboot2_word)); - - needed = used + len; - - if (needed > grub_mb2_tags_len) - { - /* Allocate new buffer. */ - grub_size_t newsize = needed * 2; - char *newarea; - - grub_dprintf ("loader", "Reallocating tag buffer (new size 0x%lx).\n", - (unsigned long) newsize); - - newarea = grub_malloc (newsize); - if (! newarea) - return grub_errno; - grub_memcpy (newarea, grub_mb2_tags, grub_mb2_tags_len); - grub_free (grub_mb2_tags); - - grub_mb2_tags_len = newsize; - grub_mb2_tags = newarea; - grub_mb2_tags_pos = newarea + used; - } - - tag = (struct multiboot2_tag_header *) grub_mb2_tags_pos; - grub_mb2_tags_pos += len; - - tag->key = key; - tag->len = len; - - if (addr) - *addr = (grub_addr_t) tag; - - grub_mb2_tags_count++; - - grub_dprintf ("loader", "Allocated tag %u at %p.\n", grub_mb2_tags_count, tag); - - return 0; -} - -static grub_err_t -grub_mb2_tag_start_create (void) -{ - return grub_mb2_tag_alloc (0, MULTIBOOT2_TAG_START, - sizeof (struct multiboot2_tag_start)); -} - -static grub_err_t -grub_mb2_tag_name_create (void) -{ - struct multiboot2_tag_name *name; - grub_addr_t name_addr; - grub_err_t err; - const char *grub_version = PACKAGE_STRING; - - err = grub_mb2_tag_alloc (&name_addr, MULTIBOOT2_TAG_NAME, - sizeof (struct multiboot2_tag_name) + - sizeof (grub_version) + 1); - if (err) - return err; - - name = (struct multiboot2_tag_name *) name_addr; - grub_strcpy (name->name, grub_version); - - return GRUB_ERR_NONE; -} - -typedef grub_err_t (*tag_create_t) (void); -static tag_create_t grub_mb2_tag_creators[] = { - grub_mb2_tag_start_create, - grub_mb2_tag_name_create, - grub_mb2_tags_arch_create, - 0, -}; - -static grub_err_t -grub_mb2_tags_create (void) -{ - tag_create_t *creator; - grub_err_t err; - - for (creator = grub_mb2_tag_creators; *creator != 0; creator++) - { - err = (*creator) (); - if (err) - goto error; - } - - return GRUB_ERR_NONE; - -error: - grub_error_push (); - grub_mb2_tags_free (); - grub_error_pop (); - return err; -} - -static grub_err_t -grub_mb2_tags_finish (void) -{ - struct multiboot2_tag_start *start; - grub_err_t err; - - /* Create the `end' tag. */ - err = grub_mb2_tag_alloc (0, MULTIBOOT2_TAG_END, - sizeof (struct multiboot2_tag_end)); - if (err) - goto error; - - /* We created the `start' tag first. Update it now. */ - start = (struct multiboot2_tag_start *) grub_mb2_tags; - start->size = grub_mb2_tags_pos - grub_mb2_tags; - return GRUB_ERR_NONE; - -error: - grub_error_push (); - grub_mb2_tags_free (); - grub_error_pop (); - return err; -} - -static grub_err_t -grub_mb2_boot (void) -{ - grub_mb2_tags_finish (); - - grub_dprintf ("loader", "Tags at %p\n", grub_mb2_tags); - grub_mb2_arch_boot (entry, grub_mb2_tags); - - /* Not reached. */ - return GRUB_ERR_NONE; -} - -static grub_err_t -grub_mb2_unload (void) -{ - struct multiboot2_tag_header *tag; - struct multiboot2_tag_header *tags = - (struct multiboot2_tag_header *) grub_mb2_tags; - - /* Free all module memory in the tag list. */ - for_each_tag (tag, tags) - { - if (tag->key == MULTIBOOT2_TAG_MODULE) - { - struct multiboot2_tag_module *module = - (struct multiboot2_tag_module *) tag; - grub_free ((void *) module->addr); - } - } - - /* Allow architecture to un-reserve memory. */ - grub_mb2_arch_unload (tags); - - /* Free the tags themselves. */ - grub_mb2_tags_free (); - - grub_dl_unref (my_mod); - - return GRUB_ERR_NONE; -} - -static grub_err_t -grub_mb2_load_other (grub_file_t file __attribute__ ((unused)), - void *buffer __attribute__ ((unused))) -{ - /* XXX Create module tag here. */ - return grub_error (GRUB_ERR_UNKNOWN_OS, "currently only ELF is supported"); -} - -/* Create the tag containing the cmdline and the address of the module data. */ -static grub_err_t -grub_mb2_tag_module_create (grub_addr_t modaddr, grub_size_t modsize, - char *type, int key, int argc, char *argv[]) -{ - struct multiboot2_tag_module *module; - grub_ssize_t argslen = 0; - grub_err_t err; - char *p; - grub_addr_t module_addr; - int i; - - /* Allocate enough space for the arguments and spaces between them. */ - for (i = 0; i < argc; i++) - argslen += grub_strlen (argv[i]) + 1; - - /* Note: includes implicit 1-byte cmdline. */ - err = grub_mb2_tag_alloc (&module_addr, key, - sizeof (struct multiboot2_tag_module) + argslen); - if (err) - return grub_errno; - - module = (struct multiboot2_tag_module *) module_addr; - module->addr = modaddr; - module->size = modsize; - grub_strcpy(module->type, type); - - /* Fill in the command line. */ - p = module->cmdline; - for (i = 0; i < argc; i++) - { - p = grub_stpcpy (p, argv[i]); - *p++ = ' '; - } - module->cmdline[argslen] = '\0'; - - return GRUB_ERR_NONE; -} - -/* Load ELF32 or ELF64. */ -static grub_err_t -grub_mb2_load_elf (grub_elf_t elf, int argc, char *argv[]) -{ - grub_addr_t kern_base; - grub_size_t kern_size; - grub_err_t err; - - if (grub_elf_is_elf32 (elf)) - { - entry = elf->ehdr.ehdr32.e_entry; - err = grub_elf32_load (elf, grub_mb2_arch_elf32_hook, &kern_base, - &kern_size); - } - else if (grub_elf_is_elf64 (elf)) - { - entry = elf->ehdr.ehdr64.e_entry; - err = grub_elf64_load (elf, grub_mb2_arch_elf64_hook, &kern_base, - &kern_size); - } - else - err = grub_error (GRUB_ERR_UNKNOWN_OS, "unknown ELF class"); - - if (err) - goto fail; - - grub_dprintf ("loader", "Entry point is 0x%lx.\n", (unsigned long) entry); - - grub_mb2_tag_module_create (kern_base, kern_size, "kernel", - MULTIBOOT2_TAG_MODULE, argc, argv); - -fail: - return err; -} - -void -grub_multiboot2 (int argc, char *argv[]) -{ - char *buffer; - grub_file_t file = 0; - grub_elf_t elf = 0; - struct multiboot2_header *header = 0; - char *p; - grub_ssize_t len; - grub_err_t err; - int header_found = 0; - - grub_loader_unset (); - - if (argc == 0) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified"); - goto fail; - } - - file = grub_gzfile_open (argv[0], 1); - if (! file) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, "couldn't open file"); - goto fail; - } - - buffer = grub_malloc (MULTIBOOT2_HEADER_SEARCH); - if (! buffer) - return; - - len = grub_file_read (file, buffer, MULTIBOOT2_HEADER_SEARCH); - if (len < 32) - { - grub_error (GRUB_ERR_BAD_OS, "file too small"); - goto fail; - } - - /* Look for the multiboot header in the buffer. The header should - be at least 8 bytes and aligned on a 8-byte boundary. */ - for (p = buffer; p <= buffer + len - 8; p += 8) - { - header = (struct multiboot2_header *) p; - if (header->magic == MULTIBOOT2_HEADER_MAGIC) - { - header_found = 1; - break; - } - } - - if (! header_found) - grub_dprintf ("loader", "No multiboot 2 header found.\n"); - - - /* Create the basic tags. */ - grub_dprintf ("loader", "Creating multiboot 2 tags\n"); - grub_mb2_tags_create (); - - /* Load the kernel and create its tag. */ - elf = grub_elf_file (file); - if (elf) - { - grub_dprintf ("loader", "Loading ELF multiboot 2 file.\n"); - err = grub_mb2_load_elf (elf, argc-1, &argv[1]); - grub_elf_close (elf); - } - else - { - grub_errno = 0; - grub_dprintf ("loader", "Loading non-ELF multiboot 2 file.\n"); - - if (header) - err = grub_mb2_load_other (file, header); - else - err = grub_error (GRUB_ERR_BAD_OS, - "need multiboot 2 header to load non-ELF files"); - grub_file_close (file); - } - - grub_free (buffer); - - if (err) - goto fail; - - /* Good to go. */ - grub_loader_set (grub_mb2_boot, grub_mb2_unload, 1); - return; - -fail: - grub_mb2_tags_free (); - grub_dl_unref (my_mod); -} - -void -grub_module2 (int argc, char *argv[]) -{ - grub_file_t file; - grub_addr_t modaddr = 0; - grub_ssize_t modsize = 0; - grub_err_t err; - - if (argc == 0) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, "no module specified"); - return; - } - - if (argc == 1) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, "no module type specified"); - return; - } - - if (entry == 0) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, - "you need to load the multiboot kernel first"); - return; - } - - /* Load module data. */ - file = grub_gzfile_open (argv[0], 1); - if (! file) - goto out; - - modsize = grub_file_size (file); - err = grub_mb2_arch_module_alloc (modsize, &modaddr); - if (err) - goto out; - - grub_dprintf ("loader", "Loading module at 0x%x - 0x%x\n", modaddr, - modaddr + modsize); - if (grub_file_read (file, (void *) modaddr, modsize) != modsize) - { - grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); - goto out; - } - - /* Create the module tag. */ - err = grub_mb2_tag_module_create (modaddr, modsize, - argv[1], MULTIBOOT2_TAG_MODULE, - argc-2, &argv[2]); - if (err) - goto out; - -out: - grub_error_push (); - - if (file) - grub_file_close (file); - - if (modaddr) - grub_mb2_arch_module_free (modaddr, modsize); - - grub_error_pop (); -} diff --git a/loader/multiboot_loader.c b/loader/multiboot_loader.c index 9e5cf1628..790f14d9a 100644 --- a/loader/multiboot_loader.c +++ b/loader/multiboot_loader.c @@ -1,7 +1,7 @@ -/* multiboot_loader.c - boot multiboot 1 or 2 OS image */ +/* multiboot_loader.c - boot multiboot kernel image */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,6 @@ */ #include -#include -#include #include #include #include @@ -31,15 +29,6 @@ grub_dl_t my_mod; -/* This tracks which version of multiboot to use when using - * the module command. By default use multiboot version 1. - * values: - * 1 - Multiboot version 1 - * 2 - Multiboot version 2 - */ - -static unsigned int module_version_status = 1; - static int find_multi_boot1_header (grub_file_t file) { @@ -69,34 +58,6 @@ find_multi_boot1_header (grub_file_t file) return found_status; } -static int -find_multi_boot2_header (grub_file_t file) -{ - struct multiboot_header *header; - char buffer[MULTIBOOT_SEARCH]; - int found_status = 0; - grub_ssize_t len; - - len = grub_file_read (file, buffer, MULTIBOOT_SEARCH); - if (len < 32) - return found_status; - - /* Look for the multiboot header in the buffer. The header should - be at least 8 bytes and aligned on a 8-byte boundary. */ - for (header = (struct multiboot_header *) buffer; - ((char *) header <= buffer + len - 8) || (header = 0); - header = (struct multiboot_header *) ((char *) header + 8)) - { - if (header->magic == MULTIBOOT2_HEADER_MAGIC) - { - found_status = 1; - break; - } - } - - return found_status; -} - static grub_err_t grub_cmd_multiboot_loader (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) @@ -122,8 +83,6 @@ grub_cmd_multiboot_loader (grub_command_t cmd __attribute__ ((unused)), /* find which header is in the file */ if (find_multi_boot1_header (file)) header_multi_ver_found = 1; - else if (find_multi_boot2_header (file)) - header_multi_ver_found = 2; else { grub_error (GRUB_ERR_BAD_OS, "multiboot header not found"); @@ -136,25 +95,9 @@ grub_cmd_multiboot_loader (grub_command_t cmd __attribute__ ((unused)), /* Launch multi boot with header */ - /* XXX Find a better way to identify this. - This is for i386-pc */ -#if defined(GRUB_MACHINE_PCBIOS) || defined(GRUB_MACHINE_COREBOOT) || \ - defined(GRUB_MACHINE_QEMU) - if (header_multi_ver_found == 1) - { - grub_dprintf ("multiboot_loader", - "Launching multiboot 1 grub_multiboot() function\n"); - grub_multiboot (argc, argv); - module_version_status = 1; - } -#endif - if (header_multi_ver_found == 0 || header_multi_ver_found == 2) - { - grub_dprintf ("multiboot_loader", - "Launching multiboot 2 grub_multiboot2() function\n"); - grub_multiboot2 (argc, argv); - module_version_status = 2; - } + grub_dprintf ("multiboot_loader", + "Launching multiboot 1 grub_multiboot() function\n"); + grub_multiboot (argc, argv); return grub_errno; @@ -172,21 +115,9 @@ grub_cmd_module_loader (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { -#if defined(GRUB_MACHINE_PCBIOS) || defined(GRUB_MACHINE_COREBOOT) || \ - defined(GRUB_MACHINE_QEMU) - if (module_version_status == 1) - { - grub_dprintf("multiboot_loader", - "Launching multiboot 1 grub_module() function\n"); - grub_module (argc, argv); - } -#endif - if (module_version_status == 2) - { - grub_dprintf("multiboot_loader", - "Launching multiboot 2 grub_module2() function\n"); - grub_module2 (argc, argv); - } + grub_dprintf("multiboot_loader", + "Launching multiboot 1 grub_module() function\n"); + grub_module (argc, argv); return grub_errno; } @@ -196,8 +127,14 @@ static grub_command_t cmd_multiboot, cmd_module; GRUB_MOD_INIT(multiboot) { cmd_multiboot = +#ifdef GRUB_USE_MULTIBOOT2 + grub_register_command ("multiboot2", grub_cmd_multiboot_loader, + 0, "Load a multiboot 2 kernel."); +#else grub_register_command ("multiboot", grub_cmd_multiboot_loader, 0, "Load a multiboot kernel."); +#endif + cmd_module = grub_register_command ("module", grub_cmd_module_loader, 0, "Load a multiboot module."); From fc054c9cb891c10d80c6eb3727ebbbab09aba460 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 7 Jan 2010 22:18:59 +0100 Subject: [PATCH 162/208] Various cleanups --- commands/xnu_uuid.c | 1 - conf/any-emu.rmk | 2 +- conf/common.rmk | 2 +- conf/i386-coreboot.rmk | 4 ++-- 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 +- kern/reader.c | 24 ------------------------ normal/menu_viewer.c | 25 ------------------------- 12 files changed, 10 insertions(+), 60 deletions(-) delete mode 100644 kern/reader.c delete mode 100644 normal/menu_viewer.c diff --git a/commands/xnu_uuid.c b/commands/xnu_uuid.c index ecf8ba00a..b6f2b2604 100644 --- a/commands/xnu_uuid.c +++ b/commands/xnu_uuid.c @@ -33,7 +33,6 @@ #include #include #include -#include /* This prefix is used by xnu and boot-132 to hash together with volume serial. */ diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index 0f6312ef7..bd1798946 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -28,7 +28,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ lib/arg.c normal/cmdline.c normal/datetime.c normal/misc.c \ normal/handler.c normal/auth.c lib/crypto.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.c normal/menu_entry.c \ normal/menu_text.c normal/crypto.c normal/term.c \ commands/terminal.c lib/charset.c \ script/main.c script/execute.c script/function.c \ diff --git a/conf/common.rmk b/conf/common.rmk index 6d57a75ea..3f1689370 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -549,7 +549,7 @@ keystatus_mod_LDFLAGS = $(COMMON_LDFLAGS) normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.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/menu_entry.c normal/menu_text.c \ normal/misc.c normal/crypto.c normal/term.c normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index 8b69f7796..c71997d97 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -21,7 +21,7 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \ kern/i386/halt.c \ kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ - kern/misc.c kern/mm.c kern/reader.c kern/term.c \ + kern/misc.c kern/mm.c kern/term.c \ kern/rescue_parser.c kern/rescue_reader.c \ kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \ kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \ @@ -65,7 +65,7 @@ kernel_img_SOURCES = kern/i386/qemu/startup.S \ kern/i386/halt.c \ kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ - kern/misc.c kern/mm.c kern/reader.c kern/term.c \ + kern/misc.c kern/mm.c kern/term.c \ kern/rescue_parser.c kern/rescue_reader.c \ kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \ kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \ diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk index 3a219e71b..f3281a1bc 100644 --- a/conf/i386-efi.rmk +++ b/conf/i386-efi.rmk @@ -39,7 +39,7 @@ pkglib_MODULES = kernel.img chain.mod appleldr.mod \ kernel_img_EXPORTS = no kernel_img_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ - kern/misc.c kern/mm.c kern/reader.c kern/term.c \ + kern/misc.c kern/mm.c kern/term.c \ kern/rescue_parser.c kern/rescue_reader.c \ kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \ kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \ diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk index 2a90fd2be..5c3a5aaf6 100644 --- a/conf/i386-ieee1275.rmk +++ b/conf/i386-ieee1275.rmk @@ -19,7 +19,7 @@ kernel_img_SOURCES = kern/i386/ieee1275/startup.S \ kern/ieee1275/cmain.c kern/ieee1275/openfw.c \ kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ - kern/misc.c kern/mm.c kern/reader.c kern/term.c \ + kern/misc.c kern/mm.c kern/term.c \ kern/rescue_parser.c kern/rescue_reader.c \ kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \ kern/env.c \ diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index afdf47e5a..44a306581 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -48,7 +48,7 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \ kern/i386/misc.S \ kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ - kern/misc.c kern/mm.c kern/reader.c kern/term.c \ + kern/misc.c kern/mm.c kern/term.c \ kern/rescue_parser.c kern/rescue_reader.c \ kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \ kern/$(target_cpu)/dl.c kern/i386/pc/init.c kern/i386/pc/mmap.c \ diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index 122455280..4587e171e 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -31,7 +31,7 @@ pkglib_PROGRAMS = kernel.img kernel_img_SOURCES = kern/powerpc/ieee1275/startup.S kern/ieee1275/cmain.c \ kern/ieee1275/ieee1275.c kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \ - kern/misc.c kern/mm.c kern/reader.c kern/term.c \ + kern/misc.c kern/mm.c kern/term.c \ kern/rescue_parser.c kern/rescue_reader.c \ kern/list.c kern/handler.c kern/command.c kern/corecmd.c \ kern/ieee1275/init.c \ diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index 9d020a84f..4ba098619 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -35,7 +35,7 @@ kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \ kern/ieee1275/ieee1275.c kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \ - kern/misc.c kern/mm.c kern/reader.c kern/term.c \ + kern/misc.c kern/mm.c kern/term.c \ kern/rescue_parser.c kern/rescue_reader.c \ kern/list.c kern/handler.c kern/command.c kern/corecmd.c \ kern/sparc64/ieee1275/ieee1275.c \ diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index a82b35222..4f6ace057 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -39,7 +39,7 @@ kernel_img_EXPORTS = no kernel_img_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \ kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ - kern/misc.c kern/mm.c kern/reader.c kern/term.c \ + kern/misc.c kern/mm.c kern/term.c \ kern/rescue_parser.c kern/rescue_reader.c \ kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \ kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \ diff --git a/kern/reader.c b/kern/reader.c deleted file mode 100644 index 74698d34b..000000000 --- a/kern/reader.c +++ /dev/null @@ -1,24 +0,0 @@ -/* reader.c - reader support */ -/* - * 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 - diff --git a/normal/menu_viewer.c b/normal/menu_viewer.c deleted file mode 100644 index b52442f40..000000000 --- a/normal/menu_viewer.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 - From 3b88cbbda5aed8d33e703128a2e1de07690eeb1f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 7 Jan 2010 22:22:11 +0100 Subject: [PATCH 163/208] Warning fixes --- normal/main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/normal/main.c b/normal/main.c index 739ad3763..7a5e3ee8e 100644 --- a/normal/main.c +++ b/normal/main.c @@ -433,8 +433,6 @@ grub_normal_init_page (struct grub_term_output *term) grub_free (unicode_msg); } -static int reader_nested; - static char * read_lists (struct grub_env_var *var __attribute__ ((unused)), const char *val) From 1dcb8d30a9d0cfb0c223b56a657f668c7349c815 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 7 Jan 2010 22:22:24 +0100 Subject: [PATCH 164/208] ChangeLog --- ChangeLog.multiterm | 122 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 ChangeLog.multiterm diff --git a/ChangeLog.multiterm b/ChangeLog.multiterm new file mode 100644 index 000000000..3228f902a --- /dev/null +++ b/ChangeLog.multiterm @@ -0,0 +1,122 @@ +2010-01-07 Vladimir Serbinenko +2010-01-07 Robert Millan + + Support for multiple terminals. + + * Makefile.in (pkglib_DATA): terminal.lst. + (terminal.lst): New target. + * commands/handler.c (grub_cmd_handler): Don't handle terminals. + (GRUB_MOD_INIT(handler)): Likewise. + (GRUB_MOD_FINI(handler)): Likewise. + * commands/help.c (grub_cmd_help): Handle multiple terminals. + * commands/keystatus.c (grub_cmd_keystatus): Likewise. + * commands/sleep.c (do_print): Use grub_term_restore_pos. + (grub_cmd_sleep): Use grub_term_save_pos. + * commands/terminal.c: New file. + * conf/any-emu.rmk (grub_emu_SOURCES): Add normal/term.c + commands/terminal.c and lib/charset.c. + * conf/common.rmk (normal_mod_SOURCES): Add normal/term.c. + (pkglib_MODULES): Add terminal.mod. + (terminal_mod_SOURCES): New variable. + (terminal_mod_CFLAGS): Likewise. + (terminal_mod_LDFLAGS): Likewise. + * genhandlerlist.sh: Don't handle terminals. + * genmk.rb: Generate terminal-*.lst. + * genterminallist.sh: New file. + * include/grub/charset.h (grub_ucs4_to_utf8_alloc): New proto. + (grub_is_valid_utf8): Likewise. + (grub_utf8_to_ucs4_alloc): Likewise. + * include/grub/menu_viewer.h (grub_menu_viewer): Rewritten. + (grub_menu_register_viewer): Changed argument. + (grub_menu_try_text): New proto. + (grub_gfxmenu_try_hook): New declaration. + * include/grub/normal.h (grub_normal_exit_level): New declaration. + (grub_menu_init_page): Additional argument term. + (grub_normal_init_page): Likewise. + (grub_cmdline_get): Arguments simplified. + (grub_utf8_to_ucs4_alloc): Removed. + (grub_print_ucs4): Additional argument term. + (grub_getstringwidth): Likewise. + (grub_print_message_indented): Likewise. + (grub_menu_text_register_instances): New proto. + (grub_show_menu): Likewise. + (read_terminal_list): Likewise. + (grub_set_more): Likewise. + * include/grub/parser.h: Include handler.h. + * include/grub/reader.h: Rewritten. + * include/grub/term.h (GRUB_TERM_NEED_INIT): Removed. + (GRUB_TERM_WIDTH): Changed to function. + (GRUB_TERM_HEIGHT): Likewise. + (GRUB_TERM_BORDER_WIDTH): Likewise. + (GRUB_TERM_BORDER_HEIGHT): Likewise. + (GRUB_TERM_NUM_ENTRIES): Likewise. + (GRUB_TERM_ENTRY_WIDTH): Likewise. + (GRUB_TERM_CURSOR_X): Likewise. + (grub_term_input_class): Likewise. + (grub_term_output_class): Likewise. + (grub_term_outputs_disabled): New declaration. + (grub_term_inputs_disabled): Likewise. + (grub_term_outputs): Likewise. + (grub_term_inputs): Likewise. + (grub_term_register_input_active): New function. + (grub_term_register_output_active): Likewise. + (grub_term_register_input): Rewritten. + (grub_term_register_output): Likewise. + (grub_term_unregister_input): Likewise. + (grub_term_unregister_output): Likewise. + (FOR_ACTIVE_TERM_INPUTS): New macro. + (FOR_DISABLED_TERM_INPUTS): Likewise. + (FOR_ACTIVE_TERM_OUTPUTS): Likewise. + (FOR_DISABLED_TERM_OUTPUTS): Likewise. + * include/grub/terminfo.h: Add oterm argument to all protypes. + * kern/main.c (grub_main): Don't call grub_register_rescue_reader. + Use grub_rescue_run. + * kern/misc.c (grub_utf8_to_ucs4): Put '?' for invalid characters. + All users updated. + * kern/reader.c: Removed. All users updated. + * kern/rescue_reader.c (grub_rescue_init): Removed. + (grub_rescue_reader): Likewise. + (grub_register_rescue_reader): Likewise. + (grub_rescue_run): New function based on kern/reader.c. + * kern/term.c: Adapted for multiterm. + * lib/charset.c (grub_ucs4_to_utf8_alloc): New function. + (grub_is_valid_utf8): Likewise. + (grub_utf8_to_ucs4_alloc): Moved from normal/menu_text.c. + * loader/i386/efi/linux.c (grub_cmd_linux): Retrieve parameters of + right terminal. + * loader/i386/linux.c (grub_linux_boot): Likewise. + * normal/auth.c (grub_username_get): New function. + (grub_auth_check_authentication): Use grub_username_get. + * normal/cmdline.c: Changed to UCS4. Adapted for multiterm. + * normal/color.c: Adapt for multiterm. + * normal/main.c (read_config_file): Don't use grub_reader_loop. + (grub_normal_init_page): Additional argument term. + (read_lists): Call read_terminal_lists. + (grub_enter_normal_mode): Call grub_cmdline_run. + Handle grub_normal_exit_level. + (grub_cmd_normal): Make reentrant. + (grub_cmd_normal_exit): New function. + (grub_normal_reader_init): Additional argument nested. Handle multiterm. + * normal/menu.c: Adapt for multiterm. + * normal/menu_entry.c: Likewise. + * normal/menu_text.c: Likewise. + * normal/menu_viewer.c: Removed. All users updated. + * normal/term.c: New file. + * term/efi/console.c (grub_console_init): Use + grub_term_register_input_active and grub_term_register_output_active. + * term/gfxterm.c (GRUB_MOD_INIT) [GRUB_MACHINE_MIPS_YEELOONG]: Likewise. + * term/i386/pc/at_keyboard.c (GRUB_MOD_INIT) + [GRUB_MACHINE_MIPS_YEELOONG] || [GRUB_MACHINE_COREBOOT] + || [GRUB_MACHINE_QEMU]: Likewise. + * term/i386/pc/vga_text.c (GRUB_MOD_INIT) [GRUB_MACHINE_COREBOOT] + || [GRUB_MACHINE_QEMU]: Likewise. + * term/i386/pc/console.c (grub_console_init): Likewise. + * term/ieee1275/ofconsole.c (grub_console_init): Likewise. + * util/console.c: Change order of includes to workaround a bug in + ncurses headers. + (grub_console_init): Use + grub_term_register_input_active and grub_term_register_output_active. + * term/terminfo.c: New argument oterm on all exported functions. + All users updated. + * util/grub-editenv.c (grub_term_input_class): Removed. + (grub_term_output_class): Likewise. From 6fc804ffbb7d0163a3f6a73dbd2b6f7c5f954fff Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Fri, 8 Jan 2010 15:19:10 +0530 Subject: [PATCH 165/208] unit testing framework --- Makefile.in | 19 +++- conf/tests.rmk | 41 ++++++++ genmk.rb | 6 +- include/grub/test.h | 88 ++++++++++++++++++ tests/example_functional_test.c | 17 ++++ tests/example_grub_script_test.in | 3 + tests/example_scripted_test.in | 3 + tests/example_unit_test.c | 20 ++++ tests/lib/functional_test.c | 75 +++++++++++++++ tests/lib/test.c | 150 ++++++++++++++++++++++++++++++ tests/lib/unit_test.c | 122 ++++++++++++++++++++++++ tests/util/grub-shell-tester.in | 109 ++++++++++++++++++++++ tests/util/grub-shell.in | 125 +++++++++++++++++++++++++ 13 files changed, 774 insertions(+), 4 deletions(-) create mode 100644 conf/tests.rmk create mode 100644 include/grub/test.h create mode 100644 tests/example_functional_test.c create mode 100644 tests/example_grub_script_test.in create mode 100644 tests/example_scripted_test.in create mode 100644 tests/example_unit_test.c create mode 100644 tests/lib/functional_test.c create mode 100644 tests/lib/test.c create mode 100644 tests/lib/unit_test.c create mode 100644 tests/util/grub-shell-tester.in create mode 100644 tests/util/grub-shell.in diff --git a/Makefile.in b/Makefile.in index ffa8716ed..2358060f2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -141,6 +141,7 @@ PROGRAMS = $(bin_UTILITIES) $(sbin_UTILITIES) SCRIPTS = $(bin_SCRIPTS) $(sbin_SCRIPTS) $(grub-mkconfig_SCRIPTS) \ $(lib_SCRIPTS) INFOS = $(info_INFOS) +TESTS = $(check_UNITTESTS) $(check_FUNCTIONALTESTS) $(check_SCRIPTEDTESTS) CLEANFILES = MOSTLYCLEANFILES = @@ -167,6 +168,8 @@ ifeq ($(platform), emu) include $(srcdir)/conf/any-emu.mk else include $(srcdir)/conf/$(target_cpu)-$(platform).mk +# For tests. +include $(srcdir)/conf/tests.mk # For external modules. -include $(wildcard $(GRUB_CONTRIB)/*/conf/common.mk) endif @@ -458,7 +461,21 @@ distcheck: dist @echo "$(distdir).tar.gz is ready for distribution" | \ sed 'h;s/./=/g;p;x;p;x' -check: +$(TESTS): $(check_SCRIPTS) $(check_MODULES) $(check_PROGRAMS) +check: all $(TESTS) + @list="$(check_UNITTESTS) $(check_SCRIPTEDTESTS)"; \ + for file in $$list; do \ + if $(builddir)/$$file; then \ + echo "$$file: PASS"; \ + else \ + echo "$$file: FAIL"; \ + fi; \ + done + @list="$(check_FUNCTIONALTESTS)"; \ + for test in $$list; do \ + echo "insmod functional_test; insmod $test; functional_test" \ + | $(builddir)/grub-shell; \ + done .SUFFIX: .SUFFIX: .c .o .S .d diff --git a/conf/tests.rmk b/conf/tests.rmk new file mode 100644 index 000000000..03d6acbd1 --- /dev/null +++ b/conf/tests.rmk @@ -0,0 +1,41 @@ +# -*- makefile -*- + +# For grub-shell +grub-shell: tests/util/grub-shell.in config.status + ./config.status --file=$@:$< + chmod +x $@ +check_SCRIPTS += grub-shell +CLEANFILES += grub-shell + +# For grub-shell-tester +grub-shell-tester: tests/util/grub-shell-tester.in config.status + ./config.status --file=$@:$< + chmod +x $@ +check_SCRIPTS += grub-shell-tester +CLEANFILES += grub-shell-tester + +check_MODULES += functional_test.mod +functional_test_mod_SOURCES = tests/lib/functional_test.c tests/lib/test.c +functional_test_mod_CFLAGS = $(COMMON_CFLAGS) +functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# Unit tests + +check_UNITTESTS += example_unit_test +example_unit_test_SOURCES = tests/example_unit_test.c kern/list.c kern/misc.c tests/lib/test.c tests/lib/unit_test.c +example_unit_test_CFLAGS = -Wno-format + +# Functional tests + +check_FUNCTIONALTESTS += example_functional_test.mod +example_functional_test_mod_SOURCES = tests/example_functional_test.c +example_functional_test_mod_CFLAGS = -Wno-format $(COMMON_CFLAGS) +example_functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# Scripted tests + +check_SCRIPTEDTESTS += example_scripted_test +example_scripted_test_SOURCES = tests/example_scripted_test.in + +check_SCRIPTEDTESTS += example_grub_script_test +example_grub_script_test_SOURCES = tests/example_grub_script_test.in diff --git a/genmk.rb b/genmk.rb index b1cce3831..006fc3d29 100644 --- a/genmk.rb +++ b/genmk.rb @@ -407,12 +407,12 @@ while l = gets Image.new(prefix, img) end - when 'MODULES' + when 'MODULES', 'FUNCTIONALTESTS' pmodules += args.split(/\s+/).collect do |pmod| PModule.new(prefix, pmod) end - when 'UTILITIES' + when 'UTILITIES', 'UNITTESTS' utils += args.split(/\s+/).collect do |util| Utility.new(prefix, util) end @@ -422,7 +422,7 @@ while l = gets Program.new(prefix, prog) end - when 'SCRIPTS' + when 'SCRIPTS', 'SCRIPTEDTESTS' scripts += args.split(/\s+/).collect do |script| Script.new(prefix, script) end diff --git a/include/grub/test.h b/include/grub/test.h new file mode 100644 index 000000000..fbc2bff8c --- /dev/null +++ b/include/grub/test.h @@ -0,0 +1,88 @@ +#ifndef GRUB_TEST_HEADER +#define GRUB_TEST_HEADER + +#include +#include +#include +#include +#include + +struct grub_test +{ + /* The next test. */ + struct grub_test *next; + + /* The test name. */ + char *name; + + /* The test main function. */ + void (*main) (void); +}; +typedef struct grub_test *grub_test_t; + +extern grub_test_t EXPORT_VAR (grub_test_list); + +void EXPORT_FUNC (grub_test_register) (const char *name, void (*test) (void)); + +void EXPORT_FUNC (grub_test_unregister) (const char *name); + +/* Execute a test and print results. */ +int grub_test_run (const char *name); + +/* Test `cond' for nonzero; log failure otherwise. */ +void grub_test_nonzero (int cond, const char *file, + const char *func, grub_uint32_t line, + const char *fmt, ...) + __attribute__ ((format (printf, 5, 6))); + +#ifdef __STDC_VERSION__ +#if __STDC_VERSION__ < 199901L +# if __GNUC__ >= 2 +# define __func__ __FUNCTION__ +# else +# define __func__ "" +# endif +#endif +#else +#define __func__ "" +#endif + +/* Macro to fill in location details and an optional error message. */ +#define grub_test_assert(cond, ...) \ + grub_test_nonzero(cond, __FILE__, __func__, __LINE__, \ + ## __VA_ARGS__, \ + "assert failed: %s", #cond) + +/* Macro to define a unit test. */ +#define GRUB_UNIT_TEST(name, funp) \ + void grub_unit_test_init (void) \ + { \ + grub_test_register (name, funp); \ + } \ + \ + void grub_unit_test_fini (void) \ + { \ + grub_test_unregister (name); \ + } + +/* Macro to define a functional test. */ +#define GRUB_FUNCTIONAL_TEST(name, funp) \ + GRUB_MOD_INIT(functional_test_##funp) \ + { \ + grub_test_register (name, funp); \ + } \ + \ + GRUB_MOD_FINI(functional_test_##funp) \ + { \ + grub_test_unregister (name); \ + } + +/* Functions that are defined differently for unit and functional tests. */ +void *grub_test_malloc (grub_size_t size); +void grub_test_free (void *ptr); +char *grub_test_strdup (const char *str); +int grub_test_vsprintf (char *str, const char *fmt, va_list args); +int grub_test_printf (const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +#endif /* ! GRUB_TEST_HEADER */ diff --git a/tests/example_functional_test.c b/tests/example_functional_test.c new file mode 100644 index 000000000..475d1c7f0 --- /dev/null +++ b/tests/example_functional_test.c @@ -0,0 +1,17 @@ +/* All tests need to include test.h for GRUB testing framework. */ +#include + +/* Functional test main method. */ +static void +example_test (void) +{ + /* Check if 1st argument is true and report with default error message. */ + grub_test_assert (1 == 1); + + /* Check if 1st argument is true and report with custom error message. */ + grub_test_assert (2 == 2, "2 equal 2 expected"); + grub_test_assert (2 == 3, "2 is not equal to %d", 3); +} + +/* Register example_test method as a functional test. */ +GRUB_FUNCTIONAL_TEST ("example_functional_test", example_test); diff --git a/tests/example_grub_script_test.in b/tests/example_grub_script_test.in new file mode 100644 index 000000000..93a90a18e --- /dev/null +++ b/tests/example_grub_script_test.in @@ -0,0 +1,3 @@ +#! @builddir@/grub-shell-tester --modules=echo + +echo "hello world" diff --git a/tests/example_scripted_test.in b/tests/example_scripted_test.in new file mode 100644 index 000000000..9ac0424c0 --- /dev/null +++ b/tests/example_scripted_test.in @@ -0,0 +1,3 @@ +#!/bin/sh -e + +true diff --git a/tests/example_unit_test.c b/tests/example_unit_test.c new file mode 100644 index 000000000..e2fad06ff --- /dev/null +++ b/tests/example_unit_test.c @@ -0,0 +1,20 @@ +/* Unit tests are normal programs, so they can include C library. */ +#include + +/* All tests need to include test.h for GRUB testing framework. */ +#include + +/* Unit test main method. */ +static void +example_test (void) +{ + /* Check if 1st argument is true and report with default error message. */ + grub_test_assert (1 == 1); + + /* Check if 1st argument is true and report with custom error message. */ + grub_test_assert (2 == 2, "2 equal 2 expected"); + grub_test_assert (2 == 3, "2 is not equal to %d", 3); +} + +/* Register example_test method as a unit test. */ +GRUB_UNIT_TEST ("example_unit_test", example_test); diff --git a/tests/lib/functional_test.c b/tests/lib/functional_test.c new file mode 100644 index 000000000..24e82932e --- /dev/null +++ b/tests/lib/functional_test.c @@ -0,0 +1,75 @@ +#include +#include +#include +#include + +void * +grub_test_malloc (grub_size_t size) +{ + return grub_malloc (size); +} + +void +grub_test_free (void *ptr) +{ + grub_free (ptr); +} + +int +grub_test_vsprintf (char *str, const char *fmt, va_list args) +{ + return grub_vsprintf (str, fmt, args); +} + +char * +grub_test_strdup (const char *str) +{ + return grub_strdup (str); +} + +int +grub_test_printf (const char *fmt, ...) +{ + int r; + va_list ap; + + va_start (ap, fmt); + r = grub_vprintf (fmt, ap); + va_end (ap); + + return r; +} + +static grub_err_t +grub_functional_test (struct grub_extcmd *cmd __attribute__ ((unused)), + int argc __attribute__ ((unused)), + char **args __attribute__ ((unused))) +{ + int i; + int status; + grub_test_t test; + + status = 0; + for (i = 0; i < argc; i++) + { + test = grub_named_list_find (GRUB_AS_NAMED_LIST (grub_test_list), + args[i]); + status = grub_test_run (test->name) ? : status; + } + + return status; +} + +static grub_extcmd_t cmd; + +GRUB_MOD_INIT (functional_test) +{ + cmd = grub_register_extcmd ("functional_test", grub_functional_test, + GRUB_COMMAND_FLAG_CMDLINE, 0, + "Run all functional tests.", 0); +} + +GRUB_MOD_FINI (functional_test) +{ + grub_unregister_extcmd (cmd); +} diff --git a/tests/lib/test.c b/tests/lib/test.c new file mode 100644 index 000000000..37f8fff72 --- /dev/null +++ b/tests/lib/test.c @@ -0,0 +1,150 @@ +#include +#include + +struct grub_test_failure +{ + /* The next failure. */ + struct grub_test_failure *next; + + /* The test source file name. */ + char *file; + + /* The test function name. */ + char *funp; + + /* The test call line number. */ + grub_uint32_t line; + + /* The test failure message. */ + char *message; +}; +typedef struct grub_test_failure *grub_test_failure_t; + +grub_test_t grub_test_list; +static grub_test_failure_t failure_list; + +static void +add_failure (const char *file, + const char *funp, + grub_uint32_t line, const char *fmt, va_list args) +{ + char buf[1024]; + grub_test_failure_t failure; + + failure = (grub_test_failure_t) grub_test_malloc (sizeof (*failure)); + if (!failure) + return; + + grub_test_vsprintf (buf, fmt, args); + + failure->file = grub_test_strdup (file ? : ""); + failure->funp = grub_test_strdup (funp ? : ""); + failure->line = line; + failure->message = grub_test_strdup (buf); + + grub_list_push (GRUB_AS_LIST_P (&failure_list), GRUB_AS_LIST (failure)); +} + +static void +free_failures (void) +{ + grub_test_failure_t item; + + while ((item = grub_list_pop (GRUB_AS_LIST_P (&failure_list))) != 0) + { + if (item->message) + grub_test_free (item->message); + + if (item->funp) + grub_test_free (item->funp); + + if (item->file) + grub_test_free (item->file); + + grub_test_free (item); + } + failure_list = 0; +} + +void +grub_test_nonzero (int cond, + const char *file, + const char *funp, grub_uint32_t line, const char *fmt, ...) +{ + va_list ap; + + if (cond) + return; + + va_start (ap, fmt); + add_failure (file, funp, line, fmt, ap); + va_end (ap); +} + +void +grub_test_register (const char *name, void (*test_main) (void)) +{ + grub_test_t test; + + test = (grub_test_t) grub_test_malloc (sizeof (*test)); + if (!test) + return; + + test->name = grub_test_strdup (name); + test->main = test_main; + + grub_list_push (GRUB_AS_LIST_P (&grub_test_list), GRUB_AS_LIST (test)); +} + +void +grub_test_unregister (const char *name) +{ + grub_test_t test; + + test = (grub_test_t) grub_named_list_find + (GRUB_AS_NAMED_LIST (grub_test_list), name); + + if (test) + { + grub_list_remove (GRUB_AS_LIST_P (&grub_test_list), + GRUB_AS_LIST (test)); + + if (test->name) + grub_test_free (test->name); + + grub_test_free (test); + } +} + +int +grub_test_run (const char *name) +{ + grub_test_t test; + + auto int print_failure (grub_test_failure_t item); + int print_failure (grub_test_failure_t item) + { + grub_test_failure_t failure = (grub_test_failure_t) item; + + grub_test_printf (" %s:%s:%u: %s\n", + (failure->file ? : ""), + (failure->funp ? : ""), + failure->line, (failure->message ? : "")); + return 0; + } + + test = grub_named_list_find (GRUB_AS_NAMED_LIST (grub_test_list), name); + if (!test) + return GRUB_ERR_FILE_NOT_FOUND; + + test->main (); + + if (!failure_list) + return GRUB_ERR_NONE; + + grub_test_printf ("%s:\n", test->name); + grub_list_iterate (GRUB_AS_LIST (failure_list), + (grub_list_hook_t) print_failure); + free_failures (); + return GRUB_ERR_TEST_FAILURE; +} diff --git a/tests/lib/unit_test.c b/tests/lib/unit_test.c new file mode 100644 index 000000000..15bb0da5d --- /dev/null +++ b/tests/lib/unit_test.c @@ -0,0 +1,122 @@ +#include +#include +#include +#include + +#include +#include +#include + +void * +grub_test_malloc (grub_size_t size) +{ + return malloc (size); +} + +void +grub_test_free (void *ptr) +{ + free (ptr); +} + +int +grub_test_vsprintf (char *str, const char *fmt, va_list args) +{ + return vsprintf (str, fmt, args); +} + +char * +grub_test_strdup (const char *str) +{ + return strdup (str); +} + +int +grub_test_printf (const char *fmt, ...) +{ + int r; + va_list ap; + + va_start (ap, fmt); + r = vprintf (fmt, ap); + va_end (ap); + + return r; +} + +int +main (int argc __attribute__ ((unused)), + char *argv[] __attribute__ ((unused))) +{ + int status = 0; + + extern void grub_unit_test_init (void); + extern void grub_unit_test_fini (void); + + auto int run_test (grub_test_t test); + int run_test (grub_test_t test) + { + status = grub_test_run (test->name) ? : status; + return 0; + } + + grub_unit_test_init (); + grub_list_iterate (GRUB_AS_LIST (grub_test_list), + (grub_list_hook_t) run_test); + grub_unit_test_fini (); + + exit (status); +} + +/* Other misc. functions necessary for successful linking. */ + +char * +grub_env_get (const char *name __attribute__ ((unused))) +{ + return NULL; +} + +grub_err_t +grub_error (grub_err_t n, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + vfprintf (stderr, fmt, ap); + va_end (ap); + + return n; +} + +void * +grub_malloc (grub_size_t size) +{ + return malloc (size); +} + +void +grub_refresh (void) +{ + fflush (stdout); +} + +void +grub_putchar (int c) +{ + putchar (c); +} + +int +grub_getkey (void) +{ + return -1; +} + +void +grub_exit (void) +{ + exit (1); +} + +struct grub_handler_class grub_term_input_class; +struct grub_handler_class grub_term_output_class; diff --git a/tests/util/grub-shell-tester.in b/tests/util/grub-shell-tester.in new file mode 100644 index 000000000..18f5e79b7 --- /dev/null +++ b/tests/util/grub-shell-tester.in @@ -0,0 +1,109 @@ +#! /bin/bash -e + +# Compares GRUB script output with BASH output. +# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,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 +# 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 . + +# Initialize some variables. +transform="@program_transform_name@" + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +libdir=@libdir@ +builddir=@builddir@ +PACKAGE_NAME=@PACKAGE_NAME@ +PACKAGE_TARNAME=@PACKAGE_TARNAME@ +PACKAGE_VERSION=@PACKAGE_VERSION@ +target_cpu=@target_cpu@ + +# Force build directory components +PATH=${builddir}:$PATH +export PATH + +# Usage: usage +# Print the usage. +usage () { + cat <. +EOF +} + +# Check the arguments. +for option in "$@"; do + case "$option" in + -h | --help) + usage + exit 0 ;; + -v | --version) + echo "$0 (GNU GRUB ${PACKAGE_VERSION})" + exit 0 ;; + --modules=*) + ms=`echo "$option" | sed -e 's/--modules=//'` + modules="$modules,$ms" ;; + --qemu-opts=*) + qs=`echo "$option" | sed -e 's/--qemu-opts=//'` + qemuopts="$qemuopts $qs" ;; + -*) + echo "Unrecognized option \`$option'" 1>&2 + usage + exit 1 + ;; + *) + if [ "x${source}" != x ] ; then + echo "too many parameters at the end" 1>&2 + usage + exit 1 + fi + source="${option}" ;; + esac +done + +if [ "x${source}" = x ] ; then + tmpfile=`mktemp` + while read; do + echo $REPLY >> ${tmpfile} + done + source=${tmpfile} +fi + +outfile1=`mktemp` +@builddir@/grub-shell --qemu-opts="${qemuopts}" --modules=${modules} ${source} >${outfile1} + +outfile2=`mktemp` +bash ${source} >${outfile2} + +if ! diff -q ${outfile1} ${outfile2} >/dev/null +then + echo "$1: GRUB and BASH outputs (${outfile1}, ${outfile2}) did not match" + status=1 +else + rm -f ${outfile1} ${outfile2} +fi + +exit $status + + diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in new file mode 100644 index 000000000..c1b2ef258 --- /dev/null +++ b/tests/util/grub-shell.in @@ -0,0 +1,125 @@ +#! /bin/bash -e + +# Run GRUB script in a Qemu instance +# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,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 +# 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 . + +# Initialize some variables. +transform="@program_transform_name@" + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +libdir=@libdir@ +builddir=@builddir@ +PACKAGE_NAME=@PACKAGE_NAME@ +PACKAGE_TARNAME=@PACKAGE_TARNAME@ +PACKAGE_VERSION=@PACKAGE_VERSION@ +target_cpu=@target_cpu@ + +# Force build directory components +PATH=${builddir}:$PATH +export PATH + +# Usage: usage +# Print the usage. +usage () { + cat <. +EOF +} + +# Check the arguments. +for option in "$@"; do + case "$option" in + -h | --help) + usage + exit 0 ;; + -v | --version) + echo "$0 (GNU GRUB ${PACKAGE_VERSION})" + exit 0 ;; + --modules=*) + ms=`echo "$option" | sed -e 's/--modules=//' -e 's/,/ /g'` + modules="$modules $ms" ;; + --qemu-opts=*) + qs=`echo "$option" | sed -e 's/--qemu-opts=//'` + qemuopts="$qemuopts $qs" ;; + -*) + echo "Unrecognized option \`$option'" 1>&2 + usage + exit 1 + ;; + *) + if [ "x${source}" != x ] ; then + echo "too many parameters at the end" 1>&2 + usage + exit 1 + fi + source="${option}" ;; + esac +done + +if [ "x${source}" = x ] ; then + tmpfile=`mktemp` + while read; do + echo $REPLY >> ${tmpfile} + done + source=${tmpfile} +fi + +cfgfile=`mktemp` +cat <${cfgfile} +grubshell=yes +insmod serial +serial +terminal_input serial +terminal_output serial +EOF + +for mod in ${modules} +do + echo "insmod ${mod}" >> ${cfgfile} +done + +cat <>${cfgfile} +source /boot/grub/testcase.cfg +halt +EOF + +isofile=`mktemp` +grub-mkrescue --output=${isofile} --override-directory=${builddir} \ + /boot/grub/grub.cfg=${cfgfile} /boot/grub/testcase.cfg=${source} \ + >/dev/null 2>&1 + +outfile=`mktemp` +qemu ${qemuopts} -nographic -serial stdio -cdrom ${isofile} -boot d | tr -d "\r" >${outfile} + +cat $outfile + +rm -f ${tmpfile} ${outfile} ${cfgfile} ${isofile} +exit 0 + + From 169b1cd2d87102670dfdb1717aef8723143d8c4b Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Fri, 8 Jan 2010 16:35:32 +0530 Subject: [PATCH 166/208] added functional tests to make-check --- Makefile.in | 19 +++++++++++++------ conf/tests.rmk | 14 +++++++------- genmk.rb | 6 +++--- include/grub/test.h | 2 +- tests/lib/functional_test.c | 21 +++++++++------------ tests/lib/test.c | 18 +++++++----------- tests/lib/unit_test.c | 2 +- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Makefile.in b/Makefile.in index 2358060f2..567571897 100644 --- a/Makefile.in +++ b/Makefile.in @@ -141,7 +141,6 @@ PROGRAMS = $(bin_UTILITIES) $(sbin_UTILITIES) SCRIPTS = $(bin_SCRIPTS) $(sbin_SCRIPTS) $(grub-mkconfig_SCRIPTS) \ $(lib_SCRIPTS) INFOS = $(info_INFOS) -TESTS = $(check_UNITTESTS) $(check_FUNCTIONALTESTS) $(check_SCRIPTEDTESTS) CLEANFILES = MOSTLYCLEANFILES = @@ -461,19 +460,27 @@ distcheck: dist @echo "$(distdir).tar.gz is ready for distribution" | \ sed 'h;s/./=/g;p;x;p;x' -$(TESTS): $(check_SCRIPTS) $(check_MODULES) $(check_PROGRAMS) +TESTS = $(check_UTILITIES) $(check_SCRIPTS) $(check_MODULES) +$(TESTS): $(test_framework_SCRIPTS) $(test_framework_MODULES) + check: all $(TESTS) - @list="$(check_UNITTESTS) $(check_SCRIPTEDTESTS)"; \ + @list="$(check_UTILITIES)"; \ for file in $$list; do \ + $(builddir)/$$file; \ + done + @list="$(check_SCRIPTS)"; \ + for file in $$list; do \ + echo "$$file:"; \ if $(builddir)/$$file; then \ echo "$$file: PASS"; \ else \ echo "$$file: FAIL"; \ fi; \ done - @list="$(check_FUNCTIONALTESTS)"; \ - for test in $$list; do \ - echo "insmod functional_test; insmod $test; functional_test" \ + @list="$(check_MODULES)"; \ + for file in $$list; do \ + mod=`basename $$file .mod`; \ + echo "insmod functional_test; insmod $$mod; functional_test" \ | $(builddir)/grub-shell; \ done diff --git a/conf/tests.rmk b/conf/tests.rmk index 03d6acbd1..c35ea0baa 100644 --- a/conf/tests.rmk +++ b/conf/tests.rmk @@ -4,38 +4,38 @@ grub-shell: tests/util/grub-shell.in config.status ./config.status --file=$@:$< chmod +x $@ -check_SCRIPTS += grub-shell +test_framework_SCRIPTS += grub-shell CLEANFILES += grub-shell # For grub-shell-tester grub-shell-tester: tests/util/grub-shell-tester.in config.status ./config.status --file=$@:$< chmod +x $@ -check_SCRIPTS += grub-shell-tester +test_framework_SCRIPTS += grub-shell-tester CLEANFILES += grub-shell-tester -check_MODULES += functional_test.mod +test_framework_MODULES += functional_test.mod functional_test_mod_SOURCES = tests/lib/functional_test.c tests/lib/test.c functional_test_mod_CFLAGS = $(COMMON_CFLAGS) functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS) # Unit tests -check_UNITTESTS += example_unit_test +check_UTILITIES += example_unit_test example_unit_test_SOURCES = tests/example_unit_test.c kern/list.c kern/misc.c tests/lib/test.c tests/lib/unit_test.c example_unit_test_CFLAGS = -Wno-format # Functional tests -check_FUNCTIONALTESTS += example_functional_test.mod +check_MODULES += example_functional_test.mod example_functional_test_mod_SOURCES = tests/example_functional_test.c example_functional_test_mod_CFLAGS = -Wno-format $(COMMON_CFLAGS) example_functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS) # Scripted tests -check_SCRIPTEDTESTS += example_scripted_test +check_SCRIPTS += example_scripted_test example_scripted_test_SOURCES = tests/example_scripted_test.in -check_SCRIPTEDTESTS += example_grub_script_test +check_SCRIPTS += example_grub_script_test example_grub_script_test_SOURCES = tests/example_grub_script_test.in diff --git a/genmk.rb b/genmk.rb index 006fc3d29..b1cce3831 100644 --- a/genmk.rb +++ b/genmk.rb @@ -407,12 +407,12 @@ while l = gets Image.new(prefix, img) end - when 'MODULES', 'FUNCTIONALTESTS' + when 'MODULES' pmodules += args.split(/\s+/).collect do |pmod| PModule.new(prefix, pmod) end - when 'UTILITIES', 'UNITTESTS' + when 'UTILITIES' utils += args.split(/\s+/).collect do |util| Utility.new(prefix, util) end @@ -422,7 +422,7 @@ while l = gets Program.new(prefix, prog) end - when 'SCRIPTS', 'SCRIPTEDTESTS' + when 'SCRIPTS' scripts += args.split(/\s+/).collect do |script| Script.new(prefix, script) end diff --git a/include/grub/test.h b/include/grub/test.h index fbc2bff8c..4b028371b 100644 --- a/include/grub/test.h +++ b/include/grub/test.h @@ -27,7 +27,7 @@ void EXPORT_FUNC (grub_test_register) (const char *name, void (*test) (void)); void EXPORT_FUNC (grub_test_unregister) (const char *name); /* Execute a test and print results. */ -int grub_test_run (const char *name); +int grub_test_run (grub_test_t test); /* Test `cond' for nonzero; log failure otherwise. */ void grub_test_nonzero (int cond, const char *file, diff --git a/tests/lib/functional_test.c b/tests/lib/functional_test.c index 24e82932e..2e03dabc4 100644 --- a/tests/lib/functional_test.c +++ b/tests/lib/functional_test.c @@ -45,19 +45,16 @@ grub_functional_test (struct grub_extcmd *cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), char **args __attribute__ ((unused))) { - int i; - int status; - grub_test_t test; + auto int run_test (grub_test_t test); + int run_test (grub_test_t test) + { + grub_test_run (test); + return 0; + } - status = 0; - for (i = 0; i < argc; i++) - { - test = grub_named_list_find (GRUB_AS_NAMED_LIST (grub_test_list), - args[i]); - status = grub_test_run (test->name) ? : status; - } - - return status; + grub_list_iterate (GRUB_AS_LIST (grub_test_list), + (grub_list_hook_t) run_test); + return GRUB_ERR_NONE; } static grub_extcmd_t cmd; diff --git a/tests/lib/test.c b/tests/lib/test.c index 37f8fff72..562c2f6e4 100644 --- a/tests/lib/test.c +++ b/tests/lib/test.c @@ -117,10 +117,8 @@ grub_test_unregister (const char *name) } int -grub_test_run (const char *name) +grub_test_run (grub_test_t test) { - grub_test_t test; - auto int print_failure (grub_test_failure_t item); int print_failure (grub_test_failure_t item) { @@ -133,18 +131,16 @@ grub_test_run (const char *name) return 0; } - test = grub_named_list_find (GRUB_AS_NAMED_LIST (grub_test_list), name); - if (!test) - return GRUB_ERR_FILE_NOT_FOUND; - test->main (); - if (!failure_list) - return GRUB_ERR_NONE; - grub_test_printf ("%s:\n", test->name); grub_list_iterate (GRUB_AS_LIST (failure_list), (grub_list_hook_t) print_failure); + if (!failure_list) + grub_test_printf ("%s: PASS\n", test->name); + else + grub_test_printf ("%s: FAIL\n", test->name); + free_failures (); - return GRUB_ERR_TEST_FAILURE; + return GRUB_ERR_NONE; } diff --git a/tests/lib/unit_test.c b/tests/lib/unit_test.c index 15bb0da5d..59931898a 100644 --- a/tests/lib/unit_test.c +++ b/tests/lib/unit_test.c @@ -56,7 +56,7 @@ main (int argc __attribute__ ((unused)), auto int run_test (grub_test_t test); int run_test (grub_test_t test) { - status = grub_test_run (test->name) ? : status; + status = grub_test_run (test) ? : status; return 0; } From cd943b7587561adf229fe9eb35cd05ad71fcb178 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 8 Jan 2010 15:19:42 +0000 Subject: [PATCH 167/208] 2010-01-08 Robert Millan * util/mkisofs/defaults.h (APPID_DEFAULT): Redefine using PACKAGE_NAME. (SYSTEM_ID_DEFAULT): Set to "GNU" unconditionally. * util/mkisofs/mkisofs.c (main): Readjust --version output. --- ChangeLog | 6 ++++++ util/mkisofs/defaults.h | 38 ++------------------------------------ util/mkisofs/mkisofs.c | 2 +- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 749b0e68c..b1f35e795 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-08 Robert Millan + + * util/mkisofs/defaults.h (APPID_DEFAULT): Redefine using PACKAGE_NAME. + (SYSTEM_ID_DEFAULT): Set to "GNU" unconditionally. + * util/mkisofs/mkisofs.c (main): Readjust --version output. + 2010-01-07 Robert Millan Reset Multiboot 2 support. New loader implements the draft in diff --git a/util/mkisofs/defaults.h b/util/mkisofs/defaults.h index dc9ad380c..2ce9e8d6b 100644 --- a/util/mkisofs/defaults.h +++ b/util/mkisofs/defaults.h @@ -8,7 +8,7 @@ #define PREPARER_DEFAULT NULL #define PUBLISHER_DEFAULT NULL #ifndef APPID_DEFAULT -#define APPID_DEFAULT "MKISOFS ISO 9660 FILESYSTEM BUILDER" +#define APPID_DEFAULT PACKAGE_NAME " ISO 9660 filesystem builder" #endif #define COPYRIGHT_DEFAULT NULL #define BIBLIO_DEFAULT NULL @@ -17,38 +17,4 @@ #define VOLUME_ID_DEFAULT "CDROM" #define BOOT_CATALOG_DEFAULT "boot.catalog" #define BOOT_IMAGE_DEFAULT NULL -#ifdef __QNX__ -#define SYSTEM_ID_DEFAULT "QNX" -#endif - -#ifdef __osf__ -#define SYSTEM_ID_DEFAULT "OSF" -#endif - -#ifdef __sun -#ifdef __SVR4 -#define SYSTEM_ID_DEFAULT "Solaris" -#else -#define SYSTEM_ID_DEFAULT "SunOS" -#endif -#endif - -#ifdef __hpux -#define SYSTEM_ID_DEFAULT "HP-UX" -#endif - -#ifdef __sgi -#define SYSTEM_ID_DEFAULT "SGI" -#endif - -#ifdef _AIX -#define SYSTEM_ID_DEFAULT "AIX" -#endif - -#ifdef _WIN -#define SYSTEM_ID_DEFAULT "Win32" -#endif /* _WIN */ - -#ifndef SYSTEM_ID_DEFAULT -#define SYSTEM_ID_DEFAULT "LINUX" -#endif +#define SYSTEM_ID_DEFAULT "GNU" diff --git a/util/mkisofs/mkisofs.c b/util/mkisofs/mkisofs.c index 588345232..b6084a24a 100644 --- a/util/mkisofs/mkisofs.c +++ b/util/mkisofs/mkisofs.c @@ -914,7 +914,7 @@ int FDECL2(main, int, argc, char **, argv){ exit (0); break; case OPTION_VERSION: - printf ("%s (%s %s)\n", program_name, PACKAGE_NAME, PACKAGE_VERSION); + printf ("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION); exit (0); break; case OPTION_NOSPLIT_SL_COMPONENT: From b394b2cab89ea8882345624286815ef1b9a81e88 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 8 Jan 2010 15:22:40 +0000 Subject: [PATCH 168/208] 2010-01-08 Robert Millan * src/mkisofs.c: Remove `ifdef linux' portability kludge. --- ChangeLog | 6 +++++- util/mkisofs/mkisofs.c | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index b1f35e795..e91e87536 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ -2010-01-08 Robert Millan +2010-01-08 Robert Millan + + * src/mkisofs.c: Remove `ifdef linux' portability kludge. + +2010-01-08 Robert Millan * util/mkisofs/defaults.h (APPID_DEFAULT): Redefine using PACKAGE_NAME. (SYSTEM_ID_DEFAULT): Set to "GNU" unconditionally. diff --git a/util/mkisofs/mkisofs.c b/util/mkisofs/mkisofs.c index b6084a24a..69b4b3d0d 100644 --- a/util/mkisofs/mkisofs.c +++ b/util/mkisofs/mkisofs.c @@ -26,12 +26,7 @@ #include "config.h" #include "mkisofs.h" #include "match.h" - -#ifdef linux -#include -#else #include "getopt.h" -#endif #include "iso9660.h" #include From 1afc27d06b9030b83f3398edd13344d8fbe81c24 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Fri, 8 Jan 2010 21:28:57 +0530 Subject: [PATCH 169/208] added changelog file --- ChangeLog.unit-testing-framework | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ChangeLog.unit-testing-framework diff --git a/ChangeLog.unit-testing-framework b/ChangeLog.unit-testing-framework new file mode 100644 index 000000000..a451108c4 --- /dev/null +++ b/ChangeLog.unit-testing-framework @@ -0,0 +1,26 @@ +2010-01-08 BVK Chaitanya + + Unit testing framework for GRUB. + + * Makefile.in: Test framework build rules for 'make check'. + * conf/tests.rmk: Build rules for individual tests and framework. + + * include/grub/test.h: Header file for whitebox tests. + * tests/lib/functional_test.c: Framework support for whitebox + functional tests. + * tests/lib/test.c: Common whitebox testing code for unit and + functional tests. + * tests/lib/unit_test.c: Framework support for whitebox unit + tests. + + * tests/util/grub-shell-tester.in: Support utility for grub-script + tests. + * tests/util/grub-shell.in: Utility to execute grub-script + commands in a Qemu instance. + + * tests/example_functional_test.c: Example whitebox functional + test. + * tests/example_grub_script_test.in: Example grub-script test. + * tests/example_scripted_test.in: Example scripted test. + * tests/example_unit_test.c: Example whitebox unit test. + From 5cc318eb3532f333dc324627dc977fe2f5bef40a Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Fri, 8 Jan 2010 22:06:46 +0530 Subject: [PATCH 170/208] replaced __func__ with simpler __FUNCTION__ macro --- include/grub/test.h | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/include/grub/test.h b/include/grub/test.h index 4b028371b..b4851bbf6 100644 --- a/include/grub/test.h +++ b/include/grub/test.h @@ -35,22 +35,10 @@ void grub_test_nonzero (int cond, const char *file, const char *fmt, ...) __attribute__ ((format (printf, 5, 6))); -#ifdef __STDC_VERSION__ -#if __STDC_VERSION__ < 199901L -# if __GNUC__ >= 2 -# define __func__ __FUNCTION__ -# else -# define __func__ "" -# endif -#endif -#else -#define __func__ "" -#endif - /* Macro to fill in location details and an optional error message. */ -#define grub_test_assert(cond, ...) \ - grub_test_nonzero(cond, __FILE__, __func__, __LINE__, \ - ## __VA_ARGS__, \ +#define grub_test_assert(cond, ...) \ + grub_test_nonzero(cond, __FILE__, __FUNCTION__, __LINE__, \ + ## __VA_ARGS__, \ "assert failed: %s", #cond) /* Macro to define a unit test. */ From 809bbfebfe4b03402be3bbaaf631ee4d562262d1 Mon Sep 17 00:00:00 2001 From: carles Date: Fri, 8 Jan 2010 21:35:38 +0000 Subject: [PATCH 171/208] 2010-01-08 Carles Pina i Estany * loader/efi/appleloader.c: Include `'. (GRUB_MOD_INIT): Gettextizze. * loader/efi/chainloader.c: Include `'. (GRUB_MOD_INIT): Gettextizze. * loader/i386/efi/linux.c: Include `'. (grub_cmd_linux): Capitalise Linux. (GRUB_MOD_INIT): Gettextizze. * loader/i386/ieee1275/linux.c: Include `'. (grub_cmd_linux): Capitalise Linux. (GRUB_MOD_INIT): Gettextizze. * loader/i386/linux.c: Include `'. (grub_cmd_linux): Capitalise Linux. (GRUB_MOD_INIT): Gettextizze. * loader/i386/pc/chainloader.c: Include `'. (GRUB_MOD_INIT): Gettextizze. * loader/i386/pc/linux.c: Include `'. (grub_cmd_linux): Capitalise Linux. (GRUB_MOD_INIT): Gettextizze. * loader/i386/xnu.c: Include `'. (grub_cpu_xnu_init): Gettextizze. * loader/multiboot_loader.c: Include `'. (GRUB_MOD_INIT): Gettextizze. * loader/powerpc/ieee1275/linux.c: Include `'. (GRUB_MOD_INIT): Gettextizze. * loader/sparc64/ieee1275/linux.c: Include `'. (grub_linux_load64): Capitalise Linux. (GRUB_MOD_INIT): Gettextizze. * loader/xnu.c: Include `'. (GRUB_MOD_INIT): Gettextizze. * po/POTFILES: Add `loader/efi/appleloader.c', `loader/efi/chainloader.c', `loader/i386/efi/linux.c', `loader/i386/ieee1275/linux.c', `loader/i386/linux.c', `loader/i386/pc/chainloader.c', `loader/i386/pc/linux.c', `loader/i386/xnu.c', `loader/multiboot_loader.c', `loader/powerpc/ieee1275/linux.c', `loader/sparc64/ieee1275/linux.c' and `loader/xnu.c'. --- ChangeLog | 39 +++++++++++++++++++++++++++++++++ loader/efi/appleloader.c | 3 ++- loader/efi/chainloader.c | 3 ++- loader/i386/efi/linux.c | 7 +++--- loader/i386/ieee1275/linux.c | 7 +++--- loader/i386/linux.c | 7 +++--- loader/i386/pc/chainloader.c | 3 ++- loader/i386/pc/linux.c | 7 +++--- loader/i386/xnu.c | 3 ++- loader/multiboot_loader.c | 7 +++--- loader/powerpc/ieee1275/linux.c | 5 +++-- loader/sparc64/ieee1275/linux.c | 7 +++--- loader/xnu.c | 21 +++++++++--------- po/POTFILES | 12 ++++++++++ 14 files changed, 97 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index e91e87536..43accdc25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,42 @@ +2010-01-08 Carles Pina i Estany + + * loader/efi/appleloader.c: Include `'. + (GRUB_MOD_INIT): Gettextizze. + * loader/efi/chainloader.c: Include `'. + (GRUB_MOD_INIT): Gettextizze. + * loader/i386/efi/linux.c: Include `'. + (grub_cmd_linux): Capitalise Linux. + (GRUB_MOD_INIT): Gettextizze. + * loader/i386/ieee1275/linux.c: Include `'. + (grub_cmd_linux): Capitalise Linux. + (GRUB_MOD_INIT): Gettextizze. + * loader/i386/linux.c: Include `'. + (grub_cmd_linux): Capitalise Linux. + (GRUB_MOD_INIT): Gettextizze. + * loader/i386/pc/chainloader.c: Include `'. + (GRUB_MOD_INIT): Gettextizze. + * loader/i386/pc/linux.c: Include `'. + (grub_cmd_linux): Capitalise Linux. + (GRUB_MOD_INIT): Gettextizze. + * loader/i386/xnu.c: Include `'. + (grub_cpu_xnu_init): Gettextizze. + * loader/multiboot_loader.c: Include `'. + (GRUB_MOD_INIT): Gettextizze. + * loader/powerpc/ieee1275/linux.c: Include `'. + (GRUB_MOD_INIT): Gettextizze. + * loader/sparc64/ieee1275/linux.c: Include `'. + (grub_linux_load64): Capitalise Linux. + (GRUB_MOD_INIT): Gettextizze. + * loader/xnu.c: Include `'. + (GRUB_MOD_INIT): Gettextizze. + * po/POTFILES: Add `loader/efi/appleloader.c', + `loader/efi/chainloader.c', `loader/i386/efi/linux.c', + `loader/i386/ieee1275/linux.c', `loader/i386/linux.c', + `loader/i386/pc/chainloader.c', `loader/i386/pc/linux.c', + `loader/i386/xnu.c', `loader/multiboot_loader.c', + `loader/powerpc/ieee1275/linux.c', `loader/sparc64/ieee1275/linux.c' + and `loader/xnu.c'. + 2010-01-08 Robert Millan * src/mkisofs.c: Remove `ifdef linux' portability kludge. diff --git a/loader/efi/appleloader.c b/loader/efi/appleloader.c index 114a0a506..dc42683a6 100644 --- a/loader/efi/appleloader.c +++ b/loader/efi/appleloader.c @@ -25,6 +25,7 @@ #include #include #include +#include static grub_dl_t my_mod; @@ -321,7 +322,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(appleloader) { cmd = grub_register_command ("appleloader", grub_cmd_appleloader, - "[OPTS]", "Boot legacy system."); + "[OPTS]", N_("Boot legacy system.")); my_mod = mod; } diff --git a/loader/efi/chainloader.c b/loader/efi/chainloader.c index 559c3f52a..a095ad931 100644 --- a/loader/efi/chainloader.c +++ b/loader/efi/chainloader.c @@ -33,6 +33,7 @@ #include #include #include +#include static grub_dl_t my_mod; @@ -336,7 +337,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(chainloader) { cmd = grub_register_command ("chainloader", grub_cmd_chainloader, - 0, "Load another boot loader."); + 0, N_("Load another boot loader.")); my_mod = mod; } diff --git a/loader/i386/efi/linux.c b/loader/i386/efi/linux.c index 1c256e377..848c1ef7d 100644 --- a/loader/i386/efi/linux.c +++ b/loader/i386/efi/linux.c @@ -33,6 +33,7 @@ #include #include #include +#include #define GRUB_LINUX_CL_OFFSET 0x1000 #define GRUB_LINUX_CL_END_OFFSET 0x2000 @@ -619,7 +620,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) { - grub_error (GRUB_ERR_READ_ERROR, "cannot read the linux header"); + grub_error (GRUB_ERR_READ_ERROR, "cannot read the Linux header"); goto fail; } @@ -989,9 +990,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "Load Linux."); + 0, N_("Load Linux.")); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "Load initrd."); + 0, N_("Load initrd.")); my_mod = mod; } diff --git a/loader/i386/ieee1275/linux.c b/loader/i386/ieee1275/linux.c index e8a6f1a52..7d556ee00 100644 --- a/loader/i386/ieee1275/linux.c +++ b/loader/i386/ieee1275/linux.c @@ -32,6 +32,7 @@ #include #include #include +#include #define GRUB_OFW_LINUX_PARAMS_ADDR 0x90000 #define GRUB_OFW_LINUX_KERNEL_ADDR 0x100000 @@ -165,7 +166,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) { - grub_error (GRUB_ERR_READ_ERROR, "cannot read the linux header"); + grub_error (GRUB_ERR_READ_ERROR, "cannot read the Linux header"); goto fail; } @@ -276,9 +277,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "Load Linux."); + 0, N_("Load Linux.")); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "Load initrd."); + 0, N_("Load initrd.")); my_mod = mod; } diff --git a/loader/i386/linux.c b/loader/i386/linux.c index 899216783..4375a1162 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 @@ -613,7 +614,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) { - grub_error (GRUB_ERR_READ_ERROR, "cannot read the linux header"); + grub_error (GRUB_ERR_READ_ERROR, "cannot read the Linux header"); goto fail; } @@ -982,9 +983,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "Load Linux."); + 0, N_("Load Linux.")); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "Load initrd."); + 0, N_("Load initrd.")); my_mod = mod; } diff --git a/loader/i386/pc/chainloader.c b/loader/i386/pc/chainloader.c index a153d80a9..81cfddac1 100644 --- a/loader/i386/pc/chainloader.c +++ b/loader/i386/pc/chainloader.c @@ -32,6 +32,7 @@ #include #include #include +#include static grub_dl_t my_mod; static int boot_drive; @@ -146,7 +147,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(chainloader) { cmd = grub_register_command ("chainloader", grub_cmd_chainloader, - 0, "Load another boot loader."); + 0, N_("Load another boot loader.")); my_mod = mod; } diff --git a/loader/i386/pc/linux.c b/loader/i386/pc/linux.c index 77b7966bf..24bb39555 100644 --- a/loader/i386/pc/linux.c +++ b/loader/i386/pc/linux.c @@ -30,6 +30,7 @@ #include #include #include +#include #define GRUB_LINUX_CL_OFFSET 0x9000 #define GRUB_LINUX_CL_END_OFFSET 0x90FF @@ -81,7 +82,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) { - grub_error (GRUB_ERR_READ_ERROR, "cannot read the linux header"); + grub_error (GRUB_ERR_READ_ERROR, "cannot read the Linux header"); goto fail; } @@ -383,10 +384,10 @@ GRUB_MOD_INIT(linux16) { cmd_linux = grub_register_command ("linux16", grub_cmd_linux, - 0, "Load Linux."); + 0, N_("Load Linux.")); cmd_initrd = grub_register_command ("initrd16", grub_cmd_initrd, - 0, "Load initrd."); + 0, N_("Load initrd.")); my_mod = mod; } diff --git a/loader/i386/xnu.c b/loader/i386/xnu.c index f71e2c306..23a8a6f7b 100644 --- a/loader/i386/xnu.c +++ b/loader/i386/xnu.c @@ -32,6 +32,7 @@ #include #include #include +#include char grub_xnu_cmdline[1024]; grub_uint32_t grub_xnu_heap_will_be_at; @@ -1026,7 +1027,7 @@ grub_cpu_xnu_init (void) { cmd_devprop_load = grub_register_command ("xnu_devprop_load", grub_cmd_devprop_load, - 0, "Load device-properties dump."); + 0, N_("Load device-properties dump.")); } void diff --git a/loader/multiboot_loader.c b/loader/multiboot_loader.c index 790f14d9a..6d042fa81 100644 --- a/loader/multiboot_loader.c +++ b/loader/multiboot_loader.c @@ -26,6 +26,7 @@ #include #include #include +#include grub_dl_t my_mod; @@ -129,15 +130,15 @@ GRUB_MOD_INIT(multiboot) cmd_multiboot = #ifdef GRUB_USE_MULTIBOOT2 grub_register_command ("multiboot2", grub_cmd_multiboot_loader, - 0, "Load a multiboot 2 kernel."); + 0, N_("Load a multiboot 2 kernel.")); #else grub_register_command ("multiboot", grub_cmd_multiboot_loader, - 0, "Load a multiboot kernel."); + 0, N_("Load a multiboot kernel.")); #endif cmd_module = grub_register_command ("module", grub_cmd_module_loader, - 0, "Load a multiboot module."); + 0, N_("Load a multiboot module.")); my_mod = mod; } diff --git a/loader/powerpc/ieee1275/linux.c b/loader/powerpc/ieee1275/linux.c index 085f5c026..39ba2ad0a 100644 --- a/loader/powerpc/ieee1275/linux.c +++ b/loader/powerpc/ieee1275/linux.c @@ -26,6 +26,7 @@ #include #include #include +#include #define ELF32_LOADMASK (0xc0000000UL) #define ELF64_LOADMASK (0xc000000000000000ULL) @@ -349,9 +350,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "Load Linux."); + 0, N_("Load Linux.")); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "Load initrd."); + 0, N_("Load initrd.")); my_mod = mod; } diff --git a/loader/sparc64/ieee1275/linux.c b/loader/sparc64/ieee1275/linux.c index 6ffad202e..4d5723c19 100644 --- a/loader/sparc64/ieee1275/linux.c +++ b/loader/sparc64/ieee1275/linux.c @@ -27,6 +27,7 @@ #include #include #include +#include static grub_dl_t my_mod; @@ -263,7 +264,7 @@ grub_linux_load64 (grub_elf_t elf) return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't map physical memory"); - grub_dprintf ("loader", "Loading linux at vaddr 0x%lx, paddr 0x%lx, size 0x%lx\n", + grub_dprintf ("loader", "Loading Linux at vaddr 0x%lx, paddr 0x%lx, size 0x%lx\n", linux_addr, paddr, linux_size); linux_paddr = paddr; @@ -516,9 +517,9 @@ GRUB_MOD_INIT(linux) fetch_translations (); cmd_linux = grub_register_command ("linux", grub_cmd_linux, - 0, "Load Linux."); + 0, N_("Load Linux.")); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, - 0, "Load initrd."); + 0, N_("Load initrd.")); my_mod = mod; } diff --git a/loader/xnu.c b/loader/xnu.c index f3ae3888a..c3dcee3ed 100644 --- a/loader/xnu.c +++ b/loader/xnu.c @@ -32,6 +32,7 @@ #include #include #include +#include struct grub_xnu_devtree_key *grub_xnu_devtree_root = 0; static int driverspackagenum = 0; @@ -1404,25 +1405,25 @@ static grub_command_t cmd_kextdir, cmd_ramdisk, cmd_resume, cmd_splash; GRUB_MOD_INIT(xnu) { cmd_kernel = grub_register_command ("xnu_kernel", grub_cmd_xnu_kernel, 0, - "Load XNU image."); + N_("Load XNU image.")); cmd_kernel64 = grub_register_command ("xnu_kernel64", grub_cmd_xnu_kernel64, - 0, "Load 64-bit XNU image."); + 0, N_("Load 64-bit XNU image.")); cmd_mkext = grub_register_command ("xnu_mkext", grub_cmd_xnu_mkext, 0, - "Load XNU extension package."); + N_("Load XNU extension package.")); cmd_kext = grub_register_command ("xnu_kext", grub_cmd_xnu_kext, 0, - "Load XNU extension."); + N_("Load XNU extension.")); cmd_kextdir = grub_register_command ("xnu_kextdir", grub_cmd_xnu_kextdir, - "DIRECTORY [OSBundleRequired]", - "Load XNU extension directory."); + N_("DIRECTORY [OSBundleRequired]"), + N_("Load XNU extension directory.")); cmd_ramdisk = grub_register_command ("xnu_ramdisk", grub_cmd_xnu_ramdisk, 0, - "Load XNU ramdisk. " - "It will be seen as md0."); + N_("Load XNU ramdisk. " + "It will be seen as md0.")); cmd_splash = grub_register_command ("xnu_splash", grub_cmd_xnu_splash, 0, - "Load a splash image for XNU."); + N_("Load a splash image for XNU.")); #ifndef GRUB_UTIL cmd_resume = grub_register_command ("xnu_resume", grub_cmd_xnu_resume, - 0, "Load XNU hibernate image."); + 0, N_("Load XNU hibernate image.")); #endif grub_cpu_xnu_init (); diff --git a/po/POTFILES b/po/POTFILES index c4ae9d562..32927256c 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -53,7 +53,19 @@ hello/hello.c lib/arg.c +loader/efi/appleloader.c +loader/efi/chainloader.c loader/i386/bsd.c +loader/i386/efi/linux.c +loader/i386/ieee1275/linux.c +loader/i386/linux.c +loader/i386/pc/chainloader.c +loader/i386/pc/linux.c +loader/i386/xnu.c +loader/multiboot_loader.c +loader/powerpc/ieee1275/linux.c +loader/sparc64/ieee1275/linux.c +loader/xnu.c normal/auth.c normal/color.c From 5ce0a83a15fa27b89f6725293710c394679d0fdf Mon Sep 17 00:00:00 2001 From: carles Date: Sat, 9 Jan 2010 20:20:27 +0000 Subject: [PATCH 172/208] 2010-01-09 Carles Pina i Estany * gettext/gettext.c (GRUB_MOD_INIT): Gettextizze. --- ChangeLog | 4 ++++ gettext/gettext.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 43accdc25..4ebdb2a48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-09 Carles Pina i Estany + + * gettext/gettext.c (GRUB_MOD_INIT): Gettextizze. + 2010-01-08 Carles Pina i Estany * loader/efi/appleloader.c: Include `'. diff --git a/gettext/gettext.c b/gettext/gettext.c index 165feb332..6fa6271f2 100644 --- a/gettext/gettext.c +++ b/gettext/gettext.c @@ -347,8 +347,8 @@ GRUB_MOD_INIT (gettext) grub_gettext_init_ext (lang); grub_register_command_p1 ("gettext", grub_cmd_translate, - "STRING", - "Translates the string with the current settings."); + N_("STRING"), + N_("Translates the string with the current settings.")); /* Reload .mo file information if lang changes. */ grub_register_variable_hook ("lang", NULL, grub_gettext_env_write_lang); From 1a064917fef933ad4ac943ea4c4841b5efd0b949 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sat, 9 Jan 2010 22:02:00 +0000 Subject: [PATCH 173/208] 2010-01-09 Robert Millan Make loader output a bit more user-friendly. * util/grub.d/10_hurd.in: Print message indicating that GNU Mach is being loaded. Likewise for the Hurd. * util/grub.d/10_kfreebsd.in (kfreebsd_entry): Print message indicating that kernel of FreeBSD ${version} is being loaded. * loader/i386/linux.c (grub_cmd_linux): Move debug info to grub_dprintf(). (grub_cmd_initrd): Likewise. * util/grub.d/10_linux.in (linux_entry): Print message indicating that Linux ${version} is being loaded. Likewise for initrd. --- ChangeLog | 16 ++++++++++++++++ loader/i386/linux.c | 10 +++++----- util/grub.d/10_hurd.in | 10 ++++++---- util/grub.d/10_kfreebsd.in | 7 ++++--- util/grub.d/10_linux.in | 4 +++- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4ebdb2a48..6f3598e6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2010-01-09 Robert Millan + + Make loader output a bit more user-friendly. + + * util/grub.d/10_hurd.in: Print message indicating that GNU Mach + is being loaded. Likewise for the Hurd. + + * util/grub.d/10_kfreebsd.in (kfreebsd_entry): Print message indicating + that kernel of FreeBSD ${version} is being loaded. + + * loader/i386/linux.c (grub_cmd_linux): Move debug info to + grub_dprintf(). + (grub_cmd_initrd): Likewise. + * util/grub.d/10_linux.in (linux_entry): Print message indicating + that Linux ${version} is being loaded. Likewise for initrd. + 2010-01-09 Carles Pina i Estany * gettext/gettext.c (GRUB_MOD_INIT): Gettextizze. diff --git a/loader/i386/linux.c b/loader/i386/linux.c index 4375a1162..7c4b061b8 100644 --- a/loader/i386/linux.c +++ b/loader/i386/linux.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -713,8 +713,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_file_seek (file, real_size + GRUB_DISK_SECTOR_SIZE); - grub_printf (" [Linux-bzImage, setup=0x%x, size=0x%x]\n", - (unsigned) real_size, (unsigned) prot_size); + grub_dprintf ("linux", "bzImage, setup=0x%x, size=0x%x\n", + (unsigned) real_size, (unsigned) prot_size); /* Look for memory size and video mode specified on the command line. */ linux_mem_size = 0; @@ -964,8 +964,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; } - grub_printf (" [Initrd, addr=0x%x, size=0x%x]\n", - (unsigned) addr, (unsigned) size); + grub_dprintf ("linux", "Initrd, addr=0x%x, size=0x%x\n", + (unsigned) addr, (unsigned) size); lh->ramdisk_image = addr; lh->ramdisk_size = size; diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index 19fd8ec27..ff883f461 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -1,7 +1,7 @@ #! /bin/sh -e # grub-mkconfig helper script. -# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. +# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -73,16 +73,18 @@ menuentry "${OS}" { EOF prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/" cat << EOF - multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} + echo $(gettext "Loading GNU Mach ...") + multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} EOF prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/" cat << EOF - module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\ + echo $(gettext "Loading the Hurd ...") + module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\ --multiboot-command-line='\${kernel-command-line}' \\ --host-priv-port='\${host-port}' \\ --device-master-port='\${device-port}' \\ --exec-server-task='\${exec-task}' -T typed '\${root}' \\ '\$(task-create)' '\$(task-resume)' - module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)' + module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)' } EOF diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index 1329bba1f..0da7cabbc 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -1,7 +1,7 @@ #! /bin/sh -e # grub-mkconfig helper script. -# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. +# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,12 +44,13 @@ kfreebsd_entry () fi printf '%s\n' "${prepare_boot_cache}" cat << EOF - kfreebsd ${rel_dirname}/${basename} + echo $(printf "$(gettext "Loading kernel of FreeBSD %s ...")" ${version}) + kfreebsd ${rel_dirname}/${basename} EOF if test -n "${devices}" ; then cat << EOF - kfreebsd_loadenv ${devices_rel_dirname}/${devices_basename} + kfreebsd_loadenv ${devices_rel_dirname}/${devices_basename} EOF fi diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 5fea5338e..0accf8f23 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -1,7 +1,7 @@ #! /bin/sh -e # grub-mkconfig helper script. -# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. +# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -64,10 +64,12 @@ linux_entry () fi printf '%s\n' "${prepare_boot_cache}" cat << EOF + echo $(printf "$(gettext "Loading Linux %s ...")" ${version}) linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then cat << EOF + echo $(gettext "Loading initial ramdisk ...") initrd ${rel_dirname}/${initrd} EOF fi From 822873a7da694d3336505bb31e4bc7cd7e019974 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sat, 9 Jan 2010 23:42:17 +0100 Subject: [PATCH 174/208] Eliminate grub_term_register_{input,output}_active. Default terminals are automatically activated because they're the only terminal that has been loaded. This solution is temporary. In the future, all terminals should auto-enable, but this is non-trivial due to resource conflict, and it shouldn't prevent merge in trunk. --- ChangeLog.multiterm | 16 +------------- genterminallist.sh | 4 +--- include/grub/term.h | 45 +++++++++++++++++++------------------- term/efi/console.c | 4 ++-- term/gfxterm.c | 4 ---- term/i386/pc/at_keyboard.c | 4 ---- term/i386/pc/console.c | 4 ++-- term/i386/pc/vga_text.c | 6 +---- term/ieee1275/ofconsole.c | 4 ++-- util/console.c | 4 ++-- 10 files changed, 33 insertions(+), 62 deletions(-) diff --git a/ChangeLog.multiterm b/ChangeLog.multiterm index 3228f902a..d16bb2222 100644 --- a/ChangeLog.multiterm +++ b/ChangeLog.multiterm @@ -1,5 +1,5 @@ 2010-01-07 Vladimir Serbinenko -2010-01-07 Robert Millan +2010-01-09 Robert Millan Support for multiple terminals. @@ -58,8 +58,6 @@ (grub_term_inputs_disabled): Likewise. (grub_term_outputs): Likewise. (grub_term_inputs): Likewise. - (grub_term_register_input_active): New function. - (grub_term_register_output_active): Likewise. (grub_term_register_input): Rewritten. (grub_term_register_output): Likewise. (grub_term_unregister_input): Likewise. @@ -102,20 +100,8 @@ * normal/menu_text.c: Likewise. * normal/menu_viewer.c: Removed. All users updated. * normal/term.c: New file. - * term/efi/console.c (grub_console_init): Use - grub_term_register_input_active and grub_term_register_output_active. - * term/gfxterm.c (GRUB_MOD_INIT) [GRUB_MACHINE_MIPS_YEELOONG]: Likewise. - * term/i386/pc/at_keyboard.c (GRUB_MOD_INIT) - [GRUB_MACHINE_MIPS_YEELOONG] || [GRUB_MACHINE_COREBOOT] - || [GRUB_MACHINE_QEMU]: Likewise. - * term/i386/pc/vga_text.c (GRUB_MOD_INIT) [GRUB_MACHINE_COREBOOT] - || [GRUB_MACHINE_QEMU]: Likewise. - * term/i386/pc/console.c (grub_console_init): Likewise. - * term/ieee1275/ofconsole.c (grub_console_init): Likewise. * util/console.c: Change order of includes to workaround a bug in ncurses headers. - (grub_console_init): Use - grub_term_register_input_active and grub_term_register_output_active. * term/terminfo.c: New argument oterm on all exported functions. All users updated. * util/grub-editenv.c (grub_term_input_class): Removed. diff --git a/genterminallist.sh b/genterminallist.sh index eb0de0c32..60f5b9105 100644 --- a/genterminallist.sh +++ b/genterminallist.sh @@ -1,6 +1,6 @@ #! /bin/sh # -# Copyright (C) 2009 Free Software Foundation, Inc. +# Copyright (C) 2009,2010 Free Software Foundation, Inc. # # This script is free software; the author # gives unlimited permission to copy and/or distribute it, @@ -17,6 +17,4 @@ module=$1 grep -v "^#" | sed -n \ -e "/grub_term_register_input *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $module/;p;}" \ - -e "/grub_term_register_input_active *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $module/;p;}" \ -e "/grub_term_register_output *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $module/;p;}" \ - -e "/grub_term_register_output_active *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $module/;p;}" diff --git a/include/grub/term.h b/include/grub/term.h index 1c57a4ede..3d644b848 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,2009 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2005,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -198,38 +198,37 @@ extern struct grub_term_input *EXPORT_VAR(grub_term_inputs_disabled); extern struct grub_term_output *EXPORT_VAR(grub_term_outputs); extern struct grub_term_input *EXPORT_VAR(grub_term_inputs); -static inline void -grub_term_register_input_active (const char *name __attribute__ ((unused)), - grub_term_input_t term) -{ - if (term->init) - term->init (); - grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term)); -} - static inline void grub_term_register_input (const char *name __attribute__ ((unused)), grub_term_input_t term) { - grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled), - GRUB_AS_LIST (term)); -} - -static inline void -grub_term_register_output_active (const char *name __attribute__ ((unused)), - grub_term_output_t term) -{ - if (term->init) - term->init (); - grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs), GRUB_AS_LIST (term)); + if (grub_term_inputs) + grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled), + GRUB_AS_LIST (term)); + else + { + /* If this is the first terminal, enable automatically. */ + if (term->init) + term->init (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term)); + } } static inline void grub_term_register_output (const char *name __attribute__ ((unused)), grub_term_output_t term) { - grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled), - GRUB_AS_LIST (term)); + if (grub_term_outputs) + grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled), + GRUB_AS_LIST (term)); + else + { + /* If this is the first terminal, enable automatically. */ + if (term->init) + term->init (); + grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs), + GRUB_AS_LIST (term)); + } } static inline void diff --git a/term/efi/console.c b/term/efi/console.c index dc07c401e..264770cae 100644 --- a/term/efi/console.c +++ b/term/efi/console.c @@ -365,8 +365,8 @@ grub_console_init (void) return; } - grub_term_register_input_active ("console", &grub_console_term_input); - grub_term_register_output_active ("console", &grub_console_term_output); + grub_term_register_input ("console", &grub_console_term_input); + grub_term_register_output ("console", &grub_console_term_output); } void diff --git a/term/gfxterm.c b/term/gfxterm.c index 2a7886aa0..fa19a5d85 100644 --- a/term/gfxterm.c +++ b/term/gfxterm.c @@ -953,11 +953,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(term_gfxterm) { -#ifdef GRUB_MACHINE_MIPS_YEELOONG - grub_term_register_output_active ("gfxterm", &grub_video_term); -#else grub_term_register_output ("gfxterm", &grub_video_term); -#endif cmd = grub_register_command ("background_image", grub_gfxterm_background_image_cmd, 0, "Load background image for active terminal."); diff --git a/term/i386/pc/at_keyboard.c b/term/i386/pc/at_keyboard.c index 594ed6787..6382c954a 100644 --- a/term/i386/pc/at_keyboard.c +++ b/term/i386/pc/at_keyboard.c @@ -278,11 +278,7 @@ static struct grub_term_input grub_at_keyboard_term = GRUB_MOD_INIT(at_keyboard) { -#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_MIPS_YEELOONG) - grub_term_register_input_active ("at_keyboard", &grub_at_keyboard_term); -#else grub_term_register_input ("at_keyboard", &grub_at_keyboard_term); -#endif } GRUB_MOD_FINI(at_keyboard) diff --git a/term/i386/pc/console.c b/term/i386/pc/console.c index 3c0fcccad..43cfe2f2a 100644 --- a/term/i386/pc/console.c +++ b/term/i386/pc/console.c @@ -71,8 +71,8 @@ static struct grub_term_output grub_console_term_output = void grub_console_init (void) { - grub_term_register_output_active ("console", &grub_console_term_output); - grub_term_register_input_active ("console", &grub_console_term_input); + grub_term_register_output ("console", &grub_console_term_output); + grub_term_register_input ("console", &grub_console_term_input); } void diff --git a/term/i386/pc/vga_text.c b/term/i386/pc/vga_text.c index 01191cef0..170f74de8 100644 --- a/term/i386/pc/vga_text.c +++ b/term/i386/pc/vga_text.c @@ -163,16 +163,12 @@ static struct grub_term_output grub_vga_text_term = .setcolorstate = grub_console_setcolorstate, .setcolor = grub_console_setcolor, .getcolor = grub_console_getcolor, - .setcursor = grub_vga_text_setcursor + .setcursor = grub_vga_text_setcursor, }; GRUB_MOD_INIT(vga_text) { -#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) - grub_term_register_output_active ("vga_text", &grub_vga_text_term); -#else grub_term_register_output ("vga_text", &grub_vga_text_term); -#endif } GRUB_MOD_FINI(vga_text) diff --git a/term/ieee1275/ofconsole.c b/term/ieee1275/ofconsole.c index 44cbb763d..3977c6286 100644 --- a/term/ieee1275/ofconsole.c +++ b/term/ieee1275/ofconsole.c @@ -420,8 +420,8 @@ static struct grub_term_output grub_ofconsole_term_output = void grub_console_init (void) { - grub_term_register_input_active ("ofconsole", &grub_ofconsole_term_input); - grub_term_register_output_active ("ofconsole", &grub_ofconsole_term_output); + grub_term_register_input ("ofconsole", &grub_ofconsole_term_input); + grub_term_register_output ("ofconsole", &grub_ofconsole_term_output); } void diff --git a/util/console.c b/util/console.c index 73195765e..382fd7f89 100644 --- a/util/console.c +++ b/util/console.c @@ -373,8 +373,8 @@ static struct grub_term_output grub_ncurses_term_output = void grub_console_init (void) { - grub_term_register_output_active ("console", &grub_ncurses_term_output); - grub_term_register_input_active ("console", &grub_ncurses_term_input); + grub_term_register_output ("console", &grub_ncurses_term_output); + grub_term_register_input ("console", &grub_ncurses_term_input); } void From cdec4d31936dae6af0db3ce99b0f4f1cda0686e2 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 10 Jan 2010 00:47:19 +0000 Subject: [PATCH 175/208] 2010-01-09 Robert Millan Fix grub-emu build. * conf/any-emu.rmk (grub_emu_SOURCES): Remove `kern/reader.c'. --- ChangeLog | 6 ++++++ conf/any-emu.rmk | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d5ca433a2..9879050bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-09 Robert Millan + + Fix grub-emu build. + + * conf/any-emu.rmk (grub_emu_SOURCES): Remove `kern/reader.c'. + 2010-01-07 Vladimir Serbinenko 2010-01-09 Robert Millan diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index bd1798946..cee9e8338 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -23,7 +23,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \ kern/err.c kern/list.c kern/handler.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/reader.c kern/term.c \ + kern/partition.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/auth.c lib/crypto.c normal/autofs.c \ From 0e60bae74e46ff8eb6f4b2745ede4e76736e2169 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 10 Jan 2010 01:10:39 +0000 Subject: [PATCH 176/208] 2010-01-10 Robert Millan Fix i386-ieee1275 build. * loader/i386/ieee1275/linux.c (grub_linux_boot): Use grub_term_width() and grub_term_height() for video_{width,height} initialization. --- ChangeLog | 9 ++++++++- loader/i386/ieee1275/linux.c | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9879050bf..f5ff60553 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,11 @@ -2010-01-09 Robert Millan +2010-01-10 Robert Millan + + Fix i386-ieee1275 build. + + * loader/i386/ieee1275/linux.c (grub_linux_boot): Use grub_term_width() + and grub_term_height() for video_{width,height} initialization. + +2010-01-10 Robert Millan Fix grub-emu build. diff --git a/loader/i386/ieee1275/linux.c b/loader/i386/ieee1275/linux.c index 7d556ee00..f6352bb9f 100644 --- a/loader/i386/ieee1275/linux.c +++ b/loader/i386/ieee1275/linux.c @@ -1,7 +1,7 @@ /* linux.c - boot Linux zImage or bzImage */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -110,8 +110,8 @@ grub_linux_boot (void) params->cl_magic = GRUB_LINUX_CL_MAGIC; params->cl_offset = GRUB_OFW_LINUX_CL_OFFSET; - params->video_width = (grub_getwh () >> 8); - params->video_height = (grub_getwh () & 0xff); + params->video_width = grub_term_width (term); + params->video_height = grub_term_height (term); params->font_size = 16; params->ofw_signature = GRUB_LINUX_OFW_SIGNATURE; From f0d0c0b726d1a947b4bd50f45e42d1052633eb11 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 10 Jan 2010 01:43:42 +0000 Subject: [PATCH 177/208] 2010-01-10 Robert Millan * loader/i386/ieee1275/linux.c (grub_linux_boot): Rework video position initialization with similar approach as with other Linux loaders. --- ChangeLog | 5 +++++ loader/i386/ieee1275/linux.c | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f5ff60553..5f141d6a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-10 Robert Millan + + * loader/i386/ieee1275/linux.c (grub_linux_boot): Rework video position + initialization with similar approach as with other Linux loaders. + 2010-01-10 Robert Millan Fix i386-ieee1275 build. diff --git a/loader/i386/ieee1275/linux.c b/loader/i386/ieee1275/linux.c index f6352bb9f..8780804fd 100644 --- a/loader/i386/ieee1275/linux.c +++ b/loader/i386/ieee1275/linux.c @@ -110,8 +110,29 @@ grub_linux_boot (void) params->cl_magic = GRUB_LINUX_CL_MAGIC; params->cl_offset = GRUB_OFW_LINUX_CL_OFFSET; - params->video_width = grub_term_width (term); - params->video_height = grub_term_height (term); + { + grub_term_output_t term; + int found = 0; + FOR_ACTIVE_TERM_OUTPUTS(term) + if (grub_strcmp (term->name, "ofconsole") == 0) + { + grub_uint16_t pos = grub_term_getxy (term); + params->video_cursor_x = pos >> 8; + params->video_cursor_y = pos & 0xff; + params->video_width = grub_term_width (term); + params->video_height = grub_term_height (term); + found = 1; + break; + } + if (!found) + { + params->video_cursor_x = 0; + params->video_cursor_y = 0; + params->video_width = 80; + params->video_height = 25; + } + } + params->font_size = 16; params->ofw_signature = GRUB_LINUX_OFW_SIGNATURE; From cd0514794a7948f5166c26cf7383f430e6a04b6a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 10 Jan 2010 18:58:18 +0100 Subject: [PATCH 178/208] MAnipulate mbi in abstract way --- ChangeLog.abstractmbi | 25 +++ conf/i386-coreboot.rmk | 6 +- conf/i386-pc.rmk | 4 +- include/grub/multiboot.h | 13 ++ loader/i386/multiboot.c | 320 +++++++------------------------- loader/i386/multiboot_elfxx.c | 5 +- loader/i386/multiboot_mbi.c | 336 ++++++++++++++++++++++++++++++++++ 7 files changed, 453 insertions(+), 256 deletions(-) create mode 100644 ChangeLog.abstractmbi create mode 100644 loader/i386/multiboot_mbi.c diff --git a/ChangeLog.abstractmbi b/ChangeLog.abstractmbi new file mode 100644 index 000000000..a5ff55b08 --- /dev/null +++ b/ChangeLog.abstractmbi @@ -0,0 +1,25 @@ +2010-01-10 Vladimir Serbinenko + + * conf/i386-coreboot.rmk (multiboot_mod_SOURCES): + Add loader/i386/multiboot_mbi.c. + (multiboot2_mod_SOURCES): Likewise. + * conf/i386-pc.rmk (multiboot_mod_SOURCES): Likewise. + (multiboot2_mod_SOURCES): Likewise. + * include/grub/multiboot.h (grub_multiboot_get_mbi_size): New proto. + (grub_multiboot_make_mbi): Likewise. + (grub_multiboot_free_mbi): Likewise. + (grub_multiboot_init_mbi): Likewise. + (grub_multiboot_add_module): Likewise. + (grub_multiboot_set_bootdev): Likewise. + * loader/i386/multiboot.c (mbi): Removed. + (mbi_dest): Likewise. + (alloc_mbi): New variable. + (grub_multiboot_payload_size): Removed. All users updated. + (grub_multiboot_pure_size): New variable. + (grub_multiboot_boot): Use grub_multiboot_make_mbi. + (grub_multiboot_unload): Use grub_multiboot_free_mbi. + (grub_get_multiboot_mmap_len): Moved to loader/i386/multiboot_mbi.c. + (grub_fill_multiboot_mmap): Likewise. + (grub_multiboot_get_bootdev): Likewise. + (grub_multiboot): Use multiboot_mbi functions. + * loader/i386/multiboot_mbi.c: New file. diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index 95ee79436..d73c9f0e2 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -142,14 +142,16 @@ serial_mod_LDFLAGS = $(COMMON_LDFLAGS) pkglib_MODULES += multiboot.mod multiboot_mod_SOURCES = loader/i386/multiboot.c \ - loader/multiboot_loader.c + loader/i386/multiboot_mbi.c \ + loader/multiboot_loader.c multiboot_mod_CFLAGS = $(COMMON_CFLAGS) multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS) pkglib_MODULES += multiboot2.mod multiboot2_mod_SOURCES = loader/i386/multiboot.c \ - loader/multiboot_loader.c + loader/multiboot_loader.c \ + loader/i386/multiboot_mbi.c multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2 multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS) multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS) diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 4215f0a34..2a69571aa 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -203,6 +203,7 @@ serial_mod_LDFLAGS = $(COMMON_LDFLAGS) pkglib_MODULES += multiboot.mod multiboot_mod_SOURCES = loader/i386/multiboot.c \ + loader/i386/multiboot_mbi.c \ loader/multiboot_loader.c multiboot_mod_CFLAGS = $(COMMON_CFLAGS) multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) @@ -210,7 +211,8 @@ multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS) pkglib_MODULES += multiboot2.mod multiboot2_mod_SOURCES = loader/i386/multiboot.c \ - loader/multiboot_loader.c + loader/i386/multiboot_mbi.c \ + loader/multiboot_loader.c multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2 multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS) multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS) diff --git a/include/grub/multiboot.h b/include/grub/multiboot.h index 041ee1f18..f9edb0c59 100644 --- a/include/grub/multiboot.h +++ b/include/grub/multiboot.h @@ -29,7 +29,20 @@ #include #endif +#include +#include + void grub_multiboot (int argc, char *argv[]); void grub_module (int argc, char *argv[]); +grub_size_t grub_multiboot_get_mbi_size (void); +grub_err_t grub_multiboot_make_mbi (void *orig, grub_uint32_t dest, + grub_off_t buf_off, grub_size_t bufsize); +void grub_multiboot_free_mbi (void); +grub_err_t grub_multiboot_init_mbi (int argc, char *argv[]); +grub_err_t grub_multiboot_add_module (grub_addr_t start, grub_size_t size, + int argc, char *argv[]); +void grub_multiboot_set_bootdev (void); + + #endif /* ! GRUB_MULTIBOOT_HEADER */ diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index f4869594e..2a69327b4 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -45,31 +45,24 @@ #include #include #include -#ifdef GRUB_MACHINE_PCBIOS -#include -#include -#include -#include -#endif #include extern grub_dl_t my_mod; -static struct multiboot_info *mbi, *mbi_dest; - -static grub_size_t code_size; +static grub_size_t code_size, alloc_mbi; char *grub_multiboot_payload_orig; grub_addr_t grub_multiboot_payload_dest; -grub_size_t grub_multiboot_payload_size; +grub_size_t grub_multiboot_pure_size; grub_uint32_t grub_multiboot_payload_eip; static grub_err_t grub_multiboot_boot (void) { + grub_size_t mbi_size; + grub_err_t err; struct grub_relocator32_state state = { .eax = MULTIBOOT_BOOTLOADER_MAGIC, - .ebx = PTR_TO_UINT32 (mbi_dest), .ecx = 0, .edx = 0, .eip = grub_multiboot_payload_eip, @@ -78,6 +71,24 @@ grub_multiboot_boot (void) .esp = 0x7ff00 }; + mbi_size = grub_multiboot_get_mbi_size (); + if (alloc_mbi < mbi_size) + { + grub_multiboot_payload_orig + = grub_relocator32_realloc (grub_multiboot_payload_orig, + grub_multiboot_pure_size + mbi_size); + if (!grub_multiboot_payload_orig) + return grub_errno; + alloc_mbi = mbi_size; + } + + state.ebx = grub_multiboot_payload_dest + grub_multiboot_pure_size; + err = grub_multiboot_make_mbi (grub_multiboot_payload_orig, + grub_multiboot_payload_dest, + grub_multiboot_pure_size, mbi_size); + if (err) + return err; + grub_relocator32_boot (grub_multiboot_payload_orig, grub_multiboot_payload_dest, state); @@ -89,69 +100,18 @@ grub_multiboot_boot (void) static grub_err_t grub_multiboot_unload (void) { - if (mbi) - { - unsigned int i; - for (i = 0; i < mbi->mods_count; i++) - { - grub_free ((void *) - ((struct multiboot_mod_list *) mbi->mods_addr)[i].mod_start); - grub_free ((void *) - ((struct multiboot_mod_list *) mbi->mods_addr)[i].cmdline); - } - grub_free ((void *) mbi->mods_addr); - } + grub_multiboot_free_mbi (); + grub_relocator32_free (grub_multiboot_payload_orig); - mbi = NULL; + alloc_mbi = 0; + grub_multiboot_payload_orig = NULL; grub_dl_unref (my_mod); return GRUB_ERR_NONE; } -/* Return the length of the Multiboot mmap that will be needed to allocate - our platform's map. */ -static grub_uint32_t -grub_get_multiboot_mmap_len (void) -{ - grub_size_t count = 0; - - auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t); - int NESTED_FUNC_ATTR hook (grub_uint64_t addr __attribute__ ((unused)), - grub_uint64_t size __attribute__ ((unused)), - grub_uint32_t type __attribute__ ((unused))) - { - count++; - return 0; - } - - grub_mmap_iterate (hook); - - return count * sizeof (struct multiboot_mmap_entry); -} - -/* Fill previously allocated Multiboot mmap. */ -static void -grub_fill_multiboot_mmap (struct multiboot_mmap_entry *first_entry) -{ - struct multiboot_mmap_entry *mmap_entry = (struct multiboot_mmap_entry *) first_entry; - - auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t); - int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type) - { - mmap_entry->addr = addr; - mmap_entry->len = size; - mmap_entry->type = type; - mmap_entry->size = sizeof (struct multiboot_mmap_entry) - sizeof (mmap_entry->size); - mmap_entry++; - - return 0; - } - - grub_mmap_iterate (hook); -} - #define MULTIBOOT_LOAD_ELF64 #include "multiboot_elfxx.c" #undef MULTIBOOT_LOAD_ELF64 @@ -172,58 +132,13 @@ grub_multiboot_load_elf (grub_file_t file, void *buffer) return grub_error (GRUB_ERR_UNKNOWN_OS, "unknown ELF class"); } -static int -grub_multiboot_get_bootdev (grub_uint32_t *bootdev) -{ -#ifdef GRUB_MACHINE_PCBIOS - char *p; - grub_uint32_t biosdev, slice = ~0, part = ~0; - grub_device_t dev; - - biosdev = grub_get_root_biosnumber (); - - dev = grub_device_open (0); - if (dev && dev->disk && dev->disk->partition) - { - - p = dev->disk->partition->partmap->get_name (dev->disk->partition); - if (p) - { - if ((p[0] >= '0') && (p[0] <= '9')) - { - slice = grub_strtoul (p, &p, 0) - 1; - - if ((p) && (p[0] == ',')) - p++; - } - - if ((p[0] >= 'a') && (p[0] <= 'z')) - part = p[0] - 'a'; - } - } - if (dev) - grub_device_close (dev); - - *bootdev = ((biosdev & 0xff) << 24) | ((slice & 0xff) << 16) - | ((part & 0xff) << 8) | 0xff; - return (biosdev != ~0UL); -#else - *bootdev = 0xffffffff; - return 0; -#endif -} - void grub_multiboot (int argc, char *argv[]) { grub_file_t file = 0; - char buffer[MULTIBOOT_SEARCH], *cmdline = 0, *p; + char buffer[MULTIBOOT_SEARCH]; struct multiboot_header *header; - grub_ssize_t len, cmdline_length, boot_loader_name_length; - grub_uint32_t mmap_length; - int i; - int cmdline_argc; - char **cmdline_argv; + grub_ssize_t len; grub_loader_unset (); @@ -274,31 +189,8 @@ grub_multiboot (int argc, char *argv[]) grub_relocator32_free (grub_multiboot_payload_orig); grub_multiboot_payload_orig = NULL; - mmap_length = grub_get_multiboot_mmap_len (); - - /* Figure out cmdline length. */ /* Skip filename. */ - cmdline_argc = argc - 1; - cmdline_argv = argv + 1; - - for (i = 0, cmdline_length = 0; i < cmdline_argc; i++) - cmdline_length += grub_strlen (cmdline_argv[i]) + 1; - - if (cmdline_length == 0) - cmdline_length = 1; - - boot_loader_name_length = sizeof(PACKAGE_STRING); - -#define cmdline_addr(x) ((void *) ((x) + code_size)) -#define boot_loader_name_addr(x) \ - ((void *) ((x) + code_size + cmdline_length)) -#define mbi_addr(x) ((void *) ((x) + code_size + cmdline_length + boot_loader_name_length)) -#define mmap_addr(x) ((void *) ((x) + code_size + cmdline_length + boot_loader_name_length + sizeof (struct multiboot_info))) - - grub_multiboot_payload_size = cmdline_length - /* boot_loader_name_length might need to grow for mbi,etc to be aligned (see below) */ - + boot_loader_name_length + 3 - + sizeof (struct multiboot_info) + mmap_length; + grub_multiboot_init_mbi (argc - 1, argv + 1); if (header->flags & MULTIBOOT_AOUT_KLUDGE) { @@ -313,10 +205,12 @@ grub_multiboot (int argc, char *argv[]) code_size = load_size; grub_multiboot_payload_dest = header->load_addr; - grub_multiboot_payload_size += code_size; + grub_multiboot_pure_size += code_size; + /* Allocate a bit more to avoid relocations in most cases. */ + alloc_mbi = grub_multiboot_get_mbi_size () + 65536; grub_multiboot_payload_orig - = grub_relocator32_alloc (grub_multiboot_payload_size); + = grub_relocator32_alloc (grub_multiboot_pure_size + alloc_mbi); if (! grub_multiboot_payload_orig) goto fail; @@ -338,53 +232,35 @@ grub_multiboot (int argc, char *argv[]) else if (grub_multiboot_load_elf (file, buffer) != GRUB_ERR_NONE) goto fail; - /* This provides alignment for the MBI, the memory map and the backward relocator. */ - boot_loader_name_length += (0x04 - ((unsigned long) mbi_addr (grub_multiboot_payload_dest) & 0x03)); - - mbi = mbi_addr (grub_multiboot_payload_orig); - mbi_dest = mbi_addr (grub_multiboot_payload_dest); - grub_memset (mbi, 0, sizeof (struct multiboot_info)); - mbi->mmap_length = mmap_length; - - grub_fill_multiboot_mmap (mmap_addr (grub_multiboot_payload_orig)); - - /* FIXME: grub_uint32_t will break for addresses above 4 GiB, but is mandated - by the spec. Is there something we can do about it? */ - mbi->mmap_addr = (grub_uint32_t) mmap_addr (grub_multiboot_payload_dest); - mbi->flags |= MULTIBOOT_INFO_MEM_MAP; - - /* Convert from bytes to kilobytes. */ - mbi->mem_lower = grub_mmap_get_lower () / 1024; - mbi->mem_upper = grub_mmap_get_upper () / 1024; - mbi->flags |= MULTIBOOT_INFO_MEMORY; - - cmdline = p = cmdline_addr (grub_multiboot_payload_orig); - if (! cmdline) - goto fail; - - for (i = 0; i < cmdline_argc; i++) + if (header->flags & MULTIBOOT_VIDEO_MODE) { - p = grub_stpcpy (p, cmdline_argv[i]); - *(p++) = ' '; + switch (header->mode_type) + { + case 1: + grub_env_set ("gfxpayload", "text"); + break; + + case 0: + { + char buf[sizeof ("XXXXXXXXXXxXXXXXXXXXXxXXXXXXXXXX,XXXXXXXXXXxXXXXXXXXXX,auto")]; + if (header->depth && header->width && header->height) + grub_sprintf (buf, "%dx%dx%d,%dx%d,auto", header->width, + header->height, header->depth, header->width, + header->height); + else if (header->width && header->height) + grub_sprintf (buf, "%dx%d,auto", header->width, header->height); + else + grub_sprintf (buf, "auto"); + + grub_env_set ("gfxpayload", buf); + break; + } + } } - /* Remove the space after the last word. */ - if (p != cmdline) - p--; - *p = 0; + grub_multiboot_set_bootdev (); - mbi->flags |= MULTIBOOT_INFO_CMDLINE; - mbi->cmdline = (grub_uint32_t) cmdline_addr (grub_multiboot_payload_dest); - - - grub_strcpy (boot_loader_name_addr (grub_multiboot_payload_orig), PACKAGE_STRING); - mbi->flags |= MULTIBOOT_INFO_BOOT_LOADER_NAME; - mbi->boot_loader_name = (grub_uint32_t) boot_loader_name_addr (grub_multiboot_payload_dest); - - if (grub_multiboot_get_bootdev (&mbi->boot_device)) - mbi->flags |= MULTIBOOT_INFO_BOOTDEV; - - grub_loader_set (grub_multiboot_boot, grub_multiboot_unload, 1); + grub_loader_set (grub_multiboot_boot, grub_multiboot_unload, 0); fail: if (file) @@ -392,22 +268,18 @@ grub_multiboot (int argc, char *argv[]) if (grub_errno != GRUB_ERR_NONE) { - grub_free (cmdline); - grub_free (mbi); + grub_relocator32_free (grub_multiboot_payload_orig); grub_dl_unref (my_mod); } } - void grub_module (int argc, char *argv[]) { grub_file_t file = 0; - grub_ssize_t size, len = 0; - char *module = 0, *cmdline = 0, *p; - int i; - int cmdline_argc; - char **cmdline_argv; + grub_ssize_t size; + char *module = 0; + grub_err_t err; if (argc == 0) { @@ -415,7 +287,7 @@ grub_module (int argc, char *argv[]) goto fail; } - if (!mbi) + if (!grub_multiboot_payload_orig) { grub_error (GRUB_ERR_BAD_ARGUMENT, "you need to load the multiboot kernel first"); @@ -431,73 +303,19 @@ grub_module (int argc, char *argv[]) if (! module) goto fail; + err = grub_multiboot_add_module ((grub_addr_t) module, size, + argc - 1, argv + 1); + if (err) + goto fail; + if (grub_file_read (file, module, size) != size) { grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file"); goto fail; } - /* Skip module name. */ - cmdline_argc = argc - 1; - cmdline_argv = argv + 1; - - for (i = 0; i < cmdline_argc; i++) - len += grub_strlen (cmdline_argv[i]) + 1; - - if (len == 0) - len = 1; - - cmdline = p = grub_malloc (len); - if (! cmdline) - goto fail; - - for (i = 0; i < cmdline_argc; i++) - { - p = grub_stpcpy (p, cmdline_argv[i]); - *(p++) = ' '; - } - - /* Remove the space after the last word. */ - if (p != cmdline) - p--; - *p = '\0'; - - if (mbi->flags & MULTIBOOT_INFO_MODS) - { - struct multiboot_mod_list *modlist = (struct multiboot_mod_list *) mbi->mods_addr; - - modlist = grub_realloc (modlist, (mbi->mods_count + 1) - * sizeof (struct multiboot_mod_list)); - if (! modlist) - goto fail; - mbi->mods_addr = (grub_uint32_t) modlist; - modlist += mbi->mods_count; - modlist->mod_start = (grub_uint32_t) module; - modlist->mod_end = (grub_uint32_t) module + size; - modlist->cmdline = (grub_uint32_t) cmdline; - modlist->pad = 0; - mbi->mods_count++; - } - else - { - struct multiboot_mod_list *modlist = grub_zalloc (sizeof (struct multiboot_mod_list)); - if (! modlist) - goto fail; - modlist->mod_start = (grub_uint32_t) module; - modlist->mod_end = (grub_uint32_t) module + size; - modlist->cmdline = (grub_uint32_t) cmdline; - mbi->mods_count = 1; - mbi->mods_addr = (grub_uint32_t) modlist; - mbi->flags |= MULTIBOOT_INFO_MODS; - } - fail: if (file) grub_file_close (file); - - if (grub_errno != GRUB_ERR_NONE) - { - grub_free (module); - grub_free (cmdline); - } } + diff --git a/loader/i386/multiboot_elfxx.c b/loader/i386/multiboot_elfxx.c index 80db25144..8f6367432 100644 --- a/loader/i386/multiboot_elfxx.c +++ b/loader/i386/multiboot_elfxx.c @@ -100,10 +100,11 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, void *buffer) code_size = (phdr(highest_segment)->p_paddr + phdr(highest_segment)->p_memsz) - phdr(lowest_segment)->p_paddr; grub_multiboot_payload_dest = phdr(lowest_segment)->p_paddr; - grub_multiboot_payload_size += code_size; + grub_multiboot_pure_size += code_size; + alloc_mbi = grub_multiboot_get_mbi_size (); grub_multiboot_payload_orig - = grub_relocator32_alloc (grub_multiboot_payload_size); + = grub_relocator32_alloc (grub_multiboot_pure_size + alloc_mbi); if (!grub_multiboot_payload_orig) return grub_errno; diff --git a/loader/i386/multiboot_mbi.c b/loader/i386/multiboot_mbi.c new file mode 100644 index 000000000..58802d44c --- /dev/null +++ b/loader/i386/multiboot_mbi.c @@ -0,0 +1,336 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,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 + * 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 +#ifdef GRUB_MACHINE_PCBIOS +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +struct module +{ + struct module *next; + grub_addr_t start; + grub_size_t size; + char *cmdline; + int cmdline_size; +}; + +struct module *modules, *modules_last; +static grub_size_t cmdline_size; +static grub_size_t total_modcmd; +static unsigned modcnt; +static char *cmdline = NULL; +static grub_uint32_t bootdev; +static int bootdev_set; + +/* Return the length of the Multiboot mmap that will be needed to allocate + our platform's map. */ +static grub_uint32_t +grub_get_multiboot_mmap_len (void) +{ + grub_size_t count = 0; + + auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t); + int NESTED_FUNC_ATTR hook (grub_uint64_t addr __attribute__ ((unused)), + grub_uint64_t size __attribute__ ((unused)), + grub_uint32_t type __attribute__ ((unused))) + { + count++; + return 0; + } + + grub_mmap_iterate (hook); + + return count * sizeof (struct multiboot_mmap_entry); +} + +grub_size_t +grub_multiboot_get_mbi_size (void) +{ + return sizeof (struct multiboot_info) + ALIGN_UP (cmdline_size, 4) + + modcnt * sizeof (struct multiboot_mod_list) + total_modcmd + + ALIGN_UP (sizeof(PACKAGE_STRING), 4) + grub_get_multiboot_mmap_len (); +} + +/* Fill previously allocated Multiboot mmap. */ +static void +grub_fill_multiboot_mmap (struct multiboot_mmap_entry *first_entry) +{ + struct multiboot_mmap_entry *mmap_entry = (struct multiboot_mmap_entry *) first_entry; + + auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t); + int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type) + { + mmap_entry->addr = addr; + mmap_entry->len = size; + switch (type) + { + case GRUB_MACHINE_MEMORY_AVAILABLE: + mmap_entry->type = MULTIBOOT_MEMORY_AVAILABLE; + break; + + default: + mmap_entry->type = MULTIBOOT_MEMORY_RESERVED; + break; + } + mmap_entry->size = sizeof (struct multiboot_mmap_entry) - sizeof (mmap_entry->size); + mmap_entry++; + + return 0; + } + + grub_mmap_iterate (hook); +} + +grub_err_t +grub_multiboot_make_mbi (void *orig, grub_uint32_t dest, grub_off_t buf_off, + grub_size_t bufsize) +{ + grub_uint8_t *ptrorig = (grub_uint8_t *) orig + buf_off; + grub_uint32_t ptrdest = dest + buf_off; + struct multiboot_info *mbi; + struct multiboot_mod_list *modlist; + unsigned i; + struct module *cur; + grub_size_t mmap_size; + + if (bufsize < grub_multiboot_get_mbi_size ()) + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "mbi buffer is too small"); + + mbi = (struct multiboot_info *) ptrorig; + ptrorig += sizeof (*mbi); + ptrdest += sizeof (*mbi); + grub_memset (mbi, 0, sizeof (*mbi)); + + grub_memcpy (ptrorig, cmdline, cmdline_size); + mbi->flags |= MULTIBOOT_INFO_CMDLINE; + mbi->cmdline = ptrdest; + ptrorig += ALIGN_UP (cmdline_size, 4); + ptrdest += ALIGN_UP (cmdline_size, 4); + + grub_memcpy (ptrorig, PACKAGE_STRING, sizeof(PACKAGE_STRING)); + mbi->flags |= MULTIBOOT_INFO_BOOT_LOADER_NAME; + mbi->boot_loader_name = ptrdest; + ptrorig += ALIGN_UP (sizeof(PACKAGE_STRING), 4); + ptrdest += ALIGN_UP (sizeof(PACKAGE_STRING), 4); + + if (modcnt) + { + mbi->flags |= MULTIBOOT_INFO_MODS; + mbi->mods_addr = ptrdest; + mbi->mods_count = modcnt; + modlist = (struct multiboot_mod_list *) ptrorig; + ptrorig += modcnt * sizeof (struct multiboot_mod_list); + ptrdest += modcnt * sizeof (struct multiboot_mod_list); + + for (i = 0, cur = modules; i < modcnt; i++, cur = cur->next) + { + modlist[i].mod_start = cur->start; + modlist[i].mod_end = modlist[i].mod_start + cur->size; + modlist[i].cmdline = ptrdest; + grub_memcpy (ptrorig, cur->cmdline, cur->cmdline_size); + ptrorig += ALIGN_UP (cur->cmdline_size, 4); + ptrdest += ALIGN_UP (cur->cmdline_size, 4); + } + } + else + { + mbi->mods_addr = 0; + mbi->mods_count = 0; + } + + mmap_size = grub_get_multiboot_mmap_len (); + grub_fill_multiboot_mmap ((struct multiboot_mmap_entry *) ptrorig); + mbi->mmap_length = mmap_size; + mbi->mmap_addr = ptrdest; + mbi->flags |= MULTIBOOT_INFO_MEM_MAP; + ptrorig += mmap_size; + ptrdest += mmap_size; + + /* Convert from bytes to kilobytes. */ + mbi->mem_lower = grub_mmap_get_lower () / 1024; + mbi->mem_upper = grub_mmap_get_upper () / 1024; + mbi->flags |= MULTIBOOT_INFO_MEMORY; + + if (bootdev_set) + { + mbi->boot_device = bootdev; + mbi->flags |= MULTIBOOT_INFO_BOOTDEV; + } + + return GRUB_ERR_NONE; +} + +void +grub_multiboot_free_mbi (void) +{ + struct module *cur, *next; + + cmdline_size = 0; + total_modcmd = 0; + modcnt = 0; + grub_free (cmdline); + cmdline = NULL; + bootdev_set = 0; + + for (cur = modules; cur; cur = next) + { + next = cur->next; + grub_free (cur->cmdline); + grub_free (cur); + } + modules = NULL; + modules_last = NULL; +} + +grub_err_t +grub_multiboot_init_mbi (int argc, char *argv[]) +{ + grub_ssize_t len = 0; + char *p; + int i; + + grub_multiboot_free_mbi (); + + for (i = 0; i < argc; i++) + len += grub_strlen (argv[i]) + 1; + if (len == 0) + len = 1; + + cmdline = p = grub_malloc (len); + if (! cmdline) + return grub_errno; + cmdline_size = len; + + for (i = 0; i < argc; i++) + { + p = grub_stpcpy (p, argv[i]); + *(p++) = ' '; + } + + /* Remove the space after the last word. */ + if (p != cmdline) + p--; + *p = '\0'; + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_multiboot_add_module (grub_addr_t start, grub_size_t size, + int argc, char *argv[]) +{ + struct module *newmod; + char *p; + grub_ssize_t len = 0; + int i; + + newmod = grub_malloc (sizeof (*newmod)); + if (!newmod) + return grub_errno; + newmod->start = start; + newmod->size = size; + + for (i = 0; i < argc; i++) + len += grub_strlen (argv[i]) + 1; + + if (len == 0) + len = 1; + + newmod->cmdline = p = grub_malloc (len); + if (! newmod->cmdline) + { + grub_free (newmod); + return grub_errno; + } + newmod->cmdline_size = len; + total_modcmd += ALIGN_UP (len, 4); + + for (i = 0; i < argc; i++) + { + p = grub_stpcpy (p, argv[i]); + *(p++) = ' '; + } + + /* Remove the space after the last word. */ + if (p != newmod->cmdline) + p--; + *p = '\0'; + + if (modules_last) + modules_last->next = newmod; + else + { + modules = newmod; + modules_last->next = NULL; + } + modules_last = newmod; + + modcnt++; + + return GRUB_ERR_NONE; +} + +void +grub_multiboot_set_bootdev (void) +{ + char *p; + grub_uint32_t biosdev, slice = ~0, part = ~0; + grub_device_t dev; + +#ifdef GRUB_MACHINE_PCBIOS + biosdev = grub_get_root_biosnumber (); +#else + biosdev = 0xffffffff; +#endif + + dev = grub_device_open (0); + if (dev && dev->disk && dev->disk->partition) + { + + p = dev->disk->partition->partmap->get_name (dev->disk->partition); + if (p) + { + if ((p[0] >= '0') && (p[0] <= '9')) + { + slice = grub_strtoul (p, &p, 0) - 1; + + if ((p) && (p[0] == ',')) + p++; + } + + if ((p[0] >= 'a') && (p[0] <= 'z')) + part = p[0] - 'a'; + } + } + if (dev) + grub_device_close (dev); + + bootdev = ((biosdev & 0xff) << 24) | ((slice & 0xff) << 16) + | ((part & 0xff) << 8) | 0xff; + bootdev_set = 1; +} From e9060a9d3b1509656241f9128480250ad6824543 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 10 Jan 2010 22:34:25 +0100 Subject: [PATCH 179/208] 2010-01-10 Vladimir Serbinenko * normal/cmdline.c (grub_cmdline_get): Fix off-by-one error which resulted in garbled command line at the end of screen. --- ChangeLog | 5 +++++ normal/cmdline.c | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f141d6a5..65da2542d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-10 Vladimir Serbinenko + + * normal/cmdline.c (grub_cmdline_get): Fix off-by-one error + which resulted in garbled command line at the end of screen. + 2010-01-10 Robert Millan * loader/i386/ieee1275/linux.c (grub_linux_boot): Rework video position diff --git a/normal/cmdline.c b/normal/cmdline.c index 656b14c6a..429c84be7 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -254,21 +254,20 @@ grub_cmdline_get (const char *prompt) for (p = buf + pos; p < buf + llen; p++) { - if (cl_term->xpos++ > cl_term->width - 2) - { - grub_putcode ('\n', cl_term->term); - - cl_term->xpos = 1; - if (cl_term->ypos == (unsigned) (cl_term->height)) - cl_term->ystart--; - else - cl_term->ypos++; - } - if (c) grub_putcode (c, cl_term->term); else grub_putcode (*p, cl_term->term); + cl_term->xpos++; + if (cl_term->xpos >= cl_term->width - 1) + { + cl_term->xpos = 0; + if (cl_term->ypos >= (unsigned) (cl_term->height - 1)) + cl_term->ystart--; + else + cl_term->ypos++; + grub_putcode ('\n', cl_term->term); + } } } From ffa8e3d2775628355960eefa2d4433d15b13d5d8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 10 Jan 2010 22:35:46 +0100 Subject: [PATCH 180/208] 2010-01-10 Vladimir Serbinenko * term/i386/pc/vga_text.c (inc_y): Fix off-by-one error which resulted in premature implicit newline. --- ChangeLog | 5 +++++ term/i386/pc/vga_text.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 65da2542d..321baa439 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-10 Vladimir Serbinenko + + * term/i386/pc/vga_text.c (inc_y): Fix off-by-one error which resulted + in premature implicit newline. + 2010-01-10 Vladimir Serbinenko * normal/cmdline.c (grub_cmdline_get): Fix off-by-one error diff --git a/term/i386/pc/vga_text.c b/term/i386/pc/vga_text.c index 170f74de8..f954cab43 100644 --- a/term/i386/pc/vga_text.c +++ b/term/i386/pc/vga_text.c @@ -77,7 +77,7 @@ inc_y (void) static void inc_x (void) { - if (grub_curr_x >= COLS - 2) + if (grub_curr_x >= COLS - 1) inc_y (); else grub_curr_x++; From a788afb626011e4fbf98d929a818735e9d2bdf1c Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 11 Jan 2010 12:00:57 +0000 Subject: [PATCH 181/208] 2010-01-11 Colin Watson * util/grub-install.in (usage): Clarify meaning of --root-directory, and make it clearer that it's optional. Based on confusion witnessed on IRC. --- ChangeLog | 6 ++++++ util/grub-install.in | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 321baa439..42343a8b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-11 Colin Watson + + * util/grub-install.in (usage): Clarify meaning of --root-directory, + and make it clearer that it's optional. Based on confusion + witnessed on IRC. + 2010-01-10 Vladimir Serbinenko * term/i386/pc/vga_text.c (inc_y): Fix off-by-one error which resulted diff --git a/util/grub-install.in b/util/grub-install.in index 1fcfb1aca..f3fd88188 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -87,9 +87,11 @@ fi INSTALL_DEVICE can be a GRUB device name or a system device filename. -grub-install copies GRUB images into the DIR/boot directory specified by ---root-directory, and uses grub-setup to install grub into the boot -sector. +grub-install copies GRUB images into /boot/grub (or /grub on NetBSD and +OpenBSD), and uses grub-setup to install grub into the boot sector. + +If the --root-directory option is used, then grub-install will copy +images into the operating system installation rooted at that directory. Report bugs to . EOF From 92ab12b09225525d1e3ebd4deb9201f21cab82e8 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 11 Jan 2010 14:55:20 +0000 Subject: [PATCH 182/208] 2010-01-11 Robert Millan * util/misc.c (canonicalize_file_name): New function. (make_system_path_relative_to_its_root): Use canonicalize_file_name() instead of realpath(). --- ChangeLog | 6 ++++++ util/misc.c | 23 ++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42343a8b6..768a65944 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-11 Robert Millan + + * util/misc.c (canonicalize_file_name): New function. + (make_system_path_relative_to_its_root): Use canonicalize_file_name() + instead of realpath(). + 2010-01-11 Colin Watson * util/grub-install.in (usage): Clarify meaning of --root-directory, diff --git a/util/misc.c b/util/misc.c index d8aa041be..47dd8c78d 100644 --- a/util/misc.c +++ b/util/misc.c @@ -479,6 +479,19 @@ fail: #endif /* __MINGW32__ */ +char * +canonicalize_file_name (const char *path) +{ + char *ret; +#ifdef PATH_MAX + ret = xmalloc (PATH_MAX); + (void) realpath (path, ret); +#else + ret = realpath (path, NULL); +#endif + return ret; +} + /* This function never prints trailing slashes (so that its output can be appended a slash unconditionally). */ char * @@ -491,15 +504,11 @@ make_system_path_relative_to_its_root (const char *path) size_t len; /* canonicalize. */ - p = realpath (path, NULL); + p = canonicalize_file_name (path); if (p == NULL) - { - if (errno != EINVAL) - grub_util_error ("failed to get realpath of %s", path); - else - grub_util_error ("realpath not supporting (path, NULL)"); - } + grub_util_error ("failed to get canonical path of %s", path); + len = strlen (p) + 1; buf = strdup (p); free (p); From afdc9ad0065bfa84b2d9a981c038a89aaba67f14 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 12 Jan 2010 09:00:55 +0530 Subject: [PATCH 183/208] fixed an error message --- ChangeLog.unit-testing-framework | 4 ++++ tests/util/grub-shell-tester.in | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog.unit-testing-framework b/ChangeLog.unit-testing-framework index a451108c4..5fd7a2f28 100644 --- a/ChangeLog.unit-testing-framework +++ b/ChangeLog.unit-testing-framework @@ -1,3 +1,7 @@ +2010-01-12 BVK Chaitanya + + * tests/util/grub-shell-tester.in: Fix error message. + 2010-01-08 BVK Chaitanya Unit testing framework for GRUB. diff --git a/tests/util/grub-shell-tester.in b/tests/util/grub-shell-tester.in index 18f5e79b7..6ed4ebcac 100644 --- a/tests/util/grub-shell-tester.in +++ b/tests/util/grub-shell-tester.in @@ -98,7 +98,7 @@ bash ${source} >${outfile2} if ! diff -q ${outfile1} ${outfile2} >/dev/null then - echo "$1: GRUB and BASH outputs (${outfile1}, ${outfile2}) did not match" + echo "${source}: GRUB and BASH outputs did not match (see diff -u ${outfile1} ${outfile2})" status=1 else rm -f ${outfile1} ${outfile2} From 350285caaefc8384ca73263fe42f89f66ec28779 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 12 Jan 2010 09:23:24 +0530 Subject: [PATCH 184/208] removed unnecessary EXPORT_* macro usage --- ChangeLog.unit-testing-framework | 2 ++ include/grub/test.h | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ChangeLog.unit-testing-framework b/ChangeLog.unit-testing-framework index 5fd7a2f28..973a7c756 100644 --- a/ChangeLog.unit-testing-framework +++ b/ChangeLog.unit-testing-framework @@ -1,5 +1,7 @@ 2010-01-12 BVK Chaitanya + * include/grub/test.h: Removed EXPORT_* usage. + * tests/util/grub-shell-tester.in: Fix error message. 2010-01-08 BVK Chaitanya diff --git a/include/grub/test.h b/include/grub/test.h index b4851bbf6..bd5b7d806 100644 --- a/include/grub/test.h +++ b/include/grub/test.h @@ -20,11 +20,10 @@ struct grub_test }; typedef struct grub_test *grub_test_t; -extern grub_test_t EXPORT_VAR (grub_test_list); +extern grub_test_t grub_test_list; -void EXPORT_FUNC (grub_test_register) (const char *name, void (*test) (void)); - -void EXPORT_FUNC (grub_test_unregister) (const char *name); +void grub_test_register (const char *name, void (*test) (void)); +void grub_test_unregister (const char *name); /* Execute a test and print results. */ int grub_test_run (grub_test_t test); From c5431d4029cfe61dcdd3f28a3bd6d9f22a0b80ea Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 12 Jan 2010 10:16:17 +0530 Subject: [PATCH 185/208] build tests on make, but run on make check --- ChangeLog.unit-testing-framework | 5 ++++- Makefile.in | 21 +++++++++------------ conf/tests.rmk | 31 ++++++++++++++++++------------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/ChangeLog.unit-testing-framework b/ChangeLog.unit-testing-framework index 973a7c756..620ac80cf 100644 --- a/ChangeLog.unit-testing-framework +++ b/ChangeLog.unit-testing-framework @@ -1,6 +1,9 @@ 2010-01-12 BVK Chaitanya - * include/grub/test.h: Removed EXPORT_* usage. + * conf/tests.rmk: Build tests on make. + * Makefile.in (check): Use new variables. + + * include/grub/test.h: Remove EXPORT_* usage. * tests/util/grub-shell-tester.in: Fix error message. diff --git a/Makefile.in b/Makefile.in index 567571897..45c6f3e45 100644 --- a/Makefile.in +++ b/Makefile.in @@ -460,15 +460,18 @@ distcheck: dist @echo "$(distdir).tar.gz is ready for distribution" | \ sed 'h;s/./=/g;p;x;p;x' -TESTS = $(check_UTILITIES) $(check_SCRIPTS) $(check_MODULES) -$(TESTS): $(test_framework_SCRIPTS) $(test_framework_MODULES) - -check: all $(TESTS) - @list="$(check_UTILITIES)"; \ +check: all $(UNIT_TESTS) $(FUNCTIONAL_TESTS) $(SCRIPTED_TESTS) + @list="$(UNIT_TESTS)"; \ for file in $$list; do \ $(builddir)/$$file; \ done - @list="$(check_SCRIPTS)"; \ + @list="$(FUNCTIONAL_TESTS)"; \ + for file in $$list; do \ + mod=`basename $$file .mod`; \ + echo "insmod functional_test; insmod $$mod; functional_test" \ + | $(builddir)/grub-shell; \ + done + @list="$(SCRIPTED_TESTS)"; \ for file in $$list; do \ echo "$$file:"; \ if $(builddir)/$$file; then \ @@ -477,12 +480,6 @@ check: all $(TESTS) echo "$$file: FAIL"; \ fi; \ done - @list="$(check_MODULES)"; \ - for file in $$list; do \ - mod=`basename $$file .mod`; \ - echo "insmod functional_test; insmod $$mod; functional_test" \ - | $(builddir)/grub-shell; \ - done .SUFFIX: .SUFFIX: .c .o .S .d diff --git a/conf/tests.rmk b/conf/tests.rmk index c35ea0baa..e894323ae 100644 --- a/conf/tests.rmk +++ b/conf/tests.rmk @@ -4,38 +4,43 @@ grub-shell: tests/util/grub-shell.in config.status ./config.status --file=$@:$< chmod +x $@ -test_framework_SCRIPTS += grub-shell +bin_SCRIPTS += grub-shell CLEANFILES += grub-shell # For grub-shell-tester grub-shell-tester: tests/util/grub-shell-tester.in config.status ./config.status --file=$@:$< chmod +x $@ -test_framework_SCRIPTS += grub-shell-tester +bin_SCRIPTS += grub-shell-tester CLEANFILES += grub-shell-tester -test_framework_MODULES += functional_test.mod +pkglib_MODULES += functional_test.mod functional_test_mod_SOURCES = tests/lib/functional_test.c tests/lib/test.c functional_test_mod_CFLAGS = $(COMMON_CFLAGS) functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS) -# Unit tests - -check_UTILITIES += example_unit_test +# Rules for unit tests +bin_UTILITIES += example_unit_test example_unit_test_SOURCES = tests/example_unit_test.c kern/list.c kern/misc.c tests/lib/test.c tests/lib/unit_test.c example_unit_test_CFLAGS = -Wno-format -# Functional tests - -check_MODULES += example_functional_test.mod +# Rules for functional tests +pkglib_MODULES += example_functional_test.mod example_functional_test_mod_SOURCES = tests/example_functional_test.c example_functional_test_mod_CFLAGS = -Wno-format $(COMMON_CFLAGS) example_functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS) -# Scripted tests - -check_SCRIPTS += example_scripted_test +# Rules for scripted tests +bin_SCRIPTS += example_scripted_test example_scripted_test_SOURCES = tests/example_scripted_test.in -check_SCRIPTS += example_grub_script_test +bin_SCRIPTS += example_grub_script_test example_grub_script_test_SOURCES = tests/example_grub_script_test.in + + +# List of tests to execute on "make check" + +SCRIPTED_TESTS = example_scripted_test +SCRIPTED_TESTS += example_grub_script_test +UNIT_TESTS = example_unit_test +FUNCTIONAL_TESTS = example_functional_test.mod From afafb37e9b56158454aeacc6072b368b8198e55f Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 12 Jan 2010 10:54:37 +0530 Subject: [PATCH 186/208] added boot device selection to grub-shell --- ChangeLog.unit-testing-framework | 2 ++ tests/util/grub-shell.in | 40 ++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/ChangeLog.unit-testing-framework b/ChangeLog.unit-testing-framework index 620ac80cf..8641d09ee 100644 --- a/ChangeLog.unit-testing-framework +++ b/ChangeLog.unit-testing-framework @@ -1,5 +1,7 @@ 2010-01-12 BVK Chaitanya + * tests/util/grub-shell.in: New --boot option. + * conf/tests.rmk: Build tests on make. * Makefile.in (check): Use new variables. diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index c1b2ef258..b103872ba 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -42,6 +42,7 @@ Run GRUB script in a Qemu instance. -h, --help print this message and exit -v, --version print the version information and exit + --boot=[fd|hd|cd] boot method for Qemu instance --modules=MODULES pre-load specified modules MODULES --qemu-opts=OPTIONS extra options to pass to Qemu instance @@ -67,11 +68,20 @@ for option in "$@"; do --qemu-opts=*) qs=`echo "$option" | sed -e 's/--qemu-opts=//'` qemuopts="$qemuopts $qs" ;; + --boot=*) + dev=`echo "$option" | sed -e 's/--boot=//'` + if [ "$dev" = "fd" ] ; then bootdev=a; + elif [ "$dev" = "hd" ] ; then bootdev=c; + elif [ "$dev" = "cd" ] ; then bootdev=d; + else + echo "Unrecognized boot method \`$dev'" 1>&2 + usage + exit 1 + fi ;; -*) echo "Unrecognized option \`$option'" 1>&2 usage - exit 1 - ;; + exit 1 ;; *) if [ "x${source}" != x ] ; then echo "too many parameters at the end" 1>&2 @@ -83,11 +93,15 @@ for option in "$@"; do done if [ "x${source}" = x ] ; then - tmpfile=`mktemp` - while read; do - echo $REPLY >> ${tmpfile} - done - source=${tmpfile} + tmpfile=`mktemp` + while read; do + echo $REPLY >> ${tmpfile} + done + source=${tmpfile} +fi + +if [ "x${bootdev}" = x ] ; then + bootdev=c # default is boot as disk image fi cfgfile=`mktemp` @@ -101,7 +115,7 @@ EOF for mod in ${modules} do - echo "insmod ${mod}" >> ${cfgfile} + echo "insmod ${mod}" >> ${cfgfile} done cat <>${cfgfile} @@ -114,12 +128,18 @@ grub-mkrescue --output=${isofile} --override-directory=${builddir} \ /boot/grub/grub.cfg=${cfgfile} /boot/grub/testcase.cfg=${source} \ >/dev/null 2>&1 +hdafile=`mktemp` +cp ${isofile} ${hdafile} + +fdafile=`mktemp` +cp ${isofile} ${fdafile} + outfile=`mktemp` -qemu ${qemuopts} -nographic -serial stdio -cdrom ${isofile} -boot d | tr -d "\r" >${outfile} +qemu ${qemuopts} -nographic -serial stdio -hda ${hdafile} -fda ${fdafile} -cdrom ${isofile} -boot ${bootdev} | tr -d "\r" >${outfile} cat $outfile -rm -f ${tmpfile} ${outfile} ${cfgfile} ${isofile} +rm -f ${tmpfile} ${outfile} ${cfgfile} ${isofile} ${hdafile} ${fdafile} exit 0 From 4d362fde5883655a9a0d5a56068e16d0e81bf9be Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 12 Jan 2010 15:49:40 +0530 Subject: [PATCH 187/208] build only functional tests on make --- ChangeLog.unit-testing-framework | 2 +- conf/tests.rmk | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ChangeLog.unit-testing-framework b/ChangeLog.unit-testing-framework index 8641d09ee..aa4d4fd03 100644 --- a/ChangeLog.unit-testing-framework +++ b/ChangeLog.unit-testing-framework @@ -2,7 +2,7 @@ * tests/util/grub-shell.in: New --boot option. - * conf/tests.rmk: Build tests on make. + * conf/tests.rmk: Build functional tests on make. * Makefile.in (check): Use new variables. * include/grub/test.h: Remove EXPORT_* usage. diff --git a/conf/tests.rmk b/conf/tests.rmk index e894323ae..18b23ff5a 100644 --- a/conf/tests.rmk +++ b/conf/tests.rmk @@ -4,14 +4,14 @@ grub-shell: tests/util/grub-shell.in config.status ./config.status --file=$@:$< chmod +x $@ -bin_SCRIPTS += grub-shell +check_SCRIPTS += grub-shell CLEANFILES += grub-shell # For grub-shell-tester grub-shell-tester: tests/util/grub-shell-tester.in config.status ./config.status --file=$@:$< chmod +x $@ -bin_SCRIPTS += grub-shell-tester +check_SCRIPTS += grub-shell-tester CLEANFILES += grub-shell-tester pkglib_MODULES += functional_test.mod @@ -20,7 +20,7 @@ functional_test_mod_CFLAGS = $(COMMON_CFLAGS) functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS) # Rules for unit tests -bin_UTILITIES += example_unit_test +check_UTILITIES += example_unit_test example_unit_test_SOURCES = tests/example_unit_test.c kern/list.c kern/misc.c tests/lib/test.c tests/lib/unit_test.c example_unit_test_CFLAGS = -Wno-format @@ -31,16 +31,20 @@ example_functional_test_mod_CFLAGS = -Wno-format $(COMMON_CFLAGS) example_functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS) # Rules for scripted tests -bin_SCRIPTS += example_scripted_test +check_SCRIPTS += example_scripted_test example_scripted_test_SOURCES = tests/example_scripted_test.in -bin_SCRIPTS += example_grub_script_test +check_SCRIPTS += example_grub_script_test example_grub_script_test_SOURCES = tests/example_grub_script_test.in # List of tests to execute on "make check" - SCRIPTED_TESTS = example_scripted_test SCRIPTED_TESTS += example_grub_script_test UNIT_TESTS = example_unit_test FUNCTIONAL_TESTS = example_functional_test.mod + +# dependencies between tests and testing-tools +$(SCRIPTED_TESTS): grub-shell grub-shell-tester +$(FUNCTIONAL_TESTS): functional_test.mod + From 0b8a223cb157791e7dde5e0bf40f3327e3ac537d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 12 Jan 2010 13:36:44 +0100 Subject: [PATCH 188/208] 2010-01-12 Vladimir Serbinenko MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * util/grub-mkpasswd-pbkdf2.c (main): Use grub_util_init_nls. Reported by: GrĂ©goire Sutre --- ChangeLog | 5 +++++ util/grub-mkpasswd-pbkdf2.c | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 768a65944..86deb525f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-12 Vladimir Serbinenko + + * util/grub-mkpasswd-pbkdf2.c (main): Use grub_util_init_nls. + Reported by: GrĂ©goire Sutre + 2010-01-11 Robert Millan * util/misc.c (canonicalize_file_name): New function. diff --git a/util/grub-mkpasswd-pbkdf2.c b/util/grub-mkpasswd-pbkdf2.c index 2f7c5efaa..b27a4e893 100644 --- a/util/grub-mkpasswd-pbkdf2.c +++ b/util/grub-mkpasswd-pbkdf2.c @@ -123,9 +123,8 @@ main (int argc, char *argv[]) int tty_changed; set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); + + grub_util_init_nls (); /* Check for options. */ while (1) From 10891398fd51394ace8504f83af419820e45070b Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 12 Jan 2010 17:56:05 +0100 Subject: [PATCH 189/208] 2010-01-12 Vladimir Serbinenko * loader/i386/pc/multiboot2.c: Removed stalled file. --- ChangeLog | 4 ++ loader/i386/pc/multiboot2.c | 122 ------------------------------------ 2 files changed, 4 insertions(+), 122 deletions(-) delete mode 100644 loader/i386/pc/multiboot2.c diff --git a/ChangeLog b/ChangeLog index 86deb525f..e2fd92f68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-12 Vladimir Serbinenko + + * loader/i386/pc/multiboot2.c: Removed stalled file. + 2010-01-12 Vladimir Serbinenko * util/grub-mkpasswd-pbkdf2.c (main): Use grub_util_init_nls. diff --git a/loader/i386/pc/multiboot2.c b/loader/i386/pc/multiboot2.c deleted file mode 100644 index 005c8a823..000000000 --- a/loader/i386/pc/multiboot2.c +++ /dev/null @@ -1,122 +0,0 @@ -/* multiboot2.c - boot a multiboot 2 OS image. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 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 - * 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 -#include - -grub_err_t -grub_mb2_arch_elf32_hook (Elf32_Phdr *phdr, - grub_addr_t *addr __attribute__ ((unused)), - int *do_load) -{ - Elf32_Addr paddr = phdr->p_paddr; - - if (phdr->p_type != PT_LOAD) - { - *do_load = 0; - return 0; - } - *do_load = 1; - - if ((paddr < grub_os_area_addr) - || (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size)) - return grub_error(GRUB_ERR_OUT_OF_RANGE,"address 0x%x is out of range", - paddr); - - return GRUB_ERR_NONE; -} - -grub_err_t -grub_mb2_arch_elf64_hook (Elf64_Phdr *phdr, - grub_addr_t *addr __attribute__ ((unused)), - int *do_load) -{ - Elf64_Addr paddr = phdr->p_paddr; - - if (phdr->p_type != PT_LOAD) - { - *do_load = 0; - return 0; - } - *do_load = 1; - - if ((paddr < grub_os_area_addr) - || (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size)) - return grub_error (GRUB_ERR_OUT_OF_RANGE, "address 0x%x is out of range", - paddr); - - return GRUB_ERR_NONE; -} - -grub_err_t -grub_mb2_arch_module_alloc (grub_size_t size, grub_addr_t *addr) -{ - grub_addr_t modaddr; - - modaddr = (grub_addr_t) grub_memalign (MULTIBOOT2_MOD_ALIGN, size); - if (! modaddr) - return grub_errno; - - *addr = modaddr; - return GRUB_ERR_NONE; -} - -grub_err_t -grub_mb2_arch_module_free (grub_addr_t addr, - grub_size_t size __attribute__ ((unused))) -{ - grub_free((void *) addr); - return GRUB_ERR_NONE; -} - -void -grub_mb2_arch_boot (grub_addr_t entry, void *tags) -{ - grub_multiboot2_real_boot (entry, tags); -} - -void -grub_mb2_arch_unload (struct multiboot2_tag_header *tags) -{ - struct multiboot2_tag_header *tag; - - /* Free all module memory in the tag list. */ - for_each_tag (tag, tags) - { - if (tag->key == MULTIBOOT2_TAG_MODULE) - { - struct multiboot2_tag_module *module = - (struct multiboot2_tag_module *) tag; - grub_free((void *) module->addr); - } - } -} - -grub_err_t -grub_mb2_tags_arch_create (void) -{ - /* XXX Create boot device et al. */ - return GRUB_ERR_NONE; -} From b16ff4662ea7a3d3187499c435c3b45a85af7563 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 12 Jan 2010 19:47:02 +0100 Subject: [PATCH 190/208] Small cleanup --- loader/i386/multiboot.c | 26 -------------------------- loader/i386/multiboot_elfxx.c | 2 +- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index 2a69327b4..5dc304117 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -232,32 +232,6 @@ grub_multiboot (int argc, char *argv[]) else if (grub_multiboot_load_elf (file, buffer) != GRUB_ERR_NONE) goto fail; - if (header->flags & MULTIBOOT_VIDEO_MODE) - { - switch (header->mode_type) - { - case 1: - grub_env_set ("gfxpayload", "text"); - break; - - case 0: - { - char buf[sizeof ("XXXXXXXXXXxXXXXXXXXXXxXXXXXXXXXX,XXXXXXXXXXxXXXXXXXXXX,auto")]; - if (header->depth && header->width && header->height) - grub_sprintf (buf, "%dx%dx%d,%dx%d,auto", header->width, - header->height, header->depth, header->width, - header->height); - else if (header->width && header->height) - grub_sprintf (buf, "%dx%d,auto", header->width, header->height); - else - grub_sprintf (buf, "auto"); - - grub_env_set ("gfxpayload", buf); - break; - } - } - } - grub_multiboot_set_bootdev (); grub_loader_set (grub_multiboot_boot, grub_multiboot_unload, 0); diff --git a/loader/i386/multiboot_elfxx.c b/loader/i386/multiboot_elfxx.c index 8f6367432..2e35183a4 100644 --- a/loader/i386/multiboot_elfxx.c +++ b/loader/i386/multiboot_elfxx.c @@ -104,7 +104,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, void *buffer) alloc_mbi = grub_multiboot_get_mbi_size (); grub_multiboot_payload_orig - = grub_relocator32_alloc (grub_multiboot_pure_size + alloc_mbi); + = grub_relocator32_alloc (grub_multiboot_pure_size + alloc_mbi + 65536); if (!grub_multiboot_payload_orig) return grub_errno; From 58655a160bd56ab3ca8ed9944639260eff21bfa8 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Wed, 13 Jan 2010 19:10:57 +0000 Subject: [PATCH 191/208] 2010-01-13 Robert Millan * util/mkisofs/rock.c (generate_rock_ridge_attributes): Fix a typo. --- ChangeLog | 4 ++++ util/mkisofs/rock.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e2fd92f68..788328502 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-13 Robert Millan + + * util/mkisofs/rock.c (generate_rock_ridge_attributes): Fix a typo. + 2010-01-12 Vladimir Serbinenko * loader/i386/pc/multiboot2.c: Removed stalled file. diff --git a/util/mkisofs/rock.c b/util/mkisofs/rock.c index a4cc27fa9..f18b0bd83 100644 --- a/util/mkisofs/rock.c +++ b/util/mkisofs/rock.c @@ -5,7 +5,7 @@ Copyright 1993 Yggdrasil Computing, Incorporated - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009,2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -306,7 +306,7 @@ int deep_opt; * the symbolic link won't fit into one SL System Use Field * print an error message and continue with splited one */ - fprintf(stderr, _("symbolic link ``%s'' to long for one SL System Use Field, splitting"), cpnt); + fprintf (stderr, _("symbolic link ``%s'' too long for one SL System Use Field, splitting"), cpnt); } if(MAYBE_ADD_CE_ENTRY(SL_SIZE + sl_bytes)) add_CE_entry(); } From c1f28820101867513d188fbe7354d5d35b0f08cb Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 13 Jan 2010 20:43:48 +0100 Subject: [PATCH 192/208] 2010-01-13 Vladimir Serbinenko * term/ieee1275/ofconsole.c (grub_ofconsole_putchar): Handle '\r'. (grub_ofconsole_getwh): Split to ... (grub_ofconsole_getwh): ... this. (grub_ofconsole_dimensions): ...and this. (grub_ofconsole_init_output): Call grub_ofconsole_dimensions. --- ChangeLog | 8 ++++++++ term/ieee1275/ofconsole.c | 20 ++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 788328502..95eebe4b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-01-13 Vladimir Serbinenko + + * term/ieee1275/ofconsole.c (grub_ofconsole_putchar): Handle '\r'. + (grub_ofconsole_getwh): Split to ... + (grub_ofconsole_getwh): ... this. + (grub_ofconsole_dimensions): ...and this. + (grub_ofconsole_init_output): Call grub_ofconsole_dimensions. + 2010-01-13 Robert Millan * util/mkisofs/rock.c (generate_rock_ridge_attributes): Fix a typo. diff --git a/term/ieee1275/ofconsole.c b/term/ieee1275/ofconsole.c index 3977c6286..a9834e23e 100644 --- a/term/ieee1275/ofconsole.c +++ b/term/ieee1275/ofconsole.c @@ -83,12 +83,17 @@ grub_ofconsole_putchar (grub_uint32_t c) grub_curr_y++; grub_curr_x = 0; } + else if (c == '\r') + { + grub_curr_x = 0; + } else { grub_curr_x++; - if (grub_curr_x > grub_ofconsole_width) + if (grub_curr_x >= grub_ofconsole_width) { grub_ofconsole_putchar ('\n'); + grub_ofconsole_putchar ('\r'); grub_curr_x++; } } @@ -234,16 +239,13 @@ grub_ofconsole_getxy (void) return ((grub_curr_x - 1) << 8) | grub_curr_y; } -static grub_uint16_t -grub_ofconsole_getwh (void) +static void +grub_ofconsole_dimensions (void) { grub_ieee1275_ihandle_t options; char *val; grub_ssize_t lval; - if (grub_ofconsole_width && grub_ofconsole_height) - return (grub_ofconsole_width << 8) | grub_ofconsole_height; - if (! grub_ieee1275_finddevice ("/options", &options) && options != (grub_ieee1275_ihandle_t) -1) { @@ -280,7 +282,11 @@ grub_ofconsole_getwh (void) grub_ofconsole_width = 80; if (! grub_ofconsole_height) grub_ofconsole_height = 24; +} +static grub_uint16_t +grub_ofconsole_getwh (void) +{ return (grub_ofconsole_width << 8) | grub_ofconsole_height; } @@ -379,6 +385,8 @@ grub_ofconsole_init_output (void) grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL); } + grub_ofconsole_dimensions (); + return 0; } From 17383dfe962e366b2c77f70506a4438602619122 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 13 Jan 2010 22:53:12 +0100 Subject: [PATCH 193/208] 2010-01-13 Vladimir Serbinenko * kern/efi/init.c (grub_efi_fini): Don't call grub_efi_mm_fini as it would result in module crash. --- ChangeLog | 5 +++++ kern/efi/init.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 95eebe4b2..f86ff3ddd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-13 Vladimir Serbinenko + + * kern/efi/init.c (grub_efi_fini): Don't call grub_efi_mm_fini as + it would result in module crash. + 2010-01-13 Vladimir Serbinenko * term/ieee1275/ofconsole.c (grub_ofconsole_putchar): Handle '\r'. diff --git a/kern/efi/init.c b/kern/efi/init.c index f9ba03852..8862eb2f9 100644 --- a/kern/efi/init.c +++ b/kern/efi/init.c @@ -82,6 +82,5 @@ void grub_efi_fini (void) { grub_efidisk_fini (); - grub_efi_mm_fini (); grub_console_fini (); } From 0b8891c276ae3b1f3d93ff881a13a405d6471269 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Thu, 14 Jan 2010 17:17:51 +0530 Subject: [PATCH 194/208] removed unnecessary grub_test_* wrappers --- ChangeLog.unit-testing-framework | 20 +++++++++++++++ include/grub/test.h | 8 ------ tests/lib/functional_test.c | 37 --------------------------- tests/lib/test.c | 44 ++++++++++++++++---------------- tests/lib/unit_test.c | 43 +++++-------------------------- 5 files changed, 48 insertions(+), 104 deletions(-) diff --git a/ChangeLog.unit-testing-framework b/ChangeLog.unit-testing-framework index aa4d4fd03..6643e9989 100644 --- a/ChangeLog.unit-testing-framework +++ b/ChangeLog.unit-testing-framework @@ -1,3 +1,23 @@ +2010-01-14 BVK Chaitanya + + Removed unnecessary grub_test_* wrappers. + + * tests/lib/unit_test.c (grub_test_malloc): Removed. + (grub_test_vsprintf): Removed. + (grub_test_strdup): Removed. + (grub_test_printf): Removed. + (grub_test_free): Replaced with.... + (grub_free): ...new wrapper. + * tests/lib/functional_test.c (grub_test_malloc): Removed. + (grub_test_free): Removed. + (grub_test_vsprintf): Removed. + (grub_test_strdup): Removed. + (grub_test_printf): Removed. + * tests/lib/test.c: Replaced + grub_test_{malloc,free,strdup,printf,vsprintf} methods with + grub_{malloc,free,strdup,printf,vsprintf} methods. + * include/grub/test.h: Removed prototypes for the above. + 2010-01-12 BVK Chaitanya * tests/util/grub-shell.in: New --boot option. diff --git a/include/grub/test.h b/include/grub/test.h index bd5b7d806..544e1c817 100644 --- a/include/grub/test.h +++ b/include/grub/test.h @@ -64,12 +64,4 @@ void grub_test_nonzero (int cond, const char *file, grub_test_unregister (name); \ } -/* Functions that are defined differently for unit and functional tests. */ -void *grub_test_malloc (grub_size_t size); -void grub_test_free (void *ptr); -char *grub_test_strdup (const char *str); -int grub_test_vsprintf (char *str, const char *fmt, va_list args); -int grub_test_printf (const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); - #endif /* ! GRUB_TEST_HEADER */ diff --git a/tests/lib/functional_test.c b/tests/lib/functional_test.c index 2e03dabc4..8ad034503 100644 --- a/tests/lib/functional_test.c +++ b/tests/lib/functional_test.c @@ -3,43 +3,6 @@ #include #include -void * -grub_test_malloc (grub_size_t size) -{ - return grub_malloc (size); -} - -void -grub_test_free (void *ptr) -{ - grub_free (ptr); -} - -int -grub_test_vsprintf (char *str, const char *fmt, va_list args) -{ - return grub_vsprintf (str, fmt, args); -} - -char * -grub_test_strdup (const char *str) -{ - return grub_strdup (str); -} - -int -grub_test_printf (const char *fmt, ...) -{ - int r; - va_list ap; - - va_start (ap, fmt); - r = grub_vprintf (fmt, ap); - va_end (ap); - - return r; -} - static grub_err_t grub_functional_test (struct grub_extcmd *cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), diff --git a/tests/lib/test.c b/tests/lib/test.c index 562c2f6e4..aba2f4415 100644 --- a/tests/lib/test.c +++ b/tests/lib/test.c @@ -1,3 +1,4 @@ +#include #include #include @@ -31,16 +32,16 @@ add_failure (const char *file, char buf[1024]; grub_test_failure_t failure; - failure = (grub_test_failure_t) grub_test_malloc (sizeof (*failure)); + failure = (grub_test_failure_t) grub_malloc (sizeof (*failure)); if (!failure) return; - grub_test_vsprintf (buf, fmt, args); + grub_vsprintf (buf, fmt, args); - failure->file = grub_test_strdup (file ? : ""); - failure->funp = grub_test_strdup (funp ? : ""); + failure->file = grub_strdup (file ? : ""); + failure->funp = grub_strdup (funp ? : ""); failure->line = line; - failure->message = grub_test_strdup (buf); + failure->message = grub_strdup (buf); grub_list_push (GRUB_AS_LIST_P (&failure_list), GRUB_AS_LIST (failure)); } @@ -53,15 +54,15 @@ free_failures (void) while ((item = grub_list_pop (GRUB_AS_LIST_P (&failure_list))) != 0) { if (item->message) - grub_test_free (item->message); + grub_free (item->message); if (item->funp) - grub_test_free (item->funp); + grub_free (item->funp); if (item->file) - grub_test_free (item->file); + grub_free (item->file); - grub_test_free (item); + grub_free (item); } failure_list = 0; } @@ -86,11 +87,11 @@ grub_test_register (const char *name, void (*test_main) (void)) { grub_test_t test; - test = (grub_test_t) grub_test_malloc (sizeof (*test)); + test = (grub_test_t) grub_malloc (sizeof (*test)); if (!test) return; - test->name = grub_test_strdup (name); + test->name = grub_strdup (name); test->main = test_main; grub_list_push (GRUB_AS_LIST_P (&grub_test_list), GRUB_AS_LIST (test)); @@ -106,13 +107,12 @@ grub_test_unregister (const char *name) if (test) { - grub_list_remove (GRUB_AS_LIST_P (&grub_test_list), - GRUB_AS_LIST (test)); + grub_list_remove (GRUB_AS_LIST_P (&grub_test_list), GRUB_AS_LIST (test)); if (test->name) - grub_test_free (test->name); + grub_free (test->name); - grub_test_free (test); + grub_free (test); } } @@ -124,22 +124,22 @@ grub_test_run (grub_test_t test) { grub_test_failure_t failure = (grub_test_failure_t) item; - grub_test_printf (" %s:%s:%u: %s\n", - (failure->file ? : ""), - (failure->funp ? : ""), - failure->line, (failure->message ? : "")); + grub_printf (" %s:%s:%u: %s\n", + (failure->file ? : ""), + (failure->funp ? : ""), + failure->line, (failure->message ? : "")); return 0; } test->main (); - grub_test_printf ("%s:\n", test->name); + grub_printf ("%s:\n", test->name); grub_list_iterate (GRUB_AS_LIST (failure_list), (grub_list_hook_t) print_failure); if (!failure_list) - grub_test_printf ("%s: PASS\n", test->name); + grub_printf ("%s: PASS\n", test->name); else - grub_test_printf ("%s: FAIL\n", test->name); + grub_printf ("%s: FAIL\n", test->name); free_failures (); return GRUB_ERR_NONE; diff --git a/tests/lib/unit_test.c b/tests/lib/unit_test.c index 59931898a..2ca011433 100644 --- a/tests/lib/unit_test.c +++ b/tests/lib/unit_test.c @@ -7,43 +7,6 @@ #include #include -void * -grub_test_malloc (grub_size_t size) -{ - return malloc (size); -} - -void -grub_test_free (void *ptr) -{ - free (ptr); -} - -int -grub_test_vsprintf (char *str, const char *fmt, va_list args) -{ - return vsprintf (str, fmt, args); -} - -char * -grub_test_strdup (const char *str) -{ - return strdup (str); -} - -int -grub_test_printf (const char *fmt, ...) -{ - int r; - va_list ap; - - va_start (ap, fmt); - r = vprintf (fmt, ap); - va_end (ap); - - return r; -} - int main (int argc __attribute__ ((unused)), char *argv[] __attribute__ ((unused))) @@ -70,6 +33,12 @@ main (int argc __attribute__ ((unused)), /* Other misc. functions necessary for successful linking. */ +void +grub_free (void *ptr) +{ + free (ptr); +} + char * grub_env_get (const char *name __attribute__ ((unused))) { From 2285d4642a6a6177d6c9d9daa2658b347ba183c2 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Thu, 14 Jan 2010 18:39:12 +0530 Subject: [PATCH 195/208] use qemu-system-i386 instead of qemu --- ChangeLog.unit-testing-framework | 4 ++++ tests/util/grub-shell.in | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog.unit-testing-framework b/ChangeLog.unit-testing-framework index 6643e9989..ba5ba8cc5 100644 --- a/ChangeLog.unit-testing-framework +++ b/ChangeLog.unit-testing-framework @@ -1,5 +1,9 @@ 2010-01-14 BVK Chaitanya + Use qemu-system-i386 instead of qemu. + + * tests/util/grub-shell.in (outfile): Use qemu-system-i386. + Removed unnecessary grub_test_* wrappers. * tests/lib/unit_test.c (grub_test_malloc): Removed. diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index b103872ba..e6fef8313 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -135,7 +135,7 @@ fdafile=`mktemp` cp ${isofile} ${fdafile} outfile=`mktemp` -qemu ${qemuopts} -nographic -serial stdio -hda ${hdafile} -fda ${fdafile} -cdrom ${isofile} -boot ${bootdev} | tr -d "\r" >${outfile} +qemu-system-i386 ${qemuopts} -nographic -serial stdio -hda ${hdafile} -fda ${fdafile} -cdrom ${isofile} -boot ${bootdev} | tr -d "\r" >${outfile} cat $outfile From 6d1e76899b216af8e83516a93231bafc9570edf7 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 14 Jan 2010 14:06:36 +0000 Subject: [PATCH 196/208] fix changelog dates --- ChangeLog.savedefault | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ChangeLog.savedefault b/ChangeLog.savedefault index 722769776..d68d75eab 100644 --- a/ChangeLog.savedefault +++ b/ChangeLog.savedefault @@ -1,18 +1,18 @@ -2010-10-05 Jordan Uggla -2010-10-05 Colin Watson +2010-01-05 Jordan Uggla +2010-01-05 Colin Watson * util/grub-reboot.in: Make sure prev_saved_entry always gets a non-empty value. -2010-10-05 Jordan Uggla -2010-10-05 Colin Watson +2010-01-05 Jordan Uggla +2010-01-05 Colin Watson * util/grub.d/00_header.in: Define a "savedefault" function for use in menu entries. * util/grub-mkconfig_lib.in (save_default_entry): Use it. -2010-10-05 Jordan Uggla -2010-10-05 Colin Watson +2010-01-05 Jordan Uggla +2010-01-05 Colin Watson * util/grub-mkconfig_lib.in (save_default_entry): Only set saved_entry if boot_once is unset. From 0a46429a55ee7701dfb450ac648b1d1a07e6287c Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 14 Jan 2010 21:08:31 +0000 Subject: [PATCH 197/208] 2010-01-14 Robert Millan * include/grub/i386/loader.h (grub_linux16_boot): Renamed to ... (grub_linux16_real_boot): ... this. * kern/i386/loader.S: Likewise. * loader/i386/pc/linux.c: Include `' and `'. (grub_linux16_boot): New function. Switches to text mode and calls grub_linux16_real_boot(). * loader/i386/bsd.c: Include `'. (grub_freebsd_boot, grub_openbsd_boot, grub_netbsd_boot): Switch to text mode before calling grub_unix_real_boot(). * loader/i386/multiboot.c: Include `'. (grub_multiboot_boot): Switch to text mode before calling grub_relocator32_boot(). * loader/i386/pc/chainloader.c: Include `'. (grub_chainloader_boot): Switch to text mode before calling grub_chainloader_real_boot(). --- ChangeLog | 21 +++++++++++++++++++++ include/grub/i386/loader.h | 4 ++-- kern/i386/loader.S | 2 +- loader/i386/bsd.c | 10 ++++++++-- loader/i386/multiboot.c | 5 ++++- loader/i386/pc/chainloader.c | 4 +++- loader/i386/pc/linux.c | 14 +++++++++++++- 7 files changed, 52 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0fa70ecf6..652cc145a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2010-01-14 Robert Millan + + * include/grub/i386/loader.h (grub_linux16_boot): Renamed to ... + (grub_linux16_real_boot): ... this. + * kern/i386/loader.S: Likewise. + * loader/i386/pc/linux.c: Include `' and `'. + (grub_linux16_boot): New function. Switches to text mode and calls + grub_linux16_real_boot(). + + * loader/i386/bsd.c: Include `'. + (grub_freebsd_boot, grub_openbsd_boot, grub_netbsd_boot): Switch to + text mode before calling grub_unix_real_boot(). + + * loader/i386/multiboot.c: Include `'. + (grub_multiboot_boot): Switch to text mode before calling + grub_relocator32_boot(). + + * loader/i386/pc/chainloader.c: Include `'. + (grub_chainloader_boot): Switch to text mode before calling + grub_chainloader_real_boot(). + 2010-01-05 Jordan Uggla 2010-01-05 Colin Watson diff --git a/include/grub/i386/loader.h b/include/grub/i386/loader.h index 0df5f757f..05954b6db 100644 --- a/include/grub/i386/loader.h +++ b/include/grub/i386/loader.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2004,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2004,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ extern grub_uint32_t EXPORT_VAR(grub_linux_prot_size); extern char *EXPORT_VAR(grub_linux_tmp_addr); extern char *EXPORT_VAR(grub_linux_real_addr); extern grub_int32_t EXPORT_VAR(grub_linux_is_bzimage); -grub_err_t EXPORT_FUNC(grub_linux16_boot) (void); +grub_err_t EXPORT_FUNC(grub_linux16_real_boot) (void); #endif #endif /* ! GRUB_LOADER_CPU_HEADER */ diff --git a/kern/i386/loader.S b/kern/i386/loader.S index 3e9c71327..ed57c43ca 100644 --- a/kern/i386/loader.S +++ b/kern/i386/loader.S @@ -59,7 +59,7 @@ VARIABLE(grub_linux_real_addr) VARIABLE(grub_linux_is_bzimage) .long 0 -FUNCTION(grub_linux16_boot) +FUNCTION(grub_linux16_real_boot) /* Must be done before zImage copy. */ call EXT_C(grub_dl_unload_all) diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 0785a3fc1..49be758c6 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008, 2009 Free Software Foundation, Inc. + * Copyright (C) 2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ #include #include #include - +#include #ifdef GRUB_MACHINE_PCBIOS #include #endif @@ -509,6 +509,8 @@ grub_freebsd_boot (void) bi.bi_kernend = kern_end; + grub_video_set_mode ("text", NULL); + if (is_64bit) { grub_uint32_t *gdt; @@ -617,6 +619,8 @@ grub_openbsd_boot (void) pa->ba_type = OPENBSD_BOOTARG_END; pa++; + grub_video_set_mode ("text", NULL); + grub_unix_real_boot (entry, bootflags, openbsd_root, OPENBSD_BOOTARG_APIVER, 0, (grub_uint32_t) (grub_mmap_get_upper () >> 10), (grub_uint32_t) (grub_mmap_get_lower () >> 10), @@ -713,6 +717,8 @@ grub_netbsd_boot (void) bootinfo->bi_data[0] = mmap; } + grub_video_set_mode ("text", NULL); + grub_unix_real_boot (entry, bootflags, 0, bootinfo, 0, (grub_uint32_t) (grub_mmap_get_upper () >> 10), (grub_uint32_t) (grub_mmap_get_lower () >> 10)); diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index 5dc304117..4360e8a2c 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -1,7 +1,7 @@ /* multiboot.c - boot a multiboot OS image. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,6 +46,7 @@ #include #include #include +#include extern grub_dl_t my_mod; static grub_size_t code_size, alloc_mbi; @@ -89,6 +90,8 @@ grub_multiboot_boot (void) if (err) return err; + grub_video_set_mode ("text", NULL); + grub_relocator32_boot (grub_multiboot_payload_orig, grub_multiboot_payload_dest, state); diff --git a/loader/i386/pc/chainloader.c b/loader/i386/pc/chainloader.c index 81cfddac1..e28a4e7f9 100644 --- a/loader/i386/pc/chainloader.c +++ b/loader/i386/pc/chainloader.c @@ -1,7 +1,7 @@ /* chainloader.c - boot another boot loader */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2004,2007,2009 Free Software Foundation, Inc. + * Copyright (C) 2002,2004,2007,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ #include #include #include +#include static grub_dl_t my_mod; static int boot_drive; @@ -41,6 +42,7 @@ static void *boot_part_addr; static grub_err_t grub_chainloader_boot (void) { + grub_video_set_mode ("text", NULL); grub_chainloader_real_boot (boot_drive, boot_part_addr); /* Never reach here. */ diff --git a/loader/i386/pc/linux.c b/loader/i386/pc/linux.c index 24bb39555..96973adb9 100644 --- a/loader/i386/pc/linux.c +++ b/loader/i386/pc/linux.c @@ -1,7 +1,7 @@ /* linux.c - boot Linux zImage or bzImage */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +31,8 @@ #include #include #include +#include +#include #define GRUB_LINUX_CL_OFFSET 0x9000 #define GRUB_LINUX_CL_END_OFFSET 0x90FF @@ -48,6 +50,16 @@ grub_linux_unload (void) return GRUB_ERR_NONE; } +static grub_err_t +grub_linux16_boot (void) +{ + grub_video_set_mode ("text", NULL); + grub_linux16_real_boot (); + + /* Not reached. */ + return GRUB_ERR_NONE; +} + static grub_err_t grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) From ba2f6848e06aa654bf8d6df02d5737aca73035b9 Mon Sep 17 00:00:00 2001 From: carles Date: Thu, 14 Jan 2010 22:31:06 +0000 Subject: [PATCH 198/208] 2010-01-14 Carles Pina i Estany * gettext/gettext.c (grub_gettext_translate): Push and pop grub_errno. (grub_gettext_delete_list): Change comment style. * kern/err.c (grub_error): Gettextizze. (grub_fatal): Gettextizze. --- ChangeLog | 8 ++++++++ gettext/gettext.c | 17 ++++++++++++++--- kern/err.c | 4 ++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 652cc145a..17083d1b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-01-14 Carles Pina i Estany + + * gettext/gettext.c (grub_gettext_translate): Push and pop + grub_errno. + (grub_gettext_delete_list): Change comment style. + * kern/err.c (grub_error): Gettextizze. + (grub_fatal): Gettextizze. + 2010-01-14 Robert Millan * include/grub/i386/loader.h (grub_linux16_boot): Renamed to ... diff --git a/gettext/gettext.c b/gettext/gettext.c index 6fa6271f2..83497b7f6 100644 --- a/gettext/gettext.c +++ b/gettext/gettext.c @@ -148,14 +148,24 @@ grub_gettext_translate (const char *orig) struct grub_gettext_msg *cur; + /* Make sure we can use grub_gettext_translate for error messages. Push + active error message to error stack and reset error message. */ + grub_error_push (); + cur = grub_named_list_find (GRUB_AS_NAMED_LIST (grub_gettext_msg_list), orig); if (cur) - return cur->translated; + { + grub_error_pop (); + return cur->translated; + } if (fd_mo == 0) - return orig; + { + grub_error_pop (); + return orig; + } min = 0; max = grub_gettext_max; @@ -205,6 +215,7 @@ grub_gettext_translate (const char *orig) grub_errno = GRUB_ERR_NONE; } + grub_error_pop (); return ret; } @@ -308,7 +319,7 @@ grub_gettext_delete_list (void) char *original = (char *) ((struct grub_gettext_msg *) item)->name; grub_free (original); - // Don't delete the translated message because could be in use. + /* Don't delete the translated message because could be in use. */ } } diff --git a/kern/err.c b/kern/err.c index 02d7d879f..1a881db25 100644 --- a/kern/err.c +++ b/kern/err.c @@ -45,7 +45,7 @@ grub_error (grub_err_t n, const char *fmt, ...) grub_errno = n; va_start (ap, fmt); - grub_vsprintf (grub_errmsg, fmt, ap); + grub_vsprintf (grub_errmsg, _(fmt), ap); va_end (ap); return n; @@ -57,7 +57,7 @@ grub_fatal (const char *fmt, ...) va_list ap; va_start (ap, fmt); - grub_vprintf (fmt, ap); + grub_vprintf (_(fmt), ap); va_end (ap); grub_abort (); From c586fbb2064081efec63333dee9d73999e2c6f42 Mon Sep 17 00:00:00 2001 From: carles Date: Thu, 14 Jan 2010 23:04:49 +0000 Subject: [PATCH 199/208] 2001-01-14 Carles Pina i Estany * loader/i386/pc/chainloader.c: Include `'. --- ChangeLog | 4 ++++ loader/i386/pc/chainloader.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 17083d1b1..fe54d5c3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2001-01-14 Carles Pina i Estany + + * loader/i386/pc/chainloader.c: Include `'. + 2010-01-14 Carles Pina i Estany * gettext/gettext.c (grub_gettext_translate): Push and pop diff --git a/loader/i386/pc/chainloader.c b/loader/i386/pc/chainloader.c index e28a4e7f9..1d6de1de7 100644 --- a/loader/i386/pc/chainloader.c +++ b/loader/i386/pc/chainloader.c @@ -34,6 +34,7 @@ #include #include #include +#include static grub_dl_t my_mod; static int boot_drive; From cca15b52c11e5f469f2fce8ce61ff1ded3b20137 Mon Sep 17 00:00:00 2001 From: carles Date: Thu, 14 Jan 2010 23:07:44 +0000 Subject: [PATCH 200/208] 2010-01-14 Carles Pina i Estany * normal/cmdline.c (print_completion): Gettextizze. --- ChangeLog | 4 ++++ normal/cmdline.c | 19 +++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe54d5c3a..0478d6cb1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-14 Carles Pina i Estany + + * normal/cmdline.c (print_completion): Gettextizze. + 2001-01-14 Carles Pina i Estany * loader/i386/pc/chainloader.c: Include `'. diff --git a/normal/cmdline.c b/normal/cmdline.c index 429c84be7..bcffffeab 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -166,31 +166,30 @@ print_completion (const char *item, grub_completion_type_t type, int count) if (count == 0) { /* If this is the first time, print a label. */ - const char *what; - + + grub_puts (""); switch (type) { case GRUB_COMPLETION_TYPE_COMMAND: - what = "commands"; + grub_puts_ (N_("Possible commands are:")); break; case GRUB_COMPLETION_TYPE_DEVICE: - what = "devices"; + grub_puts_ (N_("Possible devices are:")); break; case GRUB_COMPLETION_TYPE_FILE: - what = "files"; + grub_puts_ (N_("Possible files are:")); break; case GRUB_COMPLETION_TYPE_PARTITION: - what = "partitions"; + grub_puts_ (N_("Possible partitions are:")); break; case GRUB_COMPLETION_TYPE_ARGUMENT: - what = "arguments"; + grub_puts_ (N_("Possible arguments are:")); break; default: - what = "things"; + grub_puts_ (N_("Possible things are:")); break; } - - grub_printf ("\nPossible %s are:\n", what); + grub_puts (""); } if (type == GRUB_COMPLETION_TYPE_PARTITION) From 5c71db1b9ba1aee67cdee92cb2b7a71c9aadbf46 Mon Sep 17 00:00:00 2001 From: carles Date: Thu, 14 Jan 2010 23:20:13 +0000 Subject: [PATCH 201/208] 2010-01-14 Carles Pina i Estany * util/grub.d/30_os-prober.in: Use `set var=val' rather than plain `var=val'. --- ChangeLog | 5 +++++ util/grub.d/30_os-prober.in | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0478d6cb1..e2d8a81f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-14 Carles Pina i Estany + + * util/grub.d/30_os-prober.in: Use `set var=val' rather than plain + `var=val'. + 2010-01-14 Carles Pina i Estany * normal/cmdline.c (print_completion): Gettextizze. diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index da6eea6b6..edef37e66 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -45,10 +45,10 @@ EOF prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" cat << EOF insmod ${GRUB_VIDEO_BACKEND} - do_resume=0 + set do_resume=0 if [ /var/vm/sleepimage -nt10 / ]; then if xnu_resume /var/vm/sleepimage; then - do_resume=1 + set do_resume=1 fi fi if [ \$do_resume == 0 ]; then From 0d90e8a6fb31c9d6b9200b3a34fa3b2ffa38214d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 15 Jan 2010 16:11:18 +0100 Subject: [PATCH 202/208] 2010-01-15 Vladimir Serbinenko Video driver ids. * include/grub/video.h (grub_video_driver_id): New type. (grub_video_adapter): New member 'id'. All users updated. (grub_video_get_driver_id): New proto. * video/video.c (grub_video_get_driver_id): New function. --- ChangeLog | 9 +++++++++ include/grub/video.h | 12 ++++++++++++ video/efi_gop.c | 1 + video/efi_uga.c | 1 + video/i386/pc/vbe.c | 1 + video/video.c | 8 ++++++++ 6 files changed, 32 insertions(+) diff --git a/ChangeLog b/ChangeLog index e2d8a81f5..dc123888b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-01-15 Vladimir Serbinenko + + Video driver ids. + + * include/grub/video.h (grub_video_driver_id): New type. + (grub_video_adapter): New member 'id'. All users updated. + (grub_video_get_driver_id): New proto. + * video/video.c (grub_video_get_driver_id): New function. + 2010-01-14 Carles Pina i Estany * util/grub.d/30_os-prober.in: Use `set var=val' rather than plain diff --git a/include/grub/video.h b/include/grub/video.h index 4145db465..437c98eb9 100644 --- a/include/grub/video.h +++ b/include/grub/video.h @@ -159,10 +159,19 @@ struct grub_video_palette_data grub_uint8_t a; /* Reserved bits value (0-255). */ }; +typedef enum grub_video_driver_id + { + GRUB_VIDEO_DRIVER_NONE, + GRUB_VIDEO_DRIVER_VBE, + GRUB_VIDEO_DRIVER_EFI_UGA, + GRUB_VIDEO_DRIVER_EFI_GOP + } grub_video_driver_id_t; + struct grub_video_adapter { /* The video adapter name. */ const char *name; + grub_video_driver_id_t id; /* Initialize the video adapter. */ grub_err_t (*init) (void); @@ -310,4 +319,7 @@ grub_err_t grub_video_set_mode (const char *modestring, int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p, struct grub_video_mode_info *mode_info)); +grub_video_driver_id_t +grub_video_get_driver_id (void); + #endif /* ! GRUB_VIDEO_HEADER */ diff --git a/video/efi_gop.c b/video/efi_gop.c index 30863c1ed..13ef0ddae 100644 --- a/video/efi_gop.c +++ b/video/efi_gop.c @@ -353,6 +353,7 @@ grub_video_gop_get_info_and_fini (struct grub_video_mode_info *mode_info, static struct grub_video_adapter grub_video_gop_adapter = { .name = "EFI GOP driver", + .id = GRUB_VIDEO_DRIVER_EFI_GOP, .init = grub_video_gop_init, .fini = grub_video_gop_fini, diff --git a/video/efi_uga.c b/video/efi_uga.c index 12ca35cde..7ef7594cc 100644 --- a/video/efi_uga.c +++ b/video/efi_uga.c @@ -300,6 +300,7 @@ grub_video_uga_get_info_and_fini (struct grub_video_mode_info *mode_info, static struct grub_video_adapter grub_video_uga_adapter = { .name = "EFI UGA driver", + .id = GRUB_VIDEO_DRIVER_EFI_UGA, .init = grub_video_uga_init, .fini = grub_video_uga_fini, diff --git a/video/i386/pc/vbe.c b/video/i386/pc/vbe.c index 17d9b3282..918bab0b0 100644 --- a/video/i386/pc/vbe.c +++ b/video/i386/pc/vbe.c @@ -557,6 +557,7 @@ grub_video_vbe_get_info_and_fini (struct grub_video_mode_info *mode_info, static struct grub_video_adapter grub_video_vbe_adapter = { .name = "VESA BIOS Extension Video Driver", + .id = GRUB_VIDEO_DRIVER_VBE, .init = grub_video_vbe_init, .fini = grub_video_vbe_fini, diff --git a/video/video.c b/video/video.c index 682bebcbf..e678c2982 100644 --- a/video/video.c +++ b/video/video.c @@ -93,6 +93,14 @@ grub_video_get_info (struct grub_video_mode_info *mode_info) return grub_video_adapter_active->get_info (mode_info); } +grub_video_driver_id_t +grub_video_get_driver_id (void) +{ + if (! grub_video_adapter_active) + return GRUB_VIDEO_DRIVER_NONE; + return grub_video_adapter_active->id; +} + /* Get information about active video mode. */ grub_err_t grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info, From 884ade56545bc515a13307e24a9694b0ef357a8a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 15 Jan 2010 16:30:57 +0100 Subject: [PATCH 203/208] 2010-01-15 Vladimir Serbinenko Video multiboot support. * include/grub/multiboot.h (grub_multiboot_set_accepts_video): New prototype. * include/multiboot.h: Resynced with multiboot specification. * include/multiboot2.h: Likewise. * loader/i386/multiboot.c (UNSUPPORTED_FLAGS): Support video flags. (grub_multiboot): Parse MULTIBOOT_VIDEO_MODE fields. * loader/i386/multiboot_mbi.c (DEFAULT_VIDEO_MODE): New constant. (HAS_VGA_TEXT): Likewise. (accepts_video): New variable. (grub_multiboot_set_accepts_video): New function. (grub_multiboot_get_mbi_size): Account for video structures. (set_video_mode): New function. (retrieve_video_parameters): Likewise. (grub_multiboot_make_mbi): Fill video fields. --- ChangeLog | 19 ++++++ include/grub/multiboot.h | 2 + include/multiboot.h | 38 ++++++++++- include/multiboot2.h | 38 ++++++++++- loader/i386/multiboot.c | 34 ++++++++-- loader/i386/multiboot_mbi.c | 129 +++++++++++++++++++++++++++++++++++- 6 files changed, 252 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc123888b..8d3245ea3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2010-01-15 Vladimir Serbinenko + + Video multiboot support. + + * include/grub/multiboot.h (grub_multiboot_set_accepts_video): + New prototype. + * include/multiboot.h: Resynced with multiboot specification. + * include/multiboot2.h: Likewise. + * loader/i386/multiboot.c (UNSUPPORTED_FLAGS): Support video flags. + (grub_multiboot): Parse MULTIBOOT_VIDEO_MODE fields. + * loader/i386/multiboot_mbi.c (DEFAULT_VIDEO_MODE): New constant. + (HAS_VGA_TEXT): Likewise. + (accepts_video): New variable. + (grub_multiboot_set_accepts_video): New function. + (grub_multiboot_get_mbi_size): Account for video structures. + (set_video_mode): New function. + (retrieve_video_parameters): Likewise. + (grub_multiboot_make_mbi): Fill video fields. + 2010-01-15 Vladimir Serbinenko Video driver ids. diff --git a/include/grub/multiboot.h b/include/grub/multiboot.h index f9edb0c59..665292e33 100644 --- a/include/grub/multiboot.h +++ b/include/grub/multiboot.h @@ -35,6 +35,8 @@ void grub_multiboot (int argc, char *argv[]); void grub_module (int argc, char *argv[]); +void grub_multiboot_set_accepts_video (int val); + grub_size_t grub_multiboot_get_mbi_size (void); grub_err_t grub_multiboot_make_mbi (void *orig, grub_uint32_t dest, grub_off_t buf_off, grub_size_t bufsize); diff --git a/include/multiboot.h b/include/multiboot.h index da7afd9b3..57c154c98 100644 --- a/include/multiboot.h +++ b/include/multiboot.h @@ -85,10 +85,12 @@ #define MULTIBOOT_INFO_APM_TABLE 0x00000400 /* Is there video information? */ -#define MULTIBOOT_INFO_VIDEO_INFO 0x00000800 +#define MULTIBOOT_INFO_VBE_INFO 0x00000800 +#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000 #ifndef ASM_FILE +typedef unsigned char multiboot_uint8_t; typedef unsigned short multiboot_uint16_t; typedef unsigned int multiboot_uint32_t; typedef unsigned long long multiboot_uint64_t; @@ -187,9 +189,43 @@ struct multiboot_info multiboot_uint16_t vbe_interface_seg; multiboot_uint16_t vbe_interface_off; multiboot_uint16_t vbe_interface_len; + + multiboot_uint64_t framebuffer_addr; + multiboot_uint32_t framebuffer_pitch; + multiboot_uint32_t framebuffer_width; + multiboot_uint32_t framebuffer_height; + multiboot_uint8_t framebuffer_bpp; +#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 +#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 +#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 + multiboot_uint8_t framebuffer_type; + union + { + struct + { + multiboot_uint32_t framebuffer_palette_addr; + multiboot_uint16_t framebuffer_palette_num_colors; + }; + struct + { + multiboot_uint8_t framebuffer_red_field_position; + multiboot_uint8_t framebuffer_red_mask_size; + multiboot_uint8_t framebuffer_green_field_position; + multiboot_uint8_t framebuffer_green_mask_size; + multiboot_uint8_t framebuffer_blue_field_position; + multiboot_uint8_t framebuffer_blue_mask_size; + }; + }; }; typedef struct multiboot_info multiboot_info_t; +struct multiboot_color +{ + multiboot_uint8_t red; + multiboot_uint8_t green; + multiboot_uint8_t blue; +}; + struct multiboot_mmap_entry { multiboot_uint32_t size; diff --git a/include/multiboot2.h b/include/multiboot2.h index 0488849d7..a241a70ad 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -85,10 +85,12 @@ #define MULTIBOOT_INFO_APM_TABLE 0x00000400 /* Is there video information? */ -#define MULTIBOOT_INFO_VIDEO_INFO 0x00000800 +#define MULTIBOOT_INFO_VBE_INFO 0x00000800 +#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000 #ifndef ASM_FILE +typedef unsigned char multiboot_uint8_t; typedef unsigned short multiboot_uint16_t; typedef unsigned int multiboot_uint32_t; typedef unsigned long long multiboot_uint64_t; @@ -187,9 +189,43 @@ struct multiboot_info multiboot_uint16_t vbe_interface_seg; multiboot_uint16_t vbe_interface_off; multiboot_uint16_t vbe_interface_len; + + multiboot_uint64_t framebuffer_addr; + multiboot_uint32_t framebuffer_pitch; + multiboot_uint32_t framebuffer_width; + multiboot_uint32_t framebuffer_height; + multiboot_uint8_t framebuffer_bpp; +#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 +#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 +#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 + multiboot_uint8_t framebuffer_type; + union + { + struct + { + multiboot_uint32_t framebuffer_palette_addr; + multiboot_uint16_t framebuffer_palette_num_colors; + }; + struct + { + multiboot_uint8_t framebuffer_red_field_position; + multiboot_uint8_t framebuffer_red_mask_size; + multiboot_uint8_t framebuffer_green_field_position; + multiboot_uint8_t framebuffer_green_mask_size; + multiboot_uint8_t framebuffer_blue_field_position; + multiboot_uint8_t framebuffer_blue_mask_size; + }; + }; }; typedef struct multiboot_info multiboot_info_t; +struct multiboot_color +{ + multiboot_uint8_t red; + multiboot_uint8_t green; + multiboot_uint8_t blue; +}; + struct multiboot_mmap_entry { multiboot_uint32_t size; diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index 4360e8a2c..637bc5d49 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -28,13 +28,11 @@ */ /* The bits in the required part of flags field we don't support. */ -#define UNSUPPORTED_FLAGS 0x0000fffc +#define UNSUPPORTED_FLAGS 0x0000fff8 #include #include #include -#include -#include #include #include #include @@ -90,8 +88,6 @@ grub_multiboot_boot (void) if (err) return err; - grub_video_set_mode ("text", NULL); - grub_relocator32_boot (grub_multiboot_payload_orig, grub_multiboot_payload_dest, state); @@ -235,6 +231,34 @@ grub_multiboot (int argc, char *argv[]) else if (grub_multiboot_load_elf (file, buffer) != GRUB_ERR_NONE) goto fail; + if (header->flags & MULTIBOOT_VIDEO_MODE) + { + switch (header->mode_type) + { + case 1: + grub_env_set ("gfxpayload", "text"); + break; + + case 0: + { + char buf[sizeof ("XXXXXXXXXXxXXXXXXXXXXxXXXXXXXXXX,XXXXXXXXXXxXXXXXXXXXX,auto")]; + if (header->depth && header->width && header->height) + grub_sprintf (buf, "%dx%dx%d,%dx%d,auto", header->width, + header->height, header->depth, header->width, + header->height); + else if (header->width && header->height) + grub_sprintf (buf, "%dx%d,auto", header->width, header->height); + else + grub_sprintf (buf, "auto"); + + grub_env_set ("gfxpayload", buf); + break; + } + } + } + + grub_multiboot_set_accepts_video (!!(header->flags & MULTIBOOT_VIDEO_MODE)); + grub_multiboot_set_bootdev (); grub_loader_set (grub_multiboot_boot, grub_multiboot_unload, 0); diff --git a/loader/i386/multiboot_mbi.c b/loader/i386/multiboot_mbi.c index 58802d44c..5f33a7314 100644 --- a/loader/i386/multiboot_mbi.c +++ b/loader/i386/multiboot_mbi.c @@ -29,6 +29,16 @@ #include #include #include +#include + +#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) +#include +#define DEFAULT_VIDEO_MODE "text" +#define HAS_VGA_TEXT 1 +#else +#define DEFAULT_VIDEO_MODE "auto" +#define HAS_VGA_TEXT 0 +#endif struct module { @@ -46,6 +56,13 @@ static unsigned modcnt; static char *cmdline = NULL; static grub_uint32_t bootdev; static int bootdev_set; +static int accepts_video; + +void +grub_multiboot_set_accepts_video (int val) +{ + accepts_video = val; +} /* Return the length of the Multiboot mmap that will be needed to allocate our platform's map. */ @@ -73,7 +90,8 @@ grub_multiboot_get_mbi_size (void) { return sizeof (struct multiboot_info) + ALIGN_UP (cmdline_size, 4) + modcnt * sizeof (struct multiboot_mod_list) + total_modcmd - + ALIGN_UP (sizeof(PACKAGE_STRING), 4) + grub_get_multiboot_mmap_len (); + + ALIGN_UP (sizeof(PACKAGE_STRING), 4) + grub_get_multiboot_mmap_len () + + 256 * sizeof (struct multiboot_color); } /* Fill previously allocated Multiboot mmap. */ @@ -106,6 +124,107 @@ grub_fill_multiboot_mmap (struct multiboot_mmap_entry *first_entry) grub_mmap_iterate (hook); } +static grub_err_t +set_video_mode (void) +{ + grub_err_t err; + const char *modevar; + + if (accepts_video || !HAS_VGA_TEXT) + { + modevar = grub_env_get ("gfxpayload"); + if (! modevar || *modevar == 0) + err = grub_video_set_mode (DEFAULT_VIDEO_MODE, 0); + else + { + char *tmp; + tmp = grub_malloc (grub_strlen (modevar) + + sizeof (DEFAULT_VIDEO_MODE) + 1); + if (! tmp) + return grub_errno; + grub_sprintf (tmp, "%s;" DEFAULT_VIDEO_MODE, modevar); + err = grub_video_set_mode (tmp, 0); + grub_free (tmp); + } + } + else + err = grub_video_set_mode ("text", 0); + + return err; +} + +static grub_err_t +retrieve_video_parameters (struct multiboot_info *mbi, + grub_uint8_t *ptrorig, grub_uint32_t ptrdest) +{ + grub_err_t err; + struct grub_video_mode_info mode_info; + void *framebuffer; + grub_video_driver_id_t driv_id; + struct grub_video_palette_data palette[256]; + + err = set_video_mode (); + if (err) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + } + + grub_video_get_palette (0, ARRAY_SIZE (palette), palette); + + driv_id = grub_video_get_driver_id (); + if (driv_id == GRUB_VIDEO_DRIVER_NONE) + return GRUB_ERR_NONE; + + err = grub_video_get_info_and_fini (&mode_info, &framebuffer); + if (err) + return err; + + mbi->framebuffer_addr = (grub_addr_t) framebuffer; + mbi->framebuffer_pitch = mode_info.pitch; + + mbi->framebuffer_width = mode_info.width; + mbi->framebuffer_height = mode_info.height; + + mbi->framebuffer_bpp = mode_info.bpp; + + if (mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) + { + struct multiboot_color *mb_palette; + unsigned i; + mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED; + mbi->framebuffer_palette_addr = ptrdest; + mbi->framebuffer_palette_num_colors = mode_info.number_of_colors; + if (mbi->framebuffer_palette_num_colors > ARRAY_SIZE (palette)) + mbi->framebuffer_palette_num_colors = ARRAY_SIZE (palette); + mb_palette = (struct multiboot_color *) ptrorig; + for (i = 0; i < mbi->framebuffer_palette_num_colors; i++) + { + mb_palette[i].red = palette[i].r; + mb_palette[i].green = palette[i].g; + mb_palette[i].blue = palette[i].b; + } + ptrorig += mbi->framebuffer_palette_num_colors + * sizeof (struct multiboot_color); + ptrdest += mbi->framebuffer_palette_num_colors + * sizeof (struct multiboot_color); + } + else + { + mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_RGB; + mbi->framebuffer_red_field_position = mode_info.green_field_pos; + mbi->framebuffer_red_mask_size = mode_info.green_mask_size; + mbi->framebuffer_green_field_position = mode_info.green_field_pos; + mbi->framebuffer_green_mask_size = mode_info.green_mask_size; + mbi->framebuffer_blue_field_position = mode_info.blue_field_pos; + mbi->framebuffer_blue_mask_size = mode_info.blue_mask_size; + } + + mbi->flags |= MULTIBOOT_INFO_FRAMEBUFFER_INFO; + + return GRUB_ERR_NONE; +} + grub_err_t grub_multiboot_make_mbi (void *orig, grub_uint32_t dest, grub_off_t buf_off, grub_size_t bufsize) @@ -117,6 +236,7 @@ grub_multiboot_make_mbi (void *orig, grub_uint32_t dest, grub_off_t buf_off, unsigned i; struct module *cur; grub_size_t mmap_size; + grub_err_t err; if (bufsize < grub_multiboot_get_mbi_size ()) return grub_error (GRUB_ERR_OUT_OF_MEMORY, "mbi buffer is too small"); @@ -182,6 +302,13 @@ grub_multiboot_make_mbi (void *orig, grub_uint32_t dest, grub_off_t buf_off, mbi->flags |= MULTIBOOT_INFO_BOOTDEV; } + err = retrieve_video_parameters (mbi, ptrorig, ptrdest); + if (err) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + } + return GRUB_ERR_NONE; } From a0b766fc9b50388d12eb5ed08756f5c5ab0ad480 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 15 Jan 2010 21:11:51 +0100 Subject: [PATCH 204/208] 2010-01-15 Vladimir Serbinenko Enable multiboot on non-pc. * conf/i386-coreboot.rmk, conf/i386-pc.rmk (pkglib_MODULES): Move multiboot.mod and multiboot2.mod to ... * conf/i386.rmk (pkglib_MODULES): ... here. * conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_SOURCES): Moved to ... * conf/i386.rmk (multiboot_mod_SOURCES): .. here. * conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_CFLAGS): Moved to ... * conf/i386.rmk (multiboot_mod_CFLAGS): .. here. * conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_ASFLAGS): Moved to ... * conf/i386.rmk (multiboot_mod_ASFLAGS): .. here. * conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_LDFLAGS): Moved to ... * conf/i386.rmk (multiboot_mod_LDFLAGS): .. here. * conf/x86_64-efi.rmk (pkglib_MODULES): Remove ata.mod and relocator.mod. (ata_mod_SOURCES): Removed. (ata_mod_CFLAGS): Likewise. (ata_mod_LDFLAGS): Likewise. (relocator_mod_SOURCES): Removed. (relocator_mod_CFLAGS): Likewise. (relocator_mod_ASFLAGS): Likewise. (relocator_mod_LDFLAGS): Likewise. Include i386.mk. * include/grub/x86_64/multiboot.h: New file. * loader/i386/multiboot.c (grub_multiboot_boot) [GRUB_MACHINE_EFI]: Terminate EFI. --- ChangeLog | 33 +++++++++++++++++++++++++++++++++ conf/i386-coreboot.rmk | 16 ---------------- conf/i386-pc.rmk | 16 ---------------- conf/i386.rmk | 16 ++++++++++++++++ conf/x86_64-efi.rmk | 14 ++------------ include/grub/x86_64/multiboot.h | 1 + loader/i386/multiboot.c | 9 +++++++++ 7 files changed, 61 insertions(+), 44 deletions(-) create mode 100644 include/grub/x86_64/multiboot.h diff --git a/ChangeLog b/ChangeLog index 8d3245ea3..3acc543d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2010-01-15 Vladimir Serbinenko + + Enable multiboot on non-pc. + + * conf/i386-coreboot.rmk, conf/i386-pc.rmk (pkglib_MODULES): Move + multiboot.mod and multiboot2.mod to ... + * conf/i386.rmk (pkglib_MODULES): ... here. + * conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_SOURCES): + Moved to ... + * conf/i386.rmk (multiboot_mod_SOURCES): .. here. + * conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_CFLAGS): + Moved to ... + * conf/i386.rmk (multiboot_mod_CFLAGS): .. here. + * conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_ASFLAGS): + Moved to ... + * conf/i386.rmk (multiboot_mod_ASFLAGS): .. here. + * conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_LDFLAGS): + Moved to ... + * conf/i386.rmk (multiboot_mod_LDFLAGS): .. here. + * conf/x86_64-efi.rmk (pkglib_MODULES): Remove ata.mod and + relocator.mod. + (ata_mod_SOURCES): Removed. + (ata_mod_CFLAGS): Likewise. + (ata_mod_LDFLAGS): Likewise. + (relocator_mod_SOURCES): Removed. + (relocator_mod_CFLAGS): Likewise. + (relocator_mod_ASFLAGS): Likewise. + (relocator_mod_LDFLAGS): Likewise. + Include i386.mk. + * include/grub/x86_64/multiboot.h: New file. + * loader/i386/multiboot.c (grub_multiboot_boot) [GRUB_MACHINE_EFI]: + Terminate EFI. + 2010-01-15 Vladimir Serbinenko Video multiboot support. diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index d73c9f0e2..57fb3350c 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -140,22 +140,6 @@ serial_mod_SOURCES = term/i386/pc/serial.c serial_mod_CFLAGS = $(COMMON_CFLAGS) serial_mod_LDFLAGS = $(COMMON_LDFLAGS) -pkglib_MODULES += multiboot.mod -multiboot_mod_SOURCES = loader/i386/multiboot.c \ - loader/i386/multiboot_mbi.c \ - loader/multiboot_loader.c -multiboot_mod_CFLAGS = $(COMMON_CFLAGS) -multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) -multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS) - -pkglib_MODULES += multiboot2.mod -multiboot2_mod_SOURCES = loader/i386/multiboot.c \ - loader/multiboot_loader.c \ - loader/i386/multiboot_mbi.c -multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2 -multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS) -multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS) - # For aout.mod. aout_mod_SOURCES = loader/aout.c aout_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 2a69571aa..a89203dea 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -201,22 +201,6 @@ serial_mod_SOURCES = term/i386/pc/serial.c serial_mod_CFLAGS = $(COMMON_CFLAGS) serial_mod_LDFLAGS = $(COMMON_LDFLAGS) -pkglib_MODULES += multiboot.mod -multiboot_mod_SOURCES = loader/i386/multiboot.c \ - loader/i386/multiboot_mbi.c \ - loader/multiboot_loader.c -multiboot_mod_CFLAGS = $(COMMON_CFLAGS) -multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) -multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS) - -pkglib_MODULES += multiboot2.mod -multiboot2_mod_SOURCES = loader/i386/multiboot.c \ - loader/i386/multiboot_mbi.c \ - loader/multiboot_loader.c -multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2 -multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS) -multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS) - # For vbe.mod. vbe_mod_SOURCES = video/i386/pc/vbe.c vbe_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/i386.rmk b/conf/i386.rmk index c3f036d0f..7ef337c61 100644 --- a/conf/i386.rmk +++ b/conf/i386.rmk @@ -25,3 +25,19 @@ pkglib_MODULES += ata.mod ata_mod_SOURCES = disk/ata.c ata_mod_CFLAGS = $(COMMON_CFLAGS) ata_mod_LDFLAGS = $(COMMON_LDFLAGS) + +pkglib_MODULES += multiboot.mod +multiboot_mod_SOURCES = loader/i386/multiboot.c \ + loader/i386/multiboot_mbi.c \ + loader/multiboot_loader.c +multiboot_mod_CFLAGS = $(COMMON_CFLAGS) +multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) +multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS) + +pkglib_MODULES += multiboot2.mod +multiboot2_mod_SOURCES = loader/i386/multiboot.c \ + loader/i386/multiboot_mbi.c \ + loader/multiboot_loader.c +multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2 +multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS) +multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS) diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index 4f6ace057..122700711 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -32,7 +32,7 @@ grub_install_SOURCES = util/i386/efi/grub-install.in pkglib_MODULES = kernel.img chain.mod appleldr.mod \ halt.mod reboot.mod linux.mod pci.mod lspci.mod \ datetime.mod date.mod datehook.mod loadbios.mod \ - fixvideo.mod mmap.mod acpi.mod ata.mod + fixvideo.mod mmap.mod acpi.mod # For kernel.img. kernel_img_EXPORTS = no @@ -77,11 +77,6 @@ acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c acpi_mod_CFLAGS = $(COMMON_CFLAGS) acpi_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For ata.mod -ata_mod_SOURCES = disk/ata.c -ata_mod_CFLAGS = $(COMMON_CFLAGS) -ata_mod_LDFLAGS = $(COMMON_LDFLAGS) - # For mmap.mod. mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \ mmap/efi/mmap.c @@ -166,10 +161,5 @@ xnu_mod_CFLAGS = $(COMMON_CFLAGS) xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) xnu_mod_ASFLAGS = $(COMMON_ASFLAGS) -pkglib_MODULES += relocator.mod -relocator_mod_SOURCES = lib/i386/relocator.c lib/i386/relocator_asm.S lib/i386/relocator_backward.S -relocator_mod_CFLAGS = $(COMMON_CFLAGS) -relocator_mod_ASFLAGS = $(COMMON_ASFLAGS) -relocator_mod_LDFLAGS = $(COMMON_LDFLAGS) - +include $(srcdir)/conf/i386.mk include $(srcdir)/conf/common.mk diff --git a/include/grub/x86_64/multiboot.h b/include/grub/x86_64/multiboot.h new file mode 100644 index 000000000..957c7a5ad --- /dev/null +++ b/include/grub/x86_64/multiboot.h @@ -0,0 +1 @@ +#include diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index 637bc5d49..d06f18692 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -46,6 +46,10 @@ #include #include +#ifdef GRUB_MACHINE_EFI +#include +#endif + extern grub_dl_t my_mod; static grub_size_t code_size, alloc_mbi; @@ -88,6 +92,11 @@ grub_multiboot_boot (void) if (err) return err; +#ifdef GRUB_MACHINE_EFI + if (! grub_efi_finish_boot_services ()) + grub_fatal ("cannot exit boot services"); +#endif + grub_relocator32_boot (grub_multiboot_payload_orig, grub_multiboot_payload_dest, state); From 70a14d3d49985c98f60bcec788e9261ff5e2db16 Mon Sep 17 00:00:00 2001 From: carles Date: Sat, 16 Jan 2010 00:26:52 +0000 Subject: [PATCH 205/208] 2010-01-16 Carles Pina i Estany * util/misc.c (grub_util_warn): Gettextizze, print full stop after the message. (grub_util_info): Likewise. (grub_util_error): Likewise. * util/elf/grub-mkimage.c: Fix capitalisation, quotes, full stops and/or new lines in `grub_util_warna', `grub_util_info', `grub_util_error' calls. * util/getroot.c: Likewise. * util/grub-editenv.c: Likewise. * util/grub-emu.c: Likewise. * util/grub-fstest.c: Likewise. * util/grub-mkdevicemap.c: Likewise. * util/grub-mkfont.c: Likewise. * util/grub-mkpasswd-pbkdf2.c: Likewise. * util/grub-mkrelpath.c: Likewise. * util/grub-pe2elf.c: Likewise. * util/grub-probe.c: Likewise. * util/hostdisk.c: Likewise. * util/i386/efi/grub-mkimage.c: Likewise. * util/i386/pc/grub-mkimage.c: Likewise. * util/i386/pc/grub-setup.c: Likewise. * util/ieee1275/ofpath.c: Likewise. * util/mkisofs/eltorito.c: Likewise. * util/mkisofs/rock.c: Likewise. * util/mkisofs/write.c: Likewise. * util/raid.c: Likewise. * util/sparc64/ieee1275/grub-mkimage.c: Likewise. * util/sparc64/ieee1275/grub-setup.c: Likewise. --- ChangeLog | 31 +++++++++++++++++++++ util/elf/grub-mkimage.c | 2 +- util/getroot.c | 26 +++++++++--------- util/grub-editenv.c | 2 +- util/grub-emu.c | 6 ++--- util/grub-fstest.c | 34 +++++++++++------------ util/grub-mkdevicemap.c | 2 +- util/grub-mkfont.c | 12 ++++----- util/grub-mkpasswd-pbkdf2.c | 22 +++++++-------- util/grub-mkrelpath.c | 2 +- util/grub-pe2elf.c | 14 +++++----- util/grub-probe.c | 12 ++++----- util/hostdisk.c | 4 +-- util/i386/efi/grub-mkimage.c | 4 +-- util/i386/pc/grub-mkimage.c | 4 +-- util/i386/pc/grub-setup.c | 40 ++++++++++++++-------------- util/ieee1275/ofpath.c | 12 ++++----- util/misc.c | 15 ++++++----- util/mkisofs/eltorito.c | 6 ++--- util/mkisofs/rock.c | 2 +- util/mkisofs/write.c | 2 +- util/raid.c | 6 ++--- util/sparc64/ieee1275/grub-mkimage.c | 2 +- util/sparc64/ieee1275/grub-setup.c | 40 ++++++++++++++-------------- 24 files changed, 168 insertions(+), 134 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3acc543d4..0effe5e10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2010-01-16 Carles Pina i Estany + + * util/misc.c (grub_util_warn): Gettextizze, print full stop after + the message. + (grub_util_info): Likewise. + (grub_util_error): Likewise. + * util/elf/grub-mkimage.c: Fix capitalisation, quotes, full stops + and/or new lines in `grub_util_warna', `grub_util_info', + `grub_util_error' calls. + * util/getroot.c: Likewise. + * util/grub-editenv.c: Likewise. + * util/grub-emu.c: Likewise. + * util/grub-fstest.c: Likewise. + * util/grub-mkdevicemap.c: Likewise. + * util/grub-mkfont.c: Likewise. + * util/grub-mkpasswd-pbkdf2.c: Likewise. + * util/grub-mkrelpath.c: Likewise. + * util/grub-pe2elf.c: Likewise. + * util/grub-probe.c: Likewise. + * util/hostdisk.c: Likewise. + * util/i386/efi/grub-mkimage.c: Likewise. + * util/i386/pc/grub-mkimage.c: Likewise. + * util/i386/pc/grub-setup.c: Likewise. + * util/ieee1275/ofpath.c: Likewise. + * util/mkisofs/eltorito.c: Likewise. + * util/mkisofs/rock.c: Likewise. + * util/mkisofs/write.c: Likewise. + * util/raid.c: Likewise. + * util/sparc64/ieee1275/grub-mkimage.c: Likewise. + * util/sparc64/ieee1275/grub-setup.c: Likewise. + 2010-01-15 Vladimir Serbinenko Enable multiboot on non-pc. diff --git a/util/elf/grub-mkimage.c b/util/elf/grub-mkimage.c index 6ba8b1ae2..c0736b83f 100644 --- a/util/elf/grub-mkimage.c +++ b/util/elf/grub-mkimage.c @@ -328,7 +328,7 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name); + fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ Usage: %s -o FILE [OPTION]... [MODULES]\n\ diff --git a/util/getroot.c b/util/getroot.c index 22ad7e967..6357c8a26 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -115,14 +115,14 @@ grub_get_prefix (const char *dir) saved_cwd = xgetcwd (); if (chdir (dir) < 0) - grub_util_error ("Cannot change directory to `%s'", dir); + grub_util_error ("cannot change directory to `%s'", dir); abs_dir = xgetcwd (); strip_extra_slashes (abs_dir); prev_dir = xstrdup (abs_dir); if (stat (".", &prev_st) < 0) - grub_util_error ("Cannot stat `%s'", dir); + grub_util_error ("cannot stat `%s'", dir); if (! S_ISDIR (prev_st.st_mode)) grub_util_error ("`%s' is not a directory", dir); @@ -130,13 +130,13 @@ grub_get_prefix (const char *dir) while (1) { if (chdir ("..") < 0) - grub_util_error ("Cannot change directory to the parent"); + grub_util_error ("cannot change directory to the parent"); if (stat (".", &st) < 0) - grub_util_error ("Cannot stat current directory"); + grub_util_error ("cannot stat current directory"); if (! S_ISDIR (st.st_mode)) - grub_util_error ("Current directory is not a directory???"); + grub_util_error ("current directory is not a directory???"); if (prev_st.st_dev != st.st_dev || prev_st.st_ino == st.st_ino) break; @@ -153,7 +153,7 @@ grub_get_prefix (const char *dir) strip_extra_slashes (prefix); if (chdir (saved_cwd) < 0) - grub_util_error ("Cannot change directory to `%s'", dir); + grub_util_error ("cannot change directory to `%s'", dir); #ifdef __CYGWIN__ if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16)) @@ -236,7 +236,7 @@ find_root_device (const char *dir, dev_t dev) if (res) { if (chdir (saved_cwd) < 0) - grub_util_error ("Cannot restore the original directory"); + grub_util_error ("cannot restore the original directory"); free (saved_cwd); closedir (dp); @@ -279,7 +279,7 @@ find_root_device (const char *dir, dev_t dev) continue; if (chdir (saved_cwd) < 0) - grub_util_error ("Cannot restore the original directory"); + grub_util_error ("cannot restore the original directory"); free (saved_cwd); closedir (dp); @@ -288,7 +288,7 @@ find_root_device (const char *dir, dev_t dev) } if (chdir (saved_cwd) < 0) - grub_util_error ("Cannot restore the original directory"); + grub_util_error ("cannot restore the original directory"); free (saved_cwd); closedir (dp); @@ -445,7 +445,7 @@ grub_guess_root_device (const char *dir) struct stat st; if (stat (dir, &st) < 0) - grub_util_error ("Cannot stat `%s'", dir); + grub_util_error ("cannot stat `%s'", dir); #ifdef __CYGWIN__ /* Cygwin specific function. */ @@ -591,7 +591,7 @@ grub_util_get_grub_dev (const char *os_dev) free (p); } else - grub_util_error ("Unknown kind of RAID device `%s'", os_dev); + grub_util_error ("unknown kind of RAID device `%s'", os_dev); break; @@ -608,7 +608,7 @@ grub_util_check_block_device (const char *blk_dev) struct stat st; if (stat (blk_dev, &st) < 0) - grub_util_error ("Cannot stat `%s'", blk_dev); + grub_util_error ("cannot stat `%s'", blk_dev); if (S_ISBLK (st.st_mode)) return (blk_dev); @@ -622,7 +622,7 @@ grub_util_check_char_device (const char *blk_dev) struct stat st; if (stat (blk_dev, &st) < 0) - grub_util_error ("Cannot stat `%s'", blk_dev); + grub_util_error ("cannot stat `%s'", blk_dev); if (S_ISCHR (st.st_mode)) return (blk_dev); diff --git a/util/grub-editenv.c b/util/grub-editenv.c index 1fb1422df..ea0e4da19 100644 --- a/util/grub-editenv.c +++ b/util/grub-editenv.c @@ -69,7 +69,7 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try ``grub-editenv --help'' for more information.\n"); + fprintf (stderr, "Try `grub-editenv --help' for more information.\n"); else printf ("\ Usage: grub-editenv [OPTIONS] [FILENAME] COMMAND\n\ diff --git a/util/grub-emu.c b/util/grub-emu.c index 3f2acaaec..a04aeae78 100644 --- a/util/grub-emu.c +++ b/util/grub-emu.c @@ -129,7 +129,7 @@ usage (int status) { if (status) fprintf (stderr, - "Try ``grub-emu --help'' for more information.\n"); + "Try `grub-emu --help' for more information.\n"); else printf ( "Usage: grub-emu [OPTION]...\n" @@ -220,14 +220,14 @@ main (int argc, char *argv[]) { char *device_name = grub_guess_root_device (dir); if (! device_name) - grub_util_error ("cannot find a device for %s.\n", dir); + grub_util_error ("cannot find a device for %s", dir); root_dev = grub_util_get_grub_dev (device_name); if (! root_dev) { grub_util_info ("guessing the root device failed, because of `%s'", grub_errmsg); - grub_util_error ("Cannot guess the root device. Specify the option ``--root-device''."); + grub_util_error ("cannot guess the root device. Specify the option `--root-device'"); } } diff --git a/util/grub-fstest.c b/util/grub-fstest.c index 586dda0f9..4470cbfa5 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -71,7 +71,7 @@ execute_command (char *name, int n, char **args) cmd = grub_command_find (name); if (! cmd) - grub_util_error ("Can\'t find command %s", name); + grub_util_error ("can\'t find command %s", name); return (cmd->func) (cmd, n, args); } @@ -100,9 +100,9 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len)) dev = grub_device_open (0); if ((! dev) || (! dev->disk)) - grub_util_error ("Can\'t open device."); + grub_util_error ("can\'t open device"); - grub_util_info ("total sectors : %lld.", + grub_util_info ("total sectors : %lld", (unsigned long long) dev->disk->total_sectors); if (! leng) @@ -115,7 +115,7 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len)) len = (leng > BUF_SIZE) ? BUF_SIZE : leng; if (grub_disk_read (dev->disk, 0, skip, len, buf)) - grub_util_error ("Disk read fails at offset %lld, length %d.", + grub_util_error ("disk read fails at offset %lld, length %d", skip, len); if (hook (skip, buf, len)) @@ -132,15 +132,15 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len)) file = grub_file_open (pathname); if (!file) { - grub_util_error ("cannot open file %s.", pathname); + grub_util_error ("cannot open file %s", pathname); return; } - grub_util_info ("file size : %lld.", (unsigned long long) file->size); + grub_util_info ("file size : %lld", (unsigned long long) file->size); if (skip > file->size) { - grub_util_error ("invalid skip value %lld.", (unsigned long long) skip); + grub_util_error ("invalid skip value %lld", (unsigned long long) skip); return; } @@ -158,7 +158,7 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len)) sz = grub_file_read (file, buf, (len > BUF_SIZE) ? BUF_SIZE : len); if (sz < 0) { - grub_util_error ("read error at offset %llu.", ofs); + grub_util_error ("read error at offset %llu", ofs); break; } @@ -184,7 +184,7 @@ cmd_cp (char *src, char *dest) if ((int) fwrite (buf, 1, len, ff) != len) { - grub_util_error ("write error."); + grub_util_error ("write error"); return 1; } @@ -194,7 +194,7 @@ cmd_cp (char *src, char *dest) ff = fopen (dest, "wb"); if (ff == NULL) { - grub_util_error ("open error."); + grub_util_error ("open error"); return; } read_file (src, cp_hook); @@ -212,7 +212,7 @@ cmd_cmp (char *src, char *dest) { if ((int) fread (buf_1, 1, len, ff) != len) { - grub_util_error ("read error at offset %llu.", ofs); + grub_util_error ("read error at offset %llu", ofs); return 1; } @@ -223,7 +223,7 @@ cmd_cmp (char *src, char *dest) for (i = 0; i < len; i++, ofs++) if (buf_1[i] != buf[i]) { - grub_util_error ("compare fail at offset %llu.", ofs); + grub_util_error ("compare fail at offset %llu", ofs); return 1; } } @@ -233,12 +233,12 @@ cmd_cmp (char *src, char *dest) ff = fopen (dest, "rb"); if (ff == NULL) { - grub_util_error ("open error."); + grub_util_error ("open error"); return; } if ((skip) && (fseeko (ff, skip, SEEK_SET))) - grub_util_error ("seek error."); + grub_util_error ("seek error"); read_file (src, cmp_hook); fclose (ff); @@ -286,13 +286,13 @@ fstest (char **images, int num_disks, int cmd, int n, char **args) for (i = 0; i < num_disks; i++) { if (grub_strlen (images[i]) + 7 > sizeof (host_file)) - grub_util_error ("Pathname %s too long.", images[i]); + grub_util_error ("pathname %s too long", images[i]); grub_sprintf (loop_name, "loop%d", i); grub_sprintf (host_file, "(host)%s", images[i]); if (execute_command ("loopback", 3, argv)) - grub_util_error ("loopback command fails."); + grub_util_error ("loopback command fails"); } grub_lvm_fini (); @@ -349,7 +349,7 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name); + fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ Usage: %s [OPTION]... IMAGE_PATH COMMANDS\n\ diff --git a/util/grub-mkdevicemap.c b/util/grub-mkdevicemap.c index b4febbb8d..c68482af1 100644 --- a/util/grub-mkdevicemap.c +++ b/util/grub-mkdevicemap.c @@ -84,7 +84,7 @@ usage (int status) { if (status) fprintf (stderr, - "Try ``%s --help'' for more information.\n", program_name); + "Try `%s --help' for more information.\n", program_name); else printf ("\ Usage: %s [OPTION]...\n\ diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index 3d1c6faac..fcd35afd4 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -96,7 +96,7 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name); + fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ Usage: %s [OPTIONS] FONT_FILES\n\ @@ -347,7 +347,7 @@ write_font (struct grub_font_info *font_info, char *output_file) file = fopen (output_file, "wb"); if (! file) - grub_util_error ("Can\'t write to file %s.", output_file); + grub_util_error ("can\'t write to file %s.", output_file); offset = 0; @@ -546,7 +546,7 @@ main (int argc, char *argv[]) a = strtoul (p, &p, 0); if (*p != '-') - grub_util_error ("Invalid font range"); + grub_util_error ("invalid font range"); b = strtoul (p + 1, &p, 0); if ((font_info.num_range & (GRUB_FONT_RANGE_BLOCK - 1)) == 0) font_info.ranges = xrealloc (font_info.ranges, @@ -561,7 +561,7 @@ main (int argc, char *argv[]) if (*p) { if (*p != ',') - grub_util_error ("Invalid font range"); + grub_util_error ("invalid font range"); else p++; } @@ -598,7 +598,7 @@ main (int argc, char *argv[]) } if (! output_file) - grub_util_error ("No output file is specified."); + grub_util_error ("no output file is specified"); if (FT_Init_FreeType (&ft_lib)) grub_util_error ("FT_Init_FreeType fails"); @@ -610,7 +610,7 @@ main (int argc, char *argv[]) if (FT_New_Face (ft_lib, argv[optind], font_index, &ft_face)) { - grub_util_info ("Can't open file %s, index %d\n", argv[optind], + grub_util_info ("can't open file %s, index %d", argv[optind], font_index); continue; } diff --git a/util/grub-mkpasswd-pbkdf2.c b/util/grub-mkpasswd-pbkdf2.c index b27a4e893..f5fdcca96 100644 --- a/util/grub-mkpasswd-pbkdf2.c +++ b/util/grub-mkpasswd-pbkdf2.c @@ -74,7 +74,7 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try ``grub-scrypt --help'' for more information.\n"); + fprintf (stderr, "Try `grub-scrypt --help' for more information.\n"); else printf ("\ Usage: grub-scrypt [OPTIONS]\n\ @@ -165,12 +165,12 @@ main (int argc, char *argv[]) bufhex = malloc (buflen * 2 + 1); if (!bufhex) - grub_util_error ("Out of memory"); + grub_util_error ("out of memory"); buf = malloc (buflen); if (!buf) { free (bufhex); - grub_util_error ("Out of memory"); + grub_util_error ("out of memory"); } salt = malloc (saltlen); @@ -178,7 +178,7 @@ main (int argc, char *argv[]) { free (bufhex); free (buf); - grub_util_error ("Out of memory"); + grub_util_error ("out of memory"); } salthex = malloc (saltlen * 2 + 1); if (!salthex) @@ -186,7 +186,7 @@ main (int argc, char *argv[]) free (salt); free (bufhex); free (buf); - grub_util_error ("Out of memory"); + grub_util_error ("out of memory"); } /* Disable echoing. Based on glibc. */ @@ -225,7 +225,7 @@ main (int argc, char *argv[]) /* Restore the original setting. */ if (tty_changed) (void) tcsetattr (fileno (in), TCSAFLUSH, &s); - grub_util_error ("Failure to read password"); + grub_util_error ("failure to read password"); } if (nr >= 1 && pass1[nr-1] == '\n') pass1[nr-1] = 0; @@ -249,7 +249,7 @@ main (int argc, char *argv[]) free (bufhex); free (salthex); free (salt); - grub_util_error ("Failure to read password"); + grub_util_error ("failure to read password"); } if (nr >= 1 && pass2[nr-1] == '\n') pass2[nr-1] = 0; @@ -264,7 +264,7 @@ main (int argc, char *argv[]) free (bufhex); free (salthex); free (salt); - grub_util_error ("Passwords don't match"); + grub_util_error ("passwords don't match"); } memset (pass2, 0, strlen (pass2)); free (pass2); @@ -286,7 +286,7 @@ main (int argc, char *argv[]) free (salthex); free (salt); fclose (f); - grub_util_error ("Couldn't retrieve random data for salt"); + grub_util_error ("couldn't retrieve random data for salt"); } rd = fread (salt, 1, saltlen, f); if (rd != saltlen) @@ -299,7 +299,7 @@ main (int argc, char *argv[]) free (salthex); free (salt); fclose (f); - grub_util_error ("Couldn't retrieve random data for salt"); + grub_util_error ("couldn't retrieve random data for salt"); } fclose (f); } @@ -321,7 +321,7 @@ main (int argc, char *argv[]) memset (salthex, 0, 2 * saltlen); free (salt); free (salthex); - grub_util_error ("Cryptographic error number %d", gcry_err); + grub_util_error ("cryptographic error number %d", gcry_err); } hexify (bufhex, buf, buflen); diff --git a/util/grub-mkrelpath.c b/util/grub-mkrelpath.c index 62e400814..327f0c866 100644 --- a/util/grub-mkrelpath.c +++ b/util/grub-mkrelpath.c @@ -34,7 +34,7 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name); + fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ Usage: %s [OPTIONS] PATH\n\ diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c index fb370d9ec..488ad9b23 100644 --- a/util/grub-pe2elf.c +++ b/util/grub-pe2elf.c @@ -40,7 +40,7 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name); + fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ Usage: %s [OPTIONS] input [output]\n\ @@ -182,7 +182,7 @@ write_section_data (FILE* fp, char *image, char name[5 + strlen (pe_shdr->name)]; if (num_sections >= MAX_SECTIONS) - grub_util_error ("Too many sections"); + grub_util_error ("too many sections"); sprintf (name, ".rel%s", pe_shdr->name); @@ -230,14 +230,14 @@ write_reloc_section (FILE* fp, char *image, if ((pe_rel->symtab_index >= pe_chdr->num_symbols) || (symtab_map[pe_rel->symtab_index] == -1)) - grub_util_error ("Invalid symbol"); + grub_util_error ("invalid symbol"); if (pe_rel->type == GRUB_PE32_REL_I386_DIR32) type = R_386_32; else if (pe_rel->type == GRUB_PE32_REL_I386_REL32) type = R_386_PC32; else - grub_util_error ("Unknown pe relocation type %d\n", pe_rel->type); + grub_util_error ("unknown pe relocation type %d\n", pe_rel->type); ofs = pe_rel->offset - pe_sec->virtual_address; addr = (grub_uint32_t *)(image + pe_sec->raw_data_offset + ofs); @@ -248,14 +248,14 @@ write_reloc_section (FILE* fp, char *image, code = image[pe_sec->raw_data_offset + ofs - 1]; if (((code != 0xe8) && (code != 0xe9)) || (*addr)) - grub_util_error ("Invalid relocation (%x %x)", code, *addr); + grub_util_error ("invalid relocation (%x %x)", code, *addr); modified = 1; if (symtab[symtab_map[pe_rel->symtab_index]].st_shndx) { if (symtab[symtab_map[pe_rel->symtab_index]].st_shndx != shdr[i].sh_info) - grub_util_error ("Cross section call is not allowed"); + grub_util_error ("cross section call is not allowed"); *addr = (symtab[symtab_map[pe_rel->symtab_index]].st_value - ofs - 4); @@ -440,7 +440,7 @@ convert_pe (FILE* fp, char *image) pe_chdr = (struct grub_pe32_coff_header *) image; if (grub_le_to_cpu16 (pe_chdr->machine) != GRUB_PE32_MACHINE_I386) - grub_util_error ("Invalid coff image"); + grub_util_error ("invalid coff image"); strtab = xmalloc (STRTAB_BLOCK); strtab_max = STRTAB_BLOCK; diff --git a/util/grub-probe.c b/util/grub-probe.c index 4ba8a98e5..879098542 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -84,7 +84,7 @@ probe_partmap (grub_disk_t disk) { if (disk->partition == NULL) { - grub_util_info ("No partition map found for %s", disk->name); + grub_util_info ("no partition map found for %s", disk->name); return; } @@ -113,17 +113,17 @@ probe (const char *path, char *device_name) { #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) if (! grub_util_check_char_device (device_name)) - grub_util_error ("%s is not a character device.\n", device_name); + grub_util_error ("%s is not a character device", device_name); #else if (! grub_util_check_block_device (device_name)) - grub_util_error ("%s is not a block device.\n", device_name); + grub_util_error ("%s is not a block device", device_name); #endif } else device_name = grub_guess_root_device (path); if (! device_name) - grub_util_error ("cannot find a device for %s (is /dev mounted?).\n", path); + grub_util_error ("cannot find a device for %s (is /dev mounted?)", path); if (print == PRINT_DEVICE) { @@ -133,7 +133,7 @@ probe (const char *path, char *device_name) drive_name = grub_util_get_grub_dev (device_name); if (! drive_name) - grub_util_error ("Cannot find a GRUB drive for %s. Check your device.map.\n", device_name); + grub_util_error ("cannot find a GRUB drive for %s. Check your device.map", device_name); if (print == PRINT_DRIVE) { @@ -309,7 +309,7 @@ usage (int status) { if (status) fprintf (stderr, - "Try ``%s --help'' for more information.\n", program_name); + "Try `%s --help' for more information.\n", program_name); else printf ("\ Usage: %s [OPTION]... [PATH|DEVICE]\n\ diff --git a/util/hostdisk.c b/util/hostdisk.c index c94f4237e..603445801 100644 --- a/util/hostdisk.c +++ b/util/hostdisk.c @@ -568,7 +568,7 @@ read_device_map (const char *dev_map) fp = fopen (dev_map, "r"); if (! fp) { - grub_util_info (_("Cannot open `%s'"), dev_map); + grub_util_info (_("cannot open `%s'"), dev_map); return; } @@ -639,7 +639,7 @@ read_device_map (const char *dev_map) symbolic links. */ map[drive].device = xmalloc (PATH_MAX); if (! realpath (p, map[drive].device)) - grub_util_error ("Cannot get the real path of `%s'", p); + grub_util_error ("cannot get the real path of `%s'", p); #else map[drive].device = xstrdup (p); #endif diff --git a/util/i386/efi/grub-mkimage.c b/util/i386/efi/grub-mkimage.c index 7f5141531..8fee3e8d9 100644 --- a/util/i386/efi/grub-mkimage.c +++ b/util/i386/efi/grub-mkimage.c @@ -778,7 +778,7 @@ make_reloc_section (FILE *out, Elf_Addr current_address, Elf_Ehdr *e, if ((ELF_R_TYPE (info) == R_X86_64_32) || (ELF_R_TYPE (info) == R_X86_64_32S)) { - grub_util_error ("Can\'t add fixup entry for R_X86_64_32(S)"); + grub_util_error ("can\'t add fixup entry for R_X86_64_32(S)"); } else if (ELF_R_TYPE (info) == R_X86_64_64) { @@ -1029,7 +1029,7 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try ``grub-mkimage --help'' for more information.\n"); + fprintf (stderr, "Try `grub-mkimage --help' for more information.\n"); else printf ("\ Usage: grub-mkimage -o FILE [OPTION]... [MODULES]\n\ diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index ebf1bc7ff..08807b4d1 100644 --- a/util/i386/pc/grub-mkimage.c +++ b/util/i386/pc/grub-mkimage.c @@ -289,7 +289,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], #ifdef GRUB_MACHINE_PCBIOS if (GRUB_KERNEL_MACHINE_LINK_ADDR + core_size > GRUB_MEMORY_MACHINE_UPPER) - grub_util_error (_("Core image is too big (%p > %p)\n"), + grub_util_error (_("core image is too big (%p > %p)"), GRUB_KERNEL_MACHINE_LINK_ADDR + core_size, GRUB_MEMORY_MACHINE_UPPER); #endif @@ -326,7 +326,7 @@ static void usage (int status) { if (status) - fprintf (stderr, _("Try ``%s --help'' for more information.\n"), program_name); + fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); else printf (_("\ Usage: grub-mkimage [OPTION]... [MODULES]\n\ diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c index 909a521eb..64b017296 100644 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@ -156,7 +156,7 @@ setup (const char *dir, sector, offset, length); if (offset != 0 || length != GRUB_DISK_SECTOR_SIZE) - grub_util_error (_("The first sector of the core file is not sector-aligned")); + grub_util_error (_("the first sector of the core file is not sector-aligned")); first_sector = sector; } @@ -170,7 +170,7 @@ setup (const char *dir, sector, offset, length, (unsigned) current_segment); if (offset != 0 || last_length != GRUB_DISK_SECTOR_SIZE) - grub_util_error (_("Non-sector-aligned data is found in the core file")); + grub_util_error (_("non-sector-aligned data is found in the core file")); if (block != first_block && (grub_le_to_cpu64 (prev->start) @@ -184,7 +184,7 @@ setup (const char *dir, block--; if (block->len) - grub_util_error (_("The sectors of the core file are too fragmented")); + grub_util_error (_("the sectors of the core file are too fragmented")); } last_length = length; @@ -195,7 +195,7 @@ setup (const char *dir, boot_path = grub_util_get_path (dir, boot_file); boot_size = grub_util_get_image_size (boot_path); if (boot_size != GRUB_DISK_SECTOR_SIZE) - grub_util_error (_("The size of `%s' is not %u"), + grub_util_error (_("the size of `%s' is not %u"), boot_path, GRUB_DISK_SECTOR_SIZE); boot_img = grub_util_read_image (boot_path); free (boot_path); @@ -212,9 +212,9 @@ setup (const char *dir, core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS); if (core_size < GRUB_DISK_SECTOR_SIZE) - grub_util_error (_("The size of `%s' is too small"), core_path); + grub_util_error (_("the size of `%s' is too small"), core_path); else if (core_size > 0xFFFF * GRUB_DISK_SECTOR_SIZE) - grub_util_error (_("The size of `%s' is too large"), core_path); + grub_util_error (_("the size of `%s' is too large"), core_path); core_img = grub_util_read_image (core_path); @@ -251,7 +251,7 @@ setup (const char *dir, grub_fs_t fs; fs = grub_fs_probe (dest_dev); if (! fs) - grub_util_error (_("Unable to identify a filesystem in %s; safety check can't be performed"), + grub_util_error (_("unable to identify a filesystem in %s; safety check can't be performed"), dest_dev->disk->name); if (! fs->reserved_first_sector) @@ -304,7 +304,7 @@ setup (const char *dir, bsd_part = -1; } else - grub_util_error (_("No DOS-style partitions found")); + grub_util_error (_("no DOS-style partitions found")); } else dos_part = bsd_part = -1; @@ -413,14 +413,14 @@ setup (const char *dir, unable_to_embed: if (must_embed) - grub_util_error (_("Embedding is not possible, but this is required when " - "the root device is on a RAID array or LVM volume.")); + grub_util_error (_("embedding is not possible, but this is required when " + "the root device is on a RAID array or LVM volume")); grub_util_warn (_("Embedding is not possible. GRUB can only be installed in this " "setup by using blocklists. However, blocklists are UNRELIABLE and " "its use is discouraged.")); if (! force) - grub_util_error (_("If you really want blocklists, use --force.")); + grub_util_error (_("if you really want blocklists, use --force")); /* Make sure that GRUB reads the identical image as the OS. */ tmp_img = xmalloc (core_size); @@ -495,7 +495,7 @@ unable_to_embed: } if (i == MAX_TRIES) - grub_util_error (_("Cannot read `%s' correctly"), core_path_dev); + grub_util_error (_("cannot read `%s' correctly"), core_path_dev); /* Clean out the blocklists. */ block = first_block; @@ -508,7 +508,7 @@ unable_to_embed: block--; if ((char *) block <= core_img) - grub_util_error (_("No terminator in the core image")); + grub_util_error (_("no terminator in the core image")); } /* Now read the core image to determine where the sectors are. */ @@ -519,13 +519,13 @@ unable_to_embed: file->read_hook = save_first_sector; if (grub_file_read (file, tmp_img, GRUB_DISK_SECTOR_SIZE) != GRUB_DISK_SECTOR_SIZE) - grub_util_error (_("Failed to read the first sector of the core image")); + grub_util_error (_("failed to read the first sector of the core image")); block = first_block; file->read_hook = save_blocklists; if (grub_file_read (file, tmp_img, core_size - GRUB_DISK_SECTOR_SIZE) != (grub_ssize_t) core_size - GRUB_DISK_SECTOR_SIZE) - grub_util_error (_("Failed to read the rest sectors of the core image")); + grub_util_error (_("failed to read the rest sectors of the core image")); grub_file_close (file); @@ -544,7 +544,7 @@ unable_to_embed: grub_util_info ("opening the core image `%s'", core_path); fp = fopen (core_path, "r+b"); if (! fp) - grub_util_error (_("Cannot open `%s'"), core_path); + grub_util_error (_("cannot open `%s'"), core_path); grub_util_write_image (core_img, GRUB_DISK_SECTOR_SIZE * 2, fp); fclose (fp); @@ -584,13 +584,13 @@ static void usage (int status) { if (status) - fprintf (stderr, _("Try ``%s --help'' for more information.\n"), program_name); + fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); else printf (_("\ Usage: grub-setup [OPTION]... DEVICE\n\ \n\ Set up images to boot from DEVICE.\n\ -DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\ +DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\ \n\ -b, --boot-image=FILE use FILE as the boot image [default=%s]\n\ -c, --core-image=FILE use FILE as the core image [default=%s]\n\ @@ -751,7 +751,7 @@ main (int argc, char *argv[]) char *tmp = get_device_name (root_dev); if (! tmp) - grub_util_error (_("Invalid root device `%s'"), root_dev); + grub_util_error (_("invalid root device `%s'"), root_dev); tmp = xstrdup (tmp); free (root_dev); @@ -764,7 +764,7 @@ main (int argc, char *argv[]) { grub_util_info ("guessing the root device failed, because of `%s'", grub_errmsg); - grub_util_error (_("Cannot guess the root device. Specify the option ``--root-device''.")); + grub_util_error (_("cannot guess the root device. Specify the option `--root-device'")); } } diff --git a/util/ieee1275/ofpath.c b/util/ieee1275/ofpath.c index e90488fc3..79a0e8be5 100644 --- a/util/ieee1275/ofpath.c +++ b/util/ieee1275/ofpath.c @@ -131,12 +131,12 @@ block_device_get_sysfs_path_and_link(const char *devicenode, snprintf(sysfs_path, sysfs_path_len, "/sys/block/%s", devicenode); if (!realpath (sysfs_path, rpath)) - grub_util_error ("Cannot get the real path of `%s'", sysfs_path); + grub_util_error ("cannot get the real path of `%s'", sysfs_path); strcat(rpath, "/device"); if (!realpath (rpath, sysfs_path)) - grub_util_error ("Cannot get the real path of `%s'", rpath); + grub_util_error ("cannot get the real path of `%s'", rpath); free (rpath); } @@ -247,12 +247,12 @@ vendor_is_ATA(const char *path) snprintf(buf, PATH_MAX, "%s/vendor", path); fd = open(buf, O_RDONLY); if (fd < 0) - grub_util_error ("Cannot open 'vendor' node of `%s'", path); + grub_util_error ("cannot open 'vendor' node of `%s'", path); memset(buf, 0, PATH_MAX); err = read(fd, buf, PATH_MAX); if (err < 0) - grub_util_error ("Cannot read 'vendor' node of `%s'", path); + grub_util_error ("cannot read 'vendor' node of `%s'", path); close(fd); @@ -288,7 +288,7 @@ check_sas (char *sysfs_path, int *tgt) fd = open(path, O_RDONLY); if (fd < 0) - grub_util_error("Cannot open SAS PHY ID '%s'\n", path); + grub_util_error("cannot open SAS PHY ID `%s'\n", path); memset (phy, 0, sizeof (phy)); read (fd, phy, sizeof (phy)); @@ -375,7 +375,7 @@ grub_util_devname_to_ofpath (char *devname) name_buf = xmalloc (PATH_MAX); name_buf = realpath (devname, name_buf); if (! name_buf) - grub_util_error ("Cannot get the real path of `%s'", devname); + grub_util_error ("cannot get the real path of `%s'", devname); device = get_basename (devname); devnode = strip_trailing_digits (devname); diff --git a/util/misc.c b/util/misc.c index 47dd8c78d..7f347c872 100644 --- a/util/misc.c +++ b/util/misc.c @@ -60,11 +60,12 @@ grub_util_warn (const char *fmt, ...) { va_list ap; - fprintf (stderr, "%s: warn: ", program_name); + fprintf (stderr, _("%s: warn:"), program_name); + fprintf (stderr, " "); va_start (ap, fmt); vfprintf (stderr, fmt, ap); va_end (ap); - fputc ('\n', stderr); + fprintf (stderr, ".\n"); fflush (stderr); } @@ -75,11 +76,12 @@ grub_util_info (const char *fmt, ...) { va_list ap; - fprintf (stderr, "%s: info: ", program_name); + fprintf (stderr, _("%s: info:"), program_name); + fprintf (stderr, " "); va_start (ap, fmt); vfprintf (stderr, fmt, ap); va_end (ap); - fputc ('\n', stderr); + fprintf (".\n", stderr); fflush (stderr); } } @@ -89,11 +91,12 @@ grub_util_error (const char *fmt, ...) { va_list ap; - fprintf (stderr, "%s: error: ", program_name); + fprintf (stderr, _("%s: error:"), program_name); + fprintf (stderr, " "); va_start (ap, fmt); vfprintf (stderr, fmt, ap); va_end (ap); - fputc ('\n', stderr); + fprintf (stderr, ".\n"); exit (1); } diff --git a/util/mkisofs/eltorito.c b/util/mkisofs/eltorito.c index a134dfc48..1d2a715e0 100644 --- a/util/mkisofs/eltorito.c +++ b/util/mkisofs/eltorito.c @@ -288,7 +288,7 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc) struct eltorito_boot_info bi_table; bootimage = fopen (de->whole_name, "r+b"); if (bootimage == NULL) - error (1, errno, _("Error opening boot image file '%s' for update"), + error (1, errno, _("Error opening boot image file `%s' for update"), de->whole_name); /* Compute checksum of boot image, sans 64 bytes */ total_len = 0; @@ -296,7 +296,7 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc) while ((len = fread (csum_buffer, 1, SECTOR_SIZE, bootimage)) > 0) { if (total_len & 3) - error (1, 0, _("Odd alignment at non-end-of-file in boot image '%s'"), + error (1, 0, _("Odd alignment at non-end-of-file in boot image `%s'"), de->whole_name); if (total_len < 64) memset (csum_buffer, 0, 64 - total_len); @@ -308,7 +308,7 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc) } if (total_len != de->size) - error (1, 0, _("Boot image file '%s' changed unexpectedly"), + error (1, 0, _("Boot image file `%s' changed unexpectedly"), de->whole_name); /* End of file, set position to byte 8 */ fseeko (bootimage, (off_t) 8, SEEK_SET); diff --git a/util/mkisofs/rock.c b/util/mkisofs/rock.c index f18b0bd83..a7a39f774 100644 --- a/util/mkisofs/rock.c +++ b/util/mkisofs/rock.c @@ -306,7 +306,7 @@ int deep_opt; * the symbolic link won't fit into one SL System Use Field * print an error message and continue with splited one */ - fprintf (stderr, _("symbolic link ``%s'' too long for one SL System Use Field, splitting"), cpnt); + fprintf (stderr, _("symbolic link `%s' too long for one SL System Use Field, splitting"), cpnt); } if(MAYBE_ADD_CE_ENTRY(SL_SIZE + sl_bytes)) add_CE_entry(); } diff --git a/util/mkisofs/write.c b/util/mkisofs/write.c index 5447229c8..e1cdd213e 100644 --- a/util/mkisofs/write.c +++ b/util/mkisofs/write.c @@ -158,7 +158,7 @@ void FDECL4(xfwrite, void *, buffer, uint64_t, count, uint64_t, size, FILE *, fi sprintf(nbuf, "%s_%02d", outfile, idx++); file = freopen(nbuf, "wb", file); if (file == NULL) - error (1, errno, _("Cannot open '%s'"), nbuf); + error (1, errno, _("Cannot open `%s'"), nbuf); } while(count) diff --git a/util/raid.c b/util/raid.c index 83a0ee6e2..ec3ecd26e 100644 --- a/util/raid.c +++ b/util/raid.c @@ -50,7 +50,7 @@ grub_util_getdiskname (int major, int minor) else if (major == SCSI_DISK0_MAJOR) sprintf (name, "/dev/sd%c", 'a' + minor / 16); else - grub_util_error ("Unknown device number: %d, %d", major, minor); + grub_util_error ("unknown device number: %d, %d", major, minor); return name; } @@ -72,7 +72,7 @@ grub_util_raid_getmembers (char *name) fd = open (devname, O_RDONLY); if (fd == -1) - grub_util_error ("Can't open %s: %s", devname, strerror (errno)); + grub_util_error ("can't open %s: %s", devname, strerror (errno)); free (devname); @@ -81,7 +81,7 @@ grub_util_raid_getmembers (char *name) grub_util_error ("ioctl RAID_VERSION error: %s", strerror (errno)); if (version.major != 0 || version.minor != 90) - grub_util_error ("Unsupported RAID version: %d.%d", + grub_util_error ("unsupported RAID version: %d.%d", version.major, version.minor); ret = ioctl (fd, GET_ARRAY_INFO, &info); diff --git a/util/sparc64/ieee1275/grub-mkimage.c b/util/sparc64/ieee1275/grub-mkimage.c index 96ddfe3d7..6907b8d8a 100644 --- a/util/sparc64/ieee1275/grub-mkimage.c +++ b/util/sparc64/ieee1275/grub-mkimage.c @@ -191,7 +191,7 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name); + fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ Usage: %s [OPTION]... [MODULES]\n\ diff --git a/util/sparc64/ieee1275/grub-setup.c b/util/sparc64/ieee1275/grub-setup.c index 9d8e67562..c39ea853f 100644 --- a/util/sparc64/ieee1275/grub-setup.c +++ b/util/sparc64/ieee1275/grub-setup.c @@ -161,7 +161,7 @@ setup (const char *prefix, const char *dir, grub_util_info ("first sector is <%llu,%u,%u>", sector, offset, length); if (offset != 0 || length != GRUB_DISK_SECTOR_SIZE) - grub_util_error ("The first sector of the core file " + grub_util_error ("the first sector of the core file " "is not sector-aligned"); first_sector = sector; @@ -176,7 +176,7 @@ setup (const char *prefix, const char *dir, grub_util_info ("saving <%llu,%u,%u>", sector, offset, length); if (offset != 0 || last_length != GRUB_DISK_SECTOR_SIZE) - grub_util_error ("Non-sector-aligned data is found in the core file"); + grub_util_error ("non-sector-aligned data is found in the core file"); if (block != first_block && (grub_be_to_cpu64 (prev->start) @@ -189,7 +189,7 @@ setup (const char *prefix, const char *dir, block--; if (block->len) - grub_util_error ("The sectors of the core file are too fragmented"); + grub_util_error ("the sectors of the core file are too fragmented"); } last_length = length; @@ -201,7 +201,7 @@ setup (const char *prefix, const char *dir, boot_path = grub_util_get_path (dir, boot_file); boot_size = grub_util_get_image_size (boot_path); if (boot_size != GRUB_DISK_SECTOR_SIZE) - grub_util_error ("The size of `%s' is not %d", + grub_util_error ("the size of `%s' is not %d", boot_path, GRUB_DISK_SECTOR_SIZE); boot_img = grub_util_read_image (boot_path); free (boot_path); @@ -219,7 +219,7 @@ setup (const char *prefix, const char *dir, core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS); if (core_size < GRUB_DISK_SECTOR_SIZE) - grub_util_error ("The size of `%s' is too small", core_path); + grub_util_error ("the size of `%s' is too small", core_path); core_img = grub_util_read_image (core_path); free (core_path); @@ -229,7 +229,7 @@ setup (const char *prefix, const char *dir, + GRUB_DISK_SECTOR_SIZE - sizeof (*block)); - grub_util_info ("root is '%s', dest is '%s', and dest_ofpath is '%s'", + grub_util_info ("root is `%s', dest is `%s', and dest_ofpath is `%s'", root, dest, dest_ofpath); /* Open the root device and the destination device. */ @@ -320,7 +320,7 @@ setup (const char *prefix, const char *dir, } if (i == MAX_TRIES) - grub_util_error ("Cannot read `%s' correctly", core_path); + grub_util_error ("cannot read `%s' correctly", core_path); /* Clean out the blocklists. */ block = first_block; @@ -332,7 +332,7 @@ setup (const char *prefix, const char *dir, block--; if ((char *) block <= core_img) - grub_util_error ("No terminator in the core image"); + grub_util_error ("no terminator in the core image"); } /* Now read the core image to determine where the sectors are. */ @@ -343,13 +343,13 @@ setup (const char *prefix, const char *dir, file->read_hook = save_first_sector; if (grub_file_read (file, tmp_img, GRUB_DISK_SECTOR_SIZE) != GRUB_DISK_SECTOR_SIZE) - grub_util_error ("Failed to read the first sector of the core image"); + grub_util_error ("failed to read the first sector of the core image"); block = first_block; file->read_hook = save_blocklists; if (grub_file_read (file, tmp_img, core_size - GRUB_DISK_SECTOR_SIZE) != (grub_ssize_t) core_size - GRUB_DISK_SECTOR_SIZE) - grub_util_error ("Failed to read the rest sectors of the core image"); + grub_util_error ("failed to read the rest sectors of the core image"); grub_file_close (file); @@ -368,7 +368,7 @@ setup (const char *prefix, const char *dir, grub_util_info ("opening the core image `%s'", core_path); fp = fopen (core_path, "r+b"); if (! fp) - grub_util_error ("Cannot open `%s'", core_path); + grub_util_error ("cannot open `%s'", core_path); grub_util_write_image (core_img, GRUB_DISK_SECTOR_SIZE, fp); fclose (fp); @@ -404,13 +404,13 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name); + fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ Usage: %s [OPTION]... DEVICE\n\ \n\ Set up images to boot from DEVICE.\n\ -DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\ +DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\ \n\ -b, --boot-image=FILE use FILE as the boot image [default=%s]\n\ -c, --core-image=FILE use FILE as the core image [default=%s]\n\ @@ -559,14 +559,14 @@ find_dest_dev (struct grub_setup_info *gp, char *argv[]) fprintf (stderr, "Invalid device `%s'.\n", argv[optind]); usage (1); } - grub_util_info ("transformed OS device '%s' into GRUB device '%s'", + grub_util_info ("transformed OS device `%s' into GRUB device `%s'", argv[optind], gp->dest_dev); } else { /* For simplicity. */ gp->dest_dev = xstrdup (gp->dest_dev); - grub_util_info ("Using '%s' as GRUB device", gp->dest_dev); + grub_util_info ("Using `%s' as GRUB device", gp->dest_dev); } } @@ -578,7 +578,7 @@ check_root_dev (struct grub_setup_info *gp) char *tmp = get_device_name (gp->root_dev); if (! tmp) - grub_util_error ("Invalid root device `%s'", gp->root_dev); + grub_util_error ("invalid root device `%s'", gp->root_dev); tmp = xstrdup (tmp); free (gp->root_dev); @@ -594,11 +594,11 @@ check_root_dev (struct grub_setup_info *gp) { grub_util_info ("guessing the root device failed, because of `%s'", grub_errmsg); - grub_util_error ("Cannot guess the root device. " - "Specify the option ``--root-device''."); + grub_util_error ("cannot guess the root device. " + "Specify the option `--root-device'"); } - grub_util_info ("Guessed root device '%s' and root_dev '%s' from " - "dir '%s'", root_device, gp->root_dev, dir); + grub_util_info ("guessed root device `%s' and root_dev `%s' from " + "dir `%s'", root_device, gp->root_dev, dir); } } From 409ae1c92a9eb99a653adc3dba377ae2ed7b024e Mon Sep 17 00:00:00 2001 From: carles Date: Sat, 16 Jan 2010 00:39:14 +0000 Subject: [PATCH 206/208] 2010-01-16 Carles Pina i Estany * util/grub-editenv.c (usage): Use `program_name' instead of hardcoded string. * util/grub-emu.c (usage): Likewise. * util/grub-mkpasswd-pbkdf2.c (usage): Likewise. * util/i386/efi/grub-mkimage.c (usage): Likewise. * util/i386/pc/grub-mkimage.c (usage): Likewise. * util/i386/pc/grub-setup.c (usage): Likewise. --- ChangeLog | 10 ++++++++++ util/grub-editenv.c | 6 +++--- util/grub-emu.c | 6 +++--- util/grub-mkpasswd-pbkdf2.c | 6 +++--- util/i386/efi/grub-mkimage.c | 6 +++--- util/i386/pc/grub-mkimage.c | 4 ++-- util/i386/pc/grub-setup.c | 3 ++- 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0effe5e10..793746986 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-01-16 Carles Pina i Estany + + * util/grub-editenv.c (usage): Use `program_name' instead of hardcoded + string. + * util/grub-emu.c (usage): Likewise. + * util/grub-mkpasswd-pbkdf2.c (usage): Likewise. + * util/i386/efi/grub-mkimage.c (usage): Likewise. + * util/i386/pc/grub-mkimage.c (usage): Likewise. + * util/i386/pc/grub-setup.c (usage): Likewise. + 2010-01-16 Carles Pina i Estany * util/misc.c (grub_util_warn): Gettextizze, print full stop after diff --git a/util/grub-editenv.c b/util/grub-editenv.c index ea0e4da19..f21042c97 100644 --- a/util/grub-editenv.c +++ b/util/grub-editenv.c @@ -69,10 +69,10 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try `grub-editenv --help' for more information.\n"); + fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ -Usage: grub-editenv [OPTIONS] [FILENAME] COMMAND\n\ +Usage: %s [OPTIONS] [FILENAME] COMMAND\n\ \n\ Tool to edit environment block.\n\ \nCommands:\n\ @@ -88,7 +88,7 @@ Tool to edit environment block.\n\ If not given explicitly, FILENAME defaults to %s.\n\ \n\ Report bugs to <%s>.\n", -DEFAULT_DIRECTORY "/" GRUB_ENVBLK_DEFCFG, PACKAGE_BUGREPORT); +program_name, DEFAULT_DIRECTORY "/" GRUB_ENVBLK_DEFCFG, PACKAGE_BUGREPORT); exit (status); } diff --git a/util/grub-emu.c b/util/grub-emu.c index a04aeae78..21fc6fa09 100644 --- a/util/grub-emu.c +++ b/util/grub-emu.c @@ -129,10 +129,10 @@ usage (int status) { if (status) fprintf (stderr, - "Try `grub-emu --help' for more information.\n"); + "Try `%s --help' for more information.\n", program_name); else printf ( - "Usage: grub-emu [OPTION]...\n" + "Usage: %s [OPTION]...\n" "\n" "GRUB emulator.\n" "\n" @@ -144,7 +144,7 @@ usage (int status) " -h, --help display this message and exit\n" " -V, --version print version information and exit\n" "\n" - "Report bugs to <%s>.\n", DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); + "Report bugs to <%s>.\n", program_name, DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); return status; } diff --git a/util/grub-mkpasswd-pbkdf2.c b/util/grub-mkpasswd-pbkdf2.c index f5fdcca96..82437fdca 100644 --- a/util/grub-mkpasswd-pbkdf2.c +++ b/util/grub-mkpasswd-pbkdf2.c @@ -74,16 +74,16 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try `grub-scrypt --help' for more information.\n"); + fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ -Usage: grub-scrypt [OPTIONS]\n\ +Usage: %s [OPTIONS]\n\ \nOptions:\n\ -c number, --iteration-count=number Number of PBKDF2 iterations\n\ -l number, --buflen=number Length of generated hash\n\ -s number, --salt=number Length of salt\n\ \n\ -Report bugs to <%s>.\n", PACKAGE_BUGREPORT); +Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT); exit (status); } diff --git a/util/i386/efi/grub-mkimage.c b/util/i386/efi/grub-mkimage.c index 8fee3e8d9..f8c0f152e 100644 --- a/util/i386/efi/grub-mkimage.c +++ b/util/i386/efi/grub-mkimage.c @@ -1029,10 +1029,10 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try `grub-mkimage --help' for more information.\n"); + fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ -Usage: grub-mkimage -o FILE [OPTION]... [MODULES]\n\ +Usage: %s -o FILE [OPTION]... [MODULES]\n\ \n\ Make a bootable image of GRUB.\n\ \n\ @@ -1044,7 +1044,7 @@ Make a bootable image of GRUB.\n\ -v, --verbose print verbose messages\n\ \n\ Report bugs to <%s>.\n\ -", GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); +", program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); exit (status); } diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index 08807b4d1..16b2c6619 100644 --- a/util/i386/pc/grub-mkimage.c +++ b/util/i386/pc/grub-mkimage.c @@ -329,7 +329,7 @@ usage (int status) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); else printf (_("\ -Usage: grub-mkimage [OPTION]... [MODULES]\n\ +Usage: %s [OPTION]... [MODULES]\n\ \n\ Make a bootable image of GRUB.\n\ \n\ @@ -343,7 +343,7 @@ Make a bootable image of GRUB.\n\ -v, --verbose print verbose messages\n\ \n\ Report bugs to <%s>.\n\ -"), GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); +"), program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); exit (status); } diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c index 64b017296..4e2517ef2 100644 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@ -587,7 +587,7 @@ usage (int status) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); else printf (_("\ -Usage: grub-setup [OPTION]... DEVICE\n\ +Usage: %s [OPTION]... DEVICE\n\ \n\ Set up images to boot from DEVICE.\n\ DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\ @@ -605,6 +605,7 @@ DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\ \n\ Report bugs to <%s>.\n\ "), + program_name, DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY, DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT); From e15c215ebd8df7096d114e84167b25a19f0fd9d0 Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Sat, 16 Jan 2010 11:57:47 +0100 Subject: [PATCH 207/208] =?UTF-8?q?2010-01-16=20=20Gr=C3=A9goire=20Sutre?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * genmk.rb (class SCRIPT): Replace option -i of sed by a pipe. --- ChangeLog | 4 ++++ genmk.rb | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 793746986..e71c4ec0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-16 GrĂ©goire Sutre + + * genmk.rb (class SCRIPT): Replace option -i of sed by a pipe. + 2010-01-16 Carles Pina i Estany * util/grub-editenv.c (usage): Use `program_name' instead of hardcoded diff --git a/genmk.rb b/genmk.rb index 810a2f1be..afd1582aa 100644 --- a/genmk.rb +++ b/genmk.rb @@ -370,8 +370,7 @@ class Script "CLEANFILES += #{@name} #{@name}: #{src} $(#{src}_DEPENDENCIES) config.status - ./config.status --file=#{name}:#{src} - sed -i -e 's,@pkglib_DATA@,$(pkglib_DATA),g' $@ + ./config.status --file=-:#{src} | sed -e 's,@pkglib_DATA@,$(pkglib_DATA),g' > $@ chmod +x $@ " From ea379330f97a1a2157bb5165a94d72fb83d3ca29 Mon Sep 17 00:00:00 2001 From: carles Date: Sun, 17 Jan 2010 14:42:19 +0000 Subject: [PATCH 208/208] 2010-01-17 Carles Pina i Estany * util/misc.c (grub_util_info): Fix the order of the parameters in a fprintf call. --- ChangeLog | 5 +++++ util/misc.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e71c4ec0e..748a55565 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-17 Carles Pina i Estany + + * util/misc.c (grub_util_info): Fix the order of the parameters in a + fprintf call. + 2010-01-16 GrĂ©goire Sutre * genmk.rb (class SCRIPT): Replace option -i of sed by a pipe. diff --git a/util/misc.c b/util/misc.c index 7f347c872..0b682c445 100644 --- a/util/misc.c +++ b/util/misc.c @@ -81,7 +81,7 @@ grub_util_info (const char *fmt, ...) va_start (ap, fmt); vfprintf (stderr, fmt, ap); va_end (ap); - fprintf (".\n", stderr); + fprintf (stderr, ".\n"); fflush (stderr); } }