From 8c317b270ff609a5a1e4f9776d6ea5ec9ba05ef5 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 30 Nov 2010 15:36:47 +0100 Subject: [PATCH 001/276] 2010-11-30 Robert Millan * grub-core/commands/echo.c (grub_cmd_echo): Call grub_refresh() after printing a message. --- ChangeLog | 5 +++++ grub-core/commands/echo.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 815004080..92071f3c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-11-30 Robert Millan + + * grub-core/commands/echo.c (grub_cmd_echo): Call grub_refresh() + after printing a message. + 2010-11-23 Colin Watson * include/grub/gpt_partition.h (GRUB_GPT_PARTITION_TYPE_BIOS_BOOT): diff --git a/grub-core/commands/echo.c b/grub-core/commands/echo.c index 13bc1c3fd..2842de603 100644 --- a/grub-core/commands/echo.c +++ b/grub-core/commands/echo.c @@ -1,7 +1,7 @@ /* echo.c - Command to display a line of text */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007 Free Software Foundation, Inc. + * Copyright (C) 2006,2007,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 @@ -106,6 +106,8 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args) if (newline) grub_printf ("\n"); + grub_refresh (); + return 0; } From c5c9cd3e7de4aa669231f6c18baf08530b54a7ed Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 30 Nov 2010 16:23:41 +0100 Subject: [PATCH 002/276] Add missing include --- ChangeLog | 4 ++-- grub-core/commands/echo.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 92071f3c5..faa5f31c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ 2010-11-30 Robert Millan - * grub-core/commands/echo.c (grub_cmd_echo): Call grub_refresh() - after printing a message. + * grub-core/commands/echo.c: Include `'. + (grub_cmd_echo): Call grub_refresh() after printing a message. 2010-11-23 Colin Watson diff --git a/grub-core/commands/echo.c b/grub-core/commands/echo.c index 2842de603..7ab9f92c6 100644 --- a/grub-core/commands/echo.c +++ b/grub-core/commands/echo.c @@ -21,6 +21,7 @@ #include #include #include +#include static const struct grub_arg_option options[] = { From 3a4253b2c47c48b561a316068ce652e0e2020715 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 30 Nov 2010 19:33:12 +0100 Subject: [PATCH 003/276] 2010-11-30 Robert Millan * grub-core/loader/i386/bsd.c (grub_cmd_freebsd_loadenv, grub_cmd_freebsd_module_elf): Check whether kernel is loaded using grub_loader_is_loaded(), rather than `kernel_type', which may still be `KERNEL_TYPE_NONE' under certain error conditions. --- ChangeLog | 8 ++++++++ grub-core/loader/i386/bsd.c | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e8bcdb549..33004a8c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-11-30 Robert Millan + + * grub-core/loader/i386/bsd.c + (grub_cmd_freebsd_loadenv, grub_cmd_freebsd_module_elf): Check + whether kernel is loaded using grub_loader_is_loaded(), rather + than `kernel_type', which may still be `KERNEL_TYPE_NONE' under + certain error conditions. + 2010-11-30 Robert Millan * grub-core/commands/echo.c: Include `'. diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index b7cf115d9..91cae418c 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -1611,7 +1611,7 @@ grub_cmd_freebsd_loadenv (grub_command_t cmd __attribute__ ((unused)), char *buf = 0, *curr, *next; int len; - if (kernel_type == KERNEL_TYPE_NONE) + if (! grub_loader_is_loaded ()) return grub_error (GRUB_ERR_BAD_ARGUMENT, "you need to load the kernel first"); @@ -1844,7 +1844,7 @@ grub_cmd_freebsd_module_elf (grub_command_t cmd __attribute__ ((unused)), grub_file_t file = 0; grub_err_t err; - if (kernel_type == KERNEL_TYPE_NONE) + if (! grub_loader_is_loaded ()) return grub_error (GRUB_ERR_BAD_ARGUMENT, "you need to load the kernel first"); From 3f0f38317b0ea76c1bdaf288f0a3e2a568476507 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Tue, 30 Nov 2010 21:35:59 +0100 Subject: [PATCH 004/276] * grub-core/commands/regexp.c (grub_cmd_regexp): Remove unused variable. * grub-core/commands/wildcard.c (match_files): Likewise. --- ChangeLog | 6 ++++++ grub-core/commands/regexp.c | 1 - grub-core/commands/wildcard.c | 3 --- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33004a8c8..4effc2ff4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-11-30 Szymon Janc + + * grub-core/commands/regexp.c (grub_cmd_regexp): Remove unused + variable. + * grub-core/commands/wildcard.c (match_files): Likewise. + 2010-11-30 Robert Millan * grub-core/loader/i386/bsd.c diff --git a/grub-core/commands/regexp.c b/grub-core/commands/regexp.c index f27a147af..83c0d8d43 100644 --- a/grub-core/commands/regexp.c +++ b/grub-core/commands/regexp.c @@ -87,7 +87,6 @@ set_matches (char **varnames, char *str, grub_size_t nmatches, static grub_err_t grub_cmd_regexp (grub_extcmd_context_t ctxt, int argc, char **args) { - int argn = 0; regex_t regex; int ret; grub_size_t s; diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c index 6eab333b3..32561abe6 100644 --- a/grub-core/commands/wildcard.c +++ b/grub-core/commands/wildcard.c @@ -266,7 +266,6 @@ match_files (const char *prefix, const char *suffix, const char *end, const regex_t *regexp) { int i; - int error; char **files; unsigned nfile; char *dir; @@ -440,8 +439,6 @@ wildcard_expand (const char *s, char ***strs) else if (*start == '/') /* no device part */ { - char **r; - unsigned n; char *root; char *prefix; From bf78d5b2512b462519c546cc9a7afa6804fb3b19 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Wed, 1 Dec 2010 22:42:11 +0100 Subject: [PATCH 005/276] 2010-12-01 Robert Millan * grub-core/fs/zfs/zfs.c: New file. * grub-core/fs/zfs/zfs_fletcher.c: Likewise. * grub-core/fs/zfs/zfs_lzjb.c: Likewise. * grub-core/fs/zfs/zfs_sha256.c: Likewise. * grub-core/fs/zfs/zfsinfo.c: Likewise. * include/grub/zfs/dmu.h: Likewise. * include/grub/zfs/dmu_objset.h: Likewise. * include/grub/zfs/dnode.h: Likewise. * include/grub/zfs/dsl_dataset.h: Likewise. * include/grub/zfs/dsl_dir.h: Likewise. * include/grub/zfs/sa_impl.h: Likewise. * include/grub/zfs/spa.h: Likewise. * include/grub/zfs/uberblock_impl.h: Likewise. * include/grub/zfs/vdev_impl.h: Likewise. * include/grub/zfs/zap_impl.h: Likewise. * include/grub/zfs/zap_leaf.h: Likewise. * include/grub/zfs/zfs.h: Likewise. * include/grub/zfs/zfs_acl.h: Likewise. * include/grub/zfs/zfs_znode.h: Likewise. * include/grub/zfs/zil.h: Likewise. * include/grub/zfs/zio.h: Likewise. * include/grub/zfs/zio_checksum.h: Likewise. * Makefile.util.def: Build ZFS into libgrubmods. * grub-core/Makefile.core.def: Build zfs.mod. --- ChangeLog | 29 + Makefile.util.def | 4 + grub-core/Makefile.core.def | 13 + grub-core/fs/zfs/zfs.c | 2546 +++++++++++++++++++++++++++++ grub-core/fs/zfs/zfs_fletcher.c | 86 + grub-core/fs/zfs/zfs_lzjb.c | 95 ++ grub-core/fs/zfs/zfs_sha256.c | 145 ++ grub-core/fs/zfs/zfsinfo.c | 414 +++++ include/grub/zfs/dmu.h | 120 ++ include/grub/zfs/dmu_objset.h | 44 + include/grub/zfs/dnode.h | 81 + include/grub/zfs/dsl_dataset.h | 53 + include/grub/zfs/dsl_dir.h | 49 + include/grub/zfs/sa_impl.h | 35 + include/grub/zfs/spa.h | 312 ++++ include/grub/zfs/uberblock_impl.h | 61 + include/grub/zfs/vdev_impl.h | 70 + include/grub/zfs/zap_impl.h | 112 ++ include/grub/zfs/zap_leaf.h | 104 ++ include/grub/zfs/zfs.h | 125 ++ include/grub/zfs/zfs_acl.h | 60 + include/grub/zfs/zfs_znode.h | 71 + include/grub/zfs/zil.h | 57 + include/grub/zfs/zio.h | 85 + include/grub/zfs/zio_checksum.h | 50 + 25 files changed, 4821 insertions(+) create mode 100644 grub-core/fs/zfs/zfs.c create mode 100644 grub-core/fs/zfs/zfs_fletcher.c create mode 100644 grub-core/fs/zfs/zfs_lzjb.c create mode 100644 grub-core/fs/zfs/zfs_sha256.c create mode 100644 grub-core/fs/zfs/zfsinfo.c create mode 100644 include/grub/zfs/dmu.h create mode 100644 include/grub/zfs/dmu_objset.h create mode 100644 include/grub/zfs/dnode.h create mode 100644 include/grub/zfs/dsl_dataset.h create mode 100644 include/grub/zfs/dsl_dir.h create mode 100644 include/grub/zfs/sa_impl.h create mode 100644 include/grub/zfs/spa.h create mode 100644 include/grub/zfs/uberblock_impl.h create mode 100644 include/grub/zfs/vdev_impl.h create mode 100644 include/grub/zfs/zap_impl.h create mode 100644 include/grub/zfs/zap_leaf.h create mode 100644 include/grub/zfs/zfs.h create mode 100644 include/grub/zfs/zfs_acl.h create mode 100644 include/grub/zfs/zfs_znode.h create mode 100644 include/grub/zfs/zil.h create mode 100644 include/grub/zfs/zio.h create mode 100644 include/grub/zfs/zio_checksum.h diff --git a/ChangeLog b/ChangeLog index 4effc2ff4..e35f9876d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2010-12-01 Robert Millan + + * grub-core/fs/zfs/zfs.c: New file. + * grub-core/fs/zfs/zfs_fletcher.c: Likewise. + * grub-core/fs/zfs/zfs_lzjb.c: Likewise. + * grub-core/fs/zfs/zfs_sha256.c: Likewise. + * grub-core/fs/zfs/zfsinfo.c: Likewise. + + * include/grub/zfs/dmu.h: Likewise. + * include/grub/zfs/dmu_objset.h: Likewise. + * include/grub/zfs/dnode.h: Likewise. + * include/grub/zfs/dsl_dataset.h: Likewise. + * include/grub/zfs/dsl_dir.h: Likewise. + * include/grub/zfs/sa_impl.h: Likewise. + * include/grub/zfs/spa.h: Likewise. + * include/grub/zfs/uberblock_impl.h: Likewise. + * include/grub/zfs/vdev_impl.h: Likewise. + * include/grub/zfs/zap_impl.h: Likewise. + * include/grub/zfs/zap_leaf.h: Likewise. + * include/grub/zfs/zfs.h: Likewise. + * include/grub/zfs/zfs_acl.h: Likewise. + * include/grub/zfs/zfs_znode.h: Likewise. + * include/grub/zfs/zil.h: Likewise. + * include/grub/zfs/zio.h: Likewise. + * include/grub/zfs/zio_checksum.h: Likewise. + + * Makefile.util.def: Build ZFS into libgrubmods. + * grub-core/Makefile.core.def: Build zfs.mod. + 2010-11-30 Szymon Janc * grub-core/commands/regexp.c (grub_cmd_regexp): Remove unused diff --git a/Makefile.util.def b/Makefile.util.def index 3e8ae16f5..74984e2e9 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -70,6 +70,10 @@ library = { common = grub-core/fs/ufs2.c; common = grub-core/fs/ufs.c; common = grub-core/fs/xfs.c; + common = grub-core/fs/zfs/zfs.c; + common = grub-core/fs/zfs/zfs_lzjb.c; + common = grub-core/fs/zfs/zfs_sha256.c; + common = grub-core/fs/zfs/zfs_fletcher.c; common = grub-core/lib/arg.c; common = grub-core/lib/crypto.c; common = grub-core/lib/envblk.c; diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index ce10ba372..37c0ce970 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1007,6 +1007,19 @@ module = { common = fs/xfs.c; }; +module = { + name = zfs; + common = fs/zfs/zfs.c; + common = fs/zfs/zfs_lzjb.c; + common = fs/zfs/zfs_sha256.c; + common = fs/zfs/zfs_fletcher.c; +}; + +module = { + name = zfsinfo; + common = fs/zfs/zfsinfo.c; +}; + module = { name = pxe; i386_pc = fs/i386/pc/pxe.c; diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c new file mode 100644 index 000000000..ce735a311 --- /dev/null +++ b/grub-core/fs/zfs/zfs.c @@ -0,0 +1,2546 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2010 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * Copyright (C) 2010 Robert Millan + * + * 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 3 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * The zfs plug-in routines for GRUB are: + * + * zfs_mount() - locates a valid uberblock of the root pool and reads + * in its MOS at the memory address MOS. + * + * zfs_open() - locates a plain file object by following the MOS + * and places its dnode at the memory address DNODE. + * + * zfs_read() - read in the data blocks pointed by the DNODE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ZPOOL_PROP_BOOTFS "bootfs" + +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) + +/* + * For nvlist manipulation. (from nvpair.h) + */ +#define NV_ENCODE_NATIVE 0 +#define NV_ENCODE_XDR 1 +#define NV_BIG_ENDIAN 0 +#define NV_LITTLE_ENDIAN 1 +#define DATA_TYPE_UINT64 8 +#define DATA_TYPE_STRING 9 +#define DATA_TYPE_NVLIST 19 +#define DATA_TYPE_NVLIST_ARRAY 20 + +#ifndef GRUB_UTIL +static grub_dl_t my_mod; +#endif + +#define P2PHASE(x, align) ((x) & ((align) - 1)) +#define DVA_OFFSET_TO_PHYS_SECTOR(offset) \ + ((offset + VDEV_LABEL_START_SIZE) >> SPA_MINBLOCKSHIFT) + +/* + * FAT ZAP data structures + */ +#define ZFS_CRC64_POLY 0xC96C5795D7870F42ULL /* ECMA-182, reflected form */ +#define ZAP_HASH_IDX(hash, n) (((n) == 0) ? 0 : ((hash) >> (64 - (n)))) +#define CHAIN_END 0xffff /* end of the chunk chain */ + +/* + * The amount of space within the chunk available for the array is: + * chunk size - space for type (1) - space for next pointer (2) + */ +#define ZAP_LEAF_ARRAY_BYTES (ZAP_LEAF_CHUNKSIZE - 3) + +#define ZAP_LEAF_HASH_SHIFT(bs) (bs - 5) +#define ZAP_LEAF_HASH_NUMENTRIES(bs) (1 << ZAP_LEAF_HASH_SHIFT(bs)) +#define LEAF_HASH(bs, h) \ + ((ZAP_LEAF_HASH_NUMENTRIES(bs)-1) & \ + ((h) >> (64 - ZAP_LEAF_HASH_SHIFT(bs)-l->l_hdr.lh_prefix_len))) + +/* + * The amount of space available for chunks is: + * block size shift - hash entry size (2) * number of hash + * entries - header space (2*chunksize) + */ +#define ZAP_LEAF_NUMCHUNKS(bs) \ + (((1<l_hash + ZAP_LEAF_HASH_NUMENTRIES(bs)))[idx] +#define ZAP_LEAF_ENTRY(l, bs, idx) (&ZAP_LEAF_CHUNK(l, bs, idx).l_entry) + + +/* + * Decompression Entry - lzjb + */ +#ifndef NBBY +#define NBBY 8 +#endif + +extern grub_err_t lzjb_decompress (void *, void *, grub_size_t, grub_size_t); + +typedef grub_err_t zfs_decomp_func_t (void *s_start, void *d_start, + grub_size_t s_len, grub_size_t d_len); +typedef struct decomp_entry +{ + char *name; + zfs_decomp_func_t *decomp_func; +} decomp_entry_t; + +typedef struct dnode_end +{ + dnode_phys_t dn; + grub_zfs_endian_t endian; +} dnode_end_t; + +struct grub_zfs_data +{ + /* cache for a file block of the currently zfs_open()-ed file */ + char *file_buf; + grub_uint64_t file_start; + grub_uint64_t file_end; + + /* cache for a dnode block */ + dnode_phys_t *dnode_buf; + dnode_phys_t *dnode_mdn; + grub_uint64_t dnode_start; + grub_uint64_t dnode_end; + grub_zfs_endian_t dnode_endian; + + uberblock_t current_uberblock; + grub_disk_t disk; + + dnode_end_t mos; + dnode_end_t mdn; + dnode_end_t dnode; + + grub_disk_addr_t vdev_phys_sector; +}; + +decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = { + {"inherit", NULL}, /* ZIO_COMPRESS_INHERIT */ + {"on", lzjb_decompress}, /* ZIO_COMPRESS_ON */ + {"off", NULL}, /* ZIO_COMPRESS_OFF */ + {"lzjb", lzjb_decompress}, /* ZIO_COMPRESS_LZJB */ + {"empty", NULL}, /* ZIO_COMPRESS_EMPTY */ + {"gzip", NULL}, /* ZIO_COMPRESS_GZIP */ +}; + +static grub_err_t zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, + void *buf, struct grub_zfs_data *data); + +/* + * Our own version of log2(). Same thing as highbit()-1. + */ +static int +zfs_log2 (grub_uint64_t num) +{ + int i = 0; + + while (num > 1) + { + i++; + num = num >> 1; + } + + return (i); +} + +/* Checksum Functions */ +static void +zio_checksum_off (const void *buf __attribute__ ((unused)), + grub_uint64_t size __attribute__ ((unused)), + grub_zfs_endian_t endian __attribute__ ((unused)), + zio_cksum_t * zcp) +{ + ZIO_SET_CHECKSUM (zcp, 0, 0, 0, 0); +} + +/* Checksum Table and Values */ +zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = { + {NULL, 0, 0, "inherit"}, + {NULL, 0, 0, "on"}, + {zio_checksum_off, 0, 0, "off"}, + {zio_checksum_SHA256, 1, 1, "label"}, + {zio_checksum_SHA256, 1, 1, "gang_header"}, + {NULL, 0, 0, "zilog"}, + {fletcher_2, 0, 0, "fletcher2"}, + {fletcher_4, 1, 0, "fletcher4"}, + {zio_checksum_SHA256, 1, 0, "SHA256"}, + {NULL, 0, 0, "zilog2"}, +}; + +/* + * zio_checksum_verify: Provides support for checksum verification. + * + * Fletcher2, Fletcher4, and SHA256 are supported. + * + */ +static grub_err_t +zio_checksum_verify (zio_cksum_t zc, grub_uint32_t checksum, + grub_zfs_endian_t endian, char *buf, int size) +{ + zio_eck_t *zec = (zio_eck_t *) (buf + size) - 1; + zio_checksum_info_t *ci = &zio_checksum_table[checksum]; + zio_cksum_t actual_cksum, expected_cksum; + + if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func == NULL) + { + grub_dprintf ("zfs", "unknown checksum function %d\n", checksum); + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "unknown checksum function %d", checksum); + } + + if (ci->ci_eck) + { + expected_cksum = zec->zec_cksum; + zec->zec_cksum = zc; + ci->ci_func (buf, size, endian, &actual_cksum); + zec->zec_cksum = expected_cksum; + zc = expected_cksum; + } + else + ci->ci_func (buf, size, endian, &actual_cksum); + + if ((actual_cksum.zc_word[0] != zc.zc_word[0]) + || (actual_cksum.zc_word[1] != zc.zc_word[1]) + || (actual_cksum.zc_word[2] != zc.zc_word[2]) + || (actual_cksum.zc_word[3] != zc.zc_word[3])) + { + grub_dprintf ("zfs", "checksum %d verification failed\n", checksum); + grub_dprintf ("zfs", "actual checksum %16llx %16llx %16llx %16llx\n", + (unsigned long long) actual_cksum.zc_word[0], + (unsigned long long) actual_cksum.zc_word[1], + (unsigned long long) actual_cksum.zc_word[2], + (unsigned long long) actual_cksum.zc_word[3]); + grub_dprintf ("zfs", "expected checksum %16llx %16llx %16llx %16llx\n", + (unsigned long long) zc.zc_word[0], + (unsigned long long) zc.zc_word[1], + (unsigned long long) zc.zc_word[2], + (unsigned long long) zc.zc_word[3]); + return grub_error (GRUB_ERR_BAD_FS, "checksum verification failed"); + } + + return GRUB_ERR_NONE; +} + +/* + * vdev_uberblock_compare takes two uberblock structures and returns an integer + * indicating the more recent of the two. + * Return Value = 1 if ub2 is more recent + * Return Value = -1 if ub1 is more recent + * The most recent uberblock is determined using its transaction number and + * timestamp. The uberblock with the highest transaction number is + * considered "newer". If the transaction numbers of the two blocks match, the + * timestamps are compared to determine the "newer" of the two. + */ +static int +vdev_uberblock_compare (uberblock_t * ub1, uberblock_t * ub2) +{ + grub_zfs_endian_t ub1_endian, ub2_endian; + if (grub_zfs_to_cpu64 (ub1->ub_magic, LITTLE_ENDIAN) == UBERBLOCK_MAGIC) + ub1_endian = LITTLE_ENDIAN; + else + ub1_endian = BIG_ENDIAN; + if (grub_zfs_to_cpu64 (ub2->ub_magic, LITTLE_ENDIAN) == UBERBLOCK_MAGIC) + ub2_endian = LITTLE_ENDIAN; + else + ub2_endian = BIG_ENDIAN; + + if (grub_zfs_to_cpu64 (ub1->ub_txg, ub1_endian) + < grub_zfs_to_cpu64 (ub2->ub_txg, ub2_endian)) + return (-1); + if (grub_zfs_to_cpu64 (ub1->ub_txg, ub1_endian) + > grub_zfs_to_cpu64 (ub2->ub_txg, ub2_endian)) + return (1); + + if (grub_zfs_to_cpu64 (ub1->ub_timestamp, ub1_endian) + < grub_zfs_to_cpu64 (ub2->ub_timestamp, ub2_endian)) + return (-1); + if (grub_zfs_to_cpu64 (ub1->ub_timestamp, ub1_endian) + > grub_zfs_to_cpu64 (ub2->ub_timestamp, ub2_endian)) + return (1); + + return (0); +} + +/* + * Three pieces of information are needed to verify an uberblock: the magic + * number, the version number, and the checksum. + * + * Currently Implemented: version number, magic number + * Need to Implement: checksum + * + */ +static grub_err_t +uberblock_verify (uberblock_phys_t * ub, int offset) +{ + uberblock_t *uber = &ub->ubp_uberblock; + grub_err_t err; + grub_zfs_endian_t endian = UNKNOWN_ENDIAN; + zio_cksum_t zc; + + if (grub_zfs_to_cpu64 (uber->ub_magic, LITTLE_ENDIAN) == UBERBLOCK_MAGIC + && grub_zfs_to_cpu64 (uber->ub_version, LITTLE_ENDIAN) > 0 + && grub_zfs_to_cpu64 (uber->ub_version, LITTLE_ENDIAN) <= SPA_VERSION) + endian = LITTLE_ENDIAN; + + if (grub_zfs_to_cpu64 (uber->ub_magic, BIG_ENDIAN) == UBERBLOCK_MAGIC + && grub_zfs_to_cpu64 (uber->ub_version, BIG_ENDIAN) > 0 + && grub_zfs_to_cpu64 (uber->ub_version, BIG_ENDIAN) <= SPA_VERSION) + endian = BIG_ENDIAN; + + if (endian == UNKNOWN_ENDIAN) + return grub_error (GRUB_ERR_BAD_FS, "invalid uberblock magic"); + + grub_memset (&zc, 0, sizeof (zc)); + + zc.zc_word[0] = grub_cpu_to_zfs64 (offset, endian); + err = zio_checksum_verify (zc, ZIO_CHECKSUM_LABEL, endian, + (char *) ub, UBERBLOCK_SIZE); + + return err; +} + +/* + * Find the best uberblock. + * Return: + * Success - Pointer to the best uberblock. + * Failure - NULL + */ +static uberblock_phys_t * +find_bestub (uberblock_phys_t * ub_array, grub_disk_addr_t sector) +{ + uberblock_phys_t *ubbest = NULL; + int i; + grub_disk_addr_t offset; + grub_err_t err = GRUB_ERR_NONE; + + for (i = 0; i < (VDEV_UBERBLOCK_RING >> VDEV_UBERBLOCK_SHIFT); i++) + { + offset = (sector << SPA_MINBLOCKSHIFT) + VDEV_PHYS_SIZE + + (i << VDEV_UBERBLOCK_SHIFT); + + err = uberblock_verify (&ub_array[i], offset); + if (err) + { + grub_errno = GRUB_ERR_NONE; + continue; + } + if (ubbest == NULL + || vdev_uberblock_compare (&(ub_array[i].ubp_uberblock), + &(ubbest->ubp_uberblock)) > 0) + ubbest = &ub_array[i]; + } + if (!ubbest) + grub_errno = err; + + return (ubbest); +} + +static inline grub_size_t +get_psize (blkptr_t * bp, grub_zfs_endian_t endian) +{ + return ((((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) >> 16) & 0xffff) + 1) + << SPA_MINBLOCKSHIFT); +} + +static grub_uint64_t +dva_get_offset (dva_t * dva, grub_zfs_endian_t endian) +{ + grub_dprintf ("zfs", "dva=%llx, %llx\n", + (unsigned long long) dva->dva_word[0], + (unsigned long long) dva->dva_word[1]); + return grub_zfs_to_cpu64 ((dva)->dva_word[1], + endian) << SPA_MINBLOCKSHIFT; +} + + +/* + * Read a block of data based on the gang block address dva, + * and put its data in buf. + * + */ +static grub_err_t +zio_read_gang (blkptr_t * bp, grub_zfs_endian_t endian, dva_t * dva, void *buf, + struct grub_zfs_data *data) +{ + zio_gbh_phys_t *zio_gb; + grub_uint64_t offset, sector; + unsigned i; + grub_err_t err; + zio_cksum_t zc; + + grub_memset (&zc, 0, sizeof (zc)); + + zio_gb = grub_malloc (SPA_GANGBLOCKSIZE); + if (!zio_gb) + return grub_errno; + grub_dprintf ("zfs", endian == LITTLE_ENDIAN ? "little-endian gang\n" + :"big-endian gang\n"); + offset = dva_get_offset (dva, endian); + sector = DVA_OFFSET_TO_PHYS_SECTOR (offset); + grub_dprintf ("zfs", "offset=%llx\n", (unsigned long long) offset); + + /* read in the gang block header */ + err = grub_disk_read (data->disk, sector, 0, SPA_GANGBLOCKSIZE, + (char *) zio_gb); + if (err) + { + grub_free (zio_gb); + return err; + } + + /* XXX */ + /* self checksuming the gang block header */ + ZIO_SET_CHECKSUM (&zc, DVA_GET_VDEV (dva), + dva_get_offset (dva, endian), bp->blk_birth, 0); + err = zio_checksum_verify (zc, ZIO_CHECKSUM_GANG_HEADER, endian, + (char *) zio_gb, SPA_GANGBLOCKSIZE); + if (err) + { + grub_free (zio_gb); + return err; + } + + endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1; + + for (i = 0; i < SPA_GBH_NBLKPTRS; i++) + { + if (zio_gb->zg_blkptr[i].blk_birth == 0) + continue; + + err = zio_read_data (&zio_gb->zg_blkptr[i], endian, buf, data); + if (err) + { + grub_free (zio_gb); + return err; + } + buf = (char *) buf + get_psize (&zio_gb->zg_blkptr[i], endian); + } + grub_free (zio_gb); + return GRUB_ERR_NONE; +} + +/* + * Read in a block of raw data to buf. + */ +static grub_err_t +zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, void *buf, + struct grub_zfs_data *data) +{ + int i, psize; + grub_err_t err = GRUB_ERR_NONE; + + psize = get_psize (bp, endian); + + /* pick a good dva from the block pointer */ + for (i = 0; i < SPA_DVAS_PER_BP; i++) + { + grub_uint64_t offset, sector; + + if (bp->blk_dva[i].dva_word[0] == 0 && bp->blk_dva[i].dva_word[1] == 0) + continue; + + if ((grub_zfs_to_cpu64 (bp->blk_dva[i].dva_word[1], endian)>>63) & 1) + err = zio_read_gang (bp, endian, &bp->blk_dva[i], buf, data); + else + { + /* read in a data block */ + offset = dva_get_offset (&bp->blk_dva[i], endian); + sector = DVA_OFFSET_TO_PHYS_SECTOR (offset); + err = grub_disk_read (data->disk, sector, 0, psize, buf); + } + if (!err) + return GRUB_ERR_NONE; + grub_errno = GRUB_ERR_NONE; + } + + if (!err) + err = grub_error (GRUB_ERR_BAD_FS, "couldn't find a valid DVA"); + grub_errno = err; + + return err; +} + +/* + * Read in a block of data, verify its checksum, decompress if needed, + * and put the uncompressed data in buf. + */ +static grub_err_t +zio_read (blkptr_t * bp, grub_zfs_endian_t endian, void **buf, + grub_size_t *size, struct grub_zfs_data *data) +{ + grub_size_t lsize, psize; + unsigned int comp; + char *compbuf = NULL; + grub_err_t err; + zio_cksum_t zc = bp->blk_cksum; + grub_uint32_t checksum; + + *buf = NULL; + + checksum = (grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 40) & 0xff; + comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0x7; + lsize = (BP_IS_HOLE(bp) ? 0 : + (((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1) + << SPA_MINBLOCKSHIFT)); + psize = get_psize (bp, endian); + + if (size) + *size = lsize; + + if (comp >= ZIO_COMPRESS_FUNCTIONS) + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "compression algorithm %u not supported\n", (unsigned int) comp); + + if (comp != ZIO_COMPRESS_OFF && decomp_table[comp].decomp_func == NULL) + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "compression algorithm %s not supported\n", decomp_table[comp].name); + + if (comp != ZIO_COMPRESS_OFF) + { + compbuf = grub_malloc (psize); + if (! compbuf) + return grub_errno; + } + else + compbuf = *buf = grub_malloc (lsize); + + grub_dprintf ("zfs", "endian = %d\n", endian); + err = zio_read_data (bp, endian, compbuf, data); + if (err) + { + grub_free (compbuf); + *buf = NULL; + return err; + } + + err = zio_checksum_verify (zc, checksum, endian, compbuf, psize); + if (err) + { + grub_dprintf ("zfs", "incorrect checksum\n"); + grub_free (compbuf); + *buf = NULL; + return err; + } + + if (comp != ZIO_COMPRESS_OFF) + { + *buf = grub_malloc (lsize); + if (!*buf) + { + grub_free (compbuf); + return grub_errno; + } + + err = decomp_table[comp].decomp_func (compbuf, *buf, psize, lsize); + grub_free (compbuf); + if (err) + { + grub_free (*buf); + *buf = NULL; + return err; + } + } + + return GRUB_ERR_NONE; +} + +/* + * Get the block from a block id. + * push the block onto the stack. + * + */ +static grub_err_t +dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, + grub_zfs_endian_t *endian_out, struct grub_zfs_data *data) +{ + int idx, level; + blkptr_t *bp_array = dn->dn.dn_blkptr; + int epbs = dn->dn.dn_indblkshift - SPA_BLKPTRSHIFT; + blkptr_t *bp, *tmpbuf = 0; + grub_zfs_endian_t endian; + grub_err_t err = GRUB_ERR_NONE; + + bp = grub_malloc (sizeof (blkptr_t)); + if (!bp) + return grub_errno; + + endian = dn->endian; + for (level = dn->dn.dn_nlevels - 1; level >= 0; level--) + { + grub_dprintf ("zfs", "endian = %d\n", endian); + idx = (blkid >> (epbs * level)) & ((1 << epbs) - 1); + *bp = bp_array[idx]; + if (bp_array != dn->dn.dn_blkptr) + { + grub_free (bp_array); + bp_array = 0; + } + + if (BP_IS_HOLE (bp)) + { + grub_size_t size = grub_zfs_to_cpu16 (dn->dn.dn_datablkszsec, + dn->endian) + << SPA_MINBLOCKSHIFT; + *buf = grub_malloc (size); + if (*buf) + { + err = grub_errno; + break; + } + grub_memset (*buf, 0, size); + endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1; + break; + } + if (level == 0) + { + grub_dprintf ("zfs", "endian = %d\n", endian); + err = zio_read (bp, endian, buf, 0, data); + endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1; + break; + } + grub_dprintf ("zfs", "endian = %d\n", endian); + err = zio_read (bp, endian, (void **) &tmpbuf, 0, data); + endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1; + if (err) + break; + bp_array = tmpbuf; + } + if (bp_array != dn->dn.dn_blkptr) + grub_free (bp_array); + if (endian_out) + *endian_out = endian; + + grub_free (bp); + return err; +} + +/* + * mzap_lookup: Looks up property described by "name" and returns the value + * in "value". + */ +static grub_err_t +mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian, + int objsize, char *name, grub_uint64_t * value) +{ + int i, chunks; + mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk; + + chunks = objsize / MZAP_ENT_LEN - 1; + for (i = 0; i < chunks; i++) + { + if (grub_strcmp (mzap_ent[i].mze_name, name) == 0) + { + *value = grub_zfs_to_cpu64 (mzap_ent[i].mze_value, endian); + return GRUB_ERR_NONE; + } + } + + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "couldn't find %s", name); +} + +static int +mzap_iterate (mzap_phys_t * zapobj, grub_zfs_endian_t endian, int objsize, + int NESTED_FUNC_ATTR (*hook) (const char *name, + grub_uint64_t val)) +{ + int i, chunks; + mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk; + + chunks = objsize / MZAP_ENT_LEN - 1; + for (i = 0; i < chunks; i++) + { + grub_dprintf ("zfs", "zap: name = %s, value = %llx, cd = %x\n", + mzap_ent[i].mze_name, (long long)mzap_ent[i].mze_value, + (int)mzap_ent[i].mze_cd); + if (hook (mzap_ent[i].mze_name, + grub_zfs_to_cpu64 (mzap_ent[i].mze_value, endian))) + return 1; + } + + return 0; +} + +static grub_uint64_t +zap_hash (grub_uint64_t salt, const char *name) +{ + static grub_uint64_t table[256]; + const grub_uint8_t *cp; + grub_uint8_t c; + grub_uint64_t crc = salt; + + if (table[128] == 0) + { + grub_uint64_t *ct; + int i, j; + for (i = 0; i < 256; i++) + { + for (ct = table + i, *ct = i, j = 8; j > 0; j--) + *ct = (*ct >> 1) ^ (-(*ct & 1) & ZFS_CRC64_POLY); + } + } + + for (cp = (const grub_uint8_t *) name; (c = *cp) != '\0'; cp++) + crc = (crc >> 8) ^ table[(crc ^ c) & 0xFF]; + + /* + * Only use 28 bits, since we need 4 bits in the cookie for the + * collision differentiator. We MUST use the high bits, since + * those are the onces that we first pay attention to when + * chosing the bucket. + */ + crc &= ~((1ULL << (64 - ZAP_HASHBITS)) - 1); + + return (crc); +} + +/* + * Only to be used on 8-bit arrays. + * array_len is actual len in bytes (not encoded le_value_length). + * buf is null-terminated. + */ +/* XXX */ +static int +zap_leaf_array_equal (zap_leaf_phys_t * l, grub_zfs_endian_t endian, + int blksft, int chunk, int array_len, const char *buf) +{ + int bseen = 0; + + while (bseen < array_len) + { + struct zap_leaf_array *la = &ZAP_LEAF_CHUNK (l, blksft, chunk).l_array; + int toread = MIN (array_len - bseen, ZAP_LEAF_ARRAY_BYTES); + + if (chunk >= ZAP_LEAF_NUMCHUNKS (blksft)) + return (0); + + if (grub_memcmp (la->la_array, buf + bseen, toread) != 0) + break; + chunk = grub_zfs_to_cpu16 (la->la_next, endian); + bseen += toread; + } + return (bseen == array_len); +} + +/* XXX */ +static grub_err_t +zap_leaf_array_get (zap_leaf_phys_t * l, grub_zfs_endian_t endian, int blksft, + int chunk, int array_len, char *buf) +{ + int bseen = 0; + + while (bseen < array_len) + { + struct zap_leaf_array *la = &ZAP_LEAF_CHUNK (l, blksft, chunk).l_array; + int toread = MIN (array_len - bseen, ZAP_LEAF_ARRAY_BYTES); + + if (chunk >= ZAP_LEAF_NUMCHUNKS (blksft)) + /* Don't use grub_error because this error is to be ignored. */ + return GRUB_ERR_BAD_FS; + + grub_memcpy (buf + bseen,la->la_array, toread); + chunk = grub_zfs_to_cpu16 (la->la_next, endian); + bseen += toread; + } + return GRUB_ERR_NONE; +} + + +/* + * Given a zap_leaf_phys_t, walk thru the zap leaf chunks to get the + * value for the property "name". + * + */ +/* XXX */ +static grub_err_t +zap_leaf_lookup (zap_leaf_phys_t * l, grub_zfs_endian_t endian, + int blksft, grub_uint64_t h, + const char *name, grub_uint64_t * value) +{ + grub_uint16_t chunk; + struct zap_leaf_entry *le; + + /* Verify if this is a valid leaf block */ + if (grub_zfs_to_cpu64 (l->l_hdr.lh_block_type, endian) != ZBT_LEAF) + return grub_error (GRUB_ERR_BAD_FS, "invalid leaf type"); + if (grub_zfs_to_cpu32 (l->l_hdr.lh_magic, endian) != ZAP_LEAF_MAGIC) + return grub_error (GRUB_ERR_BAD_FS, "invalid leaf magic"); + + for (chunk = grub_zfs_to_cpu16 (l->l_hash[LEAF_HASH (blksft, h)], endian); + chunk != CHAIN_END; chunk = le->le_next) + { + + if (chunk >= ZAP_LEAF_NUMCHUNKS (blksft)) + return grub_error (GRUB_ERR_BAD_FS, "invalid chunk number"); + + le = ZAP_LEAF_ENTRY (l, blksft, chunk); + + /* Verify the chunk entry */ + if (le->le_type != ZAP_CHUNK_ENTRY) + return grub_error (GRUB_ERR_BAD_FS, "invalid chunk entry"); + + if (grub_zfs_to_cpu64 (le->le_hash,endian) != h) + continue; + + grub_dprintf ("zfs", "fzap: length %d\n", (int) le->le_name_length); + + if (zap_leaf_array_equal (l, endian, blksft, + grub_zfs_to_cpu16 (le->le_name_chunk,endian), + grub_zfs_to_cpu16 (le->le_name_length, endian), + name)) + { + struct zap_leaf_array *la; + grub_uint8_t *ip; + + if (le->le_int_size != 8 || le->le_value_length != 1) + return grub_error (GRUB_ERR_BAD_FS, "invalid leaf chunk entry"); + + /* get the uint64_t property value */ + la = &ZAP_LEAF_CHUNK (l, blksft, le->le_value_chunk).l_array; + ip = la->la_array; + + *value = grub_be_to_cpu64 (la->la_array64); + + return GRUB_ERR_NONE; + } + } + + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "couldn't find %s", name); +} + + +/* Verify if this is a fat zap header block */ +static grub_err_t +zap_verify (zap_phys_t *zap) +{ + if (zap->zap_magic != (grub_uint64_t) ZAP_MAGIC) + return grub_error (GRUB_ERR_BAD_FS, "bad ZAP magic"); + + if (zap->zap_flags != 0) + return grub_error (GRUB_ERR_BAD_FS, "bad ZAP flags"); + + if (zap->zap_salt == 0) + return grub_error (GRUB_ERR_BAD_FS, "bad ZAP salt"); + + return GRUB_ERR_NONE; +} + +/* + * Fat ZAP lookup + * + */ +/* XXX */ +static grub_err_t +fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap, + char *name, grub_uint64_t * value, struct grub_zfs_data *data) +{ + zap_leaf_phys_t *l; + grub_uint64_t hash, idx, blkid; + int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, + zap_dnode->endian) << DNODE_SHIFT); + grub_err_t err; + grub_zfs_endian_t leafendian; + + err = zap_verify (zap); + if (err) + return err; + + hash = zap_hash (zap->zap_salt, name); + + /* get block id from index */ + if (zap->zap_ptrtbl.zt_numblks != 0) + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "external pointer tables not supported"); + idx = ZAP_HASH_IDX (hash, zap->zap_ptrtbl.zt_shift); + blkid = ((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))]; + + /* Get the leaf block */ + if ((1U << blksft) < sizeof (zap_leaf_phys_t)) + return grub_error (GRUB_ERR_BAD_FS, "ZAP leaf is too small"); + err = dmu_read (zap_dnode, blkid, (void **) &l, &leafendian, data); + if (err) + return err; + + err = zap_leaf_lookup (l, leafendian, blksft, hash, name, value); + grub_free (l); + return err; +} + +/* XXX */ +static int +fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap, + int NESTED_FUNC_ATTR (*hook) (const char *name, + grub_uint64_t val), + struct grub_zfs_data *data) +{ + zap_leaf_phys_t *l; + grub_uint64_t idx, blkid; + grub_uint16_t chunk; + int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, + zap_dnode->endian) << DNODE_SHIFT); + grub_err_t err; + grub_zfs_endian_t endian; + + if (zap_verify (zap)) + return 0; + + /* get block id from index */ + if (zap->zap_ptrtbl.zt_numblks != 0) + { + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "external pointer tables not supported"); + return 0; + } + /* Get the leaf block */ + if ((1U << blksft) < sizeof (zap_leaf_phys_t)) + { + grub_error (GRUB_ERR_BAD_FS, "ZAP leaf is too small"); + return 0; + } + for (idx = 0; idx < zap->zap_ptrtbl.zt_numblks; idx++) + { + blkid = ((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))]; + + err = dmu_read (zap_dnode, blkid, (void **) &l, &endian, data); + if (err) + { + grub_errno = GRUB_ERR_NONE; + continue; + } + + /* Verify if this is a valid leaf block */ + if (grub_zfs_to_cpu64 (l->l_hdr.lh_block_type, endian) != ZBT_LEAF) + { + grub_free (l); + continue; + } + if (grub_zfs_to_cpu32 (l->l_hdr.lh_magic, endian) != ZAP_LEAF_MAGIC) + { + grub_free (l); + continue; + } + + for (chunk = 0; chunk < ZAP_LEAF_NUMCHUNKS (blksft); chunk++) + { + char *buf; + struct zap_leaf_array *la; + struct zap_leaf_entry *le; + grub_uint64_t val; + le = ZAP_LEAF_ENTRY (l, blksft, chunk); + + /* Verify the chunk entry */ + if (le->le_type != ZAP_CHUNK_ENTRY) + continue; + + buf = grub_malloc (grub_zfs_to_cpu16 (le->le_name_length, endian) + + 1); + if (zap_leaf_array_get (l, endian, blksft, le->le_name_chunk, + le->le_name_length, buf)) + { + grub_free (buf); + continue; + } + buf[le->le_name_length] = 0; + + if (le->le_int_size != 8 + || grub_zfs_to_cpu16 (le->le_value_length, endian) != 1) + continue; + + /* get the uint64_t property value */ + la = &ZAP_LEAF_CHUNK (l, blksft, le->le_value_chunk).l_array; + val = grub_be_to_cpu64 (la->la_array64); + if (hook (buf, val)) + return 1; + grub_free (buf); + } + } + return 0; +} + + +/* + * Read in the data of a zap object and find the value for a matching + * property name. + * + */ +static grub_err_t +zap_lookup (dnode_end_t * zap_dnode, char *name, grub_uint64_t * val, + struct grub_zfs_data *data) +{ + grub_uint64_t block_type; + int size; + void *zapbuf; + grub_err_t err; + grub_zfs_endian_t endian; + + grub_dprintf ("zfs", "looking for '%s'\n", name); + + /* Read in the first block of the zap object data. */ + size = grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, + zap_dnode->endian) << SPA_MINBLOCKSHIFT; + err = dmu_read (zap_dnode, 0, &zapbuf, &endian, data); + if (err) + return err; + block_type = grub_zfs_to_cpu64 (*((grub_uint64_t *) zapbuf), endian); + + grub_dprintf ("zfs", "zap read\n"); + + if (block_type == ZBT_MICRO) + { + grub_dprintf ("zfs", "micro zap\n"); + err = (mzap_lookup (zapbuf, endian, size, name, val)); + grub_dprintf ("zfs", "returned %d\n", err); + grub_free (zapbuf); + return err; + } + else if (block_type == ZBT_HEADER) + { + grub_dprintf ("zfs", "fat zap\n"); + /* this is a fat zap */ + err = (fzap_lookup (zap_dnode, zapbuf, name, val, data)); + grub_dprintf ("zfs", "returned %d\n", err); + grub_free (zapbuf); + return err; + } + + return grub_error (GRUB_ERR_BAD_FS, "unknown ZAP type"); +} + +static int +zap_iterate (dnode_end_t * zap_dnode, + int NESTED_FUNC_ATTR (*hook) (const char *name, grub_uint64_t val), + struct grub_zfs_data *data) +{ + grub_uint64_t block_type; + int size; + void *zapbuf; + grub_err_t err; + int ret; + grub_zfs_endian_t endian; + + /* Read in the first block of the zap object data. */ + size = grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, zap_dnode->endian) << SPA_MINBLOCKSHIFT; + err = dmu_read (zap_dnode, 0, &zapbuf, &endian, data); + if (err) + return 0; + block_type = grub_zfs_to_cpu64 (*((grub_uint64_t *) zapbuf), endian); + + grub_dprintf ("zfs", "zap read\n"); + + if (block_type == ZBT_MICRO) + { + grub_dprintf ("zfs", "micro zap\n"); + ret = mzap_iterate (zapbuf, endian, size, hook); + grub_free (zapbuf); + return ret; + } + else if (block_type == ZBT_HEADER) + { + grub_dprintf ("zfs", "fat zap\n"); + /* this is a fat zap */ + ret = fzap_iterate (zap_dnode, zapbuf, hook, data); + grub_free (zapbuf); + return ret; + } + grub_error (GRUB_ERR_BAD_FS, "unknown ZAP type"); + return 0; +} + + +/* + * Get the dnode of an object number from the metadnode of an object set. + * + * Input + * mdn - metadnode to get the object dnode + * objnum - object number for the object dnode + * buf - data buffer that holds the returning dnode + */ +static grub_err_t +dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type, + dnode_end_t * buf, struct grub_zfs_data *data) +{ + grub_uint64_t blkid, blksz; /* the block id this object dnode is in */ + int epbs; /* shift of number of dnodes in a block */ + int idx; /* index within a block */ + dnode_phys_t *dnbuf; + grub_err_t err; + grub_zfs_endian_t endian; + + blksz = grub_zfs_to_cpu16 (mdn->dn.dn_datablkszsec, + mdn->endian) << SPA_MINBLOCKSHIFT; + epbs = zfs_log2 (blksz) - DNODE_SHIFT; + blkid = objnum >> epbs; + idx = objnum & ((1 << epbs) - 1); + + if (data->dnode_buf != NULL && grub_memcmp (data->dnode_mdn, mdn, + sizeof (*mdn)) == 0 + && objnum >= data->dnode_start && objnum < data->dnode_end) + { + grub_memmove (&(buf->dn), &(data->dnode_buf)[idx], DNODE_SIZE); + buf->endian = data->dnode_endian; + if (type && buf->dn.dn_type != type) + return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type"); + return GRUB_ERR_NONE; + } + + grub_dprintf ("zfs", "endian = %d, blkid=%llx\n", mdn->endian, + (unsigned long long) blkid); + err = dmu_read (mdn, blkid, (void **) &dnbuf, &endian, data); + if (err) + return err; + grub_dprintf ("zfs", "alive\n"); + + grub_free (data->dnode_buf); + grub_free (data->dnode_mdn); + data->dnode_mdn = grub_malloc (sizeof (*mdn)); + if (! data->dnode_mdn) + { + grub_errno = GRUB_ERR_NONE; + data->dnode_buf = 0; + } + else + { + grub_memcpy (data->dnode_mdn, mdn, sizeof (*mdn)); + data->dnode_buf = dnbuf; + data->dnode_start = blkid << epbs; + data->dnode_end = (blkid + 1) << epbs; + data->dnode_endian = endian; + } + + grub_memmove (&(buf->dn), &dnbuf[idx], DNODE_SIZE); + buf->endian = endian; + if (type && buf->dn.dn_type != type) + return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type"); + + return GRUB_ERR_NONE; +} + +/* + * Get the file dnode for a given file name where mdn is the meta dnode + * for this ZFS object set. When found, place the file dnode in dn. + * The 'path' argument will be mangled. + * + */ +static grub_err_t +dnode_get_path (dnode_end_t * mdn, const char *path_in, dnode_end_t * dn, + struct grub_zfs_data *data) +{ + grub_uint64_t objnum, version; + char *cname, ch; + grub_err_t err = GRUB_ERR_NONE; + char *path, *path_buf; + struct dnode_chain + { + struct dnode_chain *next; + dnode_end_t dn; + }; + struct dnode_chain *dnode_path = 0, *dn_new, *root; + + dn_new = grub_malloc (sizeof (*dn_new)); + if (! dn_new) + return grub_errno; + dn_new->next = 0; + dnode_path = root = dn_new; + + err = dnode_get (mdn, MASTER_NODE_OBJ, DMU_OT_MASTER_NODE, + &(dnode_path->dn), data); + if (err) + { + grub_free (dn_new); + return err; + } + + err = zap_lookup (&(dnode_path->dn), ZPL_VERSION_STR, &version, data); + if (err) + { + grub_free (dn_new); + return err; + } + if (version > ZPL_VERSION) + { + grub_free (dn_new); + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "too new ZPL version"); + } + + err = zap_lookup (&(dnode_path->dn), ZFS_ROOT_OBJ, &objnum, data); + if (err) + { + grub_free (dn_new); + return err; + } + + err = dnode_get (mdn, objnum, 0, &(dnode_path->dn), data); + if (err) + { + grub_free (dn_new); + return err; + } + + path = path_buf = grub_strdup (path_in); + if (!path_buf) + { + grub_free (dn_new); + return grub_errno; + } + + while (1) + { + /* skip leading slashes */ + while (*path == '/') + path++; + if (!*path) + break; + /* get the next component name */ + cname = path; + while (*path && *path != '/') + path++; + /* Skip dot. */ + if (cname + 1 == path && cname[0] == '.') + continue; + /* Handle double dot. */ + if (cname + 2 == path && cname[0] == '.' && cname[1] == '.') + { + if (dn_new->next) + { + dn_new = dnode_path; + dnode_path = dn_new->next; + grub_free (dn_new); + } + else + { + err = grub_error (GRUB_ERR_FILE_NOT_FOUND, + "can't resolve .."); + break; + } + continue; + } + + ch = *path; + *path = 0; /* ensure null termination */ + + if (dnode_path->dn.dn.dn_type != DMU_OT_DIRECTORY_CONTENTS) + { + grub_free (path_buf); + return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); + } + err = zap_lookup (&(dnode_path->dn), cname, &objnum, data); + if (err) + break; + + dn_new = grub_malloc (sizeof (*dn_new)); + if (! dn_new) + { + err = grub_errno; + break; + } + dn_new->next = dnode_path; + dnode_path = dn_new; + + objnum = ZFS_DIRENT_OBJ (objnum); + err = dnode_get (mdn, objnum, 0, &(dnode_path->dn), data); + if (err) + break; + + *path = ch; +#if 0 + if (((grub_zfs_to_cpu64(((znode_phys_t *) DN_BONUS (&dnode_path->dn.dn))->zp_mode, dnode_path->dn.endian) >> 12) & 0xf) == 0xa && ch) + { + char *oldpath = path, *oldpathbuf = path_buf; + path = path_buf + = grub_malloc (sizeof (dnode_path->dn.dn.dn_bonus) + - sizeof (znode_phys_t) + grub_strlen (oldpath) + 1); + if (!path_buf) + { + grub_free (oldpathbuf); + return grub_errno; + } + grub_memcpy (path, + (char *) DN_BONUS(&dnode_path->dn.dn) + sizeof (znode_phys_t), + sizeof (dnode_path->dn.dn.dn_bonus) - sizeof (znode_phys_t)); + path [sizeof (dnode_path->dn.dn.dn_bonus) - sizeof (znode_phys_t)] = 0; + grub_memcpy (path + grub_strlen (path), oldpath, + grub_strlen (oldpath) + 1); + + grub_free (oldpathbuf); + if (path[0] != '/') + { + dn_new = dnode_path; + dnode_path = dn_new->next; + grub_free (dn_new); + } + else while (dnode_path != root) + { + dn_new = dnode_path; + dnode_path = dn_new->next; + grub_free (dn_new); + } + } +#endif + } + + if (!err) + grub_memcpy (dn, &(dnode_path->dn), sizeof (*dn)); + + while (dnode_path) + { + dn_new = dnode_path->next; + grub_free (dnode_path); + dnode_path = dn_new; + } + grub_free (path_buf); + return err; +} + +#if 0 +/* + * Get the default 'bootfs' property value from the rootpool. + * + */ +static grub_err_t +get_default_bootfsobj (dnode_phys_t * mosmdn, grub_uint64_t * obj, + struct grub_zfs_data *data) +{ + grub_uint64_t objnum = 0; + dnode_phys_t *dn; + if (!dn) + return grub_errno; + + if ((grub_errno = dnode_get (mosmdn, DMU_POOL_DIRECTORY_OBJECT, + DMU_OT_OBJECT_DIRECTORY, dn, data))) + { + grub_free (dn); + return (grub_errno); + } + + /* + * find the object number for 'pool_props', and get the dnode + * of the 'pool_props'. + */ + if (zap_lookup (dn, DMU_POOL_PROPS, &objnum, data)) + { + grub_free (dn); + return (GRUB_ERR_BAD_FS); + } + if ((grub_errno = dnode_get (mosmdn, objnum, DMU_OT_POOL_PROPS, dn, data))) + { + grub_free (dn); + return (grub_errno); + } + if (zap_lookup (dn, ZPOOL_PROP_BOOTFS, &objnum, data)) + { + grub_free (dn); + return (GRUB_ERR_BAD_FS); + } + + if (!objnum) + { + grub_free (dn); + return (GRUB_ERR_BAD_FS); + } + + *obj = objnum; + return (0); +} +#endif +/* + * Given a MOS metadnode, get the metadnode of a given filesystem name (fsname), + * e.g. pool/rootfs, or a given object number (obj), e.g. the object number + * of pool/rootfs. + * + * If no fsname and no obj are given, return the DSL_DIR metadnode. + * If fsname is given, return its metadnode and its matching object number. + * If only obj is given, return the metadnode for this object number. + * + */ +static grub_err_t +get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname, + dnode_end_t * mdn, struct grub_zfs_data *data) +{ + grub_uint64_t objnum; + grub_err_t err; + + grub_dprintf ("zfs", "endian = %d\n", mosmdn->endian); + + err = dnode_get (mosmdn, DMU_POOL_DIRECTORY_OBJECT, + DMU_OT_OBJECT_DIRECTORY, mdn, data); + if (err) + return err; + + grub_dprintf ("zfs", "alive\n"); + + err = zap_lookup (mdn, DMU_POOL_ROOT_DATASET, &objnum, data); + if (err) + return err; + + grub_dprintf ("zfs", "alive\n"); + + err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data); + if (err) + return err; + + grub_dprintf ("zfs", "alive\n"); + + while (*fsname) + { + grub_uint64_t childobj; + char *cname, ch; + + while (*fsname == '/') + fsname++; + + if (! *fsname || *fsname == '@') + break; + + cname = fsname; + while (*fsname && !grub_isspace (*fsname) && *fsname != '/') + fsname++; + ch = *fsname; + *fsname = 0; + + childobj = grub_zfs_to_cpu64 ((((dsl_dir_phys_t *) DN_BONUS (&mdn->dn)))->dd_child_dir_zapobj, mdn->endian); + err = dnode_get (mosmdn, childobj, + DMU_OT_DSL_DIR_CHILD_MAP, mdn, data); + if (err) + return err; + + err = zap_lookup (mdn, cname, &objnum, data); + if (err) + return err; + + err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data); + if (err) + return err; + + *fsname = ch; + } + return GRUB_ERR_NONE; +} + +static grub_err_t +make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data) +{ + objset_phys_t *osp; + blkptr_t *bp; + grub_size_t ospsize; + grub_err_t err; + + grub_dprintf ("zfs", "endian = %d\n", mdn->endian); + + bp = &(((dsl_dataset_phys_t *) DN_BONUS (&mdn->dn))->ds_bp); + err = zio_read (bp, mdn->endian, (void **) &osp, &ospsize, data); + if (err) + return err; + if (ospsize < OBJSET_PHYS_SIZE_V14) + { + grub_free (osp); + return grub_error (GRUB_ERR_BAD_FS, "too small osp"); + } + + mdn->endian = (grub_zfs_to_cpu64 (bp->blk_prop, mdn->endian)>>63) & 1; + grub_memmove ((char *) &(mdn->dn), (char *) &osp->os_meta_dnode, DNODE_SIZE); + grub_free (osp); + return GRUB_ERR_NONE; +} + +static grub_err_t +dnode_get_fullpath (const char *fullpath, dnode_end_t * mdn, + grub_uint64_t *mdnobj, dnode_end_t * dn, int *isfs, + struct grub_zfs_data *data) +{ + char *fsname, *snapname; + const char *ptr_at, *filename; + grub_uint64_t headobj; + grub_err_t err; + + ptr_at = grub_strchr (fullpath, '@'); + if (! ptr_at) + { + *isfs = 1; + filename = 0; + snapname = 0; + fsname = grub_strdup (fullpath); + } + else + { + const char *ptr_slash = grub_strchr (ptr_at, '/'); + + *isfs = 0; + fsname = grub_malloc (ptr_at - fullpath + 1); + if (!fsname) + return grub_errno; + grub_memcpy (fsname, fullpath, ptr_at - fullpath); + fsname[ptr_at - fullpath] = 0; + if (ptr_at[1] && ptr_at[1] != '/') + { + snapname = grub_malloc (ptr_slash - ptr_at); + if (!snapname) + { + grub_free (fsname); + return grub_errno; + } + grub_memcpy (snapname, ptr_at + 1, ptr_slash - ptr_at - 1); + snapname[ptr_slash - ptr_at - 1] = 0; + } + else + snapname = 0; + if (ptr_slash) + filename = ptr_slash; + else + filename = "/"; + grub_dprintf ("zfs", "fsname = '%s' snapname='%s' filename = '%s'\n", + fsname, snapname, filename); + } + grub_dprintf ("zfs", "alive\n"); + err = get_filesystem_dnode (&(data->mos), fsname, dn, data); + if (err) + { + grub_free (fsname); + grub_free (snapname); + return err; + } + + grub_dprintf ("zfs", "alive\n"); + + headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&dn->dn))->dd_head_dataset_obj, dn->endian); + + grub_dprintf ("zfs", "endian = %d\n", mdn->endian); + + err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, mdn, data); + if (err) + { + grub_free (fsname); + grub_free (snapname); + return err; + } + grub_dprintf ("zfs", "endian = %d\n", mdn->endian); + + if (snapname) + { + grub_uint64_t snapobj; + + snapobj = grub_zfs_to_cpu64 (((dsl_dataset_phys_t *) DN_BONUS (&mdn->dn))->ds_snapnames_zapobj, mdn->endian); + + err = dnode_get (&(data->mos), snapobj, + DMU_OT_DSL_DS_SNAP_MAP, mdn, data); + if (!err) + err = zap_lookup (mdn, snapname, &headobj, data); + if (!err) + err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, mdn, data); + if (err) + { + grub_free (fsname); + grub_free (snapname); + return err; + } + } + + if (mdnobj) + *mdnobj = headobj; + + make_mdn (mdn, data); + + grub_dprintf ("zfs", "endian = %d\n", mdn->endian); + + if (*isfs) + { + grub_free (fsname); + grub_free (snapname); + return GRUB_ERR_NONE; + } + err = dnode_get_path (mdn, filename, dn, data); + grub_free (fsname); + grub_free (snapname); + return err; +} + +/* + * For a given XDR packed nvlist, verify the first 4 bytes and move on. + * + * An XDR packed nvlist is encoded as (comments from nvs_xdr_create) : + * + * encoding method/host endian (4 bytes) + * nvl_version (4 bytes) + * nvl_nvflag (4 bytes) + * encoded nvpairs: + * encoded size of the nvpair (4 bytes) + * decoded size of the nvpair (4 bytes) + * name string size (4 bytes) + * name string data (sizeof(NV_ALIGN4(string)) + * data type (4 bytes) + * # of elements in the nvpair (4 bytes) + * data + * 2 zero's for the last nvpair + * (end of the entire list) (8 bytes) + * + */ + +static int +nvlist_find_value (char *nvlist, char *name, int valtype, char **val, + grub_size_t *size_out, grub_size_t *nelm_out) +{ + int name_len, type, encode_size; + char *nvpair, *nvp_name; + + /* Verify if the 1st and 2nd byte in the nvlist are valid. */ + /* NOTE: independently of what endianness header announces all + subsequent values are big-endian. */ + if (nvlist[0] != NV_ENCODE_XDR || (nvlist[1] != NV_LITTLE_ENDIAN + && nvlist[1] != NV_BIG_ENDIAN)) + { + grub_dprintf ("zfs", "incorrect nvlist header\n"); + grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); + return 0; + } + + /* skip the header, nvl_version, and nvl_nvflag */ + nvlist = nvlist + 4 * 3; + /* + * Loop thru the nvpair list + * The XDR representation of an integer is in big-endian byte order. + */ + while ((encode_size = grub_be_to_cpu32 (*(grub_uint32_t *) nvlist))) + { + int nelm; + + nvpair = nvlist + 4 * 2; /* skip the encode/decode size */ + + name_len = grub_be_to_cpu32 (*(grub_uint32_t *) nvpair); + nvpair += 4; + + nvp_name = nvpair; + nvpair = nvpair + ((name_len + 3) & ~3); /* align */ + + type = grub_be_to_cpu32 (*(grub_uint32_t *) nvpair); + nvpair += 4; + + nelm = grub_be_to_cpu32 (*(grub_uint32_t *) nvpair); + if (nelm < 1) + return grub_error (GRUB_ERR_BAD_FS, "empty nvpair"); + + nvpair += 4; + + if ((grub_strncmp (nvp_name, name, name_len) == 0) && type == valtype) + { + *val = nvpair; + *size_out = encode_size; + if (nelm_out) + *nelm_out = nelm; + return 1; + } + + nvlist += encode_size; /* goto the next nvpair */ + } + return 0; +} + +int +grub_zfs_nvlist_lookup_uint64 (char *nvlist, char *name, grub_uint64_t * out) +{ + char *nvpair; + grub_size_t size; + int found; + + found = nvlist_find_value (nvlist, name, DATA_TYPE_UINT64, &nvpair, &size, 0); + if (!found) + return 0; + if (size < sizeof (grub_uint64_t)) + { + grub_error (GRUB_ERR_BAD_FS, "invalid uint64"); + return 0; + } + + *out = grub_be_to_cpu64 (*(grub_uint64_t *) nvpair); + return 1; +} + +char * +grub_zfs_nvlist_lookup_string (char *nvlist, char *name) +{ + char *nvpair; + char *ret; + grub_size_t slen; + grub_size_t size; + int found; + + found = nvlist_find_value (nvlist, name, DATA_TYPE_STRING, &nvpair, &size, 0); + if (!found) + return 0; + if (size < 4) + { + grub_error (GRUB_ERR_BAD_FS, "invalid string"); + return 0; + } + slen = grub_be_to_cpu32 (*(grub_uint32_t *) nvpair); + if (slen > size - 4) + slen = size - 4; + ret = grub_malloc (slen + 1); + if (!ret) + return 0; + grub_memcpy (ret, nvpair + 4, slen); + ret[slen] = 0; + return ret; +} + +char * +grub_zfs_nvlist_lookup_nvlist (char *nvlist, char *name) +{ + char *nvpair; + char *ret; + grub_size_t size; + int found; + + found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST, &nvpair, + &size, 0); + if (!found) + return 0; + ret = grub_zalloc (size + 3 * sizeof (grub_uint32_t)); + if (!ret) + return 0; + grub_memcpy (ret, nvlist, sizeof (grub_uint32_t)); + + grub_memcpy (ret + sizeof (grub_uint32_t), nvpair, size); + return ret; +} + +int +grub_zfs_nvlist_lookup_nvlist_array_get_nelm (char *nvlist, char *name) +{ + char *nvpair; + grub_size_t nelm, size; + int found; + + found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST, &nvpair, + &size, &nelm); + if (! found) + return -1; + return nelm; +} + +char * +grub_zfs_nvlist_lookup_nvlist_array (char *nvlist, char *name, + grub_size_t index) +{ + char *nvpair, *nvpairptr; + int found; + char *ret; + grub_size_t size; + unsigned i; + grub_size_t nelm; + + found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST, &nvpair, + &size, &nelm); + if (!found) + return 0; + if (index >= nelm) + { + grub_error (GRUB_ERR_OUT_OF_RANGE, "trying to lookup past nvlist array"); + return 0; + } + + nvpairptr = nvpair; + + for (i = 0; i < index; i++) + { + grub_uint32_t encode_size; + + /* skip the header, nvl_version, and nvl_nvflag */ + nvpairptr = nvpairptr + 4 * 2; + + while (nvpairptr < nvpair + size + && (encode_size = grub_be_to_cpu32 (*(grub_uint32_t *) nvpairptr))) + nvlist += encode_size; /* goto the next nvpair */ + + nvlist = nvlist + 4 * 2; /* skip the ending 2 zeros - 8 bytes */ + } + + if (nvpairptr >= nvpair + size + || nvpairptr + grub_be_to_cpu32 (*(grub_uint32_t *) (nvpairptr + 4 * 2)) + >= nvpair + size) + { + grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist array"); + return 0; + } + + ret = grub_zalloc (grub_be_to_cpu32 (*(grub_uint32_t *) (nvpairptr + 4 * 2)) + + 3 * sizeof (grub_uint32_t)); + if (!ret) + return 0; + grub_memcpy (ret, nvlist, sizeof (grub_uint32_t)); + + grub_memcpy (ret + sizeof (grub_uint32_t), nvpairptr, size); + return ret; +} + +static grub_err_t +zfs_fetch_nvlist (struct grub_zfs_data * data, char **nvlist) +{ + grub_err_t err; + + *nvlist = grub_malloc (VDEV_PHYS_SIZE); + /* Read in the vdev name-value pair list (112K). */ + err = grub_disk_read (data->disk, data->vdev_phys_sector, 0, + VDEV_PHYS_SIZE, *nvlist); + if (err) + { + grub_free (*nvlist); + *nvlist = 0; + return err; + } + return GRUB_ERR_NONE; +} + +/* + * Check the disk label information and retrieve needed vdev name-value pairs. + * + */ +static grub_err_t +check_pool_label (struct grub_zfs_data *data) +{ + grub_uint64_t pool_state, txg = 0; + char *nvlist; +#if 0 + char *nv; +#endif + grub_uint64_t diskguid; + grub_uint64_t version; + int found; + grub_err_t err; + + err = zfs_fetch_nvlist (data, &nvlist); + if (err) + return err; + + grub_dprintf ("zfs", "check 2 passed\n"); + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_STATE, + &pool_state); + if (! found) + { + grub_free (nvlist); + if (! grub_errno) + grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_POOL_STATE " not found"); + return grub_errno; + } + grub_dprintf ("zfs", "check 3 passed\n"); + + if (pool_state == POOL_STATE_DESTROYED) + { + grub_free (nvlist); + return grub_error (GRUB_ERR_BAD_FS, "zpool is marked as destroyed"); + } + grub_dprintf ("zfs", "check 4 passed\n"); + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_TXG, &txg); + if (!found) + { + grub_free (nvlist); + if (! grub_errno) + grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_POOL_TXG " not found"); + return grub_errno; + } + grub_dprintf ("zfs", "check 6 passed\n"); + + /* not an active device */ + if (txg == 0) + { + grub_free (nvlist); + return grub_error (GRUB_ERR_BAD_FS, "zpool isn't active"); + } + grub_dprintf ("zfs", "check 7 passed\n"); + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_VERSION, + &version); + if (! found) + { + grub_free (nvlist); + if (! grub_errno) + grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_VERSION " not found"); + return grub_errno; + } + grub_dprintf ("zfs", "check 8 passed\n"); + + if (version > SPA_VERSION) + { + grub_free (nvlist); + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "too new version %llu > %llu", + (unsigned long long) version, + (unsigned long long) SPA_VERSION); + } + grub_dprintf ("zfs", "check 9 passed\n"); +#if 0 + if (nvlist_lookup_value (nvlist, ZPOOL_CONFIG_VDEV_TREE, &nv, + DATA_TYPE_NVLIST, NULL)) + { + grub_free (vdev); + return (GRUB_ERR_BAD_FS); + } + grub_dprintf ("zfs", "check 10 passed\n"); +#endif + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_GUID, &diskguid); + if (! found) + { + grub_free (nvlist); + if (! grub_errno) + grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_GUID " not found"); + return grub_errno; + } + grub_dprintf ("zfs", "check 11 passed\n"); + + grub_free (nvlist); + + return GRUB_ERR_NONE; +} + +static void +zfs_unmount (struct grub_zfs_data *data) +{ + grub_free (data->dnode_buf); + grub_free (data->dnode_mdn); + grub_free (data->file_buf); + grub_free (data); +} + +/* + * zfs_mount() locates a valid uberblock of the root pool and read in its MOS + * to the memory address MOS. + * + */ +static struct grub_zfs_data * +zfs_mount (grub_device_t dev) +{ + struct grub_zfs_data *data = 0; + int label = 0; + uberblock_phys_t *ub_array, *ubbest = NULL; + vdev_boot_header_t *bh; + objset_phys_t *osp = 0; + grub_size_t ospsize; + grub_err_t err; + int vdevnum; + + if (! dev->disk) + { + grub_error (GRUB_ERR_BAD_DEVICE, "not a disk"); + return 0; + } + + data = grub_malloc (sizeof (*data)); + if (!data) + return 0; + grub_memset (data, 0, sizeof (*data)); +#if 0 + /* if it's our first time here, zero the best uberblock out */ + if (data->best_drive == 0 && data->best_part == 0 && find_best_root) + grub_memset (¤t_uberblock, 0, sizeof (uberblock_t)); +#endif + + data->disk = dev->disk; + + ub_array = grub_malloc (VDEV_UBERBLOCK_RING); + if (!ub_array) + { + zfs_unmount (data); + return 0; + } + + bh = grub_malloc (VDEV_BOOT_HEADER_SIZE); + if (!bh) + { + zfs_unmount (data); + grub_free (ub_array); + return 0; + } + + vdevnum = VDEV_LABELS; + + /* Don't check back labels on CDROM. */ + if (grub_disk_get_size (dev->disk) == GRUB_DISK_SIZE_UNKNOWN) + vdevnum = VDEV_LABELS / 2; + + for (label = 0; ubbest == NULL && label < vdevnum; label++) + { + grub_zfs_endian_t ub_endian = UNKNOWN_ENDIAN; + grub_dprintf ("zfs", "label %d\n", label); + + data->vdev_phys_sector + = label * (sizeof (vdev_label_t) >> SPA_MINBLOCKSHIFT) + + ((VDEV_SKIP_SIZE + VDEV_BOOT_HEADER_SIZE) >> SPA_MINBLOCKSHIFT) + + (label < VDEV_LABELS / 2 ? 0 : grub_disk_get_size (dev->disk) + - VDEV_LABELS * (sizeof (vdev_label_t) >> SPA_MINBLOCKSHIFT)); + + /* Read in the uberblock ring (128K). */ + err = grub_disk_read (data->disk, data->vdev_phys_sector + + (VDEV_PHYS_SIZE >> SPA_MINBLOCKSHIFT), + 0, VDEV_UBERBLOCK_RING, (char *) ub_array); + if (err) + { + grub_errno = GRUB_ERR_NONE; + continue; + } + grub_dprintf ("zfs", "label ok %d\n", label); + + ubbest = find_bestub (ub_array, data->vdev_phys_sector); + if (!ubbest) + { + grub_dprintf ("zfs", "No uberblock found\n"); + grub_errno = GRUB_ERR_NONE; + continue; + } + ub_endian = (grub_zfs_to_cpu64 (ubbest->ubp_uberblock.ub_magic, + LITTLE_ENDIAN) == UBERBLOCK_MAGIC + ? LITTLE_ENDIAN : BIG_ENDIAN); + err = zio_read (&ubbest->ubp_uberblock.ub_rootbp, + ub_endian, + (void **) &osp, &ospsize, data); + if (err) + { + grub_dprintf ("zfs", "couldn't zio_read\n"); + grub_errno = GRUB_ERR_NONE; + continue; + } + + if (ospsize < OBJSET_PHYS_SIZE_V14) + { + grub_dprintf ("zfs", "osp too small\n"); + grub_free (osp); + continue; + } + grub_dprintf ("zfs", "ubbest %p\n", ubbest); + + err = check_pool_label (data); + if (err) + { + grub_errno = GRUB_ERR_NONE; + continue; + } +#if 0 + if (find_best_root && + vdev_uberblock_compare (&ubbest->ubp_uberblock, + &(current_uberblock)) <= 0) + continue; +#endif + /* Got the MOS. Save it at the memory addr MOS. */ + grub_memmove (&(data->mos.dn), &osp->os_meta_dnode, DNODE_SIZE); + data->mos.endian = (grub_zfs_to_cpu64 (ubbest->ubp_uberblock.ub_rootbp.blk_prop, ub_endian) >> 63) & 1; + grub_memmove (&(data->current_uberblock), + &ubbest->ubp_uberblock, sizeof (uberblock_t)); + grub_free (ub_array); + grub_free (bh); + grub_free (osp); + return data; + } + grub_error (GRUB_ERR_BAD_FS, "couldn't find a valid label"); + zfs_unmount (data); + grub_free (ub_array); + grub_free (bh); + grub_free (osp); + + return 0; +} + +grub_err_t +grub_zfs_fetch_nvlist (grub_device_t dev, char **nvlist) +{ + struct grub_zfs_data *zfs; + grub_err_t err; + + zfs = zfs_mount (dev); + if (!zfs) + return grub_errno; + err = zfs_fetch_nvlist (zfs, nvlist); + zfs_unmount (zfs); + return err; +} + +static grub_err_t +zfs_label (grub_device_t device, char **label) +{ + char *nvlist; + grub_err_t err; + struct grub_zfs_data *data; + + data = zfs_mount (device); + if (! data) + return grub_errno; + + err = zfs_fetch_nvlist (data, &nvlist); + if (err) + { + zfs_unmount (data); + return err; + } + + *label = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME); + grub_free (nvlist); + zfs_unmount (data); + return grub_errno; +} + +static grub_err_t +zfs_uuid (grub_device_t device, char **uuid) +{ + char *nvlist; + int found; + struct grub_zfs_data *data; + grub_uint64_t guid; + grub_err_t err; + + *uuid = 0; + + data = zfs_mount (device); + if (! data) + return grub_errno; + + err = zfs_fetch_nvlist (data, &nvlist); + if (err) + { + zfs_unmount (data); + return err; + } + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_GUID, &guid); + if (! found) + return grub_errno; + grub_free (nvlist); + *uuid = grub_xasprintf ("%016llx", (long long unsigned) guid); + zfs_unmount (data); + if (! *uuid) + return grub_errno; + return GRUB_ERR_NONE; +} + +/* + * zfs_open() locates a file in the rootpool by following the + * MOS and places the dnode of the file in the memory address DNODE. + */ +static grub_err_t +grub_zfs_open (struct grub_file *file, const char *fsfilename) +{ + struct grub_zfs_data *data; + grub_err_t err; + int isfs; + + data = zfs_mount (file->device); + if (! data) + return grub_errno; + + err = dnode_get_fullpath (fsfilename, &(data->mdn), 0, + &(data->dnode), &isfs, data); + if (err) + { + zfs_unmount (data); + return err; + } + + if (isfs) + { + zfs_unmount (data); + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "Missing @ or / separator"); + } + + /* We found the dnode for this file. Verify if it is a plain file. */ + if (data->dnode.dn.dn_type != DMU_OT_PLAIN_FILE_CONTENTS) + { + zfs_unmount (data); + return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a file"); + } + + /* get the file size and set the file position to 0 */ + + /* + * For DMU_OT_SA we will need to locate the SIZE attribute + * attribute, which could be either in the bonus buffer + * or the "spill" block. + */ + if (data->dnode.dn.dn_bonustype == DMU_OT_SA) + { + sa_hdr_phys_t *sahdrp; + int hdrsize; + + if (data->dnode.dn.dn_bonuslen != 0) + { + sahdrp = (sa_hdr_phys_t *) DN_BONUS (&data->dnode.dn); + } + else if (data->dnode.dn.dn_flags & DNODE_FLAG_SPILL_BLKPTR) + { + blkptr_t *bp = &data->dnode.dn.dn_spill; + + err = zio_read (bp, data->dnode.endian, (void **) &sahdrp, NULL, data); + if (err) + return err; + } + else + { + return grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt"); + } + + hdrsize = SA_HDR_SIZE (sahdrp); + file->size = *(grub_uint64_t *) ((char *) sahdrp + hdrsize + SA_SIZE_OFFSET); + } + else + { + file->size = grub_zfs_to_cpu64 (((znode_phys_t *) DN_BONUS (&data->dnode.dn))->zp_size, data->dnode.endian); + } + + file->data = data; + file->offset = 0; + +#ifndef GRUB_UTIL + grub_dl_ref (my_mod); +#endif + + return GRUB_ERR_NONE; +} + +static grub_ssize_t +grub_zfs_read (grub_file_t file, char *buf, grub_size_t len) +{ + struct grub_zfs_data *data = (struct grub_zfs_data *) file->data; + int blksz, movesize; + grub_size_t length; + grub_size_t read; + grub_err_t err; + + if (data->file_buf == NULL) + { + data->file_buf = grub_malloc (SPA_MAXBLOCKSIZE); + if (!data->file_buf) + return -1; + data->file_start = data->file_end = 0; + } + + /* + * If offset is in memory, move it into the buffer provided and return. + */ + if (file->offset >= data->file_start + && file->offset + len <= data->file_end) + { + grub_memmove (buf, data->file_buf + file->offset - data->file_start, + len); + return len; + } + + blksz = grub_zfs_to_cpu16 (data->dnode.dn.dn_datablkszsec, + data->dnode.endian) << SPA_MINBLOCKSHIFT; + + /* + * Entire Dnode is too big to fit into the space available. We + * will need to read it in chunks. This could be optimized to + * read in as large a chunk as there is space available, but for + * now, this only reads in one data block at a time. + */ + length = len; + read = 0; + while (length) + { + /* + * Find requested blkid and the offset within that block. + */ + grub_uint64_t blkid = grub_divmod64 (file->offset + read, blksz, 0); + grub_free (data->file_buf); + data->file_buf = 0; + + err = dmu_read (&(data->dnode), blkid, (void **) &(data->file_buf), + 0, data); + if (err) + return -1; + + data->file_start = blkid * blksz; + data->file_end = data->file_start + blksz; + + movesize = MIN (length, data->file_end - (int) file->offset - read); + + grub_memmove (buf, data->file_buf + file->offset + read + - data->file_start, movesize); + buf += movesize; + length -= movesize; + read += movesize; + } + + return len; +} + +static grub_err_t +grub_zfs_close (grub_file_t file) +{ + zfs_unmount ((struct grub_zfs_data *) file->data); + +#ifndef GRUB_UTIL + grub_dl_unref (my_mod); +#endif + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_zfs_getmdnobj (grub_device_t dev, const char *fsfilename, + grub_uint64_t *mdnobj) +{ + struct grub_zfs_data *data; + grub_err_t err; + int isfs; + + data = zfs_mount (dev); + if (! data) + return grub_errno; + + err = dnode_get_fullpath (fsfilename, &(data->mdn), mdnobj, + &(data->dnode), &isfs, data); + zfs_unmount (data); + return err; +} + +static void +fill_fs_info (struct grub_dirhook_info *info, + dnode_end_t mdn, struct grub_zfs_data *data) +{ + grub_err_t err; + dnode_end_t dn; + grub_uint64_t objnum; + grub_uint64_t headobj; + + grub_memset (info, 0, sizeof (*info)); + + info->dir = 1; + + if (mdn.dn.dn_type == DMU_OT_DSL_DIR) + { + headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&mdn.dn))->dd_head_dataset_obj, mdn.endian); + + err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &mdn, data); + if (err) + { + grub_dprintf ("zfs", "failed here\n"); + return; + } + } + make_mdn (&mdn, data); + err = dnode_get (&mdn, MASTER_NODE_OBJ, DMU_OT_MASTER_NODE, + &dn, data); + if (err) + { + grub_dprintf ("zfs", "failed here\n"); + return; + } + + err = zap_lookup (&dn, ZFS_ROOT_OBJ, &objnum, data); + if (err) + { + grub_dprintf ("zfs", "failed here\n"); + return; + } + + err = dnode_get (&mdn, objnum, 0, &dn, data); + if (err) + { + grub_dprintf ("zfs", "failed here\n"); + return; + } + + info->mtimeset = 1; + info->mtime = grub_zfs_to_cpu64 (((znode_phys_t *) DN_BONUS (&dn.dn))->zp_mtime[0], dn.endian); + return; +} + +static grub_err_t +grub_zfs_dir (grub_device_t device, const char *path, + int (*hook) (const char *, const struct grub_dirhook_info *)) +{ + struct grub_zfs_data *data; + grub_err_t err; + int isfs; + auto int NESTED_FUNC_ATTR iterate_zap (const char *name, grub_uint64_t val); + auto int NESTED_FUNC_ATTR iterate_zap_fs (const char *name, + grub_uint64_t val); + auto int NESTED_FUNC_ATTR iterate_zap_snap (const char *name, + grub_uint64_t val); + + int NESTED_FUNC_ATTR iterate_zap (const char *name, grub_uint64_t val) + { + struct grub_dirhook_info info; + dnode_end_t dn; + grub_memset (&info, 0, sizeof (info)); + + dnode_get (&(data->mdn), val, 0, &dn, data); + info.mtimeset = 1; + info.mtime = grub_zfs_to_cpu64 (((znode_phys_t *) DN_BONUS (&dn.dn))->zp_mtime[0], dn.endian); + info.dir = (dn.dn.dn_type == DMU_OT_DIRECTORY_CONTENTS); + grub_dprintf ("zfs", "type=%d, name=%s\n", + (int)dn.dn.dn_type, (char *)name); + return hook (name, &info); + } + + int NESTED_FUNC_ATTR iterate_zap_fs (const char *name, grub_uint64_t val) + { + struct grub_dirhook_info info; + dnode_end_t mdn; + err = dnode_get (&(data->mos), val, 0, &mdn, data); + if (err) + return 0; + if (mdn.dn.dn_type != DMU_OT_DSL_DIR) + return 0; + + fill_fs_info (&info, mdn, data); + return hook (name, &info); + } + int NESTED_FUNC_ATTR iterate_zap_snap (const char *name, grub_uint64_t val) + { + struct grub_dirhook_info info; + char *name2; + int ret; + dnode_end_t mdn; + + err = dnode_get (&(data->mos), val, 0, &mdn, data); + if (err) + return 0; + + if (mdn.dn.dn_type != DMU_OT_DSL_DATASET) + return 0; + + fill_fs_info (&info, mdn, data); + + name2 = grub_malloc (grub_strlen (name) + 2); + name2[0] = '@'; + grub_memcpy (name2 + 1, name, grub_strlen (name) + 1); + ret = hook (name2, &info); + grub_free (name2); + return ret; + } + + data = zfs_mount (device); + if (! data) + return grub_errno; + err = dnode_get_fullpath (path, &(data->mdn), 0, &(data->dnode), &isfs, data); + if (err) + { + zfs_unmount (data); + return err; + } + if (isfs) + { + grub_uint64_t childobj, headobj; + grub_uint64_t snapobj; + dnode_end_t dn; + struct grub_dirhook_info info; + + fill_fs_info (&info, data->dnode, data); + hook ("@", &info); + + childobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&data->dnode.dn))->dd_child_dir_zapobj, data->dnode.endian); + headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&data->dnode.dn))->dd_head_dataset_obj, data->dnode.endian); + err = dnode_get (&(data->mos), childobj, + DMU_OT_DSL_DIR_CHILD_MAP, &dn, data); + if (err) + { + zfs_unmount (data); + return err; + } + + zap_iterate (&dn, iterate_zap_fs, data); + + err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &dn, data); + if (err) + { + zfs_unmount (data); + return err; + } + + snapobj = grub_zfs_to_cpu64 (((dsl_dataset_phys_t *) DN_BONUS (&dn.dn))->ds_snapnames_zapobj, dn.endian); + + err = dnode_get (&(data->mos), snapobj, + DMU_OT_DSL_DS_SNAP_MAP, &dn, data); + if (err) + { + zfs_unmount (data); + return err; + } + + zap_iterate (&dn, iterate_zap_snap, data); + } + else + { + if (data->dnode.dn.dn_type != DMU_OT_DIRECTORY_CONTENTS) + { + zfs_unmount (data); + return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); + } + zap_iterate (&(data->dnode), iterate_zap, data); + } + zfs_unmount (data); + return grub_errno; +} + +static struct grub_fs grub_zfs_fs = { + .name = "zfs", + .dir = grub_zfs_dir, + .open = grub_zfs_open, + .read = grub_zfs_read, + .close = grub_zfs_close, + .label = zfs_label, + .uuid = zfs_uuid, + .mtime = 0, + .next = 0 +}; + +GRUB_MOD_INIT (zfs) +{ + grub_fs_register (&grub_zfs_fs); +#ifndef GRUB_UTIL + my_mod = mod; +#endif +} + +GRUB_MOD_FINI (zfs) +{ + grub_fs_unregister (&grub_zfs_fs); +} diff --git a/grub-core/fs/zfs/zfs_fletcher.c b/grub-core/fs/zfs/zfs_fletcher.c new file mode 100644 index 000000000..eaed15a2c --- /dev/null +++ b/grub-core/fs/zfs/zfs_fletcher.c @@ -0,0 +1,86 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2007 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * + * 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 3 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void +fletcher_2(const void *buf, grub_uint64_t size, grub_zfs_endian_t endian, + zio_cksum_t *zcp) +{ + const grub_uint64_t *ip = buf; + const grub_uint64_t *ipend = ip + (size / sizeof (grub_uint64_t)); + grub_uint64_t a0, b0, a1, b1; + + for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) + { + a0 += grub_zfs_to_cpu64 (ip[0], endian); + a1 += grub_zfs_to_cpu64 (ip[1], endian); + b0 += a0; + b1 += a1; + } + + zcp->zc_word[0] = grub_cpu_to_zfs64 (a0, endian); + zcp->zc_word[1] = grub_cpu_to_zfs64 (a1, endian); + zcp->zc_word[2] = grub_cpu_to_zfs64 (b0, endian); + zcp->zc_word[3] = grub_cpu_to_zfs64 (b1, endian); +} + +void +fletcher_4 (const void *buf, grub_uint64_t size, grub_zfs_endian_t endian, + zio_cksum_t *zcp) +{ + const grub_uint32_t *ip = buf; + const grub_uint32_t *ipend = ip + (size / sizeof (grub_uint32_t)); + grub_uint64_t a, b, c, d; + + for (a = b = c = d = 0; ip < ipend; ip++) + { + a += grub_zfs_to_cpu32 (ip[0], endian);; + b += a; + c += b; + d += c; + } + + zcp->zc_word[0] = grub_cpu_to_zfs64 (a, endian); + zcp->zc_word[1] = grub_cpu_to_zfs64 (b, endian); + zcp->zc_word[2] = grub_cpu_to_zfs64 (c, endian); + zcp->zc_word[3] = grub_cpu_to_zfs64 (d, endian); +} + diff --git a/grub-core/fs/zfs/zfs_lzjb.c b/grub-core/fs/zfs/zfs_lzjb.c new file mode 100644 index 000000000..0965d2d1f --- /dev/null +++ b/grub-core/fs/zfs/zfs_lzjb.c @@ -0,0 +1,95 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2007 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * + * 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 3 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MATCH_BITS 6 +#define MATCH_MIN 3 +#define OFFSET_MASK ((1 << (16 - MATCH_BITS)) - 1) + +/* + * Decompression Entry - lzjb + */ +#ifndef NBBY +#define NBBY 8 +#endif + +grub_err_t +lzjb_decompress (void *s_start, void *d_start, grub_size_t s_len, + grub_size_t d_len); + +grub_err_t +lzjb_decompress (void *s_start, void *d_start, grub_size_t s_len, + grub_size_t d_len) +{ + grub_uint8_t *src = s_start; + grub_uint8_t *dst = d_start; + grub_uint8_t *d_end = (grub_uint8_t *) d_start + d_len; + grub_uint8_t *s_end = (grub_uint8_t *) s_start + s_len; + grub_uint8_t *cpy, copymap = 0; + int copymask = 1 << (NBBY - 1); + + while (dst < d_end && src < s_end) + { + if ((copymask <<= 1) == (1 << NBBY)) + { + copymask = 1; + copymap = *src++; + } + if (src >= s_end) + return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed"); + if (copymap & copymask) + { + int mlen = (src[0] >> (NBBY - MATCH_BITS)) + MATCH_MIN; + int offset = ((src[0] << NBBY) | src[1]) & OFFSET_MASK; + src += 2; + cpy = dst - offset; + if (src > s_end || cpy < (grub_uint8_t *) d_start) + return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed"); + while (--mlen >= 0 && dst < d_end) + *dst++ = *cpy++; + } + else + *dst++ = *src++; + } + if (dst < d_end) + return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed"); + return GRUB_ERR_NONE; +} diff --git a/grub-core/fs/zfs/zfs_sha256.c b/grub-core/fs/zfs/zfs_sha256.c new file mode 100644 index 000000000..3dc79268a --- /dev/null +++ b/grub-core/fs/zfs/zfs_sha256.c @@ -0,0 +1,145 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2007 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * + * 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 3 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * SHA-256 checksum, as specified in FIPS 180-2, available at: + * http://csrc.nist.gov/cryptval + * + * This is a very compact implementation of SHA-256. + * It is designed to be simple and portable, not to be fast. + */ + +/* + * The literal definitions according to FIPS180-2 would be: + * + * Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z))) + * Maj(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) + * + * We use logical equivalents which require one less op. + */ +#define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) +#define Maj(x, y, z) (((x) & (y)) ^ ((z) & ((x) ^ (y)))) +#define Rot32(x, s) (((x) >> s) | ((x) << (32 - s))) +#define SIGMA0(x) (Rot32(x, 2) ^ Rot32(x, 13) ^ Rot32(x, 22)) +#define SIGMA1(x) (Rot32(x, 6) ^ Rot32(x, 11) ^ Rot32(x, 25)) +#define sigma0(x) (Rot32(x, 7) ^ Rot32(x, 18) ^ ((x) >> 3)) +#define sigma1(x) (Rot32(x, 17) ^ Rot32(x, 19) ^ ((x) >> 10)) + +static const grub_uint32_t SHA256_K[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +}; + +static void +SHA256Transform(grub_uint32_t *H, const grub_uint8_t *cp) +{ + grub_uint32_t a, b, c, d, e, f, g, h, t, T1, T2, W[64]; + + for (t = 0; t < 16; t++, cp += 4) + W[t] = (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3]; + + for (t = 16; t < 64; t++) + W[t] = sigma1(W[t - 2]) + W[t - 7] + + sigma0(W[t - 15]) + W[t - 16]; + + a = H[0]; b = H[1]; c = H[2]; d = H[3]; + e = H[4]; f = H[5]; g = H[6]; h = H[7]; + + for (t = 0; t < 64; t++) { + T1 = h + SIGMA1(e) + Ch(e, f, g) + SHA256_K[t] + W[t]; + T2 = SIGMA0(a) + Maj(a, b, c); + h = g; g = f; f = e; e = d + T1; + d = c; c = b; b = a; a = T1 + T2; + } + + H[0] += a; H[1] += b; H[2] += c; H[3] += d; + H[4] += e; H[5] += f; H[6] += g; H[7] += h; +} + +void +zio_checksum_SHA256(const void *buf, grub_uint64_t size, + grub_zfs_endian_t endian, zio_cksum_t *zcp) +{ + grub_uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; + grub_uint8_t pad[128]; + unsigned padsize = size & 63; + unsigned i; + + for (i = 0; i < size - padsize; i += 64) + SHA256Transform(H, (grub_uint8_t *)buf + i); + + for (i = 0; i < padsize; i++) + pad[i] = ((grub_uint8_t *)buf)[i]; + + for (pad[padsize++] = 0x80; (padsize & 63) != 56; padsize++) + pad[padsize] = 0; + + for (i = 0; i < 8; i++) + pad[padsize++] = (size << 3) >> (56 - 8 * i); + + for (i = 0; i < padsize; i += 64) + SHA256Transform(H, pad + i); + + zcp->zc_word[0] = grub_cpu_to_zfs64 ((grub_uint64_t)H[0] << 32 | H[1], + endian); + zcp->zc_word[1] = grub_cpu_to_zfs64 ((grub_uint64_t)H[2] << 32 | H[3], + endian); + zcp->zc_word[2] = grub_cpu_to_zfs64 ((grub_uint64_t)H[4] << 32 | H[5], + endian); + zcp->zc_word[3] = grub_cpu_to_zfs64 ((grub_uint64_t)H[6] << 32 | H[7], + endian); +} diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c new file mode 100644 index 000000000..a9a13507e --- /dev/null +++ b/grub-core/fs/zfs/zfsinfo.c @@ -0,0 +1,414 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2008 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * + * 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 3 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static inline void +print_tabs (int n) +{ + int i; + + for (i = 0; i < n; i++) + grub_printf (" "); +} + +static grub_err_t +print_state (char *nvlist, int tab) +{ + grub_uint64_t ival; + int isok = 1; + + print_tabs (tab); + grub_printf ("State: "); + + if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_REMOVED, &ival)) + { + grub_printf ("removed "); + isok = 0; + } + + if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival)) + { + grub_printf ("faulted "); + isok = 0; + } + + if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_OFFLINE, &ival)) + { + grub_printf ("offline "); + isok = 0; + } + + if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival)) + grub_printf ("degraded "); + + if (isok) + grub_printf ("online"); + grub_printf ("\n"); + + return GRUB_ERR_NONE; +} + +static grub_err_t +print_vdev_info (char *nvlist, int tab) +{ + char *type = 0; + + type = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_TYPE); + + if (!type) + { + print_tabs (tab); + grub_printf ("Incorrect VDEV: no type available\n"); + return grub_errno; + } + + if (grub_strcmp (type, VDEV_TYPE_DISK) == 0) + { + char *bootpath = 0; + char *path = 0; + char *devid = 0; + + print_tabs (tab); + grub_printf ("Leaf VDEV\n"); + + print_state (nvlist, tab); + + bootpath = + grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_PHYS_PATH); + print_tabs (tab); + if (!bootpath) + grub_printf ("Bootpath: unavailable\n"); + else + grub_printf ("Bootpath: %s\n", bootpath); + + path = grub_zfs_nvlist_lookup_string (nvlist, "path"); + print_tabs (tab); + if (!path) + grub_printf ("Path: unavailable\n"); + else + grub_printf ("Path: %s\n", path); + + devid = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_DEVID); + print_tabs (tab); + if (!devid) + grub_printf ("Devid: unavailable\n"); + else + grub_printf ("Devid: %s\n", devid); + grub_free (bootpath); + grub_free (devid); + grub_free (path); + return GRUB_ERR_NONE; + } + + if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0) + { + int nelm, i; + + nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm + (nvlist, ZPOOL_CONFIG_CHILDREN); + + print_tabs (tab); + if (nelm <= 0) + { + grub_printf ("Incorrect mirror VDEV\n"); + return GRUB_ERR_NONE; + } + grub_printf ("Mirror VDEV with %d children\n", nelm); + print_state (nvlist, tab); + + for (i = 0; i < nelm; i++) + { + char *child; + + child = grub_zfs_nvlist_lookup_nvlist_array + (nvlist, ZPOOL_CONFIG_CHILDREN, i); + + print_tabs (tab); + if (!child) + { + grub_printf ("Mirror VDEV element %d isn't correct\n", i); + continue; + } + + grub_printf ("Mirror VDEV element %d:\n", i); + print_vdev_info (child, tab + 1); + + grub_free (child); + } + } + + print_tabs (tab); + grub_printf ("Unknown VDEV type: %s\n", type); + + return GRUB_ERR_NONE; +} + +static grub_err_t +get_bootpath (char *nvlist, char **bootpath, char **devid) +{ + char *type = 0; + + type = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_TYPE); + + if (!type) + return grub_errno; + + if (grub_strcmp (type, VDEV_TYPE_DISK) == 0) + { + *bootpath = grub_zfs_nvlist_lookup_string (nvlist, + ZPOOL_CONFIG_PHYS_PATH); + *devid = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_DEVID); + if (!*bootpath || !*devid) + { + grub_free (*bootpath); + grub_free (*devid); + *bootpath = 0; + *devid = 0; + } + return GRUB_ERR_NONE; + } + + if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0) + { + int nelm, i; + + nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm + (nvlist, ZPOOL_CONFIG_CHILDREN); + + for (i = 0; i < nelm; i++) + { + char *child; + + child = grub_zfs_nvlist_lookup_nvlist_array (nvlist, + ZPOOL_CONFIG_CHILDREN, + i); + + get_bootpath (child, bootpath, devid); + + grub_free (child); + + if (*bootpath && *devid) + return GRUB_ERR_NONE; + } + } + + return GRUB_ERR_NONE; +} + +static char *poolstates[] = { + [POOL_STATE_ACTIVE] = "active", + [POOL_STATE_EXPORTED] = "exported", + [POOL_STATE_DESTROYED] = "destroyed", + [POOL_STATE_SPARE] = "reserved for hot spare", + [POOL_STATE_L2CACHE] = "level 2 ARC device", + [POOL_STATE_UNINITIALIZED] = "uninitialized", + [POOL_STATE_UNAVAIL] = "unavailable", + [POOL_STATE_POTENTIALLY_ACTIVE] = "potentially active" +}; + +static grub_err_t +grub_cmd_zfsinfo (grub_command_t cmd __attribute__ ((unused)), int argc, + char **args) +{ + grub_device_t dev; + char *devname; + grub_err_t err; + char *nvlist = 0; + char *nv = 0; + char *poolname; + grub_uint64_t guid; + grub_uint64_t pool_state; + int found; + + if (argc < 1) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required"); + + if (args[0][0] == '(' && args[0][grub_strlen (args[0]) - 1] == ')') + { + devname = grub_strdup (args[0] + 1); + if (devname) + devname[grub_strlen (devname) - 1] = 0; + } + else + devname = grub_strdup (args[0]); + if (!devname) + return grub_errno; + + dev = grub_device_open (devname); + grub_free (devname); + if (!dev) + return grub_errno; + + err = grub_zfs_fetch_nvlist (dev, &nvlist); + + grub_device_close (dev); + + if (err) + return err; + + poolname = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME); + if (!poolname) + grub_printf ("Pool name: unavailable\n"); + else + grub_printf ("Pool name: %s\n", poolname); + + found = + grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_GUID, &guid); + if (!found) + grub_printf ("Pool GUID: unavailable\n"); + else + grub_printf ("Pool GUID: %016llx\n", (long long unsigned) guid); + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_STATE, + &pool_state); + if (!found) + grub_printf ("Unable to retrieve pool state\n"); + else if (pool_state >= ARRAY_SIZE (poolstates)) + grub_printf ("Unrecognized pool state\n"); + else + grub_printf ("Pool state: %s\n", poolstates[pool_state]); + + nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE); + + if (!nv) + grub_printf ("No vdev tree available\n"); + else + print_vdev_info (nv, 1); + + grub_free (nv); + grub_free (nvlist); + + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_cmd_zfs_bootfs (grub_command_t cmd __attribute__ ((unused)), int argc, + char **args) +{ + grub_device_t dev; + char *devname; + grub_err_t err; + char *nvlist = 0; + char *nv = 0; + char *bootpath = 0, *devid = 0; + char *fsname; + char *bootfs; + char *poolname; + grub_uint64_t mdnobj; + + if (argc < 1) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "filesystem name required"); + + devname = grub_file_get_device_name (args[0]); + if (grub_errno) + return grub_errno; + + dev = grub_device_open (devname); + grub_free (devname); + if (!dev) + return grub_errno; + + err = grub_zfs_fetch_nvlist (dev, &nvlist); + + fsname = grub_strchr (args[0], ')'); + if (fsname) + fsname++; + else + fsname = args[0]; + + if (!err) + err = grub_zfs_getmdnobj (dev, fsname, &mdnobj); + + grub_device_close (dev); + + if (err) + return err; + + poolname = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME); + if (!poolname) + { + if (!grub_errno) + grub_error (GRUB_ERR_BAD_FS, "No poolname found"); + return grub_errno; + } + + nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE); + + if (nv) + get_bootpath (nv, &bootpath, &devid); + + grub_free (nv); + grub_free (nvlist); + + if (bootpath && devid) + { + bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu bootpath=%s diskdevid=%s", + poolname, (unsigned long long) mdnobj, + bootpath, devid); + if (!bootfs) + return grub_errno; + } + else + { + bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu", + poolname, (unsigned long long) mdnobj); + if (!bootfs) + return grub_errno; + } + if (argc >= 2) + grub_env_set (args[1], bootfs); + else + grub_printf ("%s\n", bootfs); + + grub_free (bootfs); + grub_free (poolname); + grub_free (bootpath); + grub_free (devid); + + return GRUB_ERR_NONE; +} + + +static grub_command_t cmd_info, cmd_bootfs; + +GRUB_MOD_INIT (zfsinfo) +{ + cmd_info = grub_register_command ("zfsinfo", grub_cmd_zfsinfo, + "zfsinfo DEVICE", + "Print ZFS info about DEVICE."); + cmd_bootfs = grub_register_command ("zfs-bootfs", grub_cmd_zfs_bootfs, + "zfs-bootfs FILESYSTEM [VARIABLE]", + "Print ZFS-BOOTFSOBJ or set it to VARIABLE"); +} + +GRUB_MOD_FINI (zfsinfo) +{ + grub_unregister_command (cmd_info); + grub_unregister_command (cmd_bootfs); +} diff --git a/include/grub/zfs/dmu.h b/include/grub/zfs/dmu.h new file mode 100644 index 000000000..7faa7088b --- /dev/null +++ b/include/grub/zfs/dmu.h @@ -0,0 +1,120 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DMU_H +#define _SYS_DMU_H + +/* + * This file describes the interface that the DMU provides for its + * consumers. + * + * The DMU also interacts with the SPA. That interface is described in + * dmu_spa.h. + */ +typedef enum dmu_object_type { + DMU_OT_NONE, + /* general: */ + DMU_OT_OBJECT_DIRECTORY, /* ZAP */ + DMU_OT_OBJECT_ARRAY, /* UINT64 */ + DMU_OT_PACKED_NVLIST, /* UINT8 (XDR by nvlist_pack/unpack) */ + DMU_OT_PACKED_NVLIST_SIZE, /* UINT64 */ + DMU_OT_BPLIST, /* UINT64 */ + DMU_OT_BPLIST_HDR, /* UINT64 */ + /* spa: */ + DMU_OT_SPACE_MAP_HEADER, /* UINT64 */ + DMU_OT_SPACE_MAP, /* UINT64 */ + /* zil: */ + DMU_OT_INTENT_LOG, /* UINT64 */ + /* dmu: */ + DMU_OT_DNODE, /* DNODE */ + DMU_OT_OBJSET, /* OBJSET */ + /* dsl: */ + DMU_OT_DSL_DIR, /* UINT64 */ + DMU_OT_DSL_DIR_CHILD_MAP, /* ZAP */ + DMU_OT_DSL_DS_SNAP_MAP, /* ZAP */ + DMU_OT_DSL_PROPS, /* ZAP */ + DMU_OT_DSL_DATASET, /* UINT64 */ + /* zpl: */ + DMU_OT_ZNODE, /* ZNODE */ + DMU_OT_OLDACL, /* OLD ACL */ + DMU_OT_PLAIN_FILE_CONTENTS, /* UINT8 */ + DMU_OT_DIRECTORY_CONTENTS, /* ZAP */ + DMU_OT_MASTER_NODE, /* ZAP */ + DMU_OT_UNLINKED_SET, /* ZAP */ + /* zvol: */ + DMU_OT_ZVOL, /* UINT8 */ + DMU_OT_ZVOL_PROP, /* ZAP */ + /* other; for testing only! */ + DMU_OT_PLAIN_OTHER, /* UINT8 */ + DMU_OT_UINT64_OTHER, /* UINT64 */ + DMU_OT_ZAP_OTHER, /* ZAP */ + /* new object types: */ + DMU_OT_ERROR_LOG, /* ZAP */ + DMU_OT_SPA_HISTORY, /* UINT8 */ + DMU_OT_SPA_HISTORY_OFFSETS, /* spa_his_phys_t */ + DMU_OT_POOL_PROPS, /* ZAP */ + DMU_OT_DSL_PERMS, /* ZAP */ + DMU_OT_ACL, /* ACL */ + DMU_OT_SYSACL, /* SYSACL */ + DMU_OT_FUID, /* FUID table (Packed NVLIST UINT8) */ + DMU_OT_FUID_SIZE, /* FUID table size UINT64 */ + DMU_OT_NEXT_CLONES, /* ZAP */ + DMU_OT_SCRUB_QUEUE, /* ZAP */ + DMU_OT_USERGROUP_USED, /* ZAP */ + DMU_OT_USERGROUP_QUOTA, /* ZAP */ + DMU_OT_USERREFS, /* ZAP */ + DMU_OT_DDT_ZAP, /* ZAP */ + DMU_OT_DDT_STATS, /* ZAP */ + DMU_OT_SA, /* System attr */ + DMU_OT_SA_MASTER_NODE, /* ZAP */ + DMU_OT_SA_ATTR_REGISTRATION, /* ZAP */ + DMU_OT_SA_ATTR_LAYOUTS, /* ZAP */ + DMU_OT_NUMTYPES +} dmu_object_type_t; + +typedef enum dmu_objset_type { + DMU_OST_NONE, + DMU_OST_META, + DMU_OST_ZFS, + DMU_OST_ZVOL, + DMU_OST_OTHER, /* For testing only! */ + DMU_OST_ANY, /* Be careful! */ + DMU_OST_NUMTYPES +} dmu_objset_type_t; + +/* + * The names of zap entries in the DIRECTORY_OBJECT of the MOS. + */ +#define DMU_POOL_DIRECTORY_OBJECT 1 +#define DMU_POOL_CONFIG "config" +#define DMU_POOL_ROOT_DATASET "root_dataset" +#define DMU_POOL_SYNC_BPLIST "sync_bplist" +#define DMU_POOL_ERRLOG_SCRUB "errlog_scrub" +#define DMU_POOL_ERRLOG_LAST "errlog_last" +#define DMU_POOL_SPARES "spares" +#define DMU_POOL_DEFLATE "deflate" +#define DMU_POOL_HISTORY "history" +#define DMU_POOL_PROPS "pool_props" +#define DMU_POOL_L2CACHE "l2cache" + +#endif /* _SYS_DMU_H */ diff --git a/include/grub/zfs/dmu_objset.h b/include/grub/zfs/dmu_objset.h new file mode 100644 index 000000000..aa1f4ab19 --- /dev/null +++ b/include/grub/zfs/dmu_objset.h @@ -0,0 +1,44 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright (C) 2010 Robert Millan + * + * 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DMU_OBJSET_H +#define _SYS_DMU_OBJSET_H + +#include + +#define OBJSET_PHYS_SIZE 2048 +#define OBJSET_PHYS_SIZE_V14 1024 + +typedef struct objset_phys { + dnode_phys_t os_meta_dnode; + zil_header_t os_zil_header; + grub_uint64_t os_type; + grub_uint64_t os_flags; + char os_pad[OBJSET_PHYS_SIZE - sizeof (dnode_phys_t)*3 - + sizeof (zil_header_t) - sizeof (grub_uint64_t)*2]; + dnode_phys_t os_userused_dnode; + dnode_phys_t os_groupused_dnode; +} objset_phys_t; + +#endif /* _SYS_DMU_OBJSET_H */ diff --git a/include/grub/zfs/dnode.h b/include/grub/zfs/dnode.h new file mode 100644 index 000000000..6b0e18427 --- /dev/null +++ b/include/grub/zfs/dnode.h @@ -0,0 +1,81 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DNODE_H +#define _SYS_DNODE_H + +#include + +/* + * Fixed constants. + */ +#define DNODE_SHIFT 9 /* 512 bytes */ +#define DN_MIN_INDBLKSHIFT 10 /* 1k */ +#define DN_MAX_INDBLKSHIFT 14 /* 16k */ +#define DNODE_BLOCK_SHIFT 14 /* 16k */ +#define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */ +#define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */ +#define DN_MAX_OFFSET_SHIFT 64 /* 2^64 bytes in a dnode */ + +/* + * Derived constants. + */ +#define DNODE_SIZE (1 << DNODE_SHIFT) +#define DN_MAX_NBLKPTR ((DNODE_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT) +#define DN_MAX_BONUSLEN (DNODE_SIZE - DNODE_CORE_SIZE - (1 << SPA_BLKPTRSHIFT)) +#define DN_MAX_OBJECT (1ULL << DN_MAX_OBJECT_SHIFT) + +#define DNODES_PER_BLOCK_SHIFT (DNODE_BLOCK_SHIFT - DNODE_SHIFT) +#define DNODES_PER_BLOCK (1ULL << DNODES_PER_BLOCK_SHIFT) +#define DNODES_PER_LEVEL_SHIFT (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT) + +#define DNODE_FLAG_SPILL_BLKPTR (1<<2) + +#define DN_BONUS(dnp) ((void*)((dnp)->dn_bonus + \ + (((dnp)->dn_nblkptr - 1) * sizeof (blkptr_t)))) + +typedef struct dnode_phys { + grub_uint8_t dn_type; /* dmu_object_type_t */ + grub_uint8_t dn_indblkshift; /* ln2(indirect block size) */ + grub_uint8_t dn_nlevels; /* 1=dn_blkptr->data blocks */ + grub_uint8_t dn_nblkptr; /* length of dn_blkptr */ + grub_uint8_t dn_bonustype; /* type of data in bonus buffer */ + grub_uint8_t dn_checksum; /* ZIO_CHECKSUM type */ + grub_uint8_t dn_compress; /* ZIO_COMPRESS type */ + grub_uint8_t dn_flags; /* DNODE_FLAG_* */ + grub_uint16_t dn_datablkszsec; /* data block size in 512b sectors */ + grub_uint16_t dn_bonuslen; /* length of dn_bonus */ + grub_uint8_t dn_pad2[4]; + + /* accounting is protected by dn_dirty_mtx */ + grub_uint64_t dn_maxblkid; /* largest allocated block ID */ + grub_uint64_t dn_used; /* bytes (or sectors) of disk space */ + + grub_uint64_t dn_pad3[4]; + + blkptr_t dn_blkptr[1]; + grub_uint8_t dn_bonus[DN_MAX_BONUSLEN - sizeof (blkptr_t)]; + blkptr_t dn_spill; +} dnode_phys_t; + +#endif /* _SYS_DNODE_H */ diff --git a/include/grub/zfs/dsl_dataset.h b/include/grub/zfs/dsl_dataset.h new file mode 100644 index 000000000..de0dc54a8 --- /dev/null +++ b/include/grub/zfs/dsl_dataset.h @@ -0,0 +1,53 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DSL_DATASET_H +#define _SYS_DSL_DATASET_H + +typedef struct dsl_dataset_phys { + grub_uint64_t ds_dir_obj; + grub_uint64_t ds_prev_snap_obj; + grub_uint64_t ds_prev_snap_txg; + grub_uint64_t ds_next_snap_obj; + grub_uint64_t ds_snapnames_zapobj; /* zap obj of snaps; ==0 for snaps */ + grub_uint64_t ds_num_children; /* clone/snap children; ==0 for head */ + grub_uint64_t ds_creation_time; /* seconds since 1970 */ + grub_uint64_t ds_creation_txg; + grub_uint64_t ds_deadlist_obj; + grub_uint64_t ds_used_bytes; + grub_uint64_t ds_compressed_bytes; + grub_uint64_t ds_uncompressed_bytes; + grub_uint64_t ds_unique_bytes; /* only relevant to snapshots */ + /* + * The ds_fsid_guid is a 56-bit ID that can change to avoid + * collisions. The ds_guid is a 64-bit ID that will never + * change, so there is a small probability that it will collide. + */ + grub_uint64_t ds_fsid_guid; + grub_uint64_t ds_guid; + grub_uint64_t ds_flags; + blkptr_t ds_bp; + grub_uint64_t ds_pad[8]; /* pad out to 320 bytes for good measure */ +} dsl_dataset_phys_t; + +#endif /* _SYS_DSL_DATASET_H */ diff --git a/include/grub/zfs/dsl_dir.h b/include/grub/zfs/dsl_dir.h new file mode 100644 index 000000000..717f3592b --- /dev/null +++ b/include/grub/zfs/dsl_dir.h @@ -0,0 +1,49 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DSL_DIR_H +#define _SYS_DSL_DIR_H + +typedef struct dsl_dir_phys { + grub_uint64_t dd_creation_time; /* not actually used */ + grub_uint64_t dd_head_dataset_obj; + grub_uint64_t dd_parent_obj; + grub_uint64_t dd_clone_parent_obj; + grub_uint64_t dd_child_dir_zapobj; + /* + * how much space our children are accounting for; for leaf + * datasets, == physical space used by fs + snaps + */ + grub_uint64_t dd_used_bytes; + grub_uint64_t dd_compressed_bytes; + grub_uint64_t dd_uncompressed_bytes; + /* Administrative quota setting */ + grub_uint64_t dd_quota; + /* Administrative reservation setting */ + grub_uint64_t dd_reserved; + grub_uint64_t dd_props_zapobj; + grub_uint64_t dd_deleg_zapobj; /* dataset permissions */ + grub_uint64_t dd_pad[20]; /* pad out to 256 bytes for good measure */ +} dsl_dir_phys_t; + +#endif /* _SYS_DSL_DIR_H */ diff --git a/include/grub/zfs/sa_impl.h b/include/grub/zfs/sa_impl.h new file mode 100644 index 000000000..8aa6e2e08 --- /dev/null +++ b/include/grub/zfs/sa_impl.h @@ -0,0 +1,35 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +#ifndef _SYS_SA_IMPL_H +#define _SYS_SA_IMPL_H + +typedef struct sa_hdr_phys { + grub_uint32_t sa_magic; + grub_uint16_t sa_layout_info; + grub_uint16_t sa_lengths[1]; +} sa_hdr_phys_t; + +#define SA_HDR_SIZE(hdr) BF32_GET_SB(hdr->sa_layout_info, 10, 16, 3, 0) +#define SA_SIZE_OFFSET 0x8 + +#endif /* _SYS_SA_IMPL_H */ diff --git a/include/grub/zfs/spa.h b/include/grub/zfs/spa.h new file mode 100644 index 000000000..36b8e6708 --- /dev/null +++ b/include/grub/zfs/spa.h @@ -0,0 +1,312 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2010 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * + * 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 3 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef GRUB_ZFS_SPA_HEADER +#define GRUB_ZFS_SPA_HEADER 1 + +typedef enum grub_zfs_endian + { + UNKNOWN_ENDIAN = -2, + LITTLE_ENDIAN = -1, + BIG_ENDIAN = 0 + } grub_zfs_endian_t; + +#define grub_zfs_to_cpu16(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu16(x) \ + : grub_le_to_cpu16(x)) +#define grub_cpu_to_zfs16(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be16(x) \ + : grub_cpu_to_le16(x)) + +#define grub_zfs_to_cpu32(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu32(x) \ + : grub_le_to_cpu32(x)) +#define grub_cpu_to_zfs32(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be32(x) \ + : grub_cpu_to_le32(x)) + +#define grub_zfs_to_cpu64(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu64(x) \ + : grub_le_to_cpu64(x)) +#define grub_cpu_to_zfs64(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be64(x) \ + : grub_cpu_to_le64(x)) + +/* + * General-purpose 32-bit and 64-bit bitfield encodings. + */ +#define BF32_DECODE(x, low, len) P2PHASE((x) >> (low), 1U << (len)) +#define BF64_DECODE(x, low, len) P2PHASE((x) >> (low), 1ULL << (len)) +#define BF32_ENCODE(x, low, len) (P2PHASE((x), 1U << (len)) << (low)) +#define BF64_ENCODE(x, low, len) (P2PHASE((x), 1ULL << (len)) << (low)) + +#define BF32_GET(x, low, len) BF32_DECODE(x, low, len) +#define BF64_GET(x, low, len) BF64_DECODE(x, low, len) + +#define BF32_SET(x, low, len, val) \ + ((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len)) +#define BF64_SET(x, low, len, val) \ + ((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len)) + +#define BF32_GET_SB(x, low, len, shift, bias) \ + ((BF32_GET(x, low, len) + (bias)) << (shift)) +#define BF64_GET_SB(x, low, len, shift, bias) \ + ((BF64_GET(x, low, len) + (bias)) << (shift)) + +#define BF32_SET_SB(x, low, len, shift, bias, val) \ + BF32_SET(x, low, len, ((val) >> (shift)) - (bias)) +#define BF64_SET_SB(x, low, len, shift, bias, val) \ + BF64_SET(x, low, len, ((val) >> (shift)) - (bias)) + +/* + * We currently support nine block sizes, from 512 bytes to 128K. + * We could go higher, but the benefits are near-zero and the cost + * of COWing a giant block to modify one byte would become excessive. + */ +#define SPA_MINBLOCKSHIFT 9 +#define SPA_MAXBLOCKSHIFT 17 +#define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT) +#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT) + +#define SPA_BLOCKSIZES (SPA_MAXBLOCKSHIFT - SPA_MINBLOCKSHIFT + 1) + +/* + * Size of block to hold the configuration data (a packed nvlist) + */ +#define SPA_CONFIG_BLOCKSIZE (1 << 14) + +/* + * The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB. + * The ASIZE encoding should be at least 64 times larger (6 more bits) + * to support up to 4-way RAID-Z mirror mode with worst-case gang block + * overhead, three DVAs per bp, plus one more bit in case we do anything + * else that expands the ASIZE. + */ +#define SPA_LSIZEBITS 16 /* LSIZE up to 32M (2^16 * 512) */ +#define SPA_PSIZEBITS 16 /* PSIZE up to 32M (2^16 * 512) */ +#define SPA_ASIZEBITS 24 /* ASIZE up to 64 times larger */ + +/* + * All SPA data is represented by 128-bit data virtual addresses (DVAs). + * The members of the dva_t should be considered opaque outside the SPA. + */ +typedef struct dva { + grub_uint64_t dva_word[2]; +} dva_t; + +/* + * Each block has a 256-bit checksum -- strong enough for cryptographic hashes. + */ +typedef struct zio_cksum { + grub_uint64_t zc_word[4]; +} zio_cksum_t; + +/* + * Each block is described by its DVAs, time of birth, checksum, etc. + * The word-by-word, bit-by-bit layout of the blkptr is as follows: + * + * 64 56 48 40 32 24 16 8 0 + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 0 | vdev1 | GRID | ASIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 1 |G| offset1 | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 2 | vdev2 | GRID | ASIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 3 |G| offset2 | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 4 | vdev3 | GRID | ASIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 5 |G| offset3 | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 6 |BDX|lvl| type | cksum | comp | PSIZE | LSIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 7 | padding | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 8 | padding | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 9 | physical birth txg | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * a | logical birth txg | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * b | fill count | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * c | checksum[0] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * d | checksum[1] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * e | checksum[2] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * f | checksum[3] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * + * Legend: + * + * vdev virtual device ID + * offset offset into virtual device + * LSIZE logical size + * PSIZE physical size (after compression) + * ASIZE allocated size (including RAID-Z parity and gang block headers) + * GRID RAID-Z layout information (reserved for future use) + * cksum checksum function + * comp compression function + * G gang block indicator + * B byteorder (endianness) + * D dedup + * X unused + * lvl level of indirection + * type DMU object type + * phys birth txg of block allocation; zero if same as logical birth txg + * log. birth transaction group in which the block was logically born + * fill count number of non-zero blocks under this bp + * checksum[4] 256-bit checksum of the data this bp describes + */ +#define SPA_BLKPTRSHIFT 7 /* blkptr_t is 128 bytes */ +#define SPA_DVAS_PER_BP 3 /* Number of DVAs in a bp */ + +typedef struct blkptr { + dva_t blk_dva[SPA_DVAS_PER_BP]; /* Data Virtual Addresses */ + grub_uint64_t blk_prop; /* size, compression, type, etc */ + grub_uint64_t blk_pad[2]; /* Extra space for the future */ + grub_uint64_t blk_phys_birth; /* txg when block was allocated */ + grub_uint64_t blk_birth; /* transaction group at birth */ + grub_uint64_t blk_fill; /* fill count */ + zio_cksum_t blk_cksum; /* 256-bit checksum */ +} blkptr_t; + +/* + * Macros to get and set fields in a bp or DVA. + */ +#define DVA_GET_ASIZE(dva) \ + BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0) +#define DVA_SET_ASIZE(dva, x) \ + BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0, x) + +#define DVA_GET_GRID(dva) BF64_GET((dva)->dva_word[0], 24, 8) +#define DVA_SET_GRID(dva, x) BF64_SET((dva)->dva_word[0], 24, 8, x) + +#define DVA_GET_VDEV(dva) BF64_GET((dva)->dva_word[0], 32, 32) +#define DVA_SET_VDEV(dva, x) BF64_SET((dva)->dva_word[0], 32, 32, x) + +#define DVA_GET_GANG(dva) BF64_GET((dva)->dva_word[1], 63, 1) +#define DVA_SET_GANG(dva, x) BF64_SET((dva)->dva_word[1], 63, 1, x) + +#define BP_GET_LSIZE(bp) \ + BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1) +#define BP_SET_LSIZE(bp, x) \ + BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x) + +#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 8) +#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 8, x) + +#define BP_GET_CHECKSUM(bp) BF64_GET((bp)->blk_prop, 40, 8) +#define BP_SET_CHECKSUM(bp, x) BF64_SET((bp)->blk_prop, 40, 8, x) + +#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8) +#define BP_SET_TYPE(bp, x) BF64_SET((bp)->blk_prop, 48, 8, x) + +#define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5) +#define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x) + +#define BP_GET_PROP_BIT_61(bp) BF64_GET((bp)->blk_prop, 61, 1) +#define BP_SET_PROP_BIT_61(bp, x) BF64_SET((bp)->blk_prop, 61, 1, x) + +#define BP_GET_DEDUP(bp) BF64_GET((bp)->blk_prop, 62, 1) +#define BP_SET_DEDUP(bp, x) BF64_SET((bp)->blk_prop, 62, 1, x) + +#define BP_GET_BYTEORDER(bp) (0 - BF64_GET((bp)->blk_prop, 63, 1)) +#define BP_SET_BYTEORDER(bp, x) BF64_SET((bp)->blk_prop, 63, 1, x) + +#define BP_PHYSICAL_BIRTH(bp) \ + ((bp)->blk_phys_birth ? (bp)->blk_phys_birth : (bp)->blk_birth) + +#define BP_SET_BIRTH(bp, logical, physical) \ +{ \ + (bp)->blk_birth = (logical); \ + (bp)->blk_phys_birth = ((logical) == (physical) ? 0 : (physical)); \ +} + +#define BP_GET_ASIZE(bp) \ + (DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \ + DVA_GET_ASIZE(&(bp)->blk_dva[2])) + +#define BP_GET_UCSIZE(bp) \ + ((BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata) ? \ + BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp)); + +#define BP_GET_NDVAS(bp) \ + (!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \ + !!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \ + !!DVA_GET_ASIZE(&(bp)->blk_dva[2])) + +#define BP_COUNT_GANG(bp) \ + (DVA_GET_GANG(&(bp)->blk_dva[0]) + \ + DVA_GET_GANG(&(bp)->blk_dva[1]) + \ + DVA_GET_GANG(&(bp)->blk_dva[2])) + +#define DVA_EQUAL(dva1, dva2) \ + ((dva1)->dva_word[1] == (dva2)->dva_word[1] && \ + (dva1)->dva_word[0] == (dva2)->dva_word[0]) + +#define BP_EQUAL(bp1, bp2) \ + (BP_PHYSICAL_BIRTH(bp1) == BP_PHYSICAL_BIRTH(bp2) && \ + DVA_EQUAL(&(bp1)->blk_dva[0], &(bp2)->blk_dva[0]) && \ + DVA_EQUAL(&(bp1)->blk_dva[1], &(bp2)->blk_dva[1]) && \ + DVA_EQUAL(&(bp1)->blk_dva[2], &(bp2)->blk_dva[2])) + +#define ZIO_CHECKSUM_EQUAL(zc1, zc2) \ + (0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \ + ((zc1).zc_word[1] - (zc2).zc_word[1]) | \ + ((zc1).zc_word[2] - (zc2).zc_word[2]) | \ + ((zc1).zc_word[3] - (zc2).zc_word[3]))) + +#define DVA_IS_VALID(dva) (DVA_GET_ASIZE(dva) != 0) + +#define ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3) \ +{ \ + (zcp)->zc_word[0] = w0; \ + (zcp)->zc_word[1] = w1; \ + (zcp)->zc_word[2] = w2; \ + (zcp)->zc_word[3] = w3; \ +} + +#define BP_IDENTITY(bp) (&(bp)->blk_dva[0]) +#define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp)) +#define BP_IS_HOLE(bp) ((bp)->blk_birth == 0) + +/* BP_IS_RAIDZ(bp) assumes no block compression */ +#define BP_IS_RAIDZ(bp) (DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \ + BP_GET_PSIZE(bp)) + +#define BP_ZERO(bp) \ +{ \ + (bp)->blk_dva[0].dva_word[0] = 0; \ + (bp)->blk_dva[0].dva_word[1] = 0; \ + (bp)->blk_dva[1].dva_word[0] = 0; \ + (bp)->blk_dva[1].dva_word[1] = 0; \ + (bp)->blk_dva[2].dva_word[0] = 0; \ + (bp)->blk_dva[2].dva_word[1] = 0; \ + (bp)->blk_prop = 0; \ + (bp)->blk_pad[0] = 0; \ + (bp)->blk_pad[1] = 0; \ + (bp)->blk_phys_birth = 0; \ + (bp)->blk_birth = 0; \ + (bp)->blk_fill = 0; \ + ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \ +} + +#define BP_SPRINTF_LEN 320 + +#endif /* ! GRUB_ZFS_SPA_HEADER */ diff --git a/include/grub/zfs/uberblock_impl.h b/include/grub/zfs/uberblock_impl.h new file mode 100644 index 000000000..9afc565c9 --- /dev/null +++ b/include/grub/zfs/uberblock_impl.h @@ -0,0 +1,61 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_UBERBLOCK_IMPL_H +#define _SYS_UBERBLOCK_IMPL_H + +/* + * The uberblock version is incremented whenever an incompatible on-disk + * format change is made to the SPA, DMU, or ZAP. + * + * Note: the first two fields should never be moved. When a storage pool + * is opened, the uberblock must be read off the disk before the version + * can be checked. If the ub_version field is moved, we may not detect + * version mismatch. If the ub_magic field is moved, applications that + * expect the magic number in the first word won't work. + */ +#define UBERBLOCK_MAGIC 0x00bab10c /* oo-ba-bloc! */ +#define UBERBLOCK_SHIFT 10 /* up to 1K */ + +typedef struct uberblock { + grub_uint64_t ub_magic; /* UBERBLOCK_MAGIC */ + grub_uint64_t ub_version; /* ZFS_VERSION */ + grub_uint64_t ub_txg; /* txg of last sync */ + grub_uint64_t ub_guid_sum; /* sum of all vdev guids */ + grub_uint64_t ub_timestamp; /* UTC time of last sync */ + blkptr_t ub_rootbp; /* MOS objset_phys_t */ +} uberblock_t; + +#define UBERBLOCK_SIZE (1ULL << UBERBLOCK_SHIFT) +#define VDEV_UBERBLOCK_SHIFT UBERBLOCK_SHIFT + +/* XXX Uberblock_phys_t is no longer in the kernel zfs */ +typedef struct uberblock_phys { + uberblock_t ubp_uberblock; + char ubp_pad[UBERBLOCK_SIZE - sizeof (uberblock_t) - + sizeof (zio_eck_t)]; + zio_eck_t ubp_zec; +} uberblock_phys_t; + + +#endif /* _SYS_UBERBLOCK_IMPL_H */ diff --git a/include/grub/zfs/vdev_impl.h b/include/grub/zfs/vdev_impl.h new file mode 100644 index 000000000..6e9002ffc --- /dev/null +++ b/include/grub/zfs/vdev_impl.h @@ -0,0 +1,70 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VDEV_IMPL_H +#define _SYS_VDEV_IMPL_H + +#define VDEV_SKIP_SIZE (8 << 10) +#define VDEV_BOOT_HEADER_SIZE (8 << 10) +#define VDEV_PHYS_SIZE (112 << 10) +#define VDEV_UBERBLOCK_RING (128 << 10) + +/* ZFS boot block */ +#define VDEV_BOOT_MAGIC 0x2f5b007b10cULL +#define VDEV_BOOT_VERSION 1 /* version number */ + +typedef struct vdev_boot_header { + grub_uint64_t vb_magic; /* VDEV_BOOT_MAGIC */ + grub_uint64_t vb_version; /* VDEV_BOOT_VERSION */ + grub_uint64_t vb_offset; /* start offset (bytes) */ + grub_uint64_t vb_size; /* size (bytes) */ + char vb_pad[VDEV_BOOT_HEADER_SIZE - 4 * sizeof (grub_uint64_t)]; +} vdev_boot_header_t; + +typedef struct vdev_phys { + char vp_nvlist[VDEV_PHYS_SIZE - sizeof (zio_eck_t)]; + zio_eck_t vp_zbt; +} vdev_phys_t; + +typedef struct vdev_label { + char vl_pad[VDEV_SKIP_SIZE]; /* 8K */ + vdev_boot_header_t vl_boot_header; /* 8K */ + vdev_phys_t vl_vdev_phys; /* 112K */ + char vl_uberblock[VDEV_UBERBLOCK_RING]; /* 128K */ +} vdev_label_t; /* 256K total */ + +/* + * Size and offset of embedded boot loader region on each label. + * The total size of the first two labels plus the boot area is 4MB. + */ +#define VDEV_BOOT_OFFSET (2 * sizeof (vdev_label_t)) +#define VDEV_BOOT_SIZE (7ULL << 19) /* 3.5M */ + +/* + * Size of label regions at the start and end of each leaf device. + */ +#define VDEV_LABEL_START_SIZE (2 * sizeof (vdev_label_t) + VDEV_BOOT_SIZE) +#define VDEV_LABEL_END_SIZE (2 * sizeof (vdev_label_t)) +#define VDEV_LABELS 4 + +#endif /* _SYS_VDEV_IMPL_H */ diff --git a/include/grub/zfs/zap_impl.h b/include/grub/zfs/zap_impl.h new file mode 100644 index 000000000..b229a0657 --- /dev/null +++ b/include/grub/zfs/zap_impl.h @@ -0,0 +1,112 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ZAP_IMPL_H +#define _SYS_ZAP_IMPL_H + +#define ZAP_MAGIC 0x2F52AB2ABULL + +#define ZAP_HASHBITS 28 +#define MZAP_ENT_LEN 64 +#define MZAP_NAME_LEN (MZAP_ENT_LEN - 8 - 4 - 2) +#define MZAP_MAX_BLKSHIFT SPA_MAXBLOCKSHIFT +#define MZAP_MAX_BLKSZ (1 << MZAP_MAX_BLKSHIFT) + +typedef struct mzap_ent_phys { + grub_uint64_t mze_value; + grub_uint32_t mze_cd; + grub_uint16_t mze_pad; /* in case we want to chain them someday */ + char mze_name[MZAP_NAME_LEN]; +} mzap_ent_phys_t; + +typedef struct mzap_phys { + grub_uint64_t mz_block_type; /* ZBT_MICRO */ + grub_uint64_t mz_salt; + grub_uint64_t mz_pad[6]; + mzap_ent_phys_t mz_chunk[1]; + /* actually variable size depending on block size */ +} mzap_phys_t; + +/* + * The (fat) zap is stored in one object. It is an array of + * 1<= 6] [zap_leaf_t] [ptrtbl] ... + * + */ + +#define ZBT_LEAF ((1ULL << 63) + 0) +#define ZBT_HEADER ((1ULL << 63) + 1) +#define ZBT_MICRO ((1ULL << 63) + 3) +/* any other values are ptrtbl blocks */ + +/* + * the embedded pointer table takes up half a block: + * block size / entry size (2^3) / 2 + */ +#define ZAP_EMBEDDED_PTRTBL_SHIFT(zap) (FZAP_BLOCK_SHIFT(zap) - 3 - 1) + +/* + * The embedded pointer table starts half-way through the block. Since + * the pointer table itself is half the block, it starts at (64-bit) + * word number (1<zap_f.zap_phys) \ + [(idx) + (1< + * + * 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 3 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + /* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef GRUB_ZFS_HEADER +#define GRUB_ZFS_HEADER 1 + +#include +#include + +/* + * On-disk version number. + */ +#define SPA_VERSION 28ULL + +/* + * The following are configuration names used in the nvlist describing a pool's + * configuration. + */ +#define ZPOOL_CONFIG_VERSION "version" +#define ZPOOL_CONFIG_POOL_NAME "name" +#define ZPOOL_CONFIG_POOL_STATE "state" +#define ZPOOL_CONFIG_POOL_TXG "txg" +#define ZPOOL_CONFIG_POOL_GUID "pool_guid" +#define ZPOOL_CONFIG_CREATE_TXG "create_txg" +#define ZPOOL_CONFIG_TOP_GUID "top_guid" +#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" +#define ZPOOL_CONFIG_TYPE "type" +#define ZPOOL_CONFIG_CHILDREN "children" +#define ZPOOL_CONFIG_ID "id" +#define ZPOOL_CONFIG_GUID "guid" +#define ZPOOL_CONFIG_PATH "path" +#define ZPOOL_CONFIG_DEVID "devid" +#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" +#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" +#define ZPOOL_CONFIG_ASHIFT "ashift" +#define ZPOOL_CONFIG_ASIZE "asize" +#define ZPOOL_CONFIG_DTL "DTL" +#define ZPOOL_CONFIG_STATS "stats" +#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" +#define ZPOOL_CONFIG_ERRCOUNT "error_count" +#define ZPOOL_CONFIG_NOT_PRESENT "not_present" +#define ZPOOL_CONFIG_SPARES "spares" +#define ZPOOL_CONFIG_IS_SPARE "is_spare" +#define ZPOOL_CONFIG_NPARITY "nparity" +#define ZPOOL_CONFIG_PHYS_PATH "phys_path" +#define ZPOOL_CONFIG_L2CACHE "l2cache" +#define ZPOOL_CONFIG_HOLE_ARRAY "hole_array" +#define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children" +#define ZPOOL_CONFIG_IS_HOLE "is_hole" +#define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram" +#define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats" +#define ZPOOL_CONFIG_DDT_STATS "ddt_stats" +/* + * The persistent vdev state is stored as separate values rather than a single + * 'vdev_state' entry. This is because a device can be in multiple states, such + * as offline and degraded. + */ +#define ZPOOL_CONFIG_OFFLINE "offline" +#define ZPOOL_CONFIG_FAULTED "faulted" +#define ZPOOL_CONFIG_DEGRADED "degraded" +#define ZPOOL_CONFIG_REMOVED "removed" + +#define VDEV_TYPE_ROOT "root" +#define VDEV_TYPE_MIRROR "mirror" +#define VDEV_TYPE_REPLACING "replacing" +#define VDEV_TYPE_RAIDZ "raidz" +#define VDEV_TYPE_DISK "disk" +#define VDEV_TYPE_FILE "file" +#define VDEV_TYPE_MISSING "missing" +#define VDEV_TYPE_HOLE "hole" +#define VDEV_TYPE_SPARE "spare" +#define VDEV_TYPE_L2CACHE "l2cache" + +/* + * pool state. The following states are written to disk as part of the normal + * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining + * states are software abstractions used at various levels to communicate pool + * state. + */ +typedef enum pool_state { + POOL_STATE_ACTIVE = 0, /* In active use */ + POOL_STATE_EXPORTED, /* Explicitly exported */ + POOL_STATE_DESTROYED, /* Explicitly destroyed */ + POOL_STATE_SPARE, /* Reserved for hot spare use */ + POOL_STATE_L2CACHE, /* Level 2 ARC device */ + POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ + POOL_STATE_UNAVAIL, /* Internal libzfs state */ + POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ +} pool_state_t; + +struct grub_zfs_data; + +grub_err_t grub_zfs_fetch_nvlist (grub_device_t dev, char **nvlist); +grub_err_t grub_zfs_getmdnobj (grub_device_t dev, const char *fsfilename, + grub_uint64_t *mdnobj); + +char *grub_zfs_nvlist_lookup_string (char *nvlist, char *name); +char *grub_zfs_nvlist_lookup_nvlist (char *nvlist, char *name); +int grub_zfs_nvlist_lookup_uint64 (char *nvlist, char *name, + grub_uint64_t *out); +char *grub_zfs_nvlist_lookup_nvlist_array (char *nvlist, char *name, + grub_size_t index); +int grub_zfs_nvlist_lookup_nvlist_array_get_nelm (char *nvlist, char *name); + +#endif /* ! GRUB_ZFS_HEADER */ diff --git a/include/grub/zfs/zfs_acl.h b/include/grub/zfs/zfs_acl.h new file mode 100644 index 000000000..65d3fdadc --- /dev/null +++ b/include/grub/zfs/zfs_acl.h @@ -0,0 +1,60 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_ZFS_ACL_H +#define _SYS_FS_ZFS_ACL_H + +#ifndef _UID_T +#define _UID_T +typedef unsigned int uid_t; /* UID type */ +#endif /* _UID_T */ + +typedef struct zfs_oldace { + grub_uint32_t z_fuid; /* "who" */ + grub_uint32_t z_access_mask; /* access mask */ + grub_uint16_t z_flags; /* flags, i.e inheritance */ + grub_uint16_t z_type; /* type of entry allow/deny */ +} zfs_oldace_t; + +#define ACE_SLOT_CNT 6 + +typedef struct zfs_znode_acl_v0 { + grub_uint64_t z_acl_extern_obj; /* ext acl pieces */ + grub_uint32_t z_acl_count; /* Number of ACEs */ + grub_uint16_t z_acl_version; /* acl version */ + grub_uint16_t z_acl_pad; /* pad */ + zfs_oldace_t z_ace_data[ACE_SLOT_CNT]; /* 6 standard ACEs */ +} zfs_znode_acl_v0_t; + +#define ZFS_ACE_SPACE (sizeof (zfs_oldace_t) * ACE_SLOT_CNT) + +typedef struct zfs_znode_acl { + grub_uint64_t z_acl_extern_obj; /* ext acl pieces */ + grub_uint32_t z_acl_size; /* Number of bytes in ACL */ + grub_uint16_t z_acl_version; /* acl version */ + grub_uint16_t z_acl_count; /* ace count */ + grub_uint8_t z_ace_data[ZFS_ACE_SPACE]; /* space for embedded ACEs */ +} zfs_znode_acl_t; + + +#endif /* _SYS_FS_ZFS_ACL_H */ diff --git a/include/grub/zfs/zfs_znode.h b/include/grub/zfs/zfs_znode.h new file mode 100644 index 000000000..87bc3f9fc --- /dev/null +++ b/include/grub/zfs/zfs_znode.h @@ -0,0 +1,71 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_ZFS_ZNODE_H +#define _SYS_FS_ZFS_ZNODE_H + +#include + +#define MASTER_NODE_OBJ 1 +#define ZFS_ROOT_OBJ "ROOT" +#define ZPL_VERSION_STR "VERSION" +#define ZFS_SA_ATTRS "SA_ATTRS" + +#define ZPL_VERSION 5ULL + +#define ZFS_DIRENT_OBJ(de) BF64_GET(de, 0, 48) + +/* + * This is the persistent portion of the znode. It is stored + * in the "bonus buffer" of the file. Short symbolic links + * are also stored in the bonus buffer. + */ +typedef struct znode_phys { + grub_uint64_t zp_atime[2]; /* 0 - last file access time */ + grub_uint64_t zp_mtime[2]; /* 16 - last file modification time */ + grub_uint64_t zp_ctime[2]; /* 32 - last file change time */ + grub_uint64_t zp_crtime[2]; /* 48 - creation time */ + grub_uint64_t zp_gen; /* 64 - generation (txg of creation) */ + grub_uint64_t zp_mode; /* 72 - file mode bits */ + grub_uint64_t zp_size; /* 80 - size of file */ + grub_uint64_t zp_parent; /* 88 - directory parent (`..') */ + grub_uint64_t zp_links; /* 96 - number of links to file */ + grub_uint64_t zp_xattr; /* 104 - DMU object for xattrs */ + grub_uint64_t zp_rdev; /* 112 - dev_t for VBLK & VCHR files */ + grub_uint64_t zp_flags; /* 120 - persistent flags */ + grub_uint64_t zp_uid; /* 128 - file owner */ + grub_uint64_t zp_gid; /* 136 - owning group */ + grub_uint64_t zp_pad[4]; /* 144 - future */ + zfs_znode_acl_t zp_acl; /* 176 - 263 ACL */ + /* + * Data may pad out any remaining bytes in the znode buffer, eg: + * + * |<---------------------- dnode_phys (512) ------------------------>| + * |<-- dnode (192) --->|<----------- "bonus" buffer (320) ---------->| + * |<---- znode (264) ---->|<---- data (56) ---->| + * + * At present, we only use this space to store symbolic links. + */ +} znode_phys_t; + +#endif /* _SYS_FS_ZFS_ZNODE_H */ diff --git a/include/grub/zfs/zil.h b/include/grub/zfs/zil.h new file mode 100644 index 000000000..4ae8daf63 --- /dev/null +++ b/include/grub/zfs/zil.h @@ -0,0 +1,57 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ZIL_H +#define _SYS_ZIL_H + +/* + * Intent log format: + * + * Each objset has its own intent log. The log header (zil_header_t) + * for objset N's intent log is kept in the Nth object of the SPA's + * intent_log objset. The log header points to a chain of log blocks, + * each of which contains log records (i.e., transactions) followed by + * a log block trailer (zil_trailer_t). The format of a log record + * depends on the record (or transaction) type, but all records begin + * with a common structure that defines the type, length, and txg. + */ + +/* + * Intent log header - this on disk structure holds fields to manage + * the log. All fields are 64 bit to easily handle cross architectures. + */ +typedef struct zil_header { + grub_uint64_t zh_claim_txg; /* txg in which log blocks were claimed */ + grub_uint64_t zh_replay_seq; /* highest replayed sequence number */ + blkptr_t zh_log; /* log chain */ + grub_uint64_t zh_claim_seq; /* highest claimed sequence number */ + grub_uint64_t zh_flags; /* header flags */ + grub_uint64_t zh_pad[4]; +} zil_header_t; + +/* + * zh_flags bit settings + */ +#define ZIL_REPLAY_NEEDED 0x1 /* replay needed - internal only */ + +#endif /* _SYS_ZIL_H */ diff --git a/include/grub/zfs/zio.h b/include/grub/zfs/zio.h new file mode 100644 index 000000000..2b177a2ce --- /dev/null +++ b/include/grub/zfs/zio.h @@ -0,0 +1,85 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ZIO_H +#define _ZIO_H + +#include + +#define ZEC_MAGIC 0x210da7ab10c7a11ULL /* zio data bloc tail */ + +typedef struct zio_eck { + grub_uint64_t zec_magic; /* for validation, endianness */ + zio_cksum_t zec_cksum; /* 256-bit checksum */ +} zio_eck_t; + +/* + * Gang block headers are self-checksumming and contain an array + * of block pointers. + */ +#define SPA_GANGBLOCKSIZE SPA_MINBLOCKSIZE +#define SPA_GBH_NBLKPTRS ((SPA_GANGBLOCKSIZE - \ + sizeof (zio_eck_t)) / sizeof (blkptr_t)) +#define SPA_GBH_FILLER ((SPA_GANGBLOCKSIZE - \ + sizeof (zio_eck_t) - \ + (SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\ + sizeof (grub_uint64_t)) + +#define ZIO_GET_IOSIZE(zio) \ + (BP_IS_GANG((zio)->io_bp) ? \ + SPA_GANGBLOCKSIZE : BP_GET_PSIZE((zio)->io_bp)) + +typedef struct zio_gbh { + blkptr_t zg_blkptr[SPA_GBH_NBLKPTRS]; + grub_uint64_t zg_filler[SPA_GBH_FILLER]; + zio_eck_t zg_tail; +} zio_gbh_phys_t; + +enum zio_checksum { + ZIO_CHECKSUM_INHERIT = 0, + ZIO_CHECKSUM_ON, + ZIO_CHECKSUM_OFF, + ZIO_CHECKSUM_LABEL, + ZIO_CHECKSUM_GANG_HEADER, + ZIO_CHECKSUM_ZILOG, + ZIO_CHECKSUM_FLETCHER_2, + ZIO_CHECKSUM_FLETCHER_4, + ZIO_CHECKSUM_SHA256, + ZIO_CHECKSUM_ZILOG2, + ZIO_CHECKSUM_FUNCTIONS +}; + +#define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_2 +#define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON + +enum zio_compress { + ZIO_COMPRESS_INHERIT = 0, + ZIO_COMPRESS_ON, + ZIO_COMPRESS_OFF, + ZIO_COMPRESS_LZJB, + ZIO_COMPRESS_EMPTY, + ZIO_COMPRESS_GZIP, + ZIO_COMPRESS_FUNCTIONS +}; + +#endif /* _ZIO_H */ diff --git a/include/grub/zfs/zio_checksum.h b/include/grub/zfs/zio_checksum.h new file mode 100644 index 000000000..b4d6382af --- /dev/null +++ b/include/grub/zfs/zio_checksum.h @@ -0,0 +1,50 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ZIO_CHECKSUM_H +#define _SYS_ZIO_CHECKSUM_H + +/* + * Signature for checksum functions. + */ +typedef void zio_checksum_t(const void *data, grub_uint64_t size, + grub_zfs_endian_t endian, zio_cksum_t *zcp); + +/* + * Information about each checksum function. + */ +typedef struct zio_checksum_info { + zio_checksum_t *ci_func; /* checksum function for each byteorder */ + int ci_correctable; /* number of correctable bits */ + int ci_eck; /* uses zio embedded checksum? */ + char *ci_name; /* descriptive name */ +} zio_checksum_info_t; + +extern void zio_checksum_SHA256 (const void *, grub_uint64_t, + grub_zfs_endian_t endian, zio_cksum_t *); +extern void fletcher_2 (const void *, grub_uint64_t, grub_zfs_endian_t endian, + zio_cksum_t *); +extern void fletcher_4 (const void *, grub_uint64_t, grub_zfs_endian_t endian, + zio_cksum_t *); + +#endif /* _SYS_ZIO_CHECKSUM_H */ From 54207d4b6cd6f8f262e320e453da9462cd046105 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Wed, 1 Dec 2010 22:55:26 +0100 Subject: [PATCH 006/276] Update GPL for ZFS code to version 3, move copyright lines for Vladimir and me to FSF (covered by our assignments) --- grub-core/fs/zfs/zfs.c | 11 ++++------- grub-core/fs/zfs/zfs_fletcher.c | 10 ++++------ grub-core/fs/zfs/zfs_lzjb.c | 10 ++++------ grub-core/fs/zfs/zfs_sha256.c | 10 ++++------ grub-core/fs/zfs/zfsinfo.c | 10 ++++------ include/grub/zfs/dmu.h | 9 ++++----- include/grub/zfs/dmu_objset.h | 9 ++++----- include/grub/zfs/dnode.h | 9 ++++----- include/grub/zfs/dsl_dataset.h | 9 ++++----- include/grub/zfs/dsl_dir.h | 9 ++++----- include/grub/zfs/sa_impl.h | 9 ++++----- include/grub/zfs/spa.h | 10 ++++------ include/grub/zfs/uberblock_impl.h | 9 ++++----- include/grub/zfs/vdev_impl.h | 9 ++++----- include/grub/zfs/zap_impl.h | 9 ++++----- include/grub/zfs/zap_leaf.h | 9 ++++----- include/grub/zfs/zfs.h | 10 ++++------ include/grub/zfs/zfs_acl.h | 9 ++++----- include/grub/zfs/zfs_znode.h | 9 ++++----- include/grub/zfs/zil.h | 9 ++++----- include/grub/zfs/zio.h | 9 ++++----- include/grub/zfs/zio_checksum.h | 9 ++++----- 22 files changed, 88 insertions(+), 118 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index ce735a311..8901af76f 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -1,23 +1,20 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2009,2010 Free Software Foundation, Inc. * Copyright 2010 Sun Microsystems, Inc. - * Copyright (C) 2009 Vladimir Serbinenko - * Copyright (C) 2010 Robert Millan * - * This program is free software; you can redistribute it and/or modify + * 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. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * The zfs plug-in routines for GRUB are: diff --git a/grub-core/fs/zfs/zfs_fletcher.c b/grub-core/fs/zfs/zfs_fletcher.c index eaed15a2c..7d27b053d 100644 --- a/grub-core/fs/zfs/zfs_fletcher.c +++ b/grub-core/fs/zfs/zfs_fletcher.c @@ -1,22 +1,20 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc. * Copyright 2007 Sun Microsystems, Inc. - * Copyright (C) 2009 Vladimir Serbinenko * - * This program is free software; you can redistribute it and/or modify + * 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. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ #include diff --git a/grub-core/fs/zfs/zfs_lzjb.c b/grub-core/fs/zfs/zfs_lzjb.c index 0965d2d1f..62b5ea6a0 100644 --- a/grub-core/fs/zfs/zfs_lzjb.c +++ b/grub-core/fs/zfs/zfs_lzjb.c @@ -1,22 +1,20 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc. * Copyright 2007 Sun Microsystems, Inc. - * Copyright (C) 2009 Vladimir Serbinenko * - * This program is free software; you can redistribute it and/or modify + * 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. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ #include diff --git a/grub-core/fs/zfs/zfs_sha256.c b/grub-core/fs/zfs/zfs_sha256.c index 3dc79268a..ba510cf69 100644 --- a/grub-core/fs/zfs/zfs_sha256.c +++ b/grub-core/fs/zfs/zfs_sha256.c @@ -1,22 +1,20 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc. * Copyright 2007 Sun Microsystems, Inc. - * Copyright (C) 2009 Vladimir Serbinenko * - * This program is free software; you can redistribute it and/or modify + * 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. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ #include diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c index a9a13507e..33065892a 100644 --- a/grub-core/fs/zfs/zfsinfo.c +++ b/grub-core/fs/zfs/zfsinfo.c @@ -1,22 +1,20 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc. * Copyright 2008 Sun Microsystems, Inc. - * Copyright (C) 2009 Vladimir Serbinenko * - * This program is free software; you can redistribute it and/or modify + * 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. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ #include diff --git a/include/grub/zfs/dmu.h b/include/grub/zfs/dmu.h index 7faa7088b..bee317e8a 100644 --- a/include/grub/zfs/dmu.h +++ b/include/grub/zfs/dmu.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/dmu_objset.h b/include/grub/zfs/dmu_objset.h index aa1f4ab19..57d21db5c 100644 --- a/include/grub/zfs/dmu_objset.h +++ b/include/grub/zfs/dmu_objset.h @@ -3,19 +3,18 @@ * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * Copyright (C) 2010 Robert Millan * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/dnode.h b/include/grub/zfs/dnode.h index 6b0e18427..279c5451e 100644 --- a/include/grub/zfs/dnode.h +++ b/include/grub/zfs/dnode.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/dsl_dataset.h b/include/grub/zfs/dsl_dataset.h index de0dc54a8..c17bf801e 100644 --- a/include/grub/zfs/dsl_dataset.h +++ b/include/grub/zfs/dsl_dataset.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/dsl_dir.h b/include/grub/zfs/dsl_dir.h index 717f3592b..41d77c790 100644 --- a/include/grub/zfs/dsl_dir.h +++ b/include/grub/zfs/dsl_dir.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/sa_impl.h b/include/grub/zfs/sa_impl.h index 8aa6e2e08..a2b728d37 100644 --- a/include/grub/zfs/sa_impl.h +++ b/include/grub/zfs/sa_impl.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/spa.h b/include/grub/zfs/spa.h index 36b8e6708..22ee03b15 100644 --- a/include/grub/zfs/spa.h +++ b/include/grub/zfs/spa.h @@ -1,22 +1,20 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc. * Copyright 2010 Sun Microsystems, Inc. - * Copyright (C) 2009 Vladimir Serbinenko * - * This program is free software; you can redistribute it and/or modify + * 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. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ #ifndef GRUB_ZFS_SPA_HEADER diff --git a/include/grub/zfs/uberblock_impl.h b/include/grub/zfs/uberblock_impl.h index 9afc565c9..1bf7f2b07 100644 --- a/include/grub/zfs/uberblock_impl.h +++ b/include/grub/zfs/uberblock_impl.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/vdev_impl.h b/include/grub/zfs/vdev_impl.h index 6e9002ffc..9b5f0a7a8 100644 --- a/include/grub/zfs/vdev_impl.h +++ b/include/grub/zfs/vdev_impl.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/zap_impl.h b/include/grub/zfs/zap_impl.h index b229a0657..e42727ab6 100644 --- a/include/grub/zfs/zap_impl.h +++ b/include/grub/zfs/zap_impl.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/zap_leaf.h b/include/grub/zfs/zap_leaf.h index 9734456f0..1ef654054 100644 --- a/include/grub/zfs/zap_leaf.h +++ b/include/grub/zfs/zap_leaf.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/zfs.h b/include/grub/zfs/zfs.h index 153c28708..057692573 100644 --- a/include/grub/zfs/zfs.h +++ b/include/grub/zfs/zfs.h @@ -1,21 +1,19 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. - * Copyright (C) 2009 Vladimir Serbinenko + * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. diff --git a/include/grub/zfs/zfs_acl.h b/include/grub/zfs/zfs_acl.h index 65d3fdadc..277738279 100644 --- a/include/grub/zfs/zfs_acl.h +++ b/include/grub/zfs/zfs_acl.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/zfs_znode.h b/include/grub/zfs/zfs_znode.h index 87bc3f9fc..efd6d10a6 100644 --- a/include/grub/zfs/zfs_znode.h +++ b/include/grub/zfs/zfs_znode.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/zil.h b/include/grub/zfs/zil.h index 4ae8daf63..45d16f402 100644 --- a/include/grub/zfs/zil.h +++ b/include/grub/zfs/zil.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/zio.h b/include/grub/zfs/zio.h index 2b177a2ce..797d4f9b3 100644 --- a/include/grub/zfs/zio.h +++ b/include/grub/zfs/zio.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. diff --git a/include/grub/zfs/zio_checksum.h b/include/grub/zfs/zio_checksum.h index b4d6382af..0ef5a3ec7 100644 --- a/include/grub/zfs/zio_checksum.h +++ b/include/grub/zfs/zio_checksum.h @@ -2,19 +2,18 @@ * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with GRUB. If not, see . */ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. From c53c723762cc4a544346b230eadddd15161b1e26 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Fri, 3 Dec 2010 08:55:57 +0530 Subject: [PATCH 007/276] print line number on error --- util/grub-script-check.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/util/grub-script-check.c b/util/grub-script-check.c index a872a0400..2d1b31c9a 100644 --- a/util/grub-script-check.c +++ b/util/grub-script-check.c @@ -73,6 +73,7 @@ main (int argc, char *argv[]) { char *argument; char *input; + int lineno = 0; FILE *file = 0; int verbose = 0; int found_input = 0; @@ -111,6 +112,7 @@ main (int argc, char *argv[]) cmdline[i] = '\0'; } + lineno++; *line = grub_strdup (cmdline); free (cmdline); @@ -189,5 +191,11 @@ main (int argc, char *argv[]) if (file) fclose (file); - return (found_input && script == 0); + if (found_input && script == 0) + { + fprintf (stderr, "error: line no: %u\n", lineno); + return 1; + } + + return 0; } From 24b7938b32e755f25302962895cb81093550533c Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 4 Dec 2010 16:19:26 +0000 Subject: [PATCH 008/276] * grub-core/kern/i386/pc/startup.S (grub_console_getkey): Use `>> 1' rather than `/ 2', as the latter requires -Wa,--divide which would require bumping our minimum binutils version. --- ChangeLog | 6 ++++++ grub-core/kern/i386/pc/startup.S | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 995799775..0c6e842de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-04 Colin Watson + + * grub-core/kern/i386/pc/startup.S (grub_console_getkey): Use `>> 1' + rather than `/ 2', as the latter requires -Wa,--divide which would + require bumping our minimum binutils version. + 2010-12-03 BVK Chaitanya * util/grub-script-check.c (main): Print script line number on diff --git a/grub-core/kern/i386/pc/startup.S b/grub-core/kern/i386/pc/startup.S index d089a3e15..7aebc8b38 100644 --- a/grub-core/kern/i386/pc/startup.S +++ b/grub-core/kern/i386/pc/startup.S @@ -650,7 +650,7 @@ FUNCTION(grub_console_getkey) jae 2f movl %edx, %eax leal LOCAL(bypass_table), %edi - movl $((LOCAL(bypass_table_end) - LOCAL(bypass_table)) / 2), %ecx + movl $((LOCAL(bypass_table_end) - LOCAL(bypass_table)) >> 1), %ecx repne scasw jz 3f From 393324be7c27ee65c3f07de5b5e56f001b8a9ed3 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Wed, 8 Dec 2010 16:43:11 +0530 Subject: [PATCH 009/276] execute menu editor commands with argument scope --- grub-core/normal/menu_entry.c | 59 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index 0bb51ca28..4db4a45c1 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -1163,37 +1163,35 @@ clear_completions_all (struct screen *screen) static int run (struct screen *screen) { - int currline = 0; - char *nextline; + char *script; int errs_before; grub_menu_t menu; + char *dummy[1] = { NULL }; - auto grub_err_t editor_getline (char **line, int cont); - grub_err_t editor_getline (char **line, int cont __attribute__ ((unused))) - { - struct line *linep = screen->lines + currline; - char *p; + auto char * editor_getsource (void); + char * editor_getsource (void) + { + int i; + int size = 0; + char *source; - if (currline > screen->num_lines) - { - *line = 0; - return 0; - } + for (i = 0; i < screen->num_lines; i++) + size += screen->lines[i].len + 1; - /* Trim down space characters. */ - for (p = linep->buf + linep->len - 1; - p >= linep->buf && grub_isspace (*p); - p--) - ; - *++p = '\0'; + source = grub_malloc (size + 1); + if (! source) + return NULL; - linep->len = p - linep->buf; - for (p = linep->buf; grub_isspace (*p); p++) - ; - *line = grub_strdup (p); - currline++; - return 0; - } + size = 0; + for (i = 0; i < screen->num_lines; i++) + { + grub_strcpy (source + size, screen->lines[i].buf); + size += screen->lines[i].len; + source[size++] = '\n'; + } + source[size] = '\0'; + return source; + } grub_cls (); grub_printf (" "); @@ -1212,12 +1210,11 @@ run (struct screen *screen) } /* Execute the script, line for line. */ - while (currline < screen->num_lines) - { - editor_getline (&nextline, 0); - if (grub_normal_parse_line (nextline, editor_getline)) - break; - } + script = editor_getsource (); + if (! script) + return 0; + grub_script_execute_sourcecode (script, 0, dummy); + grub_free (script); if (errs_before != grub_err_printed_errors) grub_wait_after_message (); From a94a667185f093fd953b8775292652bc58b0d5fe Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 9 Dec 2010 14:09:37 +0100 Subject: [PATCH 010/276] 2010-12-09 Robert Millan * NEWS: Document addition of ZFS support. --- ChangeLog | 4 ++++ NEWS | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c6e842de..f215398cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-12-09 Robert Millan + + * NEWS: Document addition of ZFS support. + 2010-12-04 Colin Watson * grub-core/kern/i386/pc/startup.S (grub_console_getkey): Use `>> 1' diff --git a/NEWS b/NEWS index 7fce921d6..36e3f25bf 100644 --- a/NEWS +++ b/NEWS @@ -51,9 +51,7 @@ New in 1.99: * Add `sendkey' command (i386-pc only). -* ZFS support in `grub-install' and `grub-mkconfig'. Note: complete - functionality requires external ZFS implementation (available from - grub-extras). +* ZFS support. * Support 1.x versions of mdadm metadata. From 1fb430f865f2c4b367ddce5c45cc1b2f3eaecd34 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 10 Dec 2010 11:45:08 +0000 Subject: [PATCH 011/276] * grub-core/gettext/gettext.c (grub_gettext_init_ext): Factor out .mo/.mo.gz opening sequence to ... (grub_mofile_open_lang): ... here. (grub_gettext_init_ext): If opening ll_CC fails, try ll. * util/grub.d/00_header.in (grub_lang): Include country part of locale. Reported by: Mario Limonciello. --- ChangeLog | 10 ++++++++ grub-core/gettext/gettext.c | 48 +++++++++++++++++++++++++++---------- util/grub.d/00_header.in | 2 +- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index f215398cc..e8ac26e83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-12-10 Colin Watson + + * grub-core/gettext/gettext.c (grub_gettext_init_ext): Factor out + .mo/.mo.gz opening sequence to ... + (grub_mofile_open_lang): ... here. + (grub_gettext_init_ext): If opening ll_CC fails, try ll. + * util/grub.d/00_header.in (grub_lang): Include country part of + locale. + Reported by: Mario Limonciello. + 2010-12-09 Robert Millan * NEWS: Document addition of ZFS support. diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c index 9ab4c3b8d..5c7db4408 100644 --- a/grub-core/gettext/gettext.c +++ b/grub-core/gettext/gettext.c @@ -261,24 +261,16 @@ grub_mofile_open (const char *filename) return fd_mo; } +/* Returning grub_file_t would be more natural, but grub_mofile_open assigns + to fd_mo anyway ... */ static void -grub_gettext_init_ext (const char *lang) +grub_mofile_open_lang (const char *locale_dir, const char *locale) { char *mo_file; - char *locale_dir; - - locale_dir = grub_env_get ("locale_dir"); - if (locale_dir == NULL) - { - grub_dprintf ("gettext", "locale_dir variable is not set up.\n"); - return; - } - - fd_mo = NULL; /* mo_file e.g.: /boot/grub/locale/ca.mo */ - mo_file = grub_xasprintf ("%s/%s.mo", locale_dir, lang); + mo_file = grub_xasprintf ("%s/%s.mo", locale_dir, locale); if (!mo_file) return; @@ -295,6 +287,38 @@ grub_gettext_init_ext (const char *lang) return; fd_mo = grub_mofile_open (mo_file); } +} + +static void +grub_gettext_init_ext (const char *locale) +{ + char *locale_dir; + + locale_dir = grub_env_get ("locale_dir"); + if (locale_dir == NULL) + { + grub_dprintf ("gettext", "locale_dir variable is not set up.\n"); + return; + } + + fd_mo = NULL; + + grub_mofile_open_lang (locale_dir, locale); + + /* ll_CC didn't work, so try ll. */ + if (fd_mo == NULL) + { + char *lang = grub_strdup (locale); + char *underscore = grub_strchr (lang, '_'); + + if (underscore) + { + *underscore = '\0'; + grub_mofile_open_lang (locale_dir, lang); + } + + grub_free (lang); + } if (fd_mo) { diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 9ed3fc3a1..a596e9c4a 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -23,7 +23,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ locale_dir=`echo ${GRUB_PREFIX}/locale | sed ${transform}` -grub_lang=`echo $LANG | cut -d _ -f 1` +grub_lang=`echo $LANG | cut -d . -f 1` . ${libdir}/grub/grub-mkconfig_lib From 5367ecd3050ebbc8e732b687303f5afc86ac3c62 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 10 Dec 2010 12:56:45 +0000 Subject: [PATCH 012/276] * .bzrignore: Ignore grub-core/rs_decoder.S. --- .bzrignore | 1 + ChangeLog | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.bzrignore b/.bzrignore index 7c5597bce..0cbb3f17f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -131,5 +131,6 @@ grub-core/gnulib/unistd.h grub-core/gnulib/warn-on-use.h grub-core/gnulib/wchar.h grub-core/gnulib/wctype.h +grub-core/rs_decoder.S widthspec.bin widthspec.h diff --git a/ChangeLog b/ChangeLog index e8ac26e83..abd1d0400 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-12-10 Colin Watson + + * .bzrignore: Ignore grub-core/rs_decoder.S. + 2010-12-10 Colin Watson * grub-core/gettext/gettext.c (grub_gettext_init_ext): Factor out From d6f07b29fca3f555b22000fde18577a45bd42b39 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 10 Dec 2010 14:38:16 +0100 Subject: [PATCH 013/276] mtime btrfs support --- grub-core/fs/btrfs.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index b7edb7e39..b7c59065c 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -172,10 +172,18 @@ struct grub_btrfs_root_item grub_uint64_t inode; }; +struct grub_btrfs_time +{ + grub_int64_t sec; + grub_uint32_t nanosec; +} __attribute__ ((aligned(4))); + struct grub_btrfs_inode { - grub_uint8_t dummy[0x10]; + grub_uint8_t dummy1[0x10]; grub_uint64_t size; + grub_uint8_t dummy2[0x70]; + struct grub_btrfs_time mtime; } __attribute__ ((packed)); struct grub_btrfs_extent_data @@ -1263,7 +1271,6 @@ grub_btrfs_dir (grub_device_t device, const char *path, } do { - struct grub_dirhook_info info; struct grub_btrfs_dir_item *cdirel; if (key_out.type != GRUB_BTRFS_ITEM_TYPE_DIR_ITEM || key_out.object_id != key_in.object_id) @@ -1295,9 +1302,20 @@ grub_btrfs_dir (grub_device_t device, const char *path, + grub_le_to_cpu16 (cdirel->m))) { char c; + struct grub_btrfs_inode inode; + struct grub_dirhook_info info; + err = grub_btrfs_read_inode (data, &inode, cdirel->key.object_id, + tree); + grub_memset (&info, 0, sizeof (info)); + if (err) + grub_errno = GRUB_ERR_NONE; + else + { + info.mtime = inode.mtime.sec; + info.mtimeset = 1; + } c = cdirel->name[grub_le_to_cpu16 (cdirel->n)]; cdirel->name[grub_le_to_cpu16 (cdirel->n)] = 0; - grub_memset (&info, 0, sizeof (info)); info.dir = (cdirel->type == GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY); if (hook (cdirel->name, &info)) goto out; From b04298cfa29418564bd86fd1053fb681000966bc Mon Sep 17 00:00:00 2001 From: kashyap garimella Date: Sat, 18 Dec 2010 15:22:11 +0100 Subject: [PATCH 014/276] * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_load): Use correct cat to grub_uint8_t * rather than grub_uint32_t *. --- ChangeLog | 5 +++++ grub-core/loader/i386/multiboot_mbi.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index abd1d0400..254c8303a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-12-18 kashyap garimella + + * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_load): Use + correct cat to grub_uint8_t * rather than grub_uint32_t *. + 2010-12-10 Colin Watson * .bzrignore: Ignore grub-core/rs_decoder.S. diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index 79f72ee0f..e3f328494 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -141,7 +141,7 @@ grub_multiboot_load (grub_file_t file) } if (header->bss_end_addr) - grub_memset ((grub_uint32_t *) source + load_size, 0, + grub_memset ((grub_uint8_t *) source + load_size, 0, header->bss_end_addr - header->load_addr - load_size); grub_multiboot_payload_eip = header->entry_addr; From e1dffcf2705db474dd3a59d8a514598af878da19 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 18 Dec 2010 14:31:05 +0100 Subject: [PATCH 015/276] * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): Set ptrdest to correct get_physical_target_address rather than incorrect get_virtual_current_address. --- ChangeLog | 6 ++++++ grub-core/loader/i386/multiboot_mbi.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 254c8303a..d7091f27c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-18 Vladimir Serbinenko + + * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): + Set ptrdest to correct get_physical_target_address rather than + incorrect get_virtual_current_address. + 2010-12-18 kashyap garimella * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_load): Use diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index e3f328494..7015666fc 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -441,7 +441,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target) if (err) return err; ptrorig = get_virtual_current_address (ch); - ptrdest = (grub_addr_t) get_virtual_current_address (ch); + ptrdest = get_physical_target_address (ch); *target = ptrdest; From 32570200a8bb64856c3125fecfc79b9467dddb50 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 18 Dec 2010 17:37:48 +0000 Subject: [PATCH 016/276] * grub-core/normal/term.c (print_more): Make \r or \n scroll one line, and other keys scroll an entire page (previous handling was for \r and \n to scroll a page and other keys to scroll two lines). --- ChangeLog | 6 ++++++ grub-core/normal/term.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7091f27c..3f15bcc7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-18 Colin Watson + + * grub-core/normal/term.c (print_more): Make \r or \n scroll one + line, and other keys scroll an entire page (previous handling was + for \r and \n to scroll a page and other keys to scroll two lines). + 2010-12-18 Vladimir Serbinenko * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c index 00721c447..a1aa3d783 100644 --- a/grub-core/normal/term.c +++ b/grub-core/normal/term.c @@ -91,16 +91,16 @@ print_more (void) grub_term_restore_pos (pos); grub_free (pos); - /* Scroll one lines or an entire page, depending on the key. */ + /* Scroll one line or an entire page, depending on the key. */ if (key == '\r' || key =='\n') - grub_normal_reset_more (); - else { static struct term_state *state; for (state = term_states; state; state = state->next) - state->num_lines -= 2; + state->num_lines--; } + else + grub_normal_reset_more (); } void From 5cf86f4b0fadf4fbe8780cf5d4592b81e86158b4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 18 Dec 2010 22:47:50 +0100 Subject: [PATCH 017/276] * util/grub-mkfont.c (main): Handle errors from FT_Set_Pixel_Sizes. --- ChangeLog | 4 ++++ util/grub-mkfont.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bc5e26582..1012833a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,10 @@ editor under argument scope. Reported by: Jordan Uggla +2010-12-18 Vladimir Serbinenko + + * util/grub-mkfont.c (main): Handle errors from FT_Set_Pixel_Sizes. + 2010-12-18 Colin Watson * grub-core/normal/term.c (print_more): Make \r or \n scroll one diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index 3e24380d1..fff6a619e 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -1170,7 +1170,8 @@ main (int argc, char *argv[]) font_info.style = ft_face->style_flags; font_info.size = size; - FT_Set_Pixel_Sizes (ft_face, size, size); + if (FT_Set_Pixel_Sizes (ft_face, size, size)) + grub_util_error ("can't set %dx%d font size", size, size); add_font (&font_info, ft_face, file_format != PF2); FT_Done_Face (ft_face); } From 7059d1ec14f7c5c44623688a7960050be9c585e0 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 19 Dec 2010 00:43:41 +0100 Subject: [PATCH 018/276] Fix handling of UTF-16 UDF labels. * grub-core/fs/udf.c (grub_udf_iterate_dir): Move string-parsing part (read_string): .. here. (grub_udf_label): Use read_string. --- ChangeLog | 8 ++++++ grub-core/fs/udf.c | 70 +++++++++++++++++++++++++++++++--------------- 2 files changed, 55 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1012833a0..333b24ab2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-12-19 Vladimir Serbinenko + + Fix handling of UTF-16 UDF labels. + + * grub-core/fs/udf.c (grub_udf_iterate_dir): Move string-parsing part + (read_string): .. here. + (grub_udf_label): Use read_string. + 2010-12-19 BVK Chaitanya * grub-core/normal/menu_entry.c (run): Execute commands from menu diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c index 7041e619e..51726edf3 100644 --- a/grub-core/fs/udf.c +++ b/grub-core/fs/udf.c @@ -788,6 +788,43 @@ fail: return 0; } +static char * +read_string (grub_uint8_t *raw, grub_size_t sz) +{ + grub_uint16_t *utf16; + char *ret; + grub_size_t utf16len = 0; + + if (raw[0] != 8 && raw[0] != 16) + return NULL; + + if (raw[0] == 8) + { + unsigned i; + utf16len = sz - 1; + utf16 = grub_malloc (utf16len * sizeof (utf16[0])); + if (!utf16) + return NULL; + for (i = 0; i < utf16len; i++) + utf16[i] = raw[i + 1]; + } + if (raw[0] == 16) + { + unsigned i; + utf16len = (sz - 1) / 2; + utf16 = grub_malloc (utf16len * sizeof (utf16[0])); + if (!utf16) + return NULL; + for (i = 0; i < utf16len; i++) + utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2]; + } + ret = grub_malloc (utf16len * 3 + 1); + if (ret) + *grub_utf16_to_utf8 ((grub_uint8_t *) ret, utf16, utf16len) = '\0'; + grub_free (utf16); + return ret; +} + static int grub_udf_iterate_dir (grub_fshelp_node_t dir, int NESTED_FUNC_ATTR @@ -841,10 +878,8 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir, else { enum grub_fshelp_filetype type; + char *filename; grub_uint8_t raw[dirent.file_ident_length]; - grub_uint16_t utf16[dirent.file_ident_length - 1]; - grub_uint8_t filename[dirent.file_ident_length * 2]; - grub_size_t utf16len = 0; type = ((dirent.characteristics & GRUB_UDF_FID_CHAR_DIRECTORY) ? (GRUB_FSHELP_DIR) : (GRUB_FSHELP_REG)); @@ -855,27 +890,16 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir, != dirent.file_ident_length) return 0; - if (raw[0] == 8) - { - unsigned i; - utf16len = dirent.file_ident_length - 1; - for (i = 0; i < utf16len; i++) - utf16[i] = raw[i + 1]; - } - if (raw[0] == 16) - { - unsigned i; - utf16len = (dirent.file_ident_length - 1) / 2; - for (i = 0; i < utf16len; i++) - utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2]; - } - if (raw[0] == 8 || raw[0] == 16) - { - *grub_utf16_to_utf8 (filename, utf16, utf16len) = '\0'; + filename = read_string (raw, dirent.file_ident_length); + if (!filename) + grub_print_error (); - if (hook ((char *) filename, type, child)) - return 1; + if (filename && hook (filename, type, child)) + { + grub_free (filename); + return 1; } + grub_free (filename); } } @@ -1004,7 +1028,7 @@ grub_udf_label (grub_device_t device, char **label) if (data) { - *label = grub_strdup ((char *) &data->lvd.ident[1]); + *label = read_string (data->lvd.ident, sizeof (data->lvd.ident)); grub_free (data); } else From a2a08a35bf2a6603b9c0ee5dc3e224f41373258c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 19 Dec 2010 00:49:52 +0100 Subject: [PATCH 019/276] * grub-core/fs/affs.c (grub_affs_fs) [GRUB_UTIL]: Explicitly set reserved_first_sector to 0. * grub-core/fs/cpio.c (grub_cpio_fs) [GRUB_UTIL]: Likewise. * grub-core/fs/sfs.c (grub_sfs_fs) [GRUB_UTIL]: Likewise. * grub-core/fs/xfs.c (grub_xfs_fs) [GRUB_UTIL]: Likewise. --- ChangeLog | 8 ++++++++ grub-core/fs/affs.c | 3 +++ grub-core/fs/cpio.c | 3 +++ grub-core/fs/sfs.c | 3 +++ grub-core/fs/xfs.c | 3 +++ 5 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 333b24ab2..99cf2cd7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-12-19 Vladimir Serbinenko + + * grub-core/fs/affs.c (grub_affs_fs) [GRUB_UTIL]: Explicitly set + reserved_first_sector to 0. + * grub-core/fs/cpio.c (grub_cpio_fs) [GRUB_UTIL]: Likewise. + * grub-core/fs/sfs.c (grub_sfs_fs) [GRUB_UTIL]: Likewise. + * grub-core/fs/xfs.c (grub_xfs_fs) [GRUB_UTIL]: Likewise. + 2010-12-19 Vladimir Serbinenko Fix handling of UTF-16 UDF labels. diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c index 3dc80752d..27e03c0c4 100644 --- a/grub-core/fs/affs.c +++ b/grub-core/fs/affs.c @@ -535,6 +535,9 @@ static struct grub_fs grub_affs_fs = .read = grub_affs_read, .close = grub_affs_close, .label = grub_affs_label, +#ifdef GRUB_UTIL + .reserved_first_sector = 0, +#endif .next = 0 }; diff --git a/grub-core/fs/cpio.c b/grub-core/fs/cpio.c index c087b4f90..2c92404c3 100644 --- a/grub-core/fs/cpio.c +++ b/grub-core/fs/cpio.c @@ -354,6 +354,9 @@ static struct grub_fs grub_cpio_fs = { .open = grub_cpio_open, .read = grub_cpio_read, .close = grub_cpio_close, +#ifdef GRUB_UTIL + .reserved_first_sector = 0, +#endif }; #ifdef MODE_USTAR diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c index 4a5005908..b49420de1 100644 --- a/grub-core/fs/sfs.c +++ b/grub-core/fs/sfs.c @@ -579,6 +579,9 @@ static struct grub_fs grub_sfs_fs = .read = grub_sfs_read, .close = grub_sfs_close, .label = grub_sfs_label, +#ifdef GRUB_UTIL + .reserved_first_sector = 0, +#endif .next = 0 }; diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 9dffe31d1..3d773856e 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -808,6 +808,9 @@ static struct grub_fs grub_xfs_fs = .close = grub_xfs_close, .label = grub_xfs_label, .uuid = grub_xfs_uuid, +#ifdef GRUB_UTIL + .reserved_first_sector = 0, +#endif .next = 0 }; From 6c85b743f5c3a07c400ffd798e87cbcf2d3ab64d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 19 Dec 2010 00:52:18 +0100 Subject: [PATCH 020/276] * grub-core/fs/affs.c (grub_affs_mount): Read data->bblock.rootblock rather than assuming than rootblock is exactly in the middle. (grub_affs_label): Likewise. --- ChangeLog | 6 ++++++ grub-core/fs/affs.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 99cf2cd7f..12836d9af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-19 Vladimir Serbinenko + + * grub-core/fs/affs.c (grub_affs_mount): Read data->bblock.rootblock + rather than assuming than rootblock is exactly in the middle. + (grub_affs_label): Likewise. + 2010-12-19 Vladimir Serbinenko * grub-core/fs/affs.c (grub_affs_fs) [GRUB_UTIL]: Explicitly set diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c index 27e03c0c4..40be4b2f6 100644 --- a/grub-core/fs/affs.c +++ b/grub-core/fs/affs.c @@ -208,7 +208,7 @@ grub_affs_mount (grub_disk_t disk) rblock = (struct grub_affs_rblock *) rootblock; /* Read the rootblock. */ - grub_disk_read (disk, (disk->total_sectors >> 1) + blocksize, 0, + grub_disk_read (disk, grub_be_to_cpu32 (data->bblock.rootblock), 0, GRUB_DISK_SECTOR_SIZE * 16, rootblock); if (grub_errno) goto fail; @@ -240,7 +240,7 @@ grub_affs_mount (grub_disk_t disk) data->disk = disk; data->htsize = grub_be_to_cpu32 (rblock->htsize); data->diropen.data = data; - data->diropen.block = (disk->total_sectors >> 1); + data->diropen.block = grub_be_to_cpu32 (data->bblock.rootblock); grub_free (rootblock); @@ -507,7 +507,7 @@ grub_affs_label (grub_device_t device, char **label) { /* The rootblock maps quite well on a file header block, it's something we can use here. */ - grub_disk_read (data->disk, disk->total_sectors >> 1, + grub_disk_read (data->disk, grub_be_to_cpu32 (data->bblock.rootblock), data->blocksize * (GRUB_DISK_SECTOR_SIZE - GRUB_AFFS_FILE_LOCATION), sizeof (file), &file); From 5318fe9804f1e95e2d04186f4bf28562c8cfaf5e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 20 Dec 2010 16:13:01 +0100 Subject: [PATCH 021/276] * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_add_module): Avoid next pointing to nowhere. --- ChangeLog | 5 +++++ grub-core/loader/i386/multiboot_mbi.c | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 12836d9af..6e564324b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-12-20 Vladimir Serbinenko + + * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_add_module): + Avoid next pointing to nowhere. + 2010-12-19 Vladimir Serbinenko * grub-core/fs/affs.c (grub_affs_mount): Read data->bblock.rootblock diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index 7015666fc..eade78e93 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -641,6 +641,7 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size, return grub_errno; newmod->start = start; newmod->size = size; + newmod->next = 0; for (i = 0; i < argc; i++) len += grub_strlen (argv[i]) + 1; From 4e01b6c821b46c83b19a22b7ecd0207780c90ab0 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 21 Dec 2010 12:49:29 +0000 Subject: [PATCH 022/276] * util/grub-mkconfig_lib.in (gettext_quoted): Add clarifying comment. Add an extra layer of quotation, requiring the output of this function to be used in a printf format string. (gettext_printf): New function. * util/grub.d/10_hurd.in: Use gettext_printf where appropriate. Extract translatable strings from here-documents and use a temporary variable instead, so that xgettext can find them. * util/grub.d/10_kfreebsd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/grub.d/20_linux_xen.in: Likewise. * po/grub.d.sed: New file. * po/Makefile.in.in ($(DOMAIN).pot-update): Extract gettext_printf arguments. Set c-format flags on all strings extracted from util/grub.d/ (xgettext refuses to include these itself for strings it extracted from a shell file, but these really are c-format). --- ChangeLog | 19 +++++++++++++++++++ po/Makefile.in.in | 8 ++++++-- po/grub.d.sed | 2 ++ util/grub-mkconfig_lib.in | 14 +++++++++++++- util/grub.d/10_hurd.in | 12 ++++++++---- util/grub.d/10_kfreebsd.in | 3 ++- util/grub.d/10_linux.in | 6 ++++-- util/grub.d/20_linux_xen.in | 6 ++++-- 8 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 po/grub.d.sed diff --git a/ChangeLog b/ChangeLog index 6e564324b..ca555a662 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2010-12-21 Colin Watson + + * util/grub-mkconfig_lib.in (gettext_quoted): Add clarifying + comment. Add an extra layer of quotation, requiring the output of + this function to be used in a printf format string. + (gettext_printf): New function. + * util/grub.d/10_hurd.in: Use gettext_printf where appropriate. + Extract translatable strings from here-documents and use a temporary + variable instead, so that xgettext can find them. + * util/grub.d/10_kfreebsd.in: Likewise. + * util/grub.d/10_linux.in: Likewise. + * util/grub.d/20_linux_xen.in: Likewise. + + * po/grub.d.sed: New file. + * po/Makefile.in.in ($(DOMAIN).pot-update): Extract gettext_printf + arguments. Set c-format flags on all strings extracted from + util/grub.d/ (xgettext refuses to include these itself for strings + it extracted from a shell file, but these really are c-format). + 2010-12-20 Vladimir Serbinenko * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_add_module): diff --git a/po/Makefile.in.in b/po/Makefile.in.in index d0af6c962..b0e7b8fa2 100644 --- a/po/Makefile.in.in +++ b/po/Makefile.in.in @@ -173,7 +173,8 @@ $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in $(srcdir)/POTFILES-shell --files-from=$(srcdir)/POTFILES-shell.in \ --copyright-holder='$(COPYRIGHT_HOLDER)' \ --msgid-bugs-address="$$msgid_bugs_address" \ - --join-existing --language=Shell --keyword=gettext_quoted \ + --join-existing --language=Shell \ + --keyword=gettext_quoted --keyword=gettext_printf \ ;; \ *) \ $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ @@ -183,10 +184,13 @@ $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in $(srcdir)/POTFILES-shell --package-name="$${package_gnu}@PACKAGE@" \ --package-version='@VERSION@' \ --msgid-bugs-address="$$msgid_bugs_address" \ - --join-existing --language=Shell --keyword=gettext_quoted \ + --join-existing --language=Shell \ + --keyword=gettext_quoted --keyword=gettext_printf \ ;; \ esac test ! -f $(DOMAIN).po || { \ + sed -f grub.d.sed < $(DOMAIN).po > $(DOMAIN).1po && \ + mv $(DOMAIN).1po $(DOMAIN).po; \ if test -f $(srcdir)/$(DOMAIN).pot; then \ sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ diff --git a/po/grub.d.sed b/po/grub.d.sed new file mode 100644 index 000000000..9fd729474 --- /dev/null +++ b/po/grub.d.sed @@ -0,0 +1,2 @@ +/^#: util\/grub\.d\//a\ +#, c-format diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 41359975e..ec4084698 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -187,8 +187,20 @@ version_find_latest () echo "$a" } +# One layer of quotation is eaten by "", the second by sed, and the third by +# printf; so this turns ' into \'. Note that you must use the output of +# this function in a printf format string. gettext_quoted () { - $gettext "$@" | sed "s/'/'\\\\''/g" + $gettext "$@" | sed "s/'/'\\\\\\\\''/g" +} + +# Run the first argument through gettext_quoted, and then pass that and all +# remaining arguments to printf. This is a useful abbreviation and tends to +# be easier to type. +gettext_printf () { + local format="$1" + shift + printf "$(gettext_quoted "$format")" "$@" } uses_abstraction () { diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index 6490913ae..eeb441aa4 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -81,14 +81,16 @@ do menuentry "${OS} ${KERNEL}" ${CLASS} { EOF prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/" + message="$(gettext_printf "Loading GNU Mach ...")" cat << EOF - echo '$(gettext_quoted "Loading GNU Mach ...")' + echo '$message' 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/" + message="$(gettext_printf "Loading the Hurd ...")" cat << EOF - echo '$(gettext_quoted "Loading the Hurd ...")' + echo '$message' module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\ --multiboot-command-line='\${kernel-command-line}' \\ --host-priv-port='\${host-port}' \\ @@ -103,13 +105,15 @@ EOF menuentry "${OS} ${KERNEL} (recovery mode)" ${CLASS} { EOF prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/" + message="$(gettext_printf "Loading GNU Mach ...")" cat << EOF - echo '$(gettext_quoted "Loading GNU Mach ...")' + echo '$message' multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} -s EOF prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/" + message="$(gettext_printf "Loading the Hurd ...")" cat << EOF - echo '$(gettext_quoted "Loading the Hurd ...")' + echo '$message' module /hurd/${hurd_fs}.static ${hurd_fs} \\ --multiboot-command-line='\${kernel-command-line}' \\ --host-priv-port='\${host-port}' \\ diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index 9cb2788df..b026812a7 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -84,8 +84,9 @@ kfreebsd_entry () fi printf '%s\n' "${prepare_boot_cache}" + message="$(gettext_printf "Loading kernel of FreeBSD %s ..." ${version})" cat << EOF - echo '$(printf "$(gettext_quoted "Loading kernel of FreeBSD %s ...")" ${version})' + echo '$message' kfreebsd ${rel_dirname}/${basename} ${args} EOF diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 7650ac9fa..a09c3e687 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -94,13 +94,15 @@ EOF prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" fi printf '%s\n' "${prepare_boot_cache}" + message="$(gettext_printf "Loading Linux %s ..." ${version})" cat << EOF - echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})' + echo '$message' linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then + message="$(gettext_printf "Loading initial ramdisk ...")" cat << EOF - echo '$(gettext_quoted "Loading initial ramdisk ...")' + echo '$message' initrd ${rel_dirname}/${initrd} EOF fi diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 649ae85dd..a90211f44 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -73,14 +73,16 @@ linux_entry () prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" fi printf '%s\n' "${prepare_boot_cache}" + message="$(gettext_printf "Loading Linux %s ..." ${version})" cat << EOF - echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})' + echo '$message' multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then + message="$(gettext_printf "Loading initial ramdisk ...")" cat << EOF - echo '$(gettext_quoted "Loading initial ramdisk ...")' + echo '$message' module ${rel_dirname}/${initrd} EOF fi From b889cfadf9e3cf85f538d5eb206028b583bff7ef Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 21 Dec 2010 13:00:10 +0000 Subject: [PATCH 023/276] * grub-core/fs/udf.c (read_string): Pacify GCC warning by initialising utf16. --- ChangeLog | 5 +++++ grub-core/fs/udf.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ca555a662..42e059d46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-12-21 Colin Watson + + * grub-core/fs/udf.c (read_string): Pacify GCC warning by + initialising utf16. + 2010-12-21 Colin Watson * util/grub-mkconfig_lib.in (gettext_quoted): Add clarifying diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c index 51726edf3..1672aab1b 100644 --- a/grub-core/fs/udf.c +++ b/grub-core/fs/udf.c @@ -791,7 +791,7 @@ fail: static char * read_string (grub_uint8_t *raw, grub_size_t sz) { - grub_uint16_t *utf16; + grub_uint16_t *utf16 = NULL; char *ret; grub_size_t utf16len = 0; From d060ad60eee798a5c7c970ca2e777c7f1d0f8caa Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 21 Dec 2010 13:52:07 +0000 Subject: [PATCH 024/276] * grub-core/commands/echo.c (grub_cmd_echo): Make UTF-8-clean by constructing a new unescaped string and passing it to grub_xputs in one go, rather than passing characters to grub_printf one at a time. --- ChangeLog | 6 ++++++ grub-core/commands/echo.c | 26 ++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42e059d46..e65dc231c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-21 Colin Watson + + * grub-core/commands/echo.c (grub_cmd_echo): Make UTF-8-clean by + constructing a new unescaped string and passing it to grub_xputs in + one go, rather than passing characters to grub_printf one at a time. + 2010-12-21 Colin Watson * grub-core/fs/udf.c (read_string): Pacify GCC warning by diff --git a/grub-core/commands/echo.c b/grub-core/commands/echo.c index 7ab9f92c6..93a452fc8 100644 --- a/grub-core/commands/echo.c +++ b/grub-core/commands/echo.c @@ -44,8 +44,14 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args) for (i = 0; i < argc; i++) { char *arg = *args; + /* Unescaping results in a string no longer than the original. */ + char *unescaped = grub_malloc (grub_strlen (arg) + 1); + char *p = unescaped; args++; + if (!unescaped) + return grub_errno; + while (*arg) { /* In case `-e' is used, parse backslashes. */ @@ -58,11 +64,11 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args) switch (*arg) { case '\\': - grub_printf ("\\"); + *p++ = '\\'; break; case 'a': - grub_printf ("\a"); + *p++ = '\a'; break; case 'c': @@ -70,23 +76,23 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args) break; case 'f': - grub_printf ("\f"); + *p++ = '\f'; break; case 'n': - grub_printf ("\n"); + *p++ = '\n'; break; case 'r': - grub_printf ("\r"); + *p++ = '\r'; break; case 't': - grub_printf ("\t"); + *p++ = '\t'; break; case 'v': - grub_printf ("\v"); + *p++ = '\v'; break; } arg++; @@ -95,10 +101,14 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args) /* This was not an escaped character, or escaping is not enabled. */ - grub_printf ("%c", *arg); + *p++ = *arg; arg++; } + *p = '\0'; + grub_xputs (unescaped); + grub_free (unescaped); + /* If another argument follows, insert a space. */ if (i != argc - 1) grub_printf (" " ); From 20641b6baad5d5a18ec5d5cd5305e01ff3c7f025 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 21 Dec 2010 16:51:08 +0000 Subject: [PATCH 025/276] * grub-core/lib/reed_solomon.c (gauss_solve): Fix size of standalone scratch area. Make sure to initialise chosen in standalone mode as well as non-standalone. Reported by: Robert Hooker and Andy Whitcroft. Tested by: Andy Whitcroft. --- ChangeLog | 8 ++++++++ grub-core/lib/reed_solomon.c | 12 +++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index e65dc231c..4c7225bc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-12-21 Colin Watson + + * grub-core/lib/reed_solomon.c (gauss_solve): Fix size of standalone + scratch area. Make sure to initialise chosen in standalone mode as + well as non-standalone. + Reported by: Robert Hooker and Andy Whitcroft. + Tested by: Andy Whitcroft. + 2010-12-21 Colin Watson * grub-core/commands/echo.c (grub_cmd_echo): Make UTF-8-clean by diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c index 4c6e160e4..6f571550a 100644 --- a/grub-core/lib/reed_solomon.c +++ b/grub-core/lib/reed_solomon.c @@ -18,6 +18,8 @@ #ifdef TEST #include +#include +#include #define xmalloc malloc #define grub_memset memset #define grub_memcpy memcpy @@ -25,8 +27,6 @@ #ifndef STANDALONE #ifdef TEST -#include -#include typedef unsigned int grub_size_t; typedef unsigned char grub_uint8_t; typedef unsigned short grub_uint16_t; @@ -45,6 +45,7 @@ typedef unsigned char grub_uint8_t; typedef unsigned short grub_uint16_t; #else #include +#include #endif void grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs); @@ -207,11 +208,12 @@ gauss_solve (gf_single_t *eq, int n, int m, gf_single_t *sol) #ifndef STANDALONE chosen = xmalloc (n * sizeof (int)); - grub_memset (chosen, -1, n * sizeof (int)); #else chosen = (void *) scratch; - scratch += n; + scratch += n * sizeof (int); #endif + for (i = 0; i < n; i++) + chosen[i] = -1; for (i = 0; i < m; i++) sol[i] = 0; gauss_eliminate (eq, n, m, chosen); @@ -228,7 +230,7 @@ gauss_solve (gf_single_t *eq, int n, int m, gf_single_t *sol) #ifndef STANDALONE free (chosen); #else - scratch -= n; + scratch -= n * sizeof (int); #endif } From 1426ef3560721b04db1d3e162957825a00753cd8 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 21 Dec 2010 17:41:47 +0000 Subject: [PATCH 026/276] * include/grub/offsets.h (GRUB_KERNEL_I386_PC_RAW_SIZE): The previous patch increased the size of the RS code by 20 bytes (at least with gcc-4.4), so increase this by 20 bytes to match. (GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART): Likewise. --- ChangeLog | 7 +++++++ include/grub/offsets.h | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c7225bc5..27e2aee97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-12-21 Colin Watson + + * include/grub/offsets.h (GRUB_KERNEL_I386_PC_RAW_SIZE): The + previous patch increased the size of the RS code by 20 bytes (at + least with gcc-4.4), so increase this by 20 bytes to match. + (GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART): Likewise. + 2010-12-21 Colin Watson * grub-core/lib/reed_solomon.c (gauss_solve): Fix size of standalone diff --git a/include/grub/offsets.h b/include/grub/offsets.h index b096abf37..817372b69 100644 --- a/include/grub/offsets.h +++ b/include/grub/offsets.h @@ -38,9 +38,9 @@ #define GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY 0x1c /* The size of the first region which won't be compressed. */ -#define GRUB_KERNEL_I386_PC_RAW_SIZE 0xc90 +#define GRUB_KERNEL_I386_PC_RAW_SIZE 0xca4 -#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x6f8 +#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x70c /* The offset of GRUB_PREFIX. */ #define GRUB_KERNEL_I386_PC_PREFIX GRUB_KERNEL_I386_PC_RAW_SIZE From ab66c69f1a91617b429d73c59987e2c0c7d898c3 Mon Sep 17 00:00:00 2001 From: Jordan Uggla Date: Thu, 23 Dec 2010 11:51:18 +0000 Subject: [PATCH 027/276] * tests/util/grub-shell.in: Suppress "ACPI shutdown failed" error to keep unit tests from failing when they shouldn't. --- ChangeLog | 5 +++++ tests/util/grub-shell.in | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 27e2aee97..79eeae387 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-12-23 Jordan Uggla + + * tests/util/grub-shell.in: Suppress "ACPI shutdown failed" error to + keep unit tests from failing when they shouldn't. + 2010-12-21 Colin Watson * include/grub/offsets.h (GRUB_KERNEL_I386_PC_RAW_SIZE): The diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index fc14ca7b0..e35d6bc65 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -132,6 +132,8 @@ done cat <>${cfgfile} source /boot/grub/testcase.cfg +# Stop serial output to suppress "ACPI shutdown failed" error. +terminal_output console halt EOF From 0354b8672cfceed56851c9bad14edfe6a33050b5 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 25 Dec 2010 14:09:36 +0100 Subject: [PATCH 028/276] * grub-core/commands/acpihalt.c (grub_acpi_halt): Sleep for 1.5 before writing an error message because of async power management. * grub-core/kern/mips/yeeloong/init.c (grub_halt): Likewise. (grub_reboot): Likewise. --- ChangeLog | 7 +++++++ grub-core/commands/acpihalt.c | 3 +++ grub-core/kern/mips/yeeloong/init.c | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index 79eeae387..452455966 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-12-25 Vladimir Serbinenko + + * grub-core/commands/acpihalt.c (grub_acpi_halt): Sleep for 1.5 before + writing an error message because of async power management. + * grub-core/kern/mips/yeeloong/init.c (grub_halt): Likewise. + (grub_reboot): Likewise. + 2010-12-23 Jordan Uggla * tests/util/grub-shell.in: Suppress "ACPI shutdown failed" error to diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c index 2789e2eca..9a4cda521 100644 --- a/grub-core/commands/acpihalt.c +++ b/grub-core/commands/acpihalt.c @@ -36,6 +36,7 @@ typedef uint8_t grub_uint8_t; #ifndef GRUB_DSDT_TEST #include +#include #include #endif @@ -324,6 +325,8 @@ grub_acpi_halt (void) } } + grub_millisleep (1500); + grub_printf ("ACPI shutdown failed\n"); } #endif diff --git a/grub-core/kern/mips/yeeloong/init.c b/grub-core/kern/mips/yeeloong/init.c index cc7c16806..cadb10773 100644 --- a/grub-core/kern/mips/yeeloong/init.c +++ b/grub-core/kern/mips/yeeloong/init.c @@ -223,6 +223,8 @@ grub_halt (void) grub_outb (grub_inb (GRUB_CPU_LOONGSON_GPIOCFG) & ~GRUB_CPU_LOONGSON_SHUTDOWN_GPIO, GRUB_CPU_LOONGSON_GPIOCFG); + grub_millisleep (1500); + grub_printf ("Shutdown failed\n"); grub_refresh (); while (1); @@ -239,6 +241,8 @@ grub_reboot (void) { grub_write_ec (GRUB_MACHINE_EC_COMMAND_REBOOT); + grub_millisleep (1500); + grub_printf ("Reboot failed\n"); grub_refresh (); while (1); From c4855fdc79c3291e907a1080accbc1b4c60abd75 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 25 Dec 2010 18:16:01 +0100 Subject: [PATCH 029/276] * util/grub.d/30_os-prober.in: Don't emit drivemap directive for Windows Server 2008. Reported by: Devin Giddings. --- ChangeLog | 6 ++++++ util/grub.d/30_os-prober.in | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 452455966..43c4dbacb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-25 Vladimir Serbinenko + + * util/grub.d/30_os-prober.in: Don't emit drivemap directive for + Windows Server 2008. + Reported by: Devin Giddings. + 2010-12-25 Vladimir Serbinenko * grub-core/commands/acpihalt.c (grub_acpi_halt): Sleep for 1.5 before diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 728ac2378..d9d4b0a96 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -111,7 +111,7 @@ EOF prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" case ${LONGNAME} in - Windows\ Vista*|Windows\ 7*) + Windows\ Vista*|Windows\ 7*|Windows\ Server\ 2008*) ;; *) cat << EOF From 022d01b8078e3277a534f43eb58484ec2c4a3911 Mon Sep 17 00:00:00 2001 From: Shea Levy <> Date: Sat, 25 Dec 2010 18:21:46 +0100 Subject: [PATCH 030/276] * grub-core/genmod.sh.in: Use @OBJCOPY@ rather than objcopy. --- ChangeLog | 4 ++++ grub-core/genmod.sh.in | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 43c4dbacb..3a20e6346 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-12-25 Shea Levy + + * grub-core/genmod.sh.in: Use @OBJCOPY@ rather than objcopy. + 2010-12-25 Vladimir Serbinenko * util/grub.d/30_os-prober.in: Don't emit drivemap directive for diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index 8dfd5d347..b97f3e1c7 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -35,7 +35,7 @@ deps=`grep ^$modname: $moddep | sed s@^.*:@@` rm -f $tmpfile $outfile # stripout .modname and .moddeps sections from input module -objcopy -R .modname -R .moddeps $infile $tmpfile +@OBJCOPY@ -R .modname -R .moddeps $infile $tmpfile # Attach .modname and .moddeps sections t1=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 @@ -45,9 +45,9 @@ t2=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 for dep in $deps; do printf "$dep\0" >> $t2; done if test -n "$deps"; then - objcopy --add-section .modname=$t1 --add-section .moddeps=$t2 $tmpfile + @OBJCOPY@ --add-section .modname=$t1 --add-section .moddeps=$t2 $tmpfile else - objcopy --add-section .modname=$t1 $tmpfile + @OBJCOPY@ --add-section .modname=$t1 $tmpfile fi rm -f $t1 $t2 From 190a011a8b15506f0403ba77a587fa63fe7c7e2a Mon Sep 17 00:00:00 2001 From: Jeroen Dekkers Date: Sat, 25 Dec 2010 22:32:54 +0100 Subject: [PATCH 031/276] * grub-core/disk/raid.c (insert_array): Don't add spurious members. --- ChangeLog | 4 ++++ grub-core/disk/raid.c | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a20e6346..249ec6bc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-12-25 Jeroen Dekkers + + * grub-core/disk/raid.c (insert_array): Don't add spurious members. + 2010-12-25 Shea Levy * grub-core/genmod.sh.in: Use @OBJCOPY@ rather than objcopy. diff --git a/grub-core/disk/raid.c b/grub-core/disk/raid.c index f1b67a859..edc2b195d 100644 --- a/grub-core/disk/raid.c +++ b/grub-core/disk/raid.c @@ -522,14 +522,16 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array, /* We found more members of the array than the array actually has according to its superblock. This shouldn't happen normally. */ - grub_dprintf ("raid", "array->nr_devs > array->total_devs (%d)?!?", - array->total_devs); + return grub_error (GRUB_ERR_BAD_DEVICE, + "superfluous RAID member (%d found)", + array->total_devs); if (array->members[new_array->index].device != NULL) /* We found multiple devices with the same number. Again, this shouldn't happen. */ - grub_dprintf ("raid", "Found two disks with the number %d?!?", - new_array->number); + return grub_error (GRUB_ERR_BAD_DEVICE, + "found two disks with the number %d", + new_array->number); if (new_array->disk_size < array->disk_size) array->disk_size = new_array->disk_size; From 5c408d0f50396e832b386e6f7678a5b401dbde84 Mon Sep 17 00:00:00 2001 From: Mirko Parthey Date: Sun, 26 Dec 2010 20:49:08 +0100 Subject: [PATCH 032/276] * grub-core/boot/i386/pc/boot.S: Fix %es:%bx pointing to nowhere on floppy probe. --- ChangeLog | 5 +++++ grub-core/boot/i386/pc/boot.S | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 249ec6bc6..80f5ef568 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-12-25 Mirko Parthey + + * grub-core/boot/i386/pc/boot.S: Fix %es:%bx pointing to nowhere on + floppy probe. + 2010-12-25 Jeroen Dekkers * grub-core/disk/raid.c (insert_array): Don't add spurious members. diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S index 320918566..635599a24 100644 --- a/grub-core/boot/i386/pc/boot.S +++ b/grub-core/boot/i386/pc/boot.S @@ -459,6 +459,8 @@ fd_probe_error_string: .asciz "Floppy" 1: /* perform read */ movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx + movw %bx, %es + xorw %bx, %bx movw $0x201, %ax movb $0, %ch movb $0, %dh From 0b2db94300dca2b7597e3fbf6ade3a1cebd72c19 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 26 Dec 2010 21:15:31 +0100 Subject: [PATCH 033/276] Handling of files of unknown size is currently limited. They can't be used e.g. for initrd or modules. Moreover gzip handling of not easily seekable files is buggy. Disable unknown file size for now. May be inefficient but works. * grub-core/io/gzio.c (test_header): Always retrieve the file size. * grub-core/io/xzio.c (grub_xzio_open): Likewise. --- ChangeLog | 10 ++++++++++ grub-core/io/gzio.c | 25 ++++++++++++------------- grub-core/io/xzio.c | 3 ++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80f5ef568..0c701a342 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-12-26 Vladimir Serbinenko + + Handling of files of unknown size is currently limited. They can't be + used e.g. for initrd or modules. Moreover gzip handling of not + easily seekable files is buggy. Disable unknown file size for now. May + be inefficient but works. + + * grub-core/io/gzio.c (test_header): Always retrieve the file size. + * grub-core/io/xzio.c (grub_xzio_open): Likewise. + 2010-12-25 Mirko Parthey * grub-core/boot/i386/pc/boot.S: Fix %es:%bx pointing to nowhere on diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c index 43b67c373..f563d7b92 100644 --- a/grub-core/io/gzio.c +++ b/grub-core/io/gzio.c @@ -212,19 +212,18 @@ test_header (grub_file_t file) gzio->data_offset = grub_file_tell (gzio->file); - grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4); - - if (grub_file_seekable (gzio->file)) - { - if (grub_file_read (gzio->file, &orig_len, 4) != 4) - { - grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format"); - return 0; - } - } - /* FIXME: this does not handle files whose original size is over 4GB. - But how can we know the real original size? */ - file->size = grub_le_to_cpu32 (orig_len); + /* FIXME: don't do this on not easily seekable files. */ + { + grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4); + if (grub_file_read (gzio->file, &orig_len, 4) != 4) + { + grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format"); + return 0; + } + /* FIXME: this does not handle files whose original size is over 4GB. + But how can we know the real original size? */ + file->size = grub_le_to_cpu32 (orig_len); + } initialize_tables (file); diff --git a/grub-core/io/xzio.c b/grub-core/io/xzio.c index 1a22bdc70..37be1790f 100644 --- a/grub-core/io/xzio.c +++ b/grub-core/io/xzio.c @@ -222,7 +222,8 @@ grub_xzio_open (grub_file_t io) xzio->buf.out_pos = 0; xzio->buf.out_size = XZBUFSIZ; - if (!test_header (file) || !(grub_file_seekable (io) && test_footer (file))) + /* FIXME: don't test footer on not easily seekable files. */ + if (!test_header (file) || !test_footer (file)) { grub_errno = GRUB_ERR_NONE; grub_file_seek (io, 0); From 25dd47804dc8f314ad2061c0d0a50e5827f1de51 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 27 Dec 2010 07:06:41 +0100 Subject: [PATCH 034/276] Don't use disk subsystem in freebsd_boot. * grub-core/loader/i386/bsd.c (freebsd_bootdev): New variable. (freebsd_biosdev): Likewise. (grub_freebsd_boot): Use freebsd_bootdev and freebsd_biosdev. (grub_cmd_freebsd): Set freebsd_bootdev and freebsd_biosdev. --- ChangeLog | 9 +++++++++ grub-core/loader/i386/bsd.c | 17 ++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c701a342..0e4a725a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-12-27 Vladimir Serbinenko + + Don't use disk subsystem in freebsd_boot. + + * grub-core/loader/i386/bsd.c (freebsd_bootdev): New variable. + (freebsd_biosdev): Likewise. + (grub_freebsd_boot): Use freebsd_bootdev and freebsd_biosdev. + (grub_cmd_freebsd): Set freebsd_bootdev and freebsd_biosdev. + 2010-12-26 Vladimir Serbinenko Handling of files of unknown size is currently limited. They can't be diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index 91cae418c..84cf1a17f 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -521,6 +521,8 @@ grub_netbsd_list_modules (void) /* This function would be here but it's under different license. */ #include "bsd_pagetable.c" +static grub_uint32_t freebsd_bootdev, freebsd_biosdev; + static grub_err_t grub_freebsd_boot (void) { @@ -528,7 +530,6 @@ grub_freebsd_boot (void) grub_uint8_t *p, *p0; grub_addr_t p_target; grub_size_t p_size = 0; - grub_uint32_t bootdev, biosdev, unit, slice, part; grub_err_t err; grub_size_t tag_buf_len = 0; @@ -564,11 +565,7 @@ grub_freebsd_boot (void) bi.version = FREEBSD_BOOTINFO_VERSION; bi.length = sizeof (bi); - grub_bsd_get_device (&biosdev, &unit, &slice, &part); - bootdev = (FREEBSD_B_DEVMAGIC + ((slice + 1) << FREEBSD_B_SLICESHIFT) + - (unit << FREEBSD_B_UNITSHIFT) + (part << FREEBSD_B_PARTSHIFT)); - - bi.boot_device = biosdev; + bi.boot_device = freebsd_biosdev; p_size = 0; grub_env_iterate (iterate_env_count); @@ -741,7 +738,7 @@ grub_freebsd_boot (void) state.ebp = stack_target; stack[0] = entry; /* "Return" address. */ stack[1] = bootflags | FREEBSD_RB_BOOTINFO; - stack[2] = bootdev; + stack[2] = freebsd_bootdev; stack[3] = 0; stack[4] = 0; stack[5] = 0; @@ -1371,6 +1368,8 @@ grub_cmd_freebsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE) { + grub_uint32_t unit, slice, part; + kern_end = ALIGN_PAGE (kern_end); if (is_elf_kernel) { @@ -1414,6 +1413,10 @@ grub_cmd_freebsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) if (err) return err; } + grub_bsd_get_device (&freebsd_biosdev, &unit, &slice, &part); + freebsd_bootdev = (FREEBSD_B_DEVMAGIC + ((slice + 1) << FREEBSD_B_SLICESHIFT) + + (unit << FREEBSD_B_UNITSHIFT) + (part << FREEBSD_B_PARTSHIFT)); + grub_loader_set (grub_freebsd_boot, grub_bsd_unload, 0); } From c76386454e2e2214c3082b26ab99f1e733cac5eb Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 27 Dec 2010 07:09:43 +0100 Subject: [PATCH 035/276] Avoid using Reed-Solomon with 0 redundancy. * grub-core/kern/i386/pc/startup.S: Remove 0-data check. * grub-core/lib/reed_solomon.c (decode_block): Do not proceed on 0 data or 0 redundancy. (grub_reed_solomon_add_redundancy): Do not proceed with 0 redundancy. (grub_reed_solomon_recover): Likewise. --- ChangeLog | 10 ++++++++++ grub-core/kern/i386/pc/startup.S | 2 -- grub-core/lib/reed_solomon.c | 16 ++++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e4a725a5..d7606da2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-12-27 Vladimir Serbinenko + + Avoid using Reed-Solomon with 0 redundancy. + + * grub-core/kern/i386/pc/startup.S: Remove 0-data check. + * grub-core/lib/reed_solomon.c (decode_block): Do not proceed on 0 data + or 0 redundancy. + (grub_reed_solomon_add_redundancy): Do not proceed with 0 redundancy. + (grub_reed_solomon_recover): Likewise. + 2010-12-27 Vladimir Serbinenko Don't use disk subsystem in freebsd_boot. diff --git a/grub-core/kern/i386/pc/startup.S b/grub-core/kern/i386/pc/startup.S index 7aebc8b38..e78a0aa9a 100644 --- a/grub-core/kern/i386/pc/startup.S +++ b/grub-core/kern/i386/pc/startup.S @@ -151,8 +151,6 @@ LOCAL (codestart): addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART), %edx movl reed_solomon_redundancy, %ecx leal _start + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART, %eax - testl %edx, %edx - jz post_reed_solomon call EXT_C (grub_reed_solomon_recover) jmp post_reed_solomon diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c index 6f571550a..9a40e2f98 100644 --- a/grub-core/lib/reed_solomon.c +++ b/grub-core/lib/reed_solomon.c @@ -372,6 +372,10 @@ decode_block (gf_single_t *ptr, grub_size_t s, grub_size_t rr = (rs + SECTOR_SIZE - 1 - i) / SECTOR_SIZE; gf_single_t m[ds + rr]; + /* Nothing to do. */ + if (!ds || !rr) + continue; + for (j = 0; j < (int) ds; j++) m[j] = ptr[SECTOR_SIZE * j + i]; for (j = 0; j < (int) rr; j++) @@ -414,6 +418,10 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size, gf_single_t *ptr = buffer; gf_single_t *rptr = ptr + s; + /* Nothing to do. */ + if (!rs) + return; + while (s > 0) { grub_size_t tt; @@ -441,6 +449,10 @@ grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs) gf_single_t *ptr = ptr_; gf_single_t *rptr = ptr + s; + /* Nothing to do. */ + if (!rs) + return; + #if defined (STANDALONE) init_inverts (); #endif @@ -454,8 +466,8 @@ grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs) tt = cs + crs; if (tt > MAX_BLOCK_SIZE) { - cs = cs * MAX_BLOCK_SIZE / tt; - crs = crs * MAX_BLOCK_SIZE / tt; + cs = (cs * MAX_BLOCK_SIZE) / tt; + crs = (crs * MAX_BLOCK_SIZE) / tt; } decode_block (ptr, cs, rptr, crs); ptr += cs; From 693db2df5615ce6297031e04361b7bcb4b0fd571 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 27 Dec 2010 07:18:24 +0100 Subject: [PATCH 036/276] * grub-core/loader/xnu.c (grub_cmd_xnu_kext): Abort if no kernel is loaded (grub_cmd_xnu_kextdir): Likewise. (grub_cmd_xnu_splash): Likewise. --- ChangeLog | 7 +++++++ grub-core/loader/xnu.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index d7606da2a..31aa19bad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-12-27 Vladimir Serbinenko + + * grub-core/loader/xnu.c (grub_cmd_xnu_kext): Abort if no kernel + is loaded + (grub_cmd_xnu_kextdir): Likewise. + (grub_cmd_xnu_splash): Likewise. + 2010-12-27 Vladimir Serbinenko Avoid using Reed-Solomon with 0 redundancy. diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index d0b32dc6f..02151dd9c 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -1198,6 +1198,10 @@ grub_cmd_xnu_kext (grub_command_t cmd __attribute__ ((unused)), int argc, char *args[]) { grub_file_t binfile = 0; + + if (! grub_xnu_heap_size) + return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded"); + if (argc == 2) { /* User explicitly specified plist and binary. */ @@ -1229,6 +1233,9 @@ grub_cmd_xnu_kextdir (grub_command_t cmd __attribute__ ((unused)), if (argc != 1 && argc != 2) return grub_error (GRUB_ERR_BAD_ARGUMENT, "directory name required"); + if (! grub_xnu_heap_size) + return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded"); + if (argc == 1) return grub_xnu_scan_dir_for_kexts (args[0], "console,root,local-root,network-root", @@ -1370,6 +1377,9 @@ grub_cmd_xnu_splash (grub_extcmd_context_t ctxt, if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); + if (! grub_xnu_heap_size) + return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded"); + if (ctxt->state[XNU_SPLASH_CMD_ARGINDEX_MODE].set && grub_strcmp (ctxt->state[XNU_SPLASH_CMD_ARGINDEX_MODE].arg, "stretch") == 0) From 14b48a19c21667755e3080b5aa4bf231693d7346 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 27 Dec 2010 07:19:51 +0100 Subject: [PATCH 037/276] * grub-core/loader/xnu.c (grub_cmd_xnu_kernel) [! GRUB_MACHINE_EFI]: Preload EFIemu. (grub_cmd_xnu_kernel64) [! GRUB_MACHINE_EFI]: Likewise. --- ChangeLog | 6 ++++++ grub-core/loader/xnu.c | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 31aa19bad..9c1d85dcd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-27 Vladimir Serbinenko + + * grub-core/loader/xnu.c (grub_cmd_xnu_kernel) [! GRUB_MACHINE_EFI]: + Preload EFIemu. + (grub_cmd_xnu_kernel64) [! GRUB_MACHINE_EFI]: Likewise. + 2010-12-27 Vladimir Serbinenko * grub-core/loader/xnu.c (grub_cmd_xnu_kext): Abort if no kernel diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index 02151dd9c..95857951a 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -34,6 +34,10 @@ #include #include +#if defined (__i386) && !defined (GRUB_MACHINE_EFI) +#include +#endif + struct grub_xnu_devtree_key *grub_xnu_devtree_root = 0; static int driverspackagenum = 0; static int driversnum = 0; @@ -424,6 +428,12 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), if (ptr != grub_xnu_cmdline) *(ptr - 1) = 0; +#if defined (__i386) && !defined (GRUB_MACHINE_EFI) + err = grub_efiemu_autocore (); + if (err) + return err; +#endif + grub_loader_set (grub_xnu_boot, grub_xnu_unload, 0); grub_xnu_lock (); @@ -529,6 +539,12 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), if (ptr != grub_xnu_cmdline) *(ptr - 1) = 0; +#if defined (__i386) && !defined (GRUB_MACHINE_EFI) + err = grub_efiemu_autocore (); + if (err) + return err; +#endif + grub_loader_set (grub_xnu_boot, grub_xnu_unload, 0); grub_xnu_lock (); From b12b923e6335dd87944b49de08a021fac0c04b1b Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 31 Dec 2010 12:37:35 +0100 Subject: [PATCH 038/276] * grub-core/loader/i386/bsdXX.c (grub_openbsd_find_ramdisk): Silence spurious warning. Reported by: crocket --- ChangeLog | 6 ++++++ grub-core/loader/i386/bsdXX.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9c1d85dcd..dae48b0e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-31 Vladimir Serbinenko + + * grub-core/loader/i386/bsdXX.c (grub_openbsd_find_ramdisk): Silence + spurious warning. + Reported by: crocket + 2010-12-27 Vladimir Serbinenko * grub-core/loader/xnu.c (grub_cmd_xnu_kernel) [! GRUB_MACHINE_EFI]: diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 29892e5fb..2dd180509 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -511,7 +511,7 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file, grub_err_t err; Elf_Ehdr e; Elf_Shdr *s; - char *shdr; + char *shdr = NULL; err = read_headers (file, &e, &shdr); if (err) From 307806cb53c3e5ef0dd15b8e8aba23b354b42416 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 31 Dec 2010 14:55:55 +0100 Subject: [PATCH 039/276] * grub-core/partmap/amiga.c (GRUB_AMIGA_RDSK_MAGIC): New define. (amiga_partition_map_iterate): Use grub_memcmp instead of grub_strcmp. Reported by:EHeM. --- ChangeLog | 6 ++++++ grub-core/partmap/amiga.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index dae48b0e6..c9339e164 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-31 Vladimir Serbinenko + + * grub-core/partmap/amiga.c (GRUB_AMIGA_RDSK_MAGIC): New define. + (amiga_partition_map_iterate): Use grub_memcmp instead of grub_strcmp. + Reported by:EHeM. + 2010-12-31 Vladimir Serbinenko * grub-core/loader/i386/bsdXX.c (grub_openbsd_find_ramdisk): Silence diff --git a/grub-core/partmap/amiga.c b/grub-core/partmap/amiga.c index f21c5b243..a3ea3499c 100644 --- a/grub-core/partmap/amiga.c +++ b/grub-core/partmap/amiga.c @@ -27,6 +27,7 @@ struct grub_amiga_rdsk { /* "RDSK". */ grub_uint8_t magic[4]; +#define GRUB_AMIGA_RDSK_MAGIC "RDSK" grub_uint32_t size; grub_int32_t checksum; grub_uint32_t scsihost; @@ -87,7 +88,8 @@ amiga_partition_map_iterate (grub_disk_t disk, if (grub_disk_read (disk, pos, 0, sizeof (rdsk), &rdsk)) return grub_errno; - if (grub_strcmp ((char *) rdsk.magic, "RDSK") == 0) + if (grub_memcmp (rdsk.magic, GRUB_AMIGA_RDSK_MAGIC, + sizeof (rdsk.magic)) == 0) { /* Found the first PART block. */ next = grub_be_to_cpu32 (rdsk.partitionlst); From 275bff5f000f1d424dd86841f10ef79d4fc6c665 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 31 Dec 2010 15:00:45 +0100 Subject: [PATCH 040/276] * grub-core/partmap/amiga.c (GRUB_AMIGA_PART_MAGIC): New define. (amiga_partition_map_iterate): Check "PART" magic to avoid a very long loop in case of incorrect amiga partmap. --- ChangeLog | 6 ++++++ grub-core/partmap/amiga.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index c9339e164..505c1cc0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-31 Vladimir Serbinenko + + * grub-core/partmap/amiga.c (GRUB_AMIGA_PART_MAGIC): New define. + (amiga_partition_map_iterate): Check "PART" magic to avoid a very long + loop in case of incorrect amiga partmap. + 2010-12-31 Vladimir Serbinenko * grub-core/partmap/amiga.c (GRUB_AMIGA_RDSK_MAGIC): New define. diff --git a/grub-core/partmap/amiga.c b/grub-core/partmap/amiga.c index a3ea3499c..1e0f23402 100644 --- a/grub-core/partmap/amiga.c +++ b/grub-core/partmap/amiga.c @@ -44,6 +44,7 @@ struct grub_amiga_partition { /* "PART". */ grub_uint8_t magic[4]; +#define GRUB_AMIGA_PART_MAGIC "PART" grub_int32_t size; grub_int32_t checksum; grub_uint32_t scsihost; @@ -110,6 +111,9 @@ amiga_partition_map_iterate (grub_disk_t disk, if (grub_disk_read (disk, next, 0, sizeof (apart), &apart)) return grub_errno; + if (grub_memcmp (apart.magic, GRUB_AMIGA_PART_MAGIC, + sizeof (apart.magic)) == 0) + /* Calculate the first block and the size of the partition. */ part.start = (grub_be_to_cpu32 (apart.lowcyl) * grub_be_to_cpu32 (apart.heads) From 1b394975e927af0533d42fc516dfc36d57a6692b Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Fri, 31 Dec 2010 22:49:42 +0000 Subject: [PATCH 041/276] * util/grub.d/20_linux_xen.in (linux_entry): Correctly capitalize Xen and reorder menu item wording to make it clearer that this entry will launch Xen. Print separate messages when loading Xen and Linux. --- ChangeLog | 7 +++++++ util/grub.d/20_linux_xen.in | 12 +++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 505c1cc0d..9881baee9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-12-31 Ian Campbell + + * util/grub.d/20_linux_xen.in (linux_entry): Correctly capitalize + Xen and reorder menu item wording to make it clearer that this entry + will launch Xen. Print separate messages when loading Xen and + Linux. + 2010-12-31 Vladimir Serbinenko * grub-core/partmap/amiga.c (GRUB_AMIGA_PART_MAGIC): New define. diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index a90211f44..ee49cd903 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -60,11 +60,11 @@ linux_entry () args="$5" xen_args="$6" if ${recovery} ; then - title="$(gettext_quoted "%s, with Linux %s and XEN %s (recovery mode)")" + title="$(gettext_quoted "%s, with Xen %s and Linux %s (recovery mode)")" else - title="$(gettext_quoted "%s, with Linux %s and XEN %s")" + title="$(gettext_quoted "%s, with Xen %s and Linux %s")" fi - printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}" "${xen_version}" + printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${xen_version}" "${version}" if ! ${recovery} ; then save_default_entry | sed -e "s/^/\t/" fi @@ -73,10 +73,12 @@ linux_entry () prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" fi printf '%s\n' "${prepare_boot_cache}" - message="$(gettext_printf "Loading Linux %s ..." ${version})" + xmessage="$(gettext_printf "Loading Xen %s ..." ${xen_version})" + lmessage="$(gettext_printf "Loading Linux %s ..." ${version})" cat << EOF - echo '$message' + echo '$xmessage' multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} + echo '$lmessage' module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then From 323a8e9c6413ea90030c24d663f4c4f12a7a1ffd Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 3 Jan 2011 14:16:42 +0100 Subject: [PATCH 042/276] * util/grub-mkfont.c (main): Report errors in FT_New_Face. --- ChangeLog | 4 ++++ util/grub-mkfont.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9881baee9..7f5a316fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-03 Vladimir Serbinenko + + * util/grub-mkfont.c (main): Report errors in FT_New_Face. + 2010-12-31 Ian Campbell * util/grub.d/20_linux_xen.in (linux_entry): Correctly capitalize diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index fff6a619e..983ac7065 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -1146,11 +1146,18 @@ main (int argc, char *argv[]) { FT_Face ft_face; int size; + FT_Error err; - if (FT_New_Face (ft_lib, argv[optind], font_index, &ft_face)) + err = FT_New_Face (ft_lib, argv[optind], font_index, &ft_face); + if (err) { - grub_util_info ("can't open file %s, index %d", argv[optind], - font_index); + grub_printf ("can't open file %s, index %d: error %d", argv[optind], + font_index, err); + if (err > 0 && err < (signed) ARRAY_SIZE (ft_errmsgs)) + printf (": %s\n", ft_errmsgs[err]); + else + printf ("\n"); + continue; } From 469ee10a7f8637ce676fd3c8f43094f4235c020a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 3 Jan 2011 14:33:43 +0100 Subject: [PATCH 043/276] * util/grub-install.in: Correctly use bootloader_id and not GRUB_DISTRIBUTOR on efibootmgr line. --- ChangeLog | 5 +++++ util/grub-install.in | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7f5a316fc..f7b08c1e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-03 Vladimir Serbinenko + + * util/grub-install.in: Correctly use bootloader_id and not + GRUB_DISTRIBUTOR on efibootmgr line. + 2011-01-03 Vladimir Serbinenko * util/grub-mkfont.c (main): Report errors in FT_New_Face. diff --git a/util/grub-install.in b/util/grub-install.in index b9e833360..716582dfd 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -648,7 +648,7 @@ elif [ x"$platform" = xefi ]; then efidir_disk="$(echo "$clean_devmap" | grep "^$(echo "$efidir_drive" | sed 's/,[^)]*//')" | cut -f2)" efidir_part="$(echo "$efidir_drive" | sed 's/^([^,]*,[^0-9]*//; s/[^0-9].*//')" efibootmgr $efi_quiet -c -d "$efidir_disk" -p "$efidir_part" -w \ - -L "$GRUB_DISTRIBUTOR" -l "\\EFI\\$efi_distributor\\$efi_file" + -L "$bootloader_id" -l "\\EFI\\$efi_distributor\\$efi_file" fi fi fi From 4af0504b724b89d7e8057e64a6260a4d04781ffd Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Mon, 3 Jan 2011 15:30:41 +0100 Subject: [PATCH 044/276] * grub-core/fs/hfsplus.c: Make parent unsigned. (grub_hfsplus_cmp_catkey): Don't compare using subtraction, it overflows. (grub_hfsplus_cmp_extkey): Likewise --- ChangeLog | 7 +++++++ grub-core/fs/hfsplus.c | 33 +++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index f7b08c1e6..d89cb8618 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-03 Dave Vasilevsky + + * grub-core/fs/hfsplus.c: Make parent unsigned. + (grub_hfsplus_cmp_catkey): Don't compare using subtraction, it + overflows. + (grub_hfsplus_cmp_extkey): Likewise + 2011-01-03 Vladimir Serbinenko * util/grub-install.in: Correctly use bootloader_id and not diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index bcb8e9584..7d7115ce3 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -178,7 +178,7 @@ enum grub_hfsplus_filetype /* Internal representation of a catalog key. */ struct grub_hfsplus_catkey_internal { - int parent; + grub_uint32_t parent; char *name; }; @@ -520,9 +520,12 @@ grub_hfsplus_cmp_catkey (struct grub_hfsplus_key *keya, int i; int diff; - diff = grub_be_to_cpu32 (catkey_a->parent) - catkey_b->parent; - if (diff) - return diff; + /* Safe unsigned comparison */ + grub_uint32_t aparent = grub_be_to_cpu32 (catkey_a->parent); + if (aparent > catkey_b->parent) + return 1; + if (aparent < catkey_b->parent) + return -1; /* Change the filename in keya so the endianness is correct. */ for (i = 0; i < grub_be_to_cpu16 (catkey_a->namelen); i++) @@ -555,15 +558,21 @@ grub_hfsplus_cmp_extkey (struct grub_hfsplus_key *keya, { struct grub_hfsplus_extkey *extkey_a = &keya->extkey; struct grub_hfsplus_extkey_internal *extkey_b = &keyb->extkey; - int diff; + grub_uint32_t akey; - diff = grub_be_to_cpu32 (extkey_a->fileid) - extkey_b->fileid; - - if (diff) - return diff; - - diff = grub_be_to_cpu32 (extkey_a->start) - extkey_b->start; - return diff; + /* Safe unsigned comparison */ + akey = grub_be_to_cpu32 (extkey_a->fileid); + if (akey > extkey_b->fileid) + return 1; + if (akey < extkey_b->fileid) + return -1; + + akey = grub_be_to_cpu32 (extkey_a->start); + if (akey > extkey_b->start) + return 1; + if (akey < extkey_b->start) + return -1; + return 0; } static char * From 99d925aad45bb0f929a24957a43b83d50929cca4 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 3 Jan 2011 23:56:45 +0000 Subject: [PATCH 045/276] * grub-core/bus/pci.c (grub_pci_iterate): Skip remaining functions on devices that do not implement function 0. --- ChangeLog | 5 +++++ grub-core/bus/pci.c | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d89cb8618..a4692b5a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-03 Colin Watson + + * grub-core/bus/pci.c (grub_pci_iterate): Skip remaining functions + on devices that do not implement function 0. + 2011-01-03 Dave Vasilevsky * grub-core/fs/hfsplus.c: Make parent unsigned. diff --git a/grub-core/bus/pci.c b/grub-core/bus/pci.c index bf14a8653..11101d42b 100644 --- a/grub-core/bus/pci.c +++ b/grub-core/bus/pci.c @@ -90,7 +90,14 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook) /* Check if there is a device present. */ if (id >> 16 == 0xFFFF) - continue; + { + if (dev.function == 0) + /* Devices are required to implement function 0, so if + it's missing then there is no device here. */ + break; + else + continue; + } #ifdef GRUB_MACHINE_MIPS_YEELOONG /* Skip ghosts. */ From 5b1bdf12314a2a76168c0d03f729d33af9e2b778 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 4 Jan 2011 13:05:19 +0000 Subject: [PATCH 046/276] * grub-core/commands/legacycfg.c (GRUB_MOD_INIT): Fix typo in descriptions of extract_legacy_entries_source and extract_legacy_entries_configfile. Reported by: Seung Soo, Ha. --- ChangeLog | 7 +++++++ grub-core/commands/legacycfg.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4692b5a7..b4a308e9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-04 Colin Watson + + * grub-core/commands/legacycfg.c (GRUB_MOD_INIT): Fix typo in + descriptions of extract_legacy_entries_source and + extract_legacy_entries_configfile. + Reported by: Seung Soo, Ha. + 2011-01-03 Colin Watson * grub-core/bus/pci.c (grub_pci_iterate): Skip remaining functions diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index 80718196a..de392ac81 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -765,12 +765,12 @@ GRUB_MOD_INIT(legacycfg) = grub_register_command ("extract_legacy_entries_source", grub_cmd_legacy_source, N_("FILE"), - N_("Parse legacy config in same context taking onl entries")); + N_("Parse legacy config in same context taking only menu entries")); cmd_configfile_extract = grub_register_command ("extract_legacy_entries_configfile", grub_cmd_legacy_source, N_("FILE"), - N_("Parse legacy config in new context taking onl entries")); + N_("Parse legacy config in new context taking only menu entries")); cmd_kernel = grub_register_command ("legacy_kernel", grub_cmd_legacy_kernel, From 956384994b66a9c1a72876738d41b5e0e24b9022 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 4 Jan 2011 15:35:10 +0100 Subject: [PATCH 047/276] * grub-core/lib/reed_solomon.c (scratch) [! STANDALONE]: Remove leftover variable. --- ChangeLog | 5 +++++ grub-core/lib/reed_solomon.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index b4a308e9a..d40ea54aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-03 Vladimir Serbinenko + + * grub-core/lib/reed_solomon.c (scratch) [! STANDALONE]: Remove leftover + variable. + 2011-01-04 Colin Watson * grub-core/commands/legacycfg.c (GRUB_MOD_INIT): Fix typo in diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c index 9a40e2f98..740a069ee 100644 --- a/grub-core/lib/reed_solomon.c +++ b/grub-core/lib/reed_solomon.c @@ -60,7 +60,9 @@ typedef grub_uint16_t gf_double_t; static char *gf_invert __attribute__ ((section(".text"))) = (void *) 0x100000; static char *scratch __attribute__ ((section(".text"))) = (void *) 0x100100; #else +#if defined (STANDALONE) static char *scratch; +#endif static grub_uint8_t gf_invert[256]; #endif From e5146ca18b828a17e79a122b648fbd390e7bd122 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 4 Jan 2011 15:37:10 +0100 Subject: [PATCH 048/276] * grub-core/lib/reed_solomon.c (main) [TEST]: Reactivate normal test. --- ChangeLog | 6 +++++- grub-core/lib/reed_solomon.c | 9 +-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index d40ea54aa..505923fa9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ -2011-01-03 Vladimir Serbinenko +2011-01-04 Vladimir Serbinenko + + * grub-core/lib/reed_solomon.c (main) [TEST]: Reactivate normal test. + +2011-01-04 Vladimir Serbinenko * grub-core/lib/reed_solomon.c (scratch) [! STANDALONE]: Remove leftover variable. diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c index 740a069ee..62aad3111 100644 --- a/grub-core/lib/reed_solomon.c +++ b/grub-core/lib/reed_solomon.c @@ -501,14 +501,10 @@ main (int argc, char **argv) fseek (in, 0, SEEK_END); s = ftell (in); fseek (in, 0, SEEK_SET); - rs = 1024 * ((s + MAX_BLOCK_SIZE - 1) / (MAX_BLOCK_SIZE - 1024)); + rs = s / 3; buf = xmalloc (s + rs + SECTOR_SIZE); fread (buf, 1, s, in); - s = 0x5fbb; - rs = 0x6af9; - -#if 0 grub_reed_solomon_add_redundancy (buf, s, rs); out = fopen ("tst_rs.bin", "wb"); @@ -520,9 +516,6 @@ main (int argc, char **argv) out = fopen ("tst_dam.bin", "wb"); fwrite (buf, 1, s + rs, out); fclose (out); -#endif - s = 0x5fbb; - rs = 0x6af9; grub_reed_solomon_recover (buf, s, rs); out = fopen ("tst_rec.bin", "wb"); From a0159f370da21f7dd264e7b4185f15907cca19ef Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 4 Jan 2011 15:39:59 +0100 Subject: [PATCH 049/276] * grub-core/lib/reed_solomon.c (grub_reed_solomon_add_redundancy): Prevent overflow. (grub_reed_solomon_recover): Likewise. --- ChangeLog | 6 ++++++ grub-core/lib/reed_solomon.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 505923fa9..3e20a118b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-04 Vladimir Serbinenko + + * grub-core/lib/reed_solomon.c (grub_reed_solomon_add_redundancy): + Prevent overflow. + (grub_reed_solomon_recover): Likewise. + 2011-01-04 Vladimir Serbinenko * grub-core/lib/reed_solomon.c (main) [TEST]: Reactivate normal test. diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c index 62aad3111..e500ba32d 100644 --- a/grub-core/lib/reed_solomon.c +++ b/grub-core/lib/reed_solomon.c @@ -433,8 +433,8 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size, tt = cs + crs; if (tt > MAX_BLOCK_SIZE) { - cs = (cs * MAX_BLOCK_SIZE) / tt; - crs = (crs * MAX_BLOCK_SIZE) / tt; + cs = ((cs * (MAX_BLOCK_SIZE / 512)) / tt) * 512; + crs = ((crs * (MAX_BLOCK_SIZE / 512)) / tt) * 512; } encode_block (ptr, cs, rptr, crs); ptr += cs; @@ -468,8 +468,8 @@ grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs) tt = cs + crs; if (tt > MAX_BLOCK_SIZE) { - cs = (cs * MAX_BLOCK_SIZE) / tt; - crs = (crs * MAX_BLOCK_SIZE) / tt; + cs = ((cs * (MAX_BLOCK_SIZE / 512)) / tt) * 512; + crs = ((crs * (MAX_BLOCK_SIZE / 512)) / tt) * 512; } decode_block (ptr, cs, rptr, crs); ptr += cs; From 446fa40081ab2602dcad9ebdfc4564e63fed1c76 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 4 Jan 2011 15:42:47 +0100 Subject: [PATCH 050/276] * grub-core/disk/i386/pc/biosdisk.c (GRUB_MOD_INIT): Workaround buggy BIOSes. --- ChangeLog | 5 +++++ grub-core/disk/i386/pc/biosdisk.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3e20a118b..f3fa4d4c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-04 Vladimir Serbinenko + + * grub-core/disk/i386/pc/biosdisk.c (GRUB_MOD_INIT): Workaround buggy + BIOSes. + 2011-01-04 Vladimir Serbinenko * grub-core/lib/reed_solomon.c (grub_reed_solomon_add_redundancy): diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c index 3f9015fb9..069bb0b59 100644 --- a/grub-core/disk/i386/pc/biosdisk.c +++ b/grub-core/disk/i386/pc/biosdisk.c @@ -624,6 +624,11 @@ GRUB_MOD_INIT(biosdisk) ((cdrp->media_type & GRUB_BIOSDISK_CDTYPE_MASK) == GRUB_BIOSDISK_CDTYPE_NO_EMUL)) cd_drive = cdrp->drive_no; + /* Since diskboot.S rejects devices over 0x90 it must be a CD booted with + cdboot.S + */ + if (grub_boot_drive >= 0x90) + cd_drive = grub_boot_drive; grub_disk_dev_register (&grub_biosdisk_dev); } From ebc71d284cae71f142486b7f6b98fbd978af3833 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 4 Jan 2011 18:15:27 +0100 Subject: [PATCH 051/276] * grub-core/kern/emu/getroot.c (grub_util_get_grub_dev): Check md/%s names. Reported by: David Pravec. --- ChangeLog | 6 ++++++ grub-core/kern/emu/getroot.c | 11 +++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3fa4d4c0..bba94dfd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-04 Vladimir Serbinenko + + * grub-core/kern/emu/getroot.c (grub_util_get_grub_dev): Check md/%s + names. + Reported by: David Pravec. + 2011-01-04 Vladimir Serbinenko * grub-core/disk/i386/pc/biosdisk.c (GRUB_MOD_INIT): Workaround buggy diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index f51dcd770..5356685e9 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -794,11 +794,18 @@ grub_util_get_grub_dev (const char *os_dev) #ifdef __linux__ { char *mdadm_name = get_mdadm_name (os_dev); + struct stat st; if (mdadm_name) { - free (grub_dev); - grub_dev = xasprintf ("md/%s", mdadm_name); + char *newname; + newname = xasprintf ("/dev/md/%s", mdadm_name); + if (stat (newname, &st) == 0) + { + free (grub_dev); + grub_dev = xasprintf ("md/%s", mdadm_name); + } + free (newname); free (mdadm_name); } } From 9eae2084f405a7ae3ac25b87daf23c224956fd42 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 4 Jan 2011 19:08:03 +0100 Subject: [PATCH 052/276] * grub-core/lib/efi/relocator.c (grub_relocator_firmware_fill_events): Ignore the memory post-4G. (grub_relocator_firmware_alloc_region): Additional debug statement. --- ChangeLog | 6 ++++++ grub-core/lib/efi/relocator.c | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bba94dfd9..cda79b44a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-04 Vladimir Serbinenko + + * grub-core/lib/efi/relocator.c (grub_relocator_firmware_fill_events): + Ignore the memory post-4G. + (grub_relocator_firmware_alloc_region): Additional debug statement. + 2011-01-04 Vladimir Serbinenko * grub-core/kern/emu/getroot.c (grub_util_get_grub_dev): Check md/%s diff --git a/grub-core/lib/efi/relocator.c b/grub-core/lib/efi/relocator.c index fc4de834b..0d346bea3 100644 --- a/grub-core/lib/efi/relocator.c +++ b/grub-core/lib/efi/relocator.c @@ -62,13 +62,25 @@ grub_relocator_firmware_fill_events (struct grub_relocator_mmap_event *events) (char *) desc < ((char *) descs + mmapsize); desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) { + grub_uint64_t start = desc->physical_start; + grub_uint64_t end = desc->physical_start + (desc->num_pages << 12); + + /* post-4G addresses are never supported on 32-bit EFI. + Moreover it has been reported that some 64-bit EFI contrary to the + spec don't map post-4G pages. So if you enable post-4G allocations, + map pages manually or check that they are mapped. + */ + if (end >= 0x100000000ULL) + end = 0x100000000ULL; + if (end <= start) + continue; if (desc->type != GRUB_EFI_CONVENTIONAL_MEMORY) continue; events[counter].type = REG_FIRMWARE_START; - events[counter].pos = desc->physical_start; + events[counter].pos = start; counter++; events[counter].type = REG_FIRMWARE_END; - events[counter].pos = desc->physical_start + (desc->num_pages << 12); + events[counter].pos = end; counter++; } @@ -85,6 +97,9 @@ grub_relocator_firmware_alloc_region (grub_addr_t start, grub_size_t size) if (grub_efi_is_finished) return 1; + grub_dprintf ("relocator", "EFI alloc: %llx, %llx\n", + (unsigned long long) start, (unsigned long long) size); + b = grub_efi_system_table->boot_services; status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ADDRESS, GRUB_EFI_LOADER_DATA, size >> 12, &address); From 18a38098ad53654bc304271464e01fe0e090249e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 5 Jan 2011 01:14:32 +0100 Subject: [PATCH 053/276] The E820 type 5 is BADRAM, not EXEC_CODE. * grub-core/loader/i386/bsd.c (GRUB_E820_EXEC_CODE): Removed. (GRUB_E820_BADRAM): New define. * grub-core/loader/i386/linux.c (grub_linux_boot): Translate code into reserved. Propagate BADRAM. * grub-core/loader/i386/bsd.c (GRUB_E820_EXEC_CODE): Removed. (GRUB_E820_BADRAM): New define. --- ChangeLog | 11 +++++++++++ grub-core/loader/i386/bsd.c | 2 +- grub-core/loader/i386/linux.c | 4 ++-- include/grub/i386/linux.h | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index cda79b44a..41241e7a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-01-05 Vladimir Serbinenko + + The E820 type 5 is BADRAM, not EXEC_CODE. + + * grub-core/loader/i386/bsd.c (GRUB_E820_EXEC_CODE): Removed. + (GRUB_E820_BADRAM): New define. + * grub-core/loader/i386/linux.c (grub_linux_boot): Translate code + into reserved. Propagate BADRAM. + * grub-core/loader/i386/bsd.c (GRUB_E820_EXEC_CODE): Removed. + (GRUB_E820_BADRAM): New define. + 2011-01-04 Vladimir Serbinenko * grub-core/lib/efi/relocator.c (grub_relocator_firmware_fill_events): diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index 84cf1a17f..08cdcda37 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -252,7 +252,7 @@ struct grub_e820_mmap #define GRUB_E820_RESERVED 2 #define GRUB_E820_ACPI 3 #define GRUB_E820_NVS 4 -#define GRUB_E820_EXEC_CODE 5 +#define GRUB_E820_BADRAM 5 static void generate_e820_mmap (grub_size_t *len, grub_size_t *cnt, void *buf) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 95aa6b456..ca88c7403 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -418,9 +418,9 @@ grub_linux_boot (void) addr, size, GRUB_E820_NVS); break; - case GRUB_MEMORY_CODE: + case GRUB_MEMORY_BADRAM: grub_e820_add_region (params->e820_map, &e820_num, - addr, size, GRUB_E820_EXEC_CODE); + addr, size, GRUB_E820_BADRAM); break; default: diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index 63f99db62..9ba83eee2 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -68,7 +68,7 @@ #define GRUB_E820_RESERVED 2 #define GRUB_E820_ACPI 3 #define GRUB_E820_NVS 4 -#define GRUB_E820_EXEC_CODE 5 +#define GRUB_E820_BADRAM 5 #define GRUB_E820_MAX_ENTRY 128 From 488f71f116916549766d4df50d364dc3400c50ba Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 5 Jan 2011 01:25:01 +0100 Subject: [PATCH 054/276] * grub-core/term/terminfo.c (grub_terminfo_readkey): Handle keys with CTRL. --- ChangeLog | 5 +++++ grub-core/term/terminfo.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 41241e7a0..0932ee7cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-05 Vladimir Serbinenko + + * grub-core/term/terminfo.c (grub_terminfo_readkey): Handle keys with + CTRL. + 2011-01-05 Vladimir Serbinenko The E820 type 5 is BADRAM, not EXEC_CODE. diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c index d01811959..8450ea231 100644 --- a/grub-core/term/terminfo.c +++ b/grub-core/term/terminfo.c @@ -403,6 +403,8 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, /* Backspace: Ctrl-h. */ if (c == 0x7f) c = '\b'; + if (c < 0x20 && c != '\t' && c!= '\b' && c != '\n' && c != '\r') + c = GRUB_TERM_CTRL | (c - 1 + 'a'); *len = 1; keys[0] = c; return; From 4c3e4f37be31b5b1ed9e1928116f0d504faac937 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 5 Jan 2011 01:28:28 +0100 Subject: [PATCH 055/276] * util/grub-install.in: Determine ofpathname, nvsetenv and efibootmgr only when needed. --- ChangeLog | 5 +++++ util/grub-install.in | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0932ee7cb..50da0e678 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-05 Vladimir Serbinenko + + * util/grub-install.in: Determine ofpathname, nvsetenv and efibootmgr + only when needed. + 2011-01-05 Vladimir Serbinenko * grub-core/term/terminfo.c (grub_terminfo_readkey): Handle keys with diff --git a/util/grub-install.in b/util/grub-install.in index 716582dfd..90360c279 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -56,9 +56,6 @@ debug_image= update_nvram=yes -ofpathname="`which ofpathname`" -nvsetenv="`which nvsetenv`" -efibootmgr="`which efibootmgr 2>/dev/null || true`" removable=no efi_quiet= @@ -585,6 +582,8 @@ if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" --device-map="${device_map}" "${install_device}" || exit 1 elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ]; then if [ x"$update_nvram" = xyes ]; then + ofpathname="`which ofpathname`" + nvsetenv="`which nvsetenv`" set "$ofpathname" dummy if test -f "$1"; then : @@ -621,6 +620,7 @@ elif [ x"$platform" = xefi ]; then cp "${grubdir}/core.${imgext}" "${efidir}/${efi_file}" # Try to make this image bootable using the EFI Boot Manager, if available. + efibootmgr="`which efibootmgr`" if test "$removable" = no && test -n "$efi_distributor" && \ test -n "$efibootmgr"; then # On Linux, we need the efivars kernel modules. From b3f8d28ad0c629d7ae77318be9fe23f8a618d11f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 5 Jan 2011 12:23:06 +0100 Subject: [PATCH 056/276] Run terminfo_cls on initing terminfo output to clear the screen and move the cursor to (0,0). * grub-core/term/ieee1275/ofconsole.c (grub_ofconsole_init_output): Call grub_terminfo_output_init. * grub-core/term/serial.c (grub_serial_term_output): Set .init. * grub-core/term/terminfo.c (grub_terminfo_output_init): New function. * include/grub/terminfo.h (grub_terminfo_output_init): New declaration. --- ChangeLog | 11 +++++++++++ grub-core/term/ieee1275/ofconsole.c | 2 ++ grub-core/term/serial.c | 1 + grub-core/term/terminfo.c | 7 +++++++ include/grub/terminfo.h | 1 + 5 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 50da0e678..0159aab3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-01-05 Vladimir Serbinenko + + Run terminfo_cls on initing terminfo output to clear the screen and + move the cursor to (0,0). + + * grub-core/term/ieee1275/ofconsole.c (grub_ofconsole_init_output): + Call grub_terminfo_output_init. + * grub-core/term/serial.c (grub_serial_term_output): Set .init. + * grub-core/term/terminfo.c (grub_terminfo_output_init): New function. + * include/grub/terminfo.h (grub_terminfo_output_init): New declaration. + 2011-01-05 Vladimir Serbinenko * util/grub-install.in: Determine ofpathname, nvsetenv and efibootmgr diff --git a/grub-core/term/ieee1275/ofconsole.c b/grub-core/term/ieee1275/ofconsole.c index 2b0bddbbb..ab74f21da 100644 --- a/grub-core/term/ieee1275/ofconsole.c +++ b/grub-core/term/ieee1275/ofconsole.c @@ -170,6 +170,8 @@ grub_ofconsole_init_output (struct grub_term_output *term) grub_ofconsole_dimensions (); + grub_terminfo_output_init (term); + return 0; } diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c index d36388359..e672a89d6 100644 --- a/grub-core/term/serial.c +++ b/grub-core/term/serial.c @@ -104,6 +104,7 @@ static struct grub_term_input grub_serial_term_input = static struct grub_term_output grub_serial_term_output = { .name = "serial", + .init = grub_terminfo_output_init, .putchar = grub_terminfo_putchar, .getwh = grub_terminfo_getwh, .getxy = grub_terminfo_getxy, diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c index 8450ea231..0a8c75c74 100644 --- a/grub-core/term/terminfo.c +++ b/grub-core/term/terminfo.c @@ -514,6 +514,13 @@ grub_terminfo_input_init (struct grub_term_input *termi) return GRUB_ERR_NONE; } +grub_err_t +grub_terminfo_output_init (struct grub_term_output *term) +{ + grub_terminfo_cls (term); + return GRUB_ERR_NONE; +} + /* GRUB Command. */ static grub_err_t diff --git a/include/grub/terminfo.h b/include/grub/terminfo.h index 8317995d8..5a552b327 100644 --- a/include/grub/terminfo.h +++ b/include/grub/terminfo.h @@ -56,6 +56,7 @@ struct grub_terminfo_output_state void (*put) (struct grub_term_output *term, const int c); }; +grub_err_t EXPORT_FUNC(grub_terminfo_output_init) (struct grub_term_output *term); void EXPORT_FUNC(grub_terminfo_gotoxy) (grub_term_output_t term, grub_uint8_t x, grub_uint8_t y); void EXPORT_FUNC(grub_terminfo_cls) (grub_term_output_t term); From 71b6a2b7a2d9d71cff26b39a941b0f7191bcea42 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 6 Jan 2011 11:09:17 +0000 Subject: [PATCH 057/276] * grub-core/kern/emu/getroot.c (find_root_device_from_mountinfo): Fix prefix check to handle the case where dir ends with a slash (most significantly, "/" itself). Reported by: Michael Vogt. --- ChangeLog | 7 +++++++ grub-core/kern/emu/getroot.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0159aab3d..a6d62da6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-06 Colin Watson + + * grub-core/kern/emu/getroot.c (find_root_device_from_mountinfo): + Fix prefix check to handle the case where dir ends with a slash + (most significantly, "/" itself). + Reported by: Michael Vogt. + 2011-01-05 Vladimir Serbinenko Run terminfo_cls on initing terminfo output to clear the screen and diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index 5356685e9..aedef9e0e 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -135,8 +135,12 @@ find_root_device_from_mountinfo (const char *dir) continue; /* only a subtree is mounted */ enc_path_len = strlen (enc_path); + /* Check that enc_path is a prefix of dir. The prefix must either be + the entire string, or end with a slash, or be immediately followed + by a slash. */ if (strncmp (dir, enc_path, enc_path_len) != 0 || - (dir[enc_path_len] && dir[enc_path_len] != '/')) + (enc_path_len && dir[enc_path_len - 1] != '/' && + dir[enc_path_len] && dir[enc_path_len] != '/')) continue; /* This is a parent of the requested directory. /proc/self/mountinfo From 415502c26a4544292046fbb0b580b352cb346f5f Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 6 Jan 2011 13:24:38 +0000 Subject: [PATCH 058/276] * tests/util/grub-shell.in: Set serial terminfo type to `dumb', to avoid causing test failures by clearing the screen. --- ChangeLog | 5 +++++ tests/util/grub-shell.in | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index a6d62da6c..a727bd4ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-06 Colin Watson + + * tests/util/grub-shell.in: Set serial terminfo type to `dumb', to + avoid causing test failures by clearing the screen. + 2011-01-06 Colin Watson * grub-core/kern/emu/getroot.c (find_root_device_from_mountinfo): diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index e35d6bc65..0213376d0 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -119,6 +119,7 @@ cat <${cfgfile} grubshell=yes insmod serial serial +terminfo serial dumb terminal_input serial terminal_output serial EOF From 014b68068d4136812f2e3dc16c986351e6fb2779 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 7 Jan 2011 13:27:34 +0100 Subject: [PATCH 059/276] =?UTF-8?q?=09*=20util/grub-setup.c=20(setup):=20H?= =?UTF-8?q?andle=20NetBSD=20and=20OpenBSD=20disklabels.=20=09Reported=20an?= =?UTF-8?q?d=20tested=20by:=20Gr=C3=A9goire=20Sutre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 5 +++++ util/grub-setup.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index a727bd4ec..d734d86b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-07 Vladimir Serbinenko + + * util/grub-setup.c (setup): Handle NetBSD and OpenBSD disklabels. + Reported and tested by: Grégoire Sutre. + 2011-01-06 Colin Watson * tests/util/grub-shell.in: Set serial terminfo type to `dumb', to diff --git a/util/grub-setup.c b/util/grub-setup.c index 5f9b29f25..b4749b433 100644 --- a/util/grub-setup.c +++ b/util/grub-setup.c @@ -49,6 +49,7 @@ #include #include "progname.h" #include +#include #define _GNU_SOURCE 1 #include @@ -339,6 +340,12 @@ setup (const char *dir, { if (p->parent != container) return 0; + /* NetBSD and OpenBSD subpartitions have metadata inside a partition, + so they are safe to ignore. + */ + if (grub_strcmp (p->partmap->name, "netbsd") == 0 + || grub_strcmp (p->partmap->name, "openbsd") == 0) + return 0; if (dest_partmap == NULL) { dest_partmap = p->partmap; @@ -352,6 +359,15 @@ setup (const char *dir, grub_partition_iterate (dest_dev->disk, identify_partmap); + if (container && grub_strcmp (container->partmap->name, "msdos") == 0 + && dest_partmap + && (container->msdostype == GRUB_PC_PARTITION_TYPE_NETBSD + || container->msdostype == GRUB_PC_PARTITION_TYPE_OPENBSD)) + { + grub_util_warn (_("Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem. This is not supported yet.")); + goto unable_to_embed; + } + fs = grub_fs_probe (dest_dev); if (!fs) grub_errno = GRUB_ERR_NONE; From 0ca09e6c528885b5af9b2f614d62f50f79fc413a Mon Sep 17 00:00:00 2001 From: Doug Nazar Date: Fri, 7 Jan 2011 14:41:44 +0100 Subject: [PATCH 060/276] * grub-core/disk/raid5_recover.c (grub_raid5_recover): Add missing array->members[i].start_sector. * grub-core/disk/raid6_recover.c (grub_raid6_recover): Likewise. --- ChangeLog | 6 ++++++ grub-core/disk/raid5_recover.c | 4 +++- grub-core/disk/raid6_recover.c | 18 +++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d734d86b6..c5cc7afa6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-07 Doug Nazar + + * grub-core/disk/raid5_recover.c (grub_raid5_recover): Add missing + array->members[i].start_sector. + * grub-core/disk/raid6_recover.c (grub_raid6_recover): Likewise. + 2011-01-07 Vladimir Serbinenko * util/grub-setup.c (setup): Handle NetBSD and OpenBSD disklabels. diff --git a/grub-core/disk/raid5_recover.c b/grub-core/disk/raid5_recover.c index 2cda67533..349eb0291 100644 --- a/grub-core/disk/raid5_recover.c +++ b/grub-core/disk/raid5_recover.c @@ -45,7 +45,9 @@ grub_raid5_recover (struct grub_raid_array *array, int disknr, if (i == disknr) continue; - err = grub_disk_read (array->members[i].device, sector, 0, size, buf2); + err = grub_disk_read (array->members[i].device, + array->members[i].start_sector + sector, + 0, size, buf2); if (err) { diff --git a/grub-core/disk/raid6_recover.c b/grub-core/disk/raid6_recover.c index 01daa2c79..dfaa60ea4 100644 --- a/grub-core/disk/raid6_recover.c +++ b/grub-core/disk/raid6_recover.c @@ -119,7 +119,8 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p, else { if ((array->members[pos].device) && - (! grub_disk_read (array->members[pos].device, sector, + (! grub_disk_read (array->members[pos].device, + array->members[i].start_sector + sector, 0, size, buf))) { grub_raid_block_xor (pbuf, buf, size); @@ -150,7 +151,9 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p, { /* One bad device */ if ((array->members[p].device) && - (! grub_disk_read (array->members[p].device, sector, 0, size, buf))) + (! grub_disk_read (array->members[p].device, + array->members[i].start_sector + sector, + 0, size, buf))) { grub_raid_block_xor (buf, pbuf, size); goto quit; @@ -163,7 +166,8 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p, } grub_errno = GRUB_ERR_NONE; - if (grub_disk_read (array->members[q].device, sector, 0, size, buf)) + if (grub_disk_read (array->members[q].device, + array->members[i].start_sector + sector, 0, size, buf)) goto quit; grub_raid_block_xor (buf, qbuf, size); @@ -181,12 +185,16 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p, goto quit; } - if (grub_disk_read (array->members[p].device, sector, 0, size, buf)) + if (grub_disk_read (array->members[p].device, + array->members[i].start_sector + sector, + 0, size, buf)) goto quit; grub_raid_block_xor (pbuf, buf, size); - if (grub_disk_read (array->members[q].device, sector, 0, size, buf)) + if (grub_disk_read (array->members[q].device, + array->members[i].start_sector + sector, + 0, size, buf)) goto quit; grub_raid_block_xor (qbuf, buf, size); From c0cf26da6b7662fd309b509b4238aa3877003f15 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 7 Jan 2011 16:17:24 +0100 Subject: [PATCH 061/276] * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Add missing endian transformations. * grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Likewise. Based on report by: Doug Nazar. --- ChangeLog | 7 +++++++ grub-core/disk/mdraid1x_linux.c | 19 ++++++++++------- grub-core/disk/mdraid_linux.c | 37 +++++++++++++++++++-------------- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index c5cc7afa6..0362abd51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-07 Vladimir Serbinenko + + * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Add missing + endian transformations. + * grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Likewise. + Based on report by: Doug Nazar. + 2011-01-07 Doug Nazar * grub-core/disk/raid5_recover.c (grub_raid5_recover): Add missing diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c index b6a48b848..155210df3 100644 --- a/grub-core/disk/mdraid1x_linux.c +++ b/grub-core/disk/mdraid1x_linux.c @@ -143,24 +143,27 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, &sb)) return grub_errno; - if (sb.magic != SB_MAGIC) + if (grub_le_to_cpu32 (sb.magic) != SB_MAGIC) continue; { grub_uint64_t sb_size; struct grub_raid_super_1x *real_sb; + grub_uint32_t level; - if (sb.major_version != 1) + if (grub_le_to_cpu32 (sb.major_version) != 1) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "Unsupported RAID version: %d", - sb.major_version); + grub_le_to_cpu32 (sb.major_version)); + + level = grub_le_to_cpu32 (sb.level); /* Multipath. */ - if ((int) sb.level == -4) - sb.level = 1; + if ((int) level == -4) + level = 1; - if (sb.level != 0 && sb.level != 1 && sb.level != 4 && - sb.level != 5 && sb.level != 6 && sb.level != 10) + if (level != 0 && level != 1 && level != 4 && + level != 5 && level != 6 && level != 10) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "Unsupported RAID level: %d", sb.level); @@ -209,7 +212,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, grub_memcpy (array->uuid, real_sb->set_uuid, 16); - *start_sector = real_sb->data_offset; + *start_sector = grub_le_to_cpu64 (real_sb->data_offset); grub_free (real_sb); return 0; diff --git a/grub-core/disk/mdraid_linux.c b/grub-core/disk/mdraid_linux.c index dc0d80ffd..7aa48fd7a 100644 --- a/grub-core/disk/mdraid_linux.c +++ b/grub-core/disk/mdraid_linux.c @@ -167,6 +167,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, grub_uint64_t size; struct grub_raid_super_09 sb; grub_uint32_t *uuid; + grub_uint32_t level; /* The sector where the mdraid 0.90 superblock is stored, if available. */ size = grub_disk_get_size (disk); @@ -178,36 +179,40 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, return grub_errno; /* Look whether there is a mdraid 0.90 superblock. */ - if (sb.md_magic != SB_MAGIC) + if (grub_le_to_cpu32 (sb.md_magic) != SB_MAGIC) return grub_error (GRUB_ERR_OUT_OF_RANGE, "not 0.9x raid"); - if (sb.major_version != 0 || sb.minor_version != 90) + if (grub_le_to_cpu32 (sb.major_version) != 0 + || grub_le_to_cpu32 (sb.minor_version) != 90) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "unsupported RAID version: %d.%d", - sb.major_version, sb.minor_version); + grub_le_to_cpu32 (sb.major_version), + grub_le_to_cpu32 (sb.minor_version)); /* FIXME: Check the checksum. */ + level = grub_le_to_cpu32 (sb.level); /* Multipath. */ - if ((int) sb.level == -4) - sb.level = 1; + if ((int) level == -4) + level = 1; - if (sb.level != 0 && sb.level != 1 && sb.level != 4 && - sb.level != 5 && sb.level != 6 && sb.level != 10) + if (level != 0 && level != 1 && level != 4 && + level != 5 && level != 6 && level != 10) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "unsupported RAID level: %d", sb.level); - if (sb.this_disk.number == 0xffff || sb.this_disk.number == 0xfffe) + "unsupported RAID level: %d", level); + if (grub_le_to_cpu32 (sb.this_disk.number) == 0xffff + || grub_le_to_cpu32 (sb.this_disk.number) == 0xfffe) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "spares aren't implemented"); array->name = NULL; - array->number = sb.md_minor; - array->level = sb.level; - array->layout = sb.layout; - array->total_devs = sb.raid_disks; - array->disk_size = (sb.size) ? sb.size * 2 : sector; - array->chunk_size = sb.chunk_size >> 9; - array->index = sb.this_disk.number; + array->number = grub_le_to_cpu32 (sb.md_minor); + array->level = level; + array->layout = grub_le_to_cpu32 (sb.layout); + array->total_devs = grub_le_to_cpu32 (sb.raid_disks); + array->disk_size = (sb.size) ? grub_le_to_cpu32 (sb.size) * 2 : sector; + array->chunk_size = grub_le_to_cpu32 (sb.chunk_size) >> 9; + array->index = grub_le_to_cpu32 (sb.this_disk.number); array->uuid_len = 16; array->uuid = grub_malloc (16); if (!array->uuid) From e72d259fe113e41722904bb25e7a51ba6bc3239c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 7 Jan 2011 17:06:42 +0100 Subject: [PATCH 062/276] * grub-core/fs/xfs.c (grub_xfs_iterate_dir): Take into account that inopos might be unaligned. --- ChangeLog | 5 +++++ grub-core/fs/xfs.c | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0362abd51..ca63b0e85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-07 Vladimir Serbinenko + + * grub-core/fs/xfs.c (grub_xfs_iterate_dir): Take into account that + inopos might be unaligned. + 2011-01-07 Vladimir Serbinenko * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Add missing diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 3d773856e..9f8dc28de 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -451,18 +451,27 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, for (i = 0; i < diro->inode.data.dir.dirhead.count; i++) { grub_uint64_t ino; - void *inopos = (((char *) de) + grub_uint8_t *inopos = (((grub_uint8_t *) de) + sizeof (struct grub_xfs_dir_entry) + de->len - 1); char name[de->len + 1]; + /* inopos might be unaligned. */ if (smallino) - { - ino = grub_be_to_cpu32 (*(grub_uint32_t *) inopos); - ino = grub_cpu_to_be64 (ino); - } + ino = (((grub_uint32_t) inopos[0]) << 24) + | (((grub_uint32_t) inopos[1]) << 16) + | (((grub_uint32_t) inopos[2]) << 8) + | (((grub_uint32_t) inopos[3]) << 0); else - ino = *(grub_uint64_t *) inopos; + ino = (((grub_uint64_t) inopos[0]) << 56) + | (((grub_uint64_t) inopos[1]) << 48) + | (((grub_uint64_t) inopos[2]) << 40) + | (((grub_uint64_t) inopos[3]) << 32) + | (((grub_uint64_t) inopos[4]) << 24) + | (((grub_uint64_t) inopos[5]) << 16) + | (((grub_uint64_t) inopos[6]) << 8) + | (((grub_uint64_t) inopos[7]) << 0); + ino = grub_cpu_to_be64 (ino); grub_memcpy (name, de->name, de->len); name[de->len] = '\0'; From 25953e10553dad2e378541a68686fc094603ec54 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Fri, 7 Jan 2011 17:09:39 +0100 Subject: [PATCH 063/276] Improve loaders' kernel command line handling. * grub-core/lib/cmdline.c: New file. * include/grub/lib/cmdline.h: Likewise. * grub-core/loader/i386/linux.c (grub_cmd_linux): Use grub_create_loader_cmdline to create kernel command line. * grub-core/loader/i386/pc/linux.c (grub_cmd_linux): Likewise. * grub-core/loader/powerpc/ieee1275/linux.c (grub_cmd_linux): Likewise. * grub-core/loader/sparc64/ieee1275/linux.c (grub_cmd_linux): Likewise. * grub-core/Makefile.core.def (linux16): Add lib/cmdline.c on i386_pc. (linux): Add lib/cmdline.c on common. --- ChangeLog | 14 +++ grub-core/Makefile.core.def | 2 + grub-core/lib/cmdline.c | 105 ++++++++++++++++++++++ grub-core/loader/i386/linux.c | 26 ++---- grub-core/loader/i386/pc/linux.c | 25 ++---- grub-core/loader/powerpc/ieee1275/linux.c | 23 ++--- grub-core/loader/sparc64/ieee1275/linux.c | 22 ++--- include/grub/lib/cmdline.h | 31 +++++++ 8 files changed, 184 insertions(+), 64 deletions(-) create mode 100644 grub-core/lib/cmdline.c create mode 100644 include/grub/lib/cmdline.h diff --git a/ChangeLog b/ChangeLog index ca63b0e85..d1ddc8741 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-01-07 Szymon Janc + + Improve loaders' kernel command line handling. + + * grub-core/lib/cmdline.c: New file. + * include/grub/lib/cmdline.h: Likewise. + * grub-core/loader/i386/linux.c (grub_cmd_linux): Use + grub_create_loader_cmdline to create kernel command line. + * grub-core/loader/i386/pc/linux.c (grub_cmd_linux): Likewise. + * grub-core/loader/powerpc/ieee1275/linux.c (grub_cmd_linux): Likewise. + * grub-core/loader/sparc64/ieee1275/linux.c (grub_cmd_linux): Likewise. + * grub-core/Makefile.core.def (linux16): Add lib/cmdline.c on i386_pc. + (linux): Add lib/cmdline.c on common. + 2011-01-07 Vladimir Serbinenko * grub-core/fs/xfs.c (grub_xfs_iterate_dir): Take into account that diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 37c0ce970..094bbc835 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1149,6 +1149,7 @@ module = { module = { name = linux16; i386_pc = loader/i386/pc/linux.c; + i386_pc = lib/cmdline.c; enable = i386_pc; }; @@ -1183,6 +1184,7 @@ module = { mips = loader/mips/linux.c; powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c; sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c; + common = lib/cmdline.c; enable = noemu; }; diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c new file mode 100644 index 000000000..a702e6487 --- /dev/null +++ b/grub-core/lib/cmdline.c @@ -0,0 +1,105 @@ +/* cmdline.c - linux command line handling */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include + +static unsigned int check_arg (char *c, int *has_space) +{ + int space = 0; + unsigned int size = 0; + + while (*c) + { + if (*c == '\\' || *c == '\'' || *c == '"') + size++; + else if (*c == ' ') + space = 1; + + size++; + c++; + } + + if (space) + size += 2; + + if (has_space) + *has_space = space; + + return size; +} + +unsigned int grub_loader_cmdline_size (int argc, char *argv[]) +{ + int i; + unsigned int size = 0; + + for (i = 0; i < argc; i++) + { + size += check_arg (argv[i], 0); + size++; /* Separator space or NULL. */ + } + + return size; +} + +int grub_create_loader_cmdline (int argc, char *argv[], char *buf, + grub_size_t size) +{ + int i, space; + unsigned int arg_size; + char *c; + + for (i = 0; i < argc; i++) + { + c = argv[i]; + arg_size = check_arg(argv[i], &space); + arg_size++; /* Separator space or NULL. */ + + if (size < arg_size) + break; + + size -= arg_size; + + if (space) + *buf++ = '"'; + + while (*c) + { + if (*c == '\\' || *c == '\'' || *c == '"') + *buf++ = '\\'; + + *buf++ = *c; + c++; + } + + if (space) + *buf++ = '"'; + + *buf++ = ' '; + } + + /* Replace last space with null. */ + if (i) + buf--; + + *buf = 0; + + return i; +} diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index ca88c7403..80f583cef 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef GRUB_MACHINE_PCBIOS #include @@ -575,7 +576,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_size_t real_size, prot_size; grub_ssize_t len; int i; - char *dest; grub_dl_ref (my_mod); @@ -836,22 +836,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), params->loadflags |= GRUB_LINUX_FLAG_QUIET; } - - /* Specify the boot file. */ - dest = grub_stpcpy ((char *) real_mode_mem + GRUB_LINUX_CL_OFFSET, - "BOOT_IMAGE="); - dest = grub_stpcpy (dest, argv[0]); - - /* Copy kernel parameters. */ - for (i = 1; - i < argc - && dest + grub_strlen (argv[i]) + 1 < ((char *) real_mode_mem - + GRUB_LINUX_CL_END_OFFSET); - i++) - { - *dest++ = ' '; - dest = grub_stpcpy (dest, argv[i]); - } + /* Create kernel command line. */ + grub_memcpy ((char *)real_mode_mem + GRUB_LINUX_CL_OFFSET, LINUX_IMAGE, + sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, + (char *)real_mode_mem + GRUB_LINUX_CL_OFFSET + + sizeof (LINUX_IMAGE) - 1, + GRUB_LINUX_CL_END_OFFSET - GRUB_LINUX_CL_OFFSET + - (sizeof (LINUX_IMAGE) - 1)); len = prot_size; if (grub_file_read (file, prot_mode_mem, len) != len) diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index 90de70f66..96d00f927 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -34,6 +34,7 @@ #include #include #include +#include #define GRUB_LINUX_CL_OFFSET 0x9000 #define GRUB_LINUX_CL_END_OFFSET 0x90FF @@ -86,7 +87,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_size_t real_size; grub_ssize_t len; int i; - char *dest; char *grub_linux_prot_chunk; int grub_linux_is_bzimage; grub_addr_t grub_linux_prot_target; @@ -286,21 +286,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), ((GRUB_LINUX_MAX_SETUP_SECTS - setup_sects - 1) << GRUB_DISK_SECTOR_BITS)); - /* Specify the boot file. */ - dest = grub_stpcpy (grub_linux_real_chunk + GRUB_LINUX_CL_OFFSET, - "BOOT_IMAGE="); - dest = grub_stpcpy (dest, argv[0]); - - /* Copy kernel parameters. */ - for (i = 1; - i < argc - && dest + grub_strlen (argv[i]) + 1 < (grub_linux_real_chunk - + GRUB_LINUX_CL_END_OFFSET); - i++) - { - *dest++ = ' '; - dest = grub_stpcpy (dest, argv[i]); - } + /* Create kernel command line. */ + grub_memcpy ((char *)grub_linux_real_chunk + GRUB_LINUX_CL_OFFSET, + LINUX_IMAGE, sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, + (char *)grub_linux_real_chunk + + GRUB_LINUX_CL_OFFSET + sizeof (LINUX_IMAGE) - 1, + GRUB_LINUX_CL_END_OFFSET - GRUB_LINUX_CL_OFFSET + - (sizeof (LINUX_IMAGE) - 1)); if (grub_linux_is_bzimage) grub_linux_prot_target = GRUB_LINUX_BZIMAGE_ADDR; diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c index 231aec1d3..a99310cfd 100644 --- a/grub-core/loader/powerpc/ieee1275/linux.c +++ b/grub-core/loader/powerpc/ieee1275/linux.c @@ -27,6 +27,7 @@ #include #include #include +#include #define ELF32_LOADMASK (0xc0000000UL) #define ELF64_LOADMASK (0xc000000000000000ULL) @@ -238,9 +239,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_elf_t elf = 0; - int i; int size; - char *dest; grub_dl_ref (my_mod); @@ -275,23 +274,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto out; } - size = sizeof ("BOOT_IMAGE=") + grub_strlen (argv[0]); - for (i = 0; i < argc; i++) - size += grub_strlen (argv[i]) + 1; - - linux_args = grub_malloc (size); + size = grub_loader_cmdline_size(argc, argv); + linux_args = grub_malloc (size + sizeof (LINUX_IMAGE)); if (! linux_args) goto out; - /* Specify the boot file. */ - dest = grub_stpcpy (linux_args, "BOOT_IMAGE="); - dest = grub_stpcpy (dest, argv[0]); - - for (i = 1; i < argc; i++) - { - *dest++ = ' '; - dest = grub_stpcpy (dest, argv[i]); - } + /* Create kernel command line. */ + grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1, + size); out: diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index 8ea96f1c9..a262049a7 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -27,6 +27,7 @@ #include #include #include +#include static grub_dl_t my_mod; @@ -295,9 +296,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), { grub_file_t file = 0; grub_elf_t elf = 0; - int i; int size; - char *dest; grub_dl_ref (my_mod); @@ -333,23 +332,16 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto out; } - size = sizeof ("BOOT_IMAGE=") + grub_strlen (argv[0]); - for (i = 0; i < argc; i++) - size += grub_strlen (argv[i]) + 1; + size = grub_loader_cmdline_size(argc, argv); - linux_args = grub_malloc (size); + linux_args = grub_malloc (size + sizeof (LINUX_IMAGE)); if (! linux_args) goto out; - /* Specify the boot file. */ - dest = grub_stpcpy (linux_args, "BOOT_IMAGE="); - dest = grub_stpcpy (dest, argv[0]); - - for (i = 1; i < argc; i++) - { - *dest++ = ' '; - dest = grub_stpcpy (dest, argv[i]); - } + /* Create kernel command line. */ + grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1, + size); out: if (elf) diff --git a/include/grub/lib/cmdline.h b/include/grub/lib/cmdline.h new file mode 100644 index 000000000..1fe8d0179 --- /dev/null +++ b/include/grub/lib/cmdline.h @@ -0,0 +1,31 @@ +/* cmdline.h - linux command line handling */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_CMDLINE_HEADER +#define GRUB_CMDLINE_HEADER 1 + +#include + +#define LINUX_IMAGE "BOOT_IMAGE=" + +unsigned int grub_loader_cmdline_size (int argc, char *argv[]); +int grub_create_loader_cmdline (int argc, char *argv[], char *buf, + grub_size_t size); + +#endif /* ! GRUB_CMDLINE_HEADER */ From 11b970d7c9e820e4d7574d0cb63ddc55cd27176e Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 7 Jan 2011 17:24:25 +0000 Subject: [PATCH 064/276] Always initialise *relroot in grub_find_root_device_from_mountinfo, otherwise we free an uninitialised pointer if /proc is unmounted. Reported by: Scott Moser. --- grub-core/kern/emu/getroot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index 373834127..a4cfaffc9 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -111,13 +111,13 @@ grub_find_root_device_from_mountinfo (const char *dir, char **relroot) size_t len = 0; char *ret = NULL; + if (relroot) + *relroot = NULL; + fp = fopen ("/proc/self/mountinfo", "r"); if (! fp) return NULL; /* fall through to other methods */ - if (relroot) - *relroot = NULL; - while (getline (&buf, &len, fp) > 0) { int mnt_id, parent_mnt_id; From 64d1f0412bbbfafb0bef788ad6fe13b28329e65d Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Fri, 7 Jan 2011 22:42:02 +0100 Subject: [PATCH 065/276] * docs/grub.texi (Support automatic decompression): Update with xz decompression support. --- ChangeLog | 5 +++++ docs/grub.texi | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1ddc8741..d65e97e09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-07 Szymon Janc + + * docs/grub.texi (Support automatic decompression): Update with xz + decompression support. + 2011-01-07 Szymon Janc Improve loaders' kernel command line handling. diff --git a/docs/grub.texi b/docs/grub.texi index 54a2d8791..daf48da13 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -346,9 +346,11 @@ ext2/ext3/ext4}, @dfn{DOS FAT12/FAT16/FAT32}, @dfn{HFS}, @dfn{HFS+}, @dfn{BSD UFS/UFS2}, and @dfn{XFS}. @xref{Filesystem}, for more information. @item Support automatic decompression -Can decompress files which were compressed by @command{gzip}. This -function is both automatic and transparent to the user (i.e. all -functions operate upon the uncompressed contents of the specified +Can decompress files which were compressed by @command{gzip} or +@command{xz}@footnote{Only CRC32 data integrity check is supported (xz default +is CRC64 so one should use --check=crc32 option). LZMA BCJ filters are +supported.}. This function is both automatic and transparent to the user +(i.e. all functions operate upon the uncompressed contents of the specified files). This greatly reduces a file size and loading time, a particularly great benefit for floppies.@footnote{There are a few pathological cases where loading a very badly organized ELF kernel might From 43f1bc8369211247259581d458a0f3aaa9782bbb Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 00:27:38 +0100 Subject: [PATCH 066/276] * grub-core/loader/i386/bsdXX.c (grub_netbsd_load_elf_meta): Silence spurious warning. Reported and tested by: Alain Greppin. --- ChangeLog | 6 ++++++ grub-core/loader/i386/bsdXX.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d65e97e09..52f59019b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-08 Vladimir Serbinenko + + * grub-core/loader/i386/bsdXX.c (grub_netbsd_load_elf_meta): + Silence spurious warning. + Reported and tested by: Alain Greppin. + 2011-01-07 Szymon Janc * docs/grub.texi (Support automatic decompression): Update with xz diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 2dd180509..5b9e7689e 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -394,7 +394,7 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, grub_err_t err; Elf_Ehdr e; Elf_Shdr *s, *symsh, *strsh; - char *shdr; + char *shdr = NULL; unsigned symsize, strsize; void *sym_chunk; grub_uint8_t *curload; From 0fd48e357f73864f7a334be23153e973f2f76f2a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 00:34:23 +0100 Subject: [PATCH 067/276] Satisfy some bison versions need for inttypes.h. * grub-core/lib/posix_wrap/inttypes.h: New file. * grub-core/lib/posix_wrap/sys/types.h (int8_t): New type. (int16_t): Likewise. (int32_t): Likewise. (int64_t): Likewise. Reported and tested by: Alain Greppin. --- ChangeLog | 11 +++++++++++ grub-core/lib/posix_wrap/inttypes.h | 1 + grub-core/lib/posix_wrap/sys/types.h | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 grub-core/lib/posix_wrap/inttypes.h diff --git a/ChangeLog b/ChangeLog index 52f59019b..1a297da01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-01-08 Vladimir Serbinenko + + Satisfy some bison versions need for inttypes.h. + + * grub-core/lib/posix_wrap/inttypes.h: New file. + * grub-core/lib/posix_wrap/sys/types.h (int8_t): New type. + (int16_t): Likewise. + (int32_t): Likewise. + (int64_t): Likewise. + Reported and tested by: Alain Greppin. + 2011-01-08 Vladimir Serbinenko * grub-core/loader/i386/bsdXX.c (grub_netbsd_load_elf_meta): diff --git a/grub-core/lib/posix_wrap/inttypes.h b/grub-core/lib/posix_wrap/inttypes.h new file mode 100644 index 000000000..a12c43b15 --- /dev/null +++ b/grub-core/lib/posix_wrap/inttypes.h @@ -0,0 +1 @@ +#include diff --git a/grub-core/lib/posix_wrap/sys/types.h b/grub-core/lib/posix_wrap/sys/types.h index 4e8331fdd..69e49509e 100644 --- a/grub-core/lib/posix_wrap/sys/types.h +++ b/grub-core/lib/posix_wrap/sys/types.h @@ -32,6 +32,11 @@ typedef grub_uint16_t uint16_t; typedef grub_uint32_t uint32_t; typedef grub_uint64_t uint64_t; +typedef grub_int8_t int8_t; +typedef grub_int16_t int16_t; +typedef grub_int32_t int32_t; +typedef grub_int64_t int64_t; + #ifdef GRUB_CPU_WORDS_BIGENDIAN #define WORDS_BIGENDIAN #else From 9462775a2df7842cf4a4c21f19e5dd1d92ef5183 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 00:39:12 +0100 Subject: [PATCH 068/276] * grub-core/Makefile.am (rs_decoder.S): Force compilation with -Os. Reported and tested by: Alain Greppin. --- ChangeLog | 5 +++++ grub-core/Makefile.am | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1a297da01..984c3fc5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-08 Vladimir Serbinenko + + * grub-core/Makefile.am (rs_decoder.S): Force compilation with -Os. + Reported and tested by: Alain Greppin. + 2011-01-08 Vladimir Serbinenko Satisfy some bison versions need for inttypes.h. diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 073ce37f6..fcf3fc42d 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -50,7 +50,7 @@ grub_script.yy.h: script/yylex.l grub_script.yy.c: grub_script.yy.h rs_decoder.S: $(srcdir)/lib/reed_solomon.c - $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(top_builddir) -S -DSTANDALONE -o $@ $< -g0 -mregparm=3 + $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Os -I$(top_builddir) -S -DSTANDALONE -o $@ $< -g0 -mregparm=3 kern/i386/pc/startup.S: $(builddir)/rs_decoder.S From ec1dfd634e3c2f09d9e293239529c5ea784ac102 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 00:44:38 +0100 Subject: [PATCH 069/276] * configure.ac: Do CPU substitution even if it's specified explicitly. Reported and tested by: Alain Greppin. --- ChangeLog | 5 +++++ configure.ac | 15 ++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 984c3fc5a..5116604f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-08 Vladimir Serbinenko + + * configure.ac: Do CPU substitution even if it's specified explicitly. + Reported and tested by: Alain Greppin. + 2011-01-08 Vladimir Serbinenko * grub-core/Makefile.am (rs_decoder.S): Force compilation with -Os. diff --git a/configure.ac b/configure.ac index c013c9022..8bb585a78 100644 --- a/configure.ac +++ b/configure.ac @@ -103,15 +103,12 @@ else platform="$with_platform" fi -# Adjust CPU unless target was explicitly specified. -if test -z "$target_alias"; then - case "$target_cpu"-"$platform" in - x86_64-efi) ;; - x86_64-emu) ;; - x86_64-*) target_cpu=i386 ;; - powerpc64-ieee1275) target_cpu=powerpc ;; - esac -fi +case "$target_cpu"-"$platform" in + x86_64-efi) ;; + x86_64-emu) ;; + x86_64-*) target_cpu=i386 ;; + powerpc64-ieee1275) target_cpu=powerpc ;; +esac # Check if the platform is supported, make final adjustments. case "$target_cpu"-"$platform" in From f9f376488bc602b6c8f370c6697e0765747ac1c6 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 01:45:57 +0100 Subject: [PATCH 070/276] =?UTF-8?q?=09*=20grub-core/term/at=5Fkeyboard.c?= =?UTF-8?q?=20(grub=5Fkeyboard=5Fgetkey):=20Silence=20spurious=20=09warnin?= =?UTF-8?q?g.=20=09Reported=20and=20tested=20by:=20Gr=C3=A9goire=20Sutre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 6 ++++++ grub-core/term/at_keyboard.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5116604f5..4c2fd2a62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-08 Vladimir Serbinenko + + * grub-core/term/at_keyboard.c (grub_keyboard_getkey): Silence spurious + warning. + Reported and tested by: Grégoire Sutre. + 2011-01-08 Vladimir Serbinenko * configure.ac: Do CPU substitution even if it's specified explicitly. diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c index 5bc3f578c..55cb76483 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -494,7 +494,7 @@ static int grub_keyboard_getkey (void) { int key; - int is_break; + int is_break = 0; key = fetch_key (&is_break); if (key == -1) From fc836af9a520da52a84c74b99d06de8a3fd117b6 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 01:50:06 +0100 Subject: [PATCH 071/276] =?UTF-8?q?=09*=20grub-core/commands/terminal.c=20?= =?UTF-8?q?(grub=5Fcmd=5Fterminal=5Finput):=20Silence=20=09aliasing=20warn?= =?UTF-8?q?ing.=20=09(grub=5Fcmd=5Fterminal=5Foutput):=20Likewise.=20=09Re?= =?UTF-8?q?ported=20and=20tested=20by:=20Gr=C3=A9goire=20Sutre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 7 +++++++ grub-core/commands/terminal.c | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c2fd2a62..7545cbef9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-08 Vladimir Serbinenko + + * grub-core/commands/terminal.c (grub_cmd_terminal_input): Silence + aliasing warning. + (grub_cmd_terminal_output): Likewise. + Reported and tested by: Grégoire Sutre. + 2011-01-08 Vladimir Serbinenko * grub-core/term/at_keyboard.c (grub_keyboard_getkey): Silence spurious diff --git a/grub-core/commands/terminal.c b/grub-core/commands/terminal.c index c8b1b6315..c2d9550f6 100644 --- a/grub-core/commands/terminal.c +++ b/grub-core/commands/terminal.c @@ -210,11 +210,11 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)), (void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, init); (void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, fini); return handle_command (argc, args, - (struct abstract_terminal **) &grub_term_inputs, - (struct abstract_terminal **) &grub_term_inputs_disabled, - grub_term_input_autoload, - N_ ("Active input terminals:"), - N_ ("Available input terminals:")); + (struct abstract_terminal **) (void *) &grub_term_inputs, + (struct abstract_terminal **) (void *) &grub_term_inputs_disabled, + grub_term_input_autoload, + N_ ("Active input terminals:"), + N_ ("Available input terminals:")); } static grub_err_t @@ -225,11 +225,12 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)), (void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, name); (void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, init); (void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, fini); - return handle_command (argc, args, (struct abstract_terminal **) &grub_term_outputs, - (struct abstract_terminal **) &grub_term_outputs_disabled, - grub_term_output_autoload, - N_ ("Active output terminals:"), - N_ ("Available output terminals:")); + return handle_command (argc, args, + (struct abstract_terminal **) (void *) &grub_term_outputs, + (struct abstract_terminal **) (void *) &grub_term_outputs_disabled, + grub_term_output_autoload, + N_ ("Active output terminals:"), + N_ ("Available output terminals:")); } static grub_command_t cmd_terminal_input, cmd_terminal_output; From e7121b69329ce5bff182ab85ccaf2f888a07a7b9 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 01:56:09 +0100 Subject: [PATCH 072/276] * grub-core/fs/zfs/zfs.c (dmu_read): Use void * for some pointers to avoid aliasing. (fzap_lookup): Likewise. (dnode_get): Likewise. (make_mdn): Likewise. (zfs_mount): Likewise. (fzap_iterate): Use temporary pointer to avoid aliasing. (grub_zfs_read): Likewise. * grub-core/loader/i386/xnu.c (grub_xnu_boot): Likewise. * grub-core/loader/xnu.c (grub_cmd_xnu_kernel): Use void * for some pointers to avoid aliasing. (grub_cmd_xnu_kernel64): Likewise. (grub_xnu_load_driver): Likewise. --- ChangeLog | 16 ++++++++++++++ grub-core/fs/zfs/zfs.c | 43 +++++++++++++++++++++---------------- grub-core/loader/i386/xnu.c | 10 +++++---- grub-core/loader/xnu.c | 27 +++++++++++++---------- 4 files changed, 63 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7545cbef9..0f132cb01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2011-01-08 Vladimir Serbinenko + + * grub-core/fs/zfs/zfs.c (dmu_read): Use void * for some pointers to + avoid aliasing. + (fzap_lookup): Likewise. + (dnode_get): Likewise. + (make_mdn): Likewise. + (zfs_mount): Likewise. + (fzap_iterate): Use temporary pointer to avoid aliasing. + (grub_zfs_read): Likewise. + * grub-core/loader/i386/xnu.c (grub_xnu_boot): Likewise. + * grub-core/loader/xnu.c (grub_cmd_xnu_kernel): Use void * for some + pointers to avoid aliasing. + (grub_cmd_xnu_kernel64): Likewise. + (grub_xnu_load_driver): Likewise. + 2011-01-08 Vladimir Serbinenko * grub-core/commands/terminal.c (grub_cmd_terminal_input): Silence diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 8901af76f..5b575f369 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -603,7 +603,8 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, int idx, level; blkptr_t *bp_array = dn->dn.dn_blkptr; int epbs = dn->dn.dn_indblkshift - SPA_BLKPTRSHIFT; - blkptr_t *bp, *tmpbuf = 0; + blkptr_t *bp; + void *tmpbuf = 0; grub_zfs_endian_t endian; grub_err_t err = GRUB_ERR_NONE; @@ -646,7 +647,7 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, break; } grub_dprintf ("zfs", "endian = %d\n", endian); - err = zio_read (bp, endian, (void **) &tmpbuf, 0, data); + err = zio_read (bp, endian, &tmpbuf, 0, data); endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1; if (err) break; @@ -880,7 +881,7 @@ static grub_err_t fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap, char *name, grub_uint64_t * value, struct grub_zfs_data *data) { - zap_leaf_phys_t *l; + void *l; grub_uint64_t hash, idx, blkid; int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, zap_dnode->endian) << DNODE_SHIFT); @@ -903,7 +904,7 @@ fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap, /* Get the leaf block */ if ((1U << blksft) < sizeof (zap_leaf_phys_t)) return grub_error (GRUB_ERR_BAD_FS, "ZAP leaf is too small"); - err = dmu_read (zap_dnode, blkid, (void **) &l, &leafendian, data); + err = dmu_read (zap_dnode, blkid, &l, &leafendian, data); if (err) return err; @@ -920,6 +921,7 @@ fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap, struct grub_zfs_data *data) { zap_leaf_phys_t *l; + void *l_in; grub_uint64_t idx, blkid; grub_uint16_t chunk; int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, @@ -947,7 +949,8 @@ fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap, { blkid = ((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))]; - err = dmu_read (zap_dnode, blkid, (void **) &l, &endian, data); + err = dmu_read (zap_dnode, blkid, &l_in, &endian, data); + l = l_in; if (err) { grub_errno = GRUB_ERR_NONE; @@ -1108,7 +1111,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type, grub_uint64_t blkid, blksz; /* the block id this object dnode is in */ int epbs; /* shift of number of dnodes in a block */ int idx; /* index within a block */ - dnode_phys_t *dnbuf; + void *dnbuf; grub_err_t err; grub_zfs_endian_t endian; @@ -1131,7 +1134,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type, grub_dprintf ("zfs", "endian = %d, blkid=%llx\n", mdn->endian, (unsigned long long) blkid); - err = dmu_read (mdn, blkid, (void **) &dnbuf, &endian, data); + err = dmu_read (mdn, blkid, &dnbuf, &endian, data); if (err) return err; grub_dprintf ("zfs", "alive\n"); @@ -1153,7 +1156,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type, data->dnode_endian = endian; } - grub_memmove (&(buf->dn), &dnbuf[idx], DNODE_SIZE); + grub_memmove (&(buf->dn), (dnode_phys_t *) dnbuf + idx, DNODE_SIZE); buf->endian = endian; if (type && buf->dn.dn_type != type) return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type"); @@ -1465,7 +1468,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname, static grub_err_t make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data) { - objset_phys_t *osp; + void *osp; blkptr_t *bp; grub_size_t ospsize; grub_err_t err; @@ -1473,7 +1476,7 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data) grub_dprintf ("zfs", "endian = %d\n", mdn->endian); bp = &(((dsl_dataset_phys_t *) DN_BONUS (&mdn->dn))->ds_bp); - err = zio_read (bp, mdn->endian, (void **) &osp, &ospsize, data); + err = zio_read (bp, mdn->endian, &osp, &ospsize, data); if (err) return err; if (ospsize < OBJSET_PHYS_SIZE_V14) @@ -1483,7 +1486,8 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data) } mdn->endian = (grub_zfs_to_cpu64 (bp->blk_prop, mdn->endian)>>63) & 1; - grub_memmove ((char *) &(mdn->dn), (char *) &osp->os_meta_dnode, DNODE_SIZE); + grub_memmove ((char *) &(mdn->dn), + (char *) &((objset_phys_t *) osp)->os_meta_dnode, DNODE_SIZE); grub_free (osp); return GRUB_ERR_NONE; } @@ -1960,7 +1964,7 @@ zfs_mount (grub_device_t dev) int label = 0; uberblock_phys_t *ub_array, *ubbest = NULL; vdev_boot_header_t *bh; - objset_phys_t *osp = 0; + void *osp = 0; grub_size_t ospsize; grub_err_t err; int vdevnum; @@ -2038,7 +2042,7 @@ zfs_mount (grub_device_t dev) ? LITTLE_ENDIAN : BIG_ENDIAN); err = zio_read (&ubbest->ubp_uberblock.ub_rootbp, ub_endian, - (void **) &osp, &ospsize, data); + &osp, &ospsize, data); if (err) { grub_dprintf ("zfs", "couldn't zio_read\n"); @@ -2067,7 +2071,8 @@ zfs_mount (grub_device_t dev) continue; #endif /* Got the MOS. Save it at the memory addr MOS. */ - grub_memmove (&(data->mos.dn), &osp->os_meta_dnode, DNODE_SIZE); + grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode, + DNODE_SIZE); data->mos.endian = (grub_zfs_to_cpu64 (ubbest->ubp_uberblock.ub_rootbp.blk_prop, ub_endian) >> 63) & 1; grub_memmove (&(data->current_uberblock), &ubbest->ubp_uberblock, sizeof (uberblock_t)); @@ -2201,7 +2206,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename) */ if (data->dnode.dn.dn_bonustype == DMU_OT_SA) { - sa_hdr_phys_t *sahdrp; + void *sahdrp; int hdrsize; if (data->dnode.dn.dn_bonuslen != 0) @@ -2212,7 +2217,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename) { blkptr_t *bp = &data->dnode.dn.dn_spill; - err = zio_read (bp, data->dnode.endian, (void **) &sahdrp, NULL, data); + err = zio_read (bp, data->dnode.endian, &sahdrp, NULL, data); if (err) return err; } @@ -2221,7 +2226,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename) return grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt"); } - hdrsize = SA_HDR_SIZE (sahdrp); + hdrsize = SA_HDR_SIZE (((sa_hdr_phys_t *) sahdrp)); file->size = *(grub_uint64_t *) ((char *) sahdrp + hdrsize + SA_SIZE_OFFSET); } else @@ -2280,6 +2285,7 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len) read = 0; while (length) { + void *t; /* * Find requested blkid and the offset within that block. */ @@ -2287,8 +2293,9 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len) grub_free (data->file_buf); data->file_buf = 0; - err = dmu_read (&(data->dnode), blkid, (void **) &(data->file_buf), + err = dmu_read (&(data->dnode), blkid, &t, 0, data); + data->file_buf = t; if (err) return -1; diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index a9435eff3..a0df6f4aa 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -951,10 +951,11 @@ grub_err_t grub_xnu_boot (void) { struct grub_xnu_boot_params *bootparams; + void *bp_in; grub_addr_t bootparams_target; grub_err_t err; grub_efi_uintn_t memory_map_size = 0; - grub_efi_memory_descriptor_t *memory_map; + void *memory_map; grub_addr_t memory_map_target; grub_efi_uintn_t map_key = 0; grub_efi_uintn_t descriptor_size = 0; @@ -1006,9 +1007,10 @@ grub_xnu_boot (void) /* Relocate the boot parameters to heap. */ err = grub_xnu_heap_malloc (sizeof (*bootparams), - (void **) &bootparams, &bootparams_target); + &bp_in, &bootparams_target); if (err) return err; + bootparams = bp_in; /* Set video. */ err = grub_xnu_set_video (bootparams); @@ -1035,7 +1037,7 @@ grub_xnu_boot (void) memory map growth. */ memory_map_size += 20 * descriptor_size; err = grub_xnu_heap_malloc (memory_map_size, - (void **) &memory_map, &memory_map_target); + &memory_map, &memory_map_target); if (err) return err; @@ -1109,7 +1111,7 @@ grub_xnu_boot (void) grub_xnu_arg1 = bootparams_target; grub_autoefi_set_virtual_address_map (memory_map_size, descriptor_size, - descriptor_version,memory_map); + descriptor_version, memory_map); state.eip = grub_xnu_entry_point; state.eax = grub_xnu_arg1; diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index 95857951a..5a84dea1c 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -342,7 +342,8 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), grub_macho_t macho; grub_uint32_t startcode, endcode; int i; - char *ptr, *loadaddr; + char *ptr; + void *loadaddr; grub_addr_t loadaddr_target; if (argc < 1) @@ -375,7 +376,7 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), if (!grub_xnu_relocator) return grub_errno; grub_xnu_heap_target_start = startcode; - err = grub_xnu_heap_malloc (endcode - startcode, (void **) &loadaddr, + err = grub_xnu_heap_malloc (endcode - startcode, &loadaddr, &loadaddr_target); if (err) @@ -386,7 +387,8 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), } /* Load kernel. */ - err = grub_macho_load32 (macho, loadaddr - startcode, GRUB_MACHO_NOBSS); + err = grub_macho_load32 (macho, (char *) loadaddr - startcode, + GRUB_MACHO_NOBSS); if (err) { grub_macho_close (macho); @@ -450,7 +452,8 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), grub_macho_t macho; grub_uint64_t startcode, endcode; int i; - char *ptr, *loadaddr; + char *ptr; + void *loadaddr; grub_addr_t loadaddr_target; if (argc < 1) @@ -486,7 +489,7 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), if (!grub_xnu_relocator) return grub_errno; grub_xnu_heap_target_start = startcode; - err = grub_xnu_heap_malloc (endcode - startcode, (void **) &loadaddr, + err = grub_xnu_heap_malloc (endcode - startcode, &loadaddr, &loadaddr_target); if (err) @@ -497,7 +500,8 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), } /* Load kernel. */ - err = grub_macho_load64 (macho, loadaddr - startcode, GRUB_MACHO_NOBSS); + err = grub_macho_load64 (macho, (char *) loadaddr - startcode, + GRUB_MACHO_NOBSS); if (err) { grub_macho_close (macho); @@ -636,7 +640,8 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) grub_file_t infoplist; struct grub_xnu_extheader *exthead; int neededspace = sizeof (*exthead); - grub_uint8_t *buf, *buf0; + grub_uint8_t *buf; + void *buf0; grub_addr_t buf_target; grub_size_t infoplistsize = 0, machosize = 0; char *name, *nameend; @@ -692,7 +697,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE); if (err) return err; - err = grub_xnu_heap_malloc (neededspace, (void **) &buf0, &buf_target); + err = grub_xnu_heap_malloc (neededspace, &buf0, &buf_target); if (err) return err; buf = buf0; @@ -704,7 +709,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) /* Load the binary. */ if (macho) { - exthead->binaryaddr = buf_target + (buf - buf0); + exthead->binaryaddr = buf_target + (buf - (grub_uint8_t *) buf0); exthead->binarysize = machosize; if (grub_xnu_is_64bit) err = grub_macho_readfile64 (macho, buf); @@ -723,7 +728,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) /* Load the plist. */ if (infoplist) { - exthead->infoplistaddr = buf_target + (buf - buf0); + exthead->infoplistaddr = buf_target + (buf - (grub_uint8_t *) buf0); exthead->infoplistsize = infoplistsize + 1; if (grub_file_read (infoplist, buf, infoplistsize) != (grub_ssize_t) (infoplistsize)) @@ -739,7 +744,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) } grub_errno = GRUB_ERR_NONE; - exthead->nameaddr = (buf - buf0) + buf_target; + exthead->nameaddr = (buf - (grub_uint8_t *) buf0) + buf_target; exthead->namesize = namelen + 1; grub_memcpy (buf, name, namelen); buf[namelen] = 0; From 53798c4bd1ae9c635740f72207c9db5509505f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Sutre?= Date: Sat, 8 Jan 2011 17:01:38 +0100 Subject: [PATCH 073/276] Check for libdevmapper header --- ChangeLog | 4 ++++ configure.ac | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0f132cb01..8a832d41d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-08 Grégoire Sutre + + * configure.ac: Check for libdevmapper header. + 2011-01-08 Vladimir Serbinenko * grub-core/fs/zfs/zfs.c (dmu_read): Use void * for some pointers to diff --git a/configure.ac b/configure.ac index 8bb585a78..a9ca130b4 100644 --- a/configure.ac +++ b/configure.ac @@ -863,6 +863,12 @@ if test x"$enable_device_mapper" = xno ; then device_mapper_excuse="explicitly disabled" fi +if test x"$device_mapper_excuse" = x ; then + # Check for device-mapper header. + AC_CHECK_HEADER([libdevmapper.h], [], + [device_mapper_excuse="need libdevmapper header"]) +fi + if test x"$device_mapper_excuse" = x ; then # Check for device-mapper library. AC_CHECK_LIB([devmapper], [dm_task_create], [], From c88172fa92efe15950247491db154c01a58df074 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 8 Jan 2011 20:22:32 +0100 Subject: [PATCH 074/276] * config.h.in (_LARGEFILE_SOURCE): Add missing define. (_FILE_OFFSET_BITS): Likewise. Reported by: Seth Goldberg. --- ChangeLog | 6 ++++++ config.h.in | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8a832d41d..30dd4798f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-08 Vladimir Serbinenko + + * config.h.in (_LARGEFILE_SOURCE): Add missing define. + (_FILE_OFFSET_BITS): Likewise. + Reported by: Seth Goldberg. + 2011-01-08 Grégoire Sutre * configure.ac: Check for libdevmapper header. diff --git a/config.h.in b/config.h.in index 6d7d95dec..3974ad7d5 100644 --- a/config.h.in +++ b/config.h.in @@ -1,3 +1,7 @@ +#undef _LARGEFILE_SOURCE +#undef _FILE_OFFSET_BITS +#define _LARGEFILE_SOURCE +#define _FILE_OFFSET_BITS 64 #if defined (GRUB_UTIL) || !defined (GRUB_MACHINE) #include #define NESTED_FUNC_ATTR From a21e5672fd8edd1f7ab17204396fb436dba0c2ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Sutre?= Date: Sun, 9 Jan 2011 23:23:25 +0100 Subject: [PATCH 075/276] Handle openbsd and netbsd types being in part_bsd module. --- ChangeLog | 5 +++++ util/grub-mkconfig_lib.in | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 30dd4798f..723df8522 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-09 Grégoire Sutre + + * util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Handle + openbsd and netbsd types being in part_bsd module. + 2011-01-08 Vladimir Serbinenko * config.h.in (_LARGEFILE_SOURCE): Add missing define. diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index ec4084698..2a48fb260 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -107,7 +107,12 @@ prepare_grub_to_access_device () partmap="`${grub_probe} --device ${device} --target=partmap`" for module in ${partmap} ; do - echo "insmod part_${module}" + case "${module}" in + netbsd | openbsd) + echo "insmod part_bsd";; + *) + echo "insmod part_${module}";; + esac done fs="`${grub_probe} --device ${device} --target=fs`" From 1f060f399a5eebbb50f0e3aa41e734de09380aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Sutre?= Date: Mon, 10 Jan 2011 01:08:40 +0100 Subject: [PATCH 076/276] Teach grub-mkconfig to load fs modules for NetBSD. --- ChangeLog | 5 ++++ util/grub.d/10_netbsd.in | 62 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 723df8522..e215db3bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-09 Grégoire Sutre + + * util/grub.d/10_netbsd.in (netbsd_load_fs_module): New function. + (netbsd_entry): Use netbsd_load_fs_module() to load filesystem module. + 2011-01-09 Grégoire Sutre * util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Handle diff --git a/util/grub.d/10_netbsd.in b/util/grub.d/10_netbsd.in index 13f9d923a..ffd31ad93 100644 --- a/util/grub.d/10_netbsd.in +++ b/util/grub.d/10_netbsd.in @@ -27,11 +27,65 @@ export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR=@localedir@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then - OS=NetBSD + OS="NetBSD" else OS="${GRUB_DISTRIBUTOR} NetBSD" fi +netbsd_load_fs_module () +{ + loader="$1" # "knetbsd" or "multiboot" + kernel="$2" # absolute path to the kernel file + + case $(zcat -f "${kernel}" | file -bL - | cut -d , -f 2 | tr -d ' ') in + Intel80386) + karch="i386" + ;; + x86-64) + karch="amd64" + ;; + *) + return + ;; + esac + + case $(${grub_probe} --target=fs -d ${GRUB_DEVICE}) in + ext2) + kmod="ext2fs" + ;; + fat) + kmod="msdosfs" + ;; + ntfs) + kmod="ntfs" + ;; + ufs*) + kmod="ffs" + ;; + *) + return + ;; + esac + + kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }') + kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod" + + if test -z "$karch" -o -z "$kversion" -o ! -f "${kmodule}"; then + return + fi + + kmodule_rel=$(make_system_path_relative_to_its_root "$kmodule") || return + prepare_grub_to_access_device $(${grub_probe} -t device "${kmodule}") | sed -e 's,^, ,' + case "${loader}" in + knetbsd) + printf "\tknetbsd_module_elf %s\n" "${kmodule_rel}" + ;; + multiboot) + printf "\tmodule %s\n" "${kmodule_rel}" + ;; + esac +} + netbsd_entry () { loader="$1" # "knetbsd" or "multiboot" @@ -59,6 +113,9 @@ netbsd_entry () "${kernel}" "${kernel}" "${kroot_device}" "${GRUB_CMDLINE_NETBSD} ${args}" ;; esac + + netbsd_load_fs_module "${loader}" "${kernel}" + printf "}\n" } @@ -72,8 +129,7 @@ for k in $(ls -t /netbsd*) ; do if ! grub_file_is_not_garbage "$k" ; then continue fi - if ! ((file -bL "$k" | grep -q "${pattern}") || - (zcat "$k" | file -bL - | grep -q "${pattern}")) 2>/dev/null ; then + if ! (zcat -f "$k" | file -bL - | grep -q "${pattern}") 2>/dev/null ; then continue fi From cf0eaf13a102d71b8f7d56af8b1d00a623903d0e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 17:28:29 +0100 Subject: [PATCH 077/276] * grub-core/disk/raid.c (insert_array): Display RAID name in duplicate members errors. --- ChangeLog | 5 +++++ grub-core/disk/raid.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e215db3bd..85495e8ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/disk/raid.c (insert_array): Display RAID name in duplicate + members errors. + 2011-01-09 Grégoire Sutre * util/grub.d/10_netbsd.in (netbsd_load_fs_module): New function. diff --git a/grub-core/disk/raid.c b/grub-core/disk/raid.c index edc2b195d..c789fea50 100644 --- a/grub-core/disk/raid.c +++ b/grub-core/disk/raid.c @@ -530,8 +530,8 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array, /* We found multiple devices with the same number. Again, this shouldn't happen. */ return grub_error (GRUB_ERR_BAD_DEVICE, - "found two disks with the number %d", - new_array->number); + "found two disks with the index %d for RAID %s", + new_array->index, array->name); if (new_array->disk_size < array->disk_size) array->disk_size = new_array->disk_size; From b1969b304927c0fcd7ad812d97e564ddf3216476 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 17:35:32 +0100 Subject: [PATCH 078/276] * grub-core/fs/btrfs.c (grub_btrfs_mount): Transform out of range into badfs. Reported by: TiCPU. --- ChangeLog | 6 ++++++ grub-core/fs/btrfs.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 85495e8ad..12927d0f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/fs/btrfs.c (grub_btrfs_mount): Transform out of range into + badfs. + Reported by: TiCPU. + 2011-01-10 Vladimir Serbinenko * grub-core/disk/raid.c (insert_array): Display RAID name in duplicate diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index a2ee485b4..179891da8 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -60,6 +60,9 @@ grub_btrfs_mount (grub_disk_t disk) return data; fail: + if (grub_errno == GRUB_ERR_OUT_OF_RANGE) + grub_error (GRUB_ERR_BAD_FS, "not a Btrfs filesystem"); + grub_free (data); return NULL; } From c49849cc63560d02e042eda337135dbcf72a92fa Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 17:51:06 +0100 Subject: [PATCH 079/276] * grub-core/kern/i386/pc/mmap.c (grub_get_conv_memsize): New function. (grub_machine_mmap_iterate): Take low memory into account --- ChangeLog | 5 +++++ grub-core/kern/i386/pc/mmap.c | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 12927d0f2..34703b81d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/kern/i386/pc/mmap.c (grub_get_conv_memsize): New function. + (grub_machine_mmap_iterate): Take low memory into account + 2011-01-10 Vladimir Serbinenko * grub-core/fs/btrfs.c (grub_btrfs_mount): Transform out of range into diff --git a/grub-core/kern/i386/pc/mmap.c b/grub-core/kern/i386/pc/mmap.c index a305d4511..480ffa949 100644 --- a/grub-core/kern/i386/pc/mmap.c +++ b/grub-core/kern/i386/pc/mmap.c @@ -36,6 +36,22 @@ struct grub_machine_mmap_entry } __attribute__((packed)); +/* + * + * grub_get_conv_memsize(i) : return the conventional memory size in KB. + * BIOS call "INT 12H" to get conventional memory size + * The return value in AX. + */ +static inline grub_uint16_t +grub_get_conv_memsize (void) +{ + struct grub_bios_int_registers regs; + + regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; + grub_bios_interrupt (0x12, ®s); + return regs.eax & 0xffff; +} + /* * grub_get_ext_memsize() : return the extended memory size in KB. * BIOS call "INT 15H, AH=88H" to get extended memory size @@ -155,6 +171,10 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook) { grub_uint32_t eisa_mmap = grub_get_eisa_mmap (); + if (hook (0x0, ((grub_uint32_t) grub_get_conv_memsize ()) << 10, + GRUB_MEMORY_AVAILABLE)) + return 0; + if (eisa_mmap) { if (hook (0x100000, (eisa_mmap & 0xFFFF) << 10, @@ -162,7 +182,8 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook) hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MEMORY_AVAILABLE); } else - hook (0x100000, grub_get_ext_memsize () << 10, GRUB_MEMORY_AVAILABLE); + hook (0x100000, ((grub_uint32_t) grub_get_ext_memsize ()) << 10, + GRUB_MEMORY_AVAILABLE); } return 0; From db87be2aeab310b4740c0a6c556f667d43dd342e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 17:54:21 +0100 Subject: [PATCH 080/276] * grub-core/kern/i386/pc/init.c (grub_get_conv_memsize): Removed. (grub_machine_init): Don't check amount of low memory as reportedly INT 12h can be broken and if low memory is too low we wouldn't have gotten into grub_machine_init anyway. --- ChangeLog | 7 +++++++ grub-core/kern/i386/pc/init.c | 23 +++++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34703b81d..a1d948151 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/kern/i386/pc/init.c (grub_get_conv_memsize): Removed. + (grub_machine_init): Don't check amount of low memory as reportedly + INT 12h can be broken and if low memory is too low we wouldn't have + gotten into grub_machine_init anyway. + 2011-01-10 Vladimir Serbinenko * grub-core/kern/i386/pc/mmap.c (grub_get_conv_memsize): New function. diff --git a/grub-core/kern/i386/pc/init.c b/grub-core/kern/i386/pc/init.c index 122c2c556..d8c337bde 100644 --- a/grub-core/kern/i386/pc/init.c +++ b/grub-core/kern/i386/pc/init.c @@ -140,36 +140,27 @@ compact_mem_regions (void) } } -/* - * - * grub_get_conv_memsize(i) : return the conventional memory size in KB. - * BIOS call "INT 12H" to get conventional memory size - * The return value in AX. - */ -static inline grub_uint16_t -grub_get_conv_memsize (void) -{ - struct grub_bios_int_registers regs; - - regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; - grub_bios_interrupt (0x12, ®s); - return regs.eax & 0xffff; -} - void grub_machine_init (void) { int i; +#if 0 int grub_lower_mem; +#endif /* Initialize the console as early as possible. */ grub_console_init (); + /* This sanity check is useless since top of GRUB_MEMORY_MACHINE_RESERVED_END + is used for stack and if it's unavailable we wouldn't have gotten so far. + */ +#if 0 grub_lower_mem = grub_get_conv_memsize () << 10; /* Sanity check. */ if (grub_lower_mem < GRUB_MEMORY_MACHINE_RESERVED_END) grub_fatal ("too small memory"); +#endif /* FIXME: This prevents loader/i386/linux.c from using low memory. When our heap implements support for requesting a chunk in low memory, this should From ce6bb3ee31b651a09cd513cf8af5fb3b142bb82c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 19:20:50 +0100 Subject: [PATCH 081/276] * util/grub-menulst2cfg.c (main): Trim the line. --- ChangeLog | 4 ++++ util/grub-menulst2cfg.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a1d948151..64f9a5be9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-10 Vladimir Serbinenko + + * util/grub-menulst2cfg.c (main): Trim the line. + 2011-01-10 Vladimir Serbinenko * grub-core/kern/i386/pc/init.c (grub_get_conv_memsize): Removed. diff --git a/util/grub-menulst2cfg.c b/util/grub-menulst2cfg.c index e29c6b17c..da1c289a8 100644 --- a/util/grub-menulst2cfg.c +++ b/util/grub-menulst2cfg.c @@ -78,9 +78,12 @@ main (int argc, char **argv) { char *oldname = NULL; char *newsuffix; + char *ptr; + + for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++); oldname = entryname; - parsed = grub_legacy_parse (buf, &entryname, &newsuffix); + parsed = grub_legacy_parse (ptr, &entryname, &newsuffix); if (newsuffix) { suffixlen += strlen (newsuffix); From 47a77af5e8f03eed1edb60f81ab7764d54ab515a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 19:25:00 +0100 Subject: [PATCH 082/276] * grub-core/commands/legacycfg.c (legacy_file): Trim the line. --- ChangeLog | 4 ++++ grub-core/commands/legacycfg.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 64f9a5be9..6461f79f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/commands/legacycfg.c (legacy_file): Trim the line. + 2011-01-10 Vladimir Serbinenko * util/grub-menulst2cfg.c (main): Trim the line. diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index de392ac81..71ac5c620 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -83,9 +83,13 @@ legacy_file (const char *filename) { char *oldname = NULL; char *newsuffix; + char *ptr; + + for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++); oldname = entryname; - parsed = grub_legacy_parse (buf, &entryname, &newsuffix); + parsed = grub_legacy_parse (ptr, &entryname, &newsuffix); + grub_free (buf); buf = NULL; if (newsuffix) { From 6fef99b4e4121ccd3bf9208c13faa6433a51453f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 19:52:12 +0100 Subject: [PATCH 083/276] * util/grub-mklayout.c (usage): Update help text. --- ChangeLog | 4 ++++ util/grub-mklayout.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6461f79f4..d856bbff2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-10 Vladimir Serbinenko + + * util/grub-mklayout.c (usage): Update help text. + 2011-01-10 Vladimir Serbinenko * grub-core/commands/legacycfg.c (legacy_file): Trim the line. diff --git a/util/grub-mklayout.c b/util/grub-mklayout.c index e90d955ff..36f6e04fc 100644 --- a/util/grub-mklayout.c +++ b/util/grub-mklayout.c @@ -259,8 +259,9 @@ usage (int status) fprintf (stderr, "Try `%s --help' for more information.\n", program_name); else printf ("\ -Usage: %s [OPTIONS] LAYOUT\n\ - -o, --output set output base name file. Default is LAYOUT.gkb\n\ +Usage: %s [OPTIONS]\n\ + -i, --input set input filename. Default is STDIN\n\ + -o, --output set output filename. Default is STDOUT\n\ -h, --help display this message and exit.\n\ -V, --version print version information and exit.\n\ -v, --verbose print verbose messages.\n\ From dcb883b1623c730190357ad8803f88e592b6d364 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:27:58 +0100 Subject: [PATCH 084/276] Submenu default support. * grub-core/normal/menu.c (grub_menu_execute_entry): New parameter auto_boot. All users updated. Declared static. Handle chosen and default with submenus. (grub_menu_execute_with_fallback): Declared static. Don't notify failure if autobooted. Upper level does it. (menuentry_eq): New function. (get_entry_number): Use menuentry_eq. (show_menu): New parameter "autobooted". All users updated. (grub_show_menu): Likewise. * include/grub/normal.h (grub_show_menu): Likewise. * include/grub/menu.h (grub_menu_execute_entry): Removed. (grub_menu_execute_with_fallback): Likewise. --- ChangeLog | 18 +++++ grub-core/commands/legacycfg.c | 2 +- grub-core/normal/main.c | 2 +- grub-core/normal/menu.c | 130 +++++++++++++++++++++++++++++---- grub-core/normal/menu_entry.c | 2 +- include/grub/menu.h | 5 -- include/grub/normal.h | 2 +- 7 files changed, 137 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index d856bbff2..976c2cf5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2011-01-10 Vladimir Serbinenko + + Submenu default support. + + * grub-core/normal/menu.c (grub_menu_execute_entry): New parameter + auto_boot. All users updated. + Declared static. + Handle chosen and default with submenus. + (grub_menu_execute_with_fallback): Declared static. + Don't notify failure if autobooted. Upper level does it. + (menuentry_eq): New function. + (get_entry_number): Use menuentry_eq. + (show_menu): New parameter "autobooted". All users updated. + (grub_show_menu): Likewise. + * include/grub/normal.h (grub_show_menu): Likewise. + * include/grub/menu.h (grub_menu_execute_entry): Removed. + (grub_menu_execute_with_fallback): Likewise. + 2011-01-10 Vladimir Serbinenko * util/grub-mklayout.c (usage): Update help text. diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index 71ac5c620..23c1c1908 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -213,7 +213,7 @@ grub_cmd_legacy_source (struct grub_command *cmd, grub_menu_t menu; menu = grub_env_get_menu (); if (menu && menu->size) - grub_show_menu (menu, 1); + grub_show_menu (menu, 1, 0); if (!extractor) grub_env_context_close (); } diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index 3bfbbeb72..69bf5e6b5 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -287,7 +287,7 @@ grub_normal_execute (const char *config, int nested, int batch) { if (menu && menu->size) { - grub_show_menu (menu, nested); + grub_show_menu (menu, nested, 0); if (nested) grub_normal_free_menu (menu); } diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index 807ad51e0..6a123a6de 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -154,12 +154,15 @@ get_and_remove_first_entry_number (const char *name) } /* Run a menu entry. */ -void -grub_menu_execute_entry(grub_menu_entry_t entry) +static void +grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) { grub_err_t err = GRUB_ERR_NONE; int errs_before; grub_menu_t menu; + char *optr, *buf, *oldchosen = NULL, *olddefault = NULL; + const char *ptr, *chosen, *def; + grub_size_t sz = 0; if (entry->restricted) err = grub_auth_check_authentication (entry->users); @@ -173,6 +176,9 @@ grub_menu_execute_entry(grub_menu_entry_t entry) errs_before = grub_err_printed_errors; + chosen = grub_env_get ("chosen"); + def = grub_env_get ("default"); + if (entry->submenu) { grub_env_context_open (); @@ -180,9 +186,64 @@ grub_menu_execute_entry(grub_menu_entry_t entry) if (! menu) return; grub_env_set_menu (menu); + if (auto_boot) + grub_env_set ("timeout", "0"); } - grub_env_set ("chosen", entry->title); + for (ptr = entry->title; *ptr; ptr++) + sz += (*ptr == '>') ? 2 : 1; + if (chosen) + { + oldchosen = grub_strdup (chosen); + if (!oldchosen) + grub_print_error (); + } + if (def) + { + olddefault = grub_strdup (def); + if (!olddefault) + grub_print_error (); + } + sz++; + if (chosen) + sz += grub_strlen (chosen); + sz++; + buf = grub_malloc (sz); + if (!buf) + grub_print_error (); + else + { + optr = buf; + if (chosen) + { + optr = grub_stpcpy (optr, chosen); + *optr++ = '>'; + } + for (ptr = entry->title; *ptr; ptr++) + { + if (*ptr == '>') + *optr++ = '>'; + *optr++ = *ptr; + } + *optr = 0; + grub_env_set ("chosen", buf); + grub_env_export ("chosen"); + grub_free (buf); + } + for (ptr = def; *ptr; ptr++) + { + if (ptr[0] == '>' && ptr[1] == '>') + { + ptr++; + continue; + } + if (ptr[0] == '>') + break; + } + if (ptr[0] && ptr[1]) + grub_env_set ("default", ptr + 1); + else + grub_env_unset ("default"); grub_script_execute_sourcecode (entry->sourcecode, entry->argc, entry->args); if (errs_before != grub_err_printed_errors) @@ -196,20 +257,30 @@ grub_menu_execute_entry(grub_menu_entry_t entry) { if (menu && menu->size) { - grub_show_menu (menu, 1); + grub_show_menu (menu, 1, auto_boot); grub_normal_free_menu (menu); } grub_env_context_close (); } + if (oldchosen) + grub_env_set ("chosen", oldchosen); + else + grub_env_unset ("chosen"); + if (olddefault) + grub_env_set ("default", olddefault); + else + grub_env_unset ("default"); + grub_env_unset ("timeout"); } /* Execute ENTRY from the menu MENU, falling back to entries specified in the environment variable "fallback" if it fails. CALLBACK is a pointer to a struct of function pointers which are used to allow the caller provide feedback to the user. */ -void +static void grub_menu_execute_with_fallback (grub_menu_t menu, grub_menu_entry_t entry, + int autobooted, grub_menu_execute_callback_t callback, void *callback_data) { @@ -217,7 +288,7 @@ grub_menu_execute_with_fallback (grub_menu_t menu, callback->notify_booting (entry, callback_data); - grub_menu_execute_entry (entry); + grub_menu_execute_entry (entry, 1); /* Deal with fallback entries. */ while ((fallback_entry = get_and_remove_first_entry_number ("fallback")) @@ -228,14 +299,15 @@ grub_menu_execute_with_fallback (grub_menu_t menu, entry = grub_menu_get_entry (menu, fallback_entry); callback->notify_fallback (entry, callback_data); - grub_menu_execute_entry (entry); + grub_menu_execute_entry (entry, 1); /* If the function call to execute the entry returns at all, then this is taken to indicate a boot failure. For menu entries that do something other than actually boot an operating system, this could assume incorrectly that something failed. */ } - callback->notify_failure (callback_data); + if (!autobooted) + callback->notify_failure (callback_data); } static struct grub_menu_viewer *viewers; @@ -309,11 +381,35 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer) viewers = viewer; } +static int +menuentry_eq (const char *title, const char *spec) +{ + const char *ptr1, *ptr2; + ptr1 = title; + ptr2 = spec; + while (1) + { + if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0) + return 1; + if (*ptr2 == '>' && ptr2[1] != '>') + return 0; + if (*ptr2 == '>') + ptr2++; + if (*ptr1 != *ptr2) + return 0; + if (*ptr1 == 0) + return 1; + ptr1++; + ptr2++; + } +} + + /* Get the entry number from the variable NAME. */ static int get_entry_number (grub_menu_t menu, const char *name) { - char *val; + const char *val; int entry; val = grub_env_get (name); @@ -334,7 +430,7 @@ get_entry_number (grub_menu_t menu, const char *name) for (i = 0; e; i++) { - if (grub_strcmp (e->title, val) == 0) + if (menuentry_eq (e->title, val)) { entry = i; break; @@ -590,7 +686,7 @@ static struct grub_menu_execute_callback execution_callback = }; static grub_err_t -show_menu (grub_menu_t menu, int nested) +show_menu (grub_menu_t menu, int nested, int autobooted) { while (1) { @@ -609,22 +705,26 @@ show_menu (grub_menu_t menu, int nested) grub_cls (); if (auto_boot) - grub_menu_execute_with_fallback (menu, e, &execution_callback, 0); + grub_menu_execute_with_fallback (menu, e, autobooted, + &execution_callback, 0); else - grub_menu_execute_entry (e); + grub_menu_execute_entry (e, 0); + if (autobooted) + break; } return GRUB_ERR_NONE; } grub_err_t -grub_show_menu (grub_menu_t menu, int nested) +grub_show_menu (grub_menu_t menu, int nested, int autoboot) { grub_err_t err1, err2; while (1) { - err1 = show_menu (menu, nested); + err1 = show_menu (menu, nested, autoboot); + autoboot = 0; grub_print_error (); if (grub_normal_exit_level) diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index 4db4a45c1..e744d8d69 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -1227,7 +1227,7 @@ run (struct screen *screen) { if (menu && menu->size) { - grub_show_menu (menu, 1); + grub_show_menu (menu, 1, 0); grub_normal_free_menu (menu); } grub_env_context_close (); diff --git a/include/grub/menu.h b/include/grub/menu.h index 5ff356beb..1f23a2363 100644 --- a/include/grub/menu.h +++ b/include/grub/menu.h @@ -94,11 +94,6 @@ typedef struct grub_menu_execute_callback grub_menu_entry_t grub_menu_get_entry (grub_menu_t menu, int no); int grub_menu_get_timeout (void); void grub_menu_set_timeout (int timeout); -void grub_menu_execute_entry (grub_menu_entry_t entry); -void grub_menu_execute_with_fallback (grub_menu_t menu, - grub_menu_entry_t entry, - grub_menu_execute_callback_t callback, - void *callback_data); void grub_menu_entry_run (grub_menu_entry_t entry); int grub_menu_get_default_entry_index (grub_menu_t menu); diff --git a/include/grub/normal.h b/include/grub/normal.h index 187567797..3b99e073a 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -89,7 +89,7 @@ void grub_print_message_indented (const char *msg, int margin_left, void grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested); grub_err_t -grub_show_menu (grub_menu_t menu, int nested); +grub_show_menu (grub_menu_t menu, int nested, int autobooted); /* Defined in `handler.c'. */ void read_handler_list (void); From a508e7764271aa8abcb4c93a799eec64326806e4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:31:27 +0100 Subject: [PATCH 085/276] * util/grub-kbdcomp.in: Add missing transform and bindir variables. Reported by: nebuchadnezzar. --- ChangeLog | 5 +++++ util/grub-kbdcomp.in | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 976c2cf5b..eff9002cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-10 Vladimir Serbinenko + + * util/grub-kbdcomp.in: Add missing transform and bindir variables. + Reported by: nebuchadnezzar. + 2011-01-10 Vladimir Serbinenko Submenu default support. diff --git a/util/grub-kbdcomp.in b/util/grub-kbdcomp.in index 87b24bcdf..b7e706c24 100644 --- a/util/grub-kbdcomp.in +++ b/util/grub-kbdcomp.in @@ -1,5 +1,9 @@ #!/bin/sh +transform="@program_transform_name@" + +bindir="@bindir@" + grub_mklayout=${bindir}/`echo grub-mklayout | sed ${transform}` ckbcomp "$@" | $grub_mklayout -o "$1".gkb From d570097a04f3249274d1d588d51b1fffa8aa6513 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:41:58 +0100 Subject: [PATCH 086/276] * util/grub-kbdcomp.in: Add missing prefix and exec_prefix variables. Reported by: nebuchadnezzar. --- ChangeLog | 5 +++++ util/grub-kbdcomp.in | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index eff9002cf..5ef4b1c95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-10 Vladimir Serbinenko + + * util/grub-kbdcomp.in: Add missing prefix and exec_prefix variables. + Reported by: nebuchadnezzar. + 2011-01-10 Vladimir Serbinenko * util/grub-kbdcomp.in: Add missing transform and bindir variables. diff --git a/util/grub-kbdcomp.in b/util/grub-kbdcomp.in index b7e706c24..05e516d23 100644 --- a/util/grub-kbdcomp.in +++ b/util/grub-kbdcomp.in @@ -2,6 +2,8 @@ transform="@program_transform_name@" +prefix="@prefix@" +exec_prefix="@exec_prefix@" bindir="@bindir@" grub_mklayout=${bindir}/`echo grub-mklayout | sed ${transform}` From ae67942e7819481499fbc9710781b5eacaf445b3 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:51:10 +0100 Subject: [PATCH 087/276] Don't use post-4G memory on EFI even if 64-bit since some non-compliant implementations bug on them. * grub-core/kern/efi/mm.c (grub_efi_allocate_pages): Skip post-4G memory. (filter_memory_map): Likewise. --- ChangeLog | 9 +++++++++ grub-core/kern/efi/mm.c | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ef4b1c95..0b9b9b6aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-01-10 Vladimir Serbinenko + + Don't use post-4G memory on EFI even if 64-bit since some non-compliant + implementations bug on them. + + * grub-core/kern/efi/mm.c (grub_efi_allocate_pages): Skip post-4G + memory. + (filter_memory_map): Likewise. + 2011-01-10 Vladimir Serbinenko * util/grub-kbdcomp.in: Add missing prefix and exec_prefix variables. diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index a715da076..8b9e6ec25 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -52,13 +52,13 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address, grub_efi_status_t status; grub_efi_boot_services_t *b; -#if GRUB_TARGET_SIZEOF_VOID_P < 8 +#if 1 /* Limit the memory access to less than 4GB for 32-bit platforms. */ if (address > 0xffffffff) return 0; #endif -#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL) +#if 1 if (address == 0) { type = GRUB_EFI_ALLOCATE_MAX_ADDRESS; @@ -251,7 +251,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) { if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY -#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL) +#if 1 && desc->physical_start <= 0xffffffff #endif && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000 @@ -267,7 +267,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, desc->physical_start = 0x100000; } -#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL) +#if 1 if (BYTES_TO_PAGES (filtered_desc->physical_start) + filtered_desc->num_pages > BYTES_TO_PAGES (0x100000000LL)) From b3ff6ff0565a4f774763eb71f70979b126029dce Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:56:11 +0100 Subject: [PATCH 088/276] * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Use comma as separator and pass bootpath/devid even if only one of them is available. Reported by: Seth Goldberg. --- ChangeLog | 6 ++++++ grub-core/fs/zfs/zfsinfo.c | 23 ++++++++--------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b9b9b6aa..4433ffa5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-10 Vladimir Serbinenko + + * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Use comma as + separator and pass bootpath/devid even if only one of them is available. + Reported by: Seth Goldberg. + 2011-01-10 Vladimir Serbinenko Don't use post-4G memory on EFI even if 64-bit since some non-compliant diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c index 33065892a..5a7b5ec44 100644 --- a/grub-core/fs/zfs/zfsinfo.c +++ b/grub-core/fs/zfs/zfsinfo.c @@ -364,21 +364,14 @@ grub_cmd_zfs_bootfs (grub_command_t cmd __attribute__ ((unused)), int argc, grub_free (nv); grub_free (nvlist); - if (bootpath && devid) - { - bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu bootpath=%s diskdevid=%s", - poolname, (unsigned long long) mdnobj, - bootpath, devid); - if (!bootfs) - return grub_errno; - } - else - { - bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu", - poolname, (unsigned long long) mdnobj); - if (!bootfs) - return grub_errno; - } + bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu%s%s%s%s", + poolname, (unsigned long long) mdnobj, + bootpath ? ",bootpath=" : "", + bootpath ? : "", + devid ? ",diskdevid=" : "", + devid ? : ""); + if (!bootfs) + return grub_errno; if (argc >= 2) grub_env_set (args[1], bootfs); else From c2fa6cbb42dd3e2a17e7074a2eec421c31f4b4fa Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 10 Jan 2011 23:57:49 +0100 Subject: [PATCH 089/276] * util/grub-menulst2cfg.c: Add missing include of misc.h. --- ChangeLog | 4 ++++ util/grub-menulst2cfg.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4433ffa5e..63a0ee46c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-10 Vladimir Serbinenko + + * util/grub-menulst2cfg.c: Add missing include of misc.h. + 2011-01-10 Vladimir Serbinenko * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Use comma as diff --git a/util/grub-menulst2cfg.c b/util/grub-menulst2cfg.c index da1c289a8..513af47c1 100644 --- a/util/grub-menulst2cfg.c +++ b/util/grub-menulst2cfg.c @@ -23,6 +23,7 @@ #include #include #include +#include int main (int argc, char **argv) From 3395fe5230ef31f838692b88dc0c7ebc62599151 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 11 Jan 2011 00:02:01 +0100 Subject: [PATCH 090/276] Pass more appropriate video id to Linux. * grub-core/loader/i386/linux.c (grub_linux_setup_video): Use grub_video_get_driver_id and variable gfxpayloadforcelfb to fill have_vga. (grub_linux_boot): Rely on grub_linux_setup_video to fill have_vga and shift params->lfb_size. * include/grub/i386/linux.h: Make an enume out of have_vga values. --- BUGS | 2 ++ ChangeLog | 11 ++++++++ grub-core/loader/i386/linux.c | 51 +++++++++++++++++++++++++---------- include/grub/i386/linux.h | 10 ++++--- 4 files changed, 57 insertions(+), 17 deletions(-) create mode 100644 BUGS diff --git a/BUGS b/BUGS new file mode 100644 index 000000000..0faebcdcc --- /dev/null +++ b/BUGS @@ -0,0 +1,2 @@ +Currently search and assembling multidevice abstractions scans all the devices which can be slow. +Cache isn't used correctly for video which results in slowness. diff --git a/ChangeLog b/ChangeLog index 63a0ee46c..1a6a71bc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-01-10 Vladimir Serbinenko + + Pass more appropriate video id to Linux. + + * grub-core/loader/i386/linux.c (grub_linux_setup_video): Use + grub_video_get_driver_id and variable gfxpayloadforcelfb to + fill have_vga. + (grub_linux_boot): Rely on grub_linux_setup_video to fill have_vga and + shift params->lfb_size. + * include/grub/i386/linux.h: Make an enume out of have_vga values. + 2011-01-10 Vladimir Serbinenko * util/grub-menulst2cfg.c: Add missing include of misc.h. diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 80f583cef..80960570b 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -313,6 +313,13 @@ grub_linux_setup_video (struct linux_kernel_params *params) struct grub_video_mode_info mode_info; void *framebuffer; grub_err_t err; + grub_video_driver_id_t driver_id; + char *gfxlfbvar = grub_env_get ("gfxpayloadforcelfb"); + + driver_id = grub_video_get_driver_id (); + + if (driver_id == GRUB_VIDEO_DRIVER_NONE) + return 1; err = grub_video_get_info_and_fini (&mode_info, &framebuffer); @@ -339,12 +346,40 @@ grub_linux_setup_video (struct linux_kernel_params *params) params->reserved_mask_size = mode_info.reserved_mask_size; params->reserved_field_pos = mode_info.reserved_field_pos; + if (gfxlfbvar && (gfxlfbvar[0] == '1' || gfxlfbvar[0] == 'y')) + params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE; + else + { + switch (driver_id) + { + case GRUB_VIDEO_DRIVER_VBE: + params->lfb_size >>= 16; + params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA; + break; + + case GRUB_VIDEO_DRIVER_EFI_UGA: + case GRUB_VIDEO_DRIVER_EFI_GOP: + params->have_vga = GRUB_VIDEO_LINUX_TYPE_EFIFB; + break; + + /* FIXME: check if better id is available. */ + case GRUB_VIDEO_DRIVER_SM712: + case GRUB_VIDEO_DRIVER_VGA: + case GRUB_VIDEO_DRIVER_CIRRUS: + case GRUB_VIDEO_DRIVER_BOCHS: + /* Make gcc happy. */ + case GRUB_VIDEO_DRIVER_SDL: + case GRUB_VIDEO_DRIVER_NONE: + params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE; + break; + } + } #ifdef GRUB_MACHINE_PCBIOS /* VESA packed modes may come with zeroed mask sizes, which need to be set here according to DAC Palette width. If we don't, this results in Linux displaying a black screen. */ - if (mode_info.bpp <= 8) + if (driver_id == GRUB_VIDEO_DRIVER_VBE && mode_info.bpp <= 8) { struct grub_vbe_info_block controller_info; int status; @@ -457,15 +492,7 @@ grub_linux_boot (void) grub_errno = GRUB_ERR_NONE; } - if (! grub_linux_setup_video (params)) - { - /* Use generic framebuffer unless VESA is known to be supported. */ - if (params->have_vga != GRUB_VIDEO_LINUX_TYPE_VESA) - params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE; - else - params->lfb_size >>= 16; - } - else + if (grub_linux_setup_video (params)) { #if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) params->have_vga = GRUB_VIDEO_LINUX_TYPE_TEXT; @@ -771,10 +798,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), break; } - /* We can't detect VESA, but user is implicitly telling us that it - is built-in because `vga=' parameter was used. */ - params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA; - linux_mode = &grub_vesa_mode_table[vid_mode - GRUB_VESA_MODE_TABLE_START]; diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index 9ba83eee2..fed58a630 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -79,9 +79,13 @@ struct grub_e820_mmap grub_uint32_t type; } __attribute__((packed)); -#define GRUB_VIDEO_LINUX_TYPE_TEXT 0x01 -#define GRUB_VIDEO_LINUX_TYPE_VESA 0x23 /* VESA VGA in graphic mode. */ -#define GRUB_VIDEO_LINUX_TYPE_SIMPLE 0x70 /* Linear framebuffer without any additional functions. */ +enum + { + GRUB_VIDEO_LINUX_TYPE_TEXT = 0x01, + GRUB_VIDEO_LINUX_TYPE_VESA = 0x23, /* VESA VGA in graphic mode. */ + GRUB_VIDEO_LINUX_TYPE_EFIFB = 0x70, /* EFI Framebuffer. */ + GRUB_VIDEO_LINUX_TYPE_SIMPLE = 0x70 /* Linear framebuffer without any additional functions. */ + }; /* For the Linux/i386 boot protocol version 2.03. */ struct linux_kernel_header From f093110b52d6d2b3b97fd1c07388f441863e0f5f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 11 Jan 2011 00:06:01 +0100 Subject: [PATCH 091/276] * BUGS: New file. --- BUGS | 9 +++++++-- ChangeLog | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/BUGS b/BUGS index 0faebcdcc..46faa6452 100644 --- a/BUGS +++ b/BUGS @@ -1,2 +1,7 @@ -Currently search and assembling multidevice abstractions scans all the devices which can be slow. -Cache isn't used correctly for video which results in slowness. +GRUB team is aware of following problems: + - Currently search and assembling multidevice abstractions scans + all the devices which can be slow. + - Cache isn't used correctly for video which results in slowness. + +While these are bugs their solution has a potential of breaking more and more +seriously. So it was decided for 1.99 that they aren't fixed. diff --git a/ChangeLog b/ChangeLog index 1a6a71bc5..894f886b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-11 Vladimir Serbinenko + + * BUGS: New file. + 2011-01-10 Vladimir Serbinenko Pass more appropriate video id to Linux. From 45146057263bc0d47cefe2f46ee6157f92fd3af4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 11 Jan 2011 00:44:56 +0100 Subject: [PATCH 092/276] =?UTF-8?q?=09*=20grub-core/loader/i386/multiboot?= =?UTF-8?q?=5Fmbi.c=20(grub=5Fmultiboot=5Fmake=5Fmbi):=20=09Take=20into=20?= =?UTF-8?q?account=20space=20used=20by=20ELF=20sections=20and=20multiboot?= =?UTF-8?q?=20palette.=20=09Reported=20by:=20Gr=C3=A9goire=20Sutre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 6 ++++++ grub-core/loader/i386/multiboot_mbi.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index 894f886b4..73571a549 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-11 Vladimir Serbinenko + + * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): + Take into account space used by ELF sections and multiboot palette. + Reported by: Grégoire Sutre. + 2011-01-11 Vladimir Serbinenko * BUGS: New file. diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index eade78e93..b98bda223 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -539,6 +539,9 @@ grub_multiboot_make_mbi (grub_uint32_t *target) mbi->u.elf_sec.shndx = elf_sec_shstrndx; mbi->flags |= MULTIBOOT_INFO_ELF_SHDR; + + ptrorig += elf_sec_entsize * elf_sec_num; + ptrdest += elf_sec_entsize * elf_sec_num; } err = retrieve_video_parameters (mbi, ptrorig, ptrdest); @@ -547,6 +550,16 @@ grub_multiboot_make_mbi (grub_uint32_t *target) grub_print_error (); grub_errno = GRUB_ERR_NONE; } + + if ((mbi->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO) + && mbi->framebuffer_type == MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED) + { + ptrorig += mbi->framebuffer_palette_num_colors + * sizeof (struct multiboot_color); + ptrdest += mbi->framebuffer_palette_num_colors + * sizeof (struct multiboot_color); + } + #if GRUB_MACHINE_HAS_VBE ptrorig += sizeof (struct grub_vbe_info_block); ptrdest += sizeof (struct grub_vbe_info_block); From 4531a206a1c112d405ef9ea00f2e06037ef0c01a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 11 Jan 2011 11:51:05 +0100 Subject: [PATCH 093/276] * grub-core/fs/i386/pc/pxe.c (set_mac_env): Export variable. (set_env_limn_ro): Likewise. (GRUB_MOD_INIT): Likewise. * grub-core/hook/datehook.c (GRUB_MOD_INIT): Likewise. Change to ARRAY_SIZE while on it. (GRUB_MOD_FINI): Change to ARRAY_SIZE. * grub-core/normal/context.c (grub_env_export): Move from here ... * grub-core/kern/env.c (grub_env_export): ... here. * grub-core/normal/context.c (grub_cmd_export): Skip exporting root and prefix. * grub-core/kern/main.c (grub_main): Export root and prefix. * include/grub/env.h (grub_env_export): Export. Reported by: Seth Goldberg. --- ChangeLog | 16 ++++++++++++++++ grub-core/fs/i386/pc/pxe.c | 9 +++++++++ grub-core/hook/datehook.c | 15 +++++++++------ grub-core/kern/env.c | 20 ++++++++++++++++++++ grub-core/kern/main.c | 2 ++ grub-core/normal/context.c | 23 ----------------------- include/grub/env.h | 2 +- 7 files changed, 57 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 73571a549..a4f7122fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2011-01-11 Vladimir Serbinenko + + * grub-core/fs/i386/pc/pxe.c (set_mac_env): Export variable. + (set_env_limn_ro): Likewise. + (GRUB_MOD_INIT): Likewise. + * grub-core/hook/datehook.c (GRUB_MOD_INIT): Likewise. Change to + ARRAY_SIZE while on it. + (GRUB_MOD_FINI): Change to ARRAY_SIZE. + * grub-core/normal/context.c (grub_env_export): Move from here ... + * grub-core/kern/env.c (grub_env_export): ... here. + * grub-core/normal/context.c (grub_cmd_export): Skip exporting root and + prefix. + * grub-core/kern/main.c (grub_main): Export root and prefix. + * include/grub/env.h (grub_env_export): Export. + Reported by: Seth Goldberg. + 2011-01-11 Vladimir Serbinenko * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): diff --git a/grub-core/fs/i386/pc/pxe.c b/grub-core/fs/i386/pc/pxe.c index cbb3c7d87..e2b53d637 100644 --- a/grub-core/fs/i386/pc/pxe.c +++ b/grub-core/fs/i386/pc/pxe.c @@ -420,6 +420,7 @@ set_mac_env (grub_uint8_t *mac_addr, grub_size_t mac_len) grub_env_set ("net_pxe_mac", buf); /* XXX: Is it possible to change MAC in PXE? */ grub_register_variable_hook ("net_pxe_mac", 0, grub_env_write_readonly); + grub_env_export ("net_pxe_mac"); } static void @@ -431,6 +432,7 @@ set_env_limn_ro (const char *varname, char *value, grub_size_t len) grub_env_set (varname, value); value[len] = c; grub_register_variable_hook (varname, 0, grub_env_write_readonly); + grub_env_export (varname); } static void @@ -624,12 +626,19 @@ GRUB_MOD_INIT(pxe) grub_env_write_pxe_default_server); grub_register_variable_hook ("pxe_default_gateway", 0, grub_env_write_pxe_default_gateway); + /* XXX: Is it possible to change IP in PXE? */ grub_register_variable_hook ("net_pxe_ip", 0, grub_env_write_readonly); grub_register_variable_hook ("pxe_blksize", 0, grub_env_write_pxe_blocksize); + + grub_env_export ("pxe_default_server"); + grub_env_export ("pxe_default_gateway"); + grub_env_export ("net_pxe_ip"); + grub_env_export ("pxe_blksize"); + grub_disk_dev_register (&grub_pxe_dev); grub_fs_register (&grub_pxefs_fs); } diff --git a/grub-core/hook/datehook.c b/grub-core/hook/datehook.c index 9b5b54bf3..d855311d3 100644 --- a/grub-core/hook/datehook.c +++ b/grub-core/hook/datehook.c @@ -86,18 +86,21 @@ grub_read_hook_datetime (struct grub_env_var *var, GRUB_MOD_INIT(datehook) { - int i; + unsigned i; - for (i = 0; i < 7; i++) - grub_register_variable_hook (grub_datetime_names[i], - grub_read_hook_datetime, 0); + for (i = 0; i < ARRAY_SIZE (grub_datetime_names); i++) + { + grub_register_variable_hook (grub_datetime_names[i], + grub_read_hook_datetime, 0); + grub_env_export (grub_datetime_names[i]); + } } GRUB_MOD_FINI(datehook) { - int i; + unsigned i; - for (i = 0; i < 7; i++) + for (i = 0; i < ARRAY_SIZE (grub_datetime_names); i++) { grub_register_variable_hook (grub_datetime_names[i], 0, 0); grub_env_unset (grub_datetime_names[i]); diff --git a/grub-core/kern/env.c b/grub-core/kern/env.c index 84b3a001d..8f843a872 100644 --- a/grub-core/kern/env.c +++ b/grub-core/kern/env.c @@ -240,3 +240,23 @@ grub_register_variable_hook (const char *name, return GRUB_ERR_NONE; } + +grub_err_t +grub_env_export (const char *name) +{ + struct grub_env_var *var; + + var = grub_env_find (name); + if (! var) + { + grub_err_t err; + + err = grub_env_set (name, ""); + if (err) + return err; + var = grub_env_find (name); + } + var->global = 1; + + return GRUB_ERR_NONE; +} diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c index 8b6c8a180..da7123234 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -189,6 +189,8 @@ grub_main (void) for convenience. */ grub_machine_set_prefix (); grub_set_root_dev (); + grub_env_export ("root"); + grub_env_export ("prefix"); grub_register_core_commands (); diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c index 75beeefda..b73161d0b 100644 --- a/grub-core/normal/context.c +++ b/grub-core/normal/context.c @@ -175,26 +175,6 @@ grub_env_extractor_close (int source) return err; } -grub_err_t -grub_env_export (const char *name) -{ - struct grub_env_var *var; - - var = grub_env_find (name); - if (! var) - { - grub_err_t err; - - err = grub_env_set (name, ""); - if (err) - return err; - var = grub_env_find (name); - } - var->global = 1; - - return GRUB_ERR_NONE; -} - static grub_command_t export_cmd; static grub_err_t @@ -216,9 +196,6 @@ grub_cmd_export (struct grub_command *cmd __attribute__ ((unused)), void grub_context_init (void) { - grub_env_export ("root"); - grub_env_export ("prefix"); - export_cmd = grub_register_command ("export", grub_cmd_export, N_("ENVVAR [ENVVAR] ..."), N_("Export variables.")); diff --git a/include/grub/env.h b/include/grub/env.h index 6d1f0de6e..c0107f16a 100644 --- a/include/grub/env.h +++ b/include/grub/env.h @@ -53,7 +53,7 @@ grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name, grub_err_t grub_env_context_open (void); grub_err_t grub_env_context_close (void); -grub_err_t grub_env_export (const char *name); +grub_err_t EXPORT_FUNC(grub_env_export) (const char *name); void grub_env_unset_menu (void); grub_menu_t grub_env_get_menu (void); From 86205c94c3f85579f56b005896c4ad3cf0c69d00 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 11 Jan 2011 09:08:57 -0600 Subject: [PATCH 094/276] * util/grub-mklayout.c (console_grub_equivalences_shift): Terminate with NULL. (console_grub_equivalences_unshift): Likewise. Reported by: Daniel Dehennin. --- ChangeLog | 7 +++++++ util/grub-mklayout.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index a4f7122fb..56a8db213 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-11 Colin Watson + + * util/grub-mklayout.c (console_grub_equivalences_shift): Terminate + with NULL. + (console_grub_equivalences_unshift): Likewise. + Reported by: Daniel Dehennin. + 2011-01-11 Vladimir Serbinenko * grub-core/fs/i386/pc/pxe.c (set_mac_env): Export variable. diff --git a/util/grub-mklayout.c b/util/grub-mklayout.c index 36f6e04fc..04501cb40 100644 --- a/util/grub-mklayout.c +++ b/util/grub-mklayout.c @@ -60,6 +60,8 @@ static struct console_grub_equivalence console_grub_equivalences_shift[] = { {"KP_8", '8'}, {"KP_9", '9'}, {"KP_Period", '.'}, + + {NULL, '\0'} }; static struct console_grub_equivalence console_grub_equivalences_unshift[] = { @@ -74,6 +76,8 @@ static struct console_grub_equivalence console_grub_equivalences_unshift[] = { {"KP_8", GRUB_TERM_KEY_UP}, {"KP_9", GRUB_TERM_KEY_PPAGE}, {"KP_Period", GRUB_TERM_KEY_DC}, + + {NULL, '\0'} }; static struct console_grub_equivalence console_grub_equivalences_common[] = { From 9da068a5dc3b507276552980fc9c6459aef0a02d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 11 Jan 2011 23:01:07 +0100 Subject: [PATCH 095/276] * grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32): Apply loadmask before doing any calculations. Use correct type for offset. (grub_linux_load64): Likewise. --- ChangeLog | 6 ++++++ grub-core/loader/powerpc/ieee1275/linux.c | 16 +++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 56a8db213..05e2ec8c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-11 Vladimir Serbinenko + + * grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32): Apply + loadmask before doing any calculations. Use correct type for offset. + (grub_linux_load64): Likewise. + 2011-01-11 Colin Watson * util/grub-mklayout.c (console_grub_equivalences_shift): Terminate diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c index a99310cfd..0cf0eb825 100644 --- a/grub-core/loader/powerpc/ieee1275/linux.c +++ b/grub-core/loader/powerpc/ieee1275/linux.c @@ -152,7 +152,8 @@ grub_linux_load32 (grub_elf_t elf) Elf32_Addr base_addr; grub_addr_t seg_addr; grub_uint32_t align; - int offset; + grub_uint32_t offset; + Elf32_Addr entry; linux_size = grub_elf32_size (elf, &base_addr, &align); if (linux_size == 0) @@ -160,9 +161,12 @@ grub_linux_load32 (grub_elf_t elf) /* Pad it; the kernel scribbles over memory beyond its load address. */ linux_size += 0x100000; - offset = elf->ehdr.ehdr32.e_entry - base_addr; + /* Linux's entry point incorrectly contains a virtual address. */ + entry = elf->ehdr.ehdr32.e_entry & ~ELF32_LOADMASK; + /* Linux's incorrectly contains a virtual address. */ base_addr &= ~ELF32_LOADMASK; + offset = entry - base_addr; /* On some systems, firmware occupies the memory we're trying to use. * Happily, Linux can be loaded anywhere (it relocates itself). Iterate @@ -196,7 +200,8 @@ grub_linux_load64 (grub_elf_t elf) Elf64_Addr base_addr; grub_addr_t seg_addr; grub_uint64_t align; - int offset; + grub_uint64_t offset; + Elf64_Addr entry; linux_size = grub_elf64_size (elf, &base_addr, &align); if (linux_size == 0) @@ -204,9 +209,10 @@ grub_linux_load64 (grub_elf_t elf) /* Pad it; the kernel scribbles over memory beyond its load address. */ linux_size += 0x100000; - offset = elf->ehdr.ehdr64.e_entry - base_addr; - /* Linux's incorrectly contains a virtual address. */ base_addr &= ~ELF64_LOADMASK; + entry = elf->ehdr.ehdr64.e_entry & ~ELF64_LOADMASK; + offset = entry - base_addr; + /* Linux's incorrectly contains a virtual address. */ /* On some systems, firmware occupies the memory we're trying to use. * Happily, Linux can be loaded anywhere (it relocates itself). Iterate From 51fa856c58720eeb6b018a2181716a5458e5fbae Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 11 Jan 2011 17:49:27 -0600 Subject: [PATCH 096/276] * configure.ac: Fall back to `true' if `makeinfo' does not exist. --- ChangeLog | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 05e2ec8c7..e14a33968 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-11 Colin Watson + + * configure.ac: Fall back to `true' if `makeinfo' does not exist. + 2011-01-11 Vladimir Serbinenko * grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32): Apply diff --git a/configure.ac b/configure.ac index a9ca130b4..055c65e67 100644 --- a/configure.ac +++ b/configure.ac @@ -246,7 +246,7 @@ else fi # These are not a "must". -AC_PATH_PROG(MAKEINFO, makeinfo) +AC_PATH_PROGS(MAKEINFO, makeinfo true) # # Checks for host programs. From b44a558c9a133f398364bc953ba540e1909c1f31 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 12 Jan 2011 11:26:28 +0100 Subject: [PATCH 097/276] Use alias->path rather than buggy "canon". * grub-core/disk/ieee1275/ofdisk.c (ofdisk_hash_add_real): New function. (ofdisk_hash_add): New argument curcan. All users updated. --- ChangeLog | 7 +++++++ grub-core/disk/ieee1275/ofdisk.c | 34 ++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index e14a33968..958850421 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-12 Vladimir Serbinenko + + Use alias->path rather than buggy "canon". + + * grub-core/disk/ieee1275/ofdisk.c (ofdisk_hash_add_real): New function. + (ofdisk_hash_add): New argument curcan. All users updated. + 2011-01-11 Colin Watson * configure.ac: Fall back to `true' if `makeinfo' does not exist. diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 85c34609e..0a935d5c2 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -62,11 +62,10 @@ ofdisk_hash_find (const char *devpath) } static struct ofdisk_hash_ent * -ofdisk_hash_add (char *devpath) +ofdisk_hash_add_real (char *devpath) { + struct ofdisk_hash_ent *p; struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)]; - struct ofdisk_hash_ent *p, *pcan; - char *curcan; p = grub_malloc(sizeof (*p)); if (!p) @@ -76,17 +75,27 @@ ofdisk_hash_add (char *devpath) p->next = *head; p->shortest = 0; *head = p; + return p; +} + +static struct ofdisk_hash_ent * +ofdisk_hash_add (char *devpath, char *curcan) +{ + struct ofdisk_hash_ent *p, *pcan; + + p = ofdisk_hash_add_real (devpath); + + grub_dprintf ("disk", "devpath = %s, canonical = %s\n", devpath, curcan); - curcan = grub_ieee1275_canonicalise_devname (devpath); if (!curcan) { - grub_errno = GRUB_ERR_NONE; + p->shortest = devpath; return p; } pcan = ofdisk_hash_find (curcan); if (!pcan) - pcan = ofdisk_hash_add (curcan); + pcan = ofdisk_hash_add_real (curcan); else grub_free (curcan); @@ -118,17 +127,22 @@ scan (void) return 0; grub_dprintf ("disk", "disk name = %s\n", alias->name); + grub_dprintf ("disk", "disk name = %s, path = %s\n", alias->name, + alias->path); - op = ofdisk_hash_find (alias->path); + op = ofdisk_hash_find (alias->name); if (!op) { char *name = grub_strdup (alias->name); - if (!name) + char *can = grub_strdup (alias->path); + if (!name || !can) { grub_errno = GRUB_ERR_NONE; + grub_free (name); + grub_free (can); return 0; } - op = ofdisk_hash_add (name); + op = ofdisk_hash_add (name, can); } return 0; } @@ -247,7 +261,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) struct ofdisk_hash_ent *op; op = ofdisk_hash_find (devpath); if (!op) - op = ofdisk_hash_add (devpath); + op = ofdisk_hash_add (devpath, NULL); else grub_free (devpath); if (!op) From b8494fbe5c6b816dc7386eb7dc60a3922b86fdb7 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 12 Jan 2011 11:52:51 +0100 Subject: [PATCH 098/276] * grub-core/normal/context.c (grub_env_context_close): Silence spurious warning. * grub-core/normal/menu.c (grub_menu_execute_entry): Likewise. * grub-core/partmap/msdos.c (pc_partition_map_embed): Use unsigned counter. --- ChangeLog | 8 ++++++++ grub-core/normal/context.c | 3 ++- grub-core/normal/menu.c | 2 +- grub-core/partmap/msdos.c | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 958850421..6efb466bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-01-12 Vladimir Serbinenko + + * grub-core/normal/context.c (grub_env_context_close): Silence spurious + warning. + * grub-core/normal/menu.c (grub_menu_execute_entry): Likewise. + * grub-core/partmap/msdos.c (pc_partition_map_embed): Use unsigned + counter. + 2011-01-12 Vladimir Serbinenko Use alias->path rather than buggy "canon". diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c index b73161d0b..108679913 100644 --- a/grub-core/normal/context.c +++ b/grub-core/normal/context.c @@ -148,7 +148,7 @@ grub_env_context_close (void) grub_err_t grub_env_extractor_close (int source) { - grub_menu_t menu, menu2; + grub_menu_t menu = NULL; grub_menu_entry_t *last; grub_err_t err; @@ -161,6 +161,7 @@ grub_env_extractor_close (int source) if (source) { + grub_menu_t menu2; menu2 = grub_env_get_menu (); last = &menu2->entry_list; diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index 6a123a6de..e62482122 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -159,7 +159,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) { grub_err_t err = GRUB_ERR_NONE; int errs_before; - grub_menu_t menu; + grub_menu_t menu = NULL; char *optr, *buf, *oldchosen = NULL, *olddefault = NULL; const char *ptr, *chosen, *def; grub_size_t sz = 0; diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c index f99e27a6e..d411c4405 100644 --- a/grub-core/partmap/msdos.c +++ b/grub-core/partmap/msdos.c @@ -234,7 +234,7 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, if (end >= *nsectors + 1) { - int i; + unsigned i; *nsectors = end - 1; *sectors = grub_malloc (*nsectors * sizeof (**sectors)); if (!*sectors) From 8fc0a24576669f28e98f9ccc1b40b8e742f95aad Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 12 Jan 2011 11:55:52 +0100 Subject: [PATCH 099/276] * grub-core/Makefile.core.def (ieee1275_fb): Disable on sparc. It doesn't work well there. --- ChangeLog | 5 +++++ grub-core/Makefile.core.def | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6efb466bb..915fd2619 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-12 Vladimir Serbinenko + + * grub-core/Makefile.core.def (ieee1275_fb): Disable on sparc. + It doesn't work well there. + 2011-01-12 Vladimir Serbinenko * grub-core/normal/context.c (grub_env_context_close): Silence spurious diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 094bbc835..2cca4fa95 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1463,7 +1463,6 @@ module = { name = ieee1275_fb; ieee1275 = video/ieee1275.c; enable = powerpc; - enable = sparc64; }; module = { From f8f479dbbbd908551f2c691b3b7d35997f3a1a7b Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 12 Jan 2011 12:49:16 +0100 Subject: [PATCH 100/276] * util/grub-mkfont.c (write_font_pf2): Use appropriate type for data variable. Fixes problem on big endian platforms. --- ChangeLog | 5 +++++ util/grub-mkfont.c | 17 ++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 915fd2619..254fc2c6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-12 Vladimir Serbinenko + + * util/grub-mkfont.c (write_font_pf2): Use appropriate type for data + variable. Fixes problem on big endian platforms. + 2011-01-12 Vladimir Serbinenko * grub-core/Makefile.core.def (ieee1275_fb): Disable on sparc. diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index 983ac7065..3108d4694 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -859,7 +859,7 @@ void write_font_pf2 (struct grub_font_info *font_info, char *output_file) { FILE *file; - grub_uint32_t leng, data; + grub_uint32_t leng; char style_name[20], *font_name; int offset; struct grub_glyph_info *cur; @@ -959,12 +959,14 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file) for (cur = font_info->glyphs_sorted; cur < font_info->glyphs_sorted + font_info->num_glyphs; cur++) { - data = grub_cpu_to_be32 (cur->char_code); - grub_util_write_image ((char *) &data, 4, file); - data = 0; - grub_util_write_image ((char *) &data, 1, file); - data = grub_cpu_to_be32 (offset); - grub_util_write_image ((char *) &data, 4, file); + grub_uint32_t data32; + grub_uint8_t data8; + data32 = grub_cpu_to_be32 (cur->char_code); + grub_util_write_image ((char *) &data32, 4, file); + data8 = 0; + grub_util_write_image ((char *) &data8, 1, file); + data32 = grub_cpu_to_be32 (offset); + grub_util_write_image ((char *) &data32, 4, file); offset += 10 + cur->bitmap_size; } @@ -976,6 +978,7 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file) for (cur = font_info->glyphs_sorted; cur < font_info->glyphs_sorted + font_info->num_glyphs; cur++) { + grub_uint16_t data; data = grub_cpu_to_be16 (cur->width); grub_util_write_image ((char *) &data, 2, file); data = grub_cpu_to_be16 (cur->height); From 173b71e9fea74cb2edfab96418f92bc589a17dc4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 12 Jan 2011 19:51:19 +0100 Subject: [PATCH 101/276] * util/grub.d/00_header.in (load_video): Handle the case when no video drivers available. Thanks to: Axel Beckert. --- ChangeLog | 6 ++++++ util/grub.d/00_header.in | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 254fc2c6f..74c6affff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-12 Vladimir Serbinenko + + * util/grub.d/00_header.in (load_video): Handle the case when no video + drivers available. + Thanks to: Axel Beckert. + 2011-01-12 Vladimir Serbinenko * util/grub-mkfont.c (write_font_pf2): Use appropriate type for data diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index a596e9c4a..420b3f32c 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -84,11 +84,16 @@ if [ -n "${GRUB_VIDEO_BACKEND}" ]; then EOF else # Insert all available backends; GRUB will use the most appropriate. + have_video=0; for backend in $(cat "${GRUB_PREFIX}/video.lst"); do + have_video=1; cat < Date: Wed, 12 Jan 2011 19:58:32 +0100 Subject: [PATCH 102/276] * util/ieee1275/ofpath.c (grub_util_devname_to_ofpath): Use the realpath'ed device string. Handle floppy (somewhat). Issue error in unknown case rather than garbage. Reported by: Axel Beckert. --- ChangeLog | 8 ++++++++ util/ieee1275/ofpath.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 74c6affff..7a3f3f63a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-01-12 Vladimir Serbinenko + + * util/ieee1275/ofpath.c (grub_util_devname_to_ofpath): Use the + realpath'ed device string. + Handle floppy (somewhat). + Issue error in unknown case rather than garbage. + Reported by: Axel Beckert. + 2011-01-12 Vladimir Serbinenko * util/grub.d/00_header.in (load_video): Handle the case when no video diff --git a/util/ieee1275/ofpath.c b/util/ieee1275/ofpath.c index fa0d48cf9..1a433345d 100644 --- a/util/ieee1275/ofpath.c +++ b/util/ieee1275/ofpath.c @@ -377,8 +377,8 @@ grub_util_devname_to_ofpath (const char *devname) if (! name_buf) grub_util_error ("cannot get the real path of `%s'", devname); - device = get_basename (devname); - devnode = strip_trailing_digits (devname); + device = get_basename (name_buf); + devnode = strip_trailing_digits (name_buf); devicenode = strip_trailing_digits (device); ofpath = xmalloc (OF_PATH_MAX); @@ -391,6 +391,13 @@ grub_util_devname_to_ofpath (const char *devname) else if (device[0] == 'v' && device[1] == 'd' && device[2] == 'i' && device[3] == 's' && device[4] == 'k') of_path_of_vdisk(ofpath, name_buf, device, devnode, devicenode); + else if (device[0] == 'f' && device[1] == 'd' + && device[2] == '0' && device[3] == '\0') + /* All the models I've seen have a devalias "floppy". + New models have no floppy at all. */ + strcpy (ofpath, "floppy"); + else + grub_util_error ("unknown device type %s\n", device); free (devnode); free (devicenode); From bd1a4147141708625214564959684257a6614935 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 12 Jan 2011 17:27:52 -0600 Subject: [PATCH 103/276] Resolve the device returned by grub_find_root_device_from_mountinfo or find_root_device_from_libzfs using grub_find_device. Reported by: Roderich Schupp. --- grub-core/kern/emu/getroot.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index df3a4d765..92ff971e5 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -467,7 +467,7 @@ grub_find_device (const char *path, dev_t dev) char * grub_guess_root_device (const char *dir) { - char *os_dev; + char *os_dev = NULL; #ifdef __GNU__ file_t file; mach_port_t *ports; @@ -526,30 +526,42 @@ grub_guess_root_device (const char *dir) mach_port_deallocate (mach_task_self (), file); #else /* !__GNU__ */ struct stat st; + dev_t dev; #ifdef __linux__ - os_dev = grub_find_root_device_from_mountinfo (dir, NULL); - if (os_dev) - return os_dev; + if (!os_dev) + os_dev = grub_find_root_device_from_mountinfo (dir, NULL); #endif /* __linux__ */ #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) - os_dev = find_root_device_from_libzfs (dir); - if (os_dev) - return os_dev; + if (!os_dev) + os_dev = find_root_device_from_libzfs (dir); #endif - if (stat (dir, &st) < 0) - grub_util_error ("cannot stat `%s'", dir); + if (os_dev) + { + if (stat (os_dev, &st) >= 0) + dev = st.st_rdev; + else + grub_util_error ("cannot stat `%s'", os_dev); + free (os_dev); + } + else + { + if (stat (dir, &st) >= 0) + dev = st.st_dev; + else + grub_util_error ("cannot stat `%s'", dir); + } #ifdef __CYGWIN__ /* Cygwin specific function. */ - os_dev = grub_find_device (dir, st.st_dev); + os_dev = grub_find_device (dir, dev); #else /* This might be truly slow, but is there any better way? */ - os_dev = grub_find_device ("/dev", st.st_dev); + os_dev = grub_find_device ("/dev", dev); #endif #endif /* !__GNU__ */ From f1632d4dd050baee3d2a41730c45ab21f741c62f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 13 Jan 2011 22:23:49 +0100 Subject: [PATCH 104/276] Fix compilation on cygwin. * conf/Makefile.common (STRIPFLAGS_KERNEL): Add -F elf32-i386 and -R .drectve on cygwin. * conf/i386-pc-cygwin-img-ld.sc: Merge rdata and pdata into data. * configure.ac: Use $(top_builddir) in TARGET_OBJ2ELF. (COND_CYGWIN): New condition. * grub-core/Makefile.am (%.mod): Set TARGET_OBJ2ELF. * grub-core/genmod.sh.in: Use ${TARGET_OBJ2ELF} and not @TARGET_OBJ2ELF@. * util/grub-pe2elf.c (write_symbol_table): Use pe_symtab->type and not type to determine whether aux is to be used. --- ChangeLog | 15 +++++++++++++++ conf/Makefile.common | 4 ++++ conf/i386-pc-cygwin-img-ld.sc | 6 ------ configure.ac | 3 ++- grub-core/Makefile.am | 2 +- grub-core/genmod.sh.in | 4 ++-- util/grub-pe2elf.c | 2 +- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a3f3f63a..696da1215 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2011-01-13 Vladimir Serbinenko + + Fix compilation on cygwin. + + * conf/Makefile.common (STRIPFLAGS_KERNEL): Add -F elf32-i386 and + -R .drectve on cygwin. + * conf/i386-pc-cygwin-img-ld.sc: Merge rdata and pdata into data. + * configure.ac: Use $(top_builddir) in TARGET_OBJ2ELF. + (COND_CYGWIN): New condition. + * grub-core/Makefile.am (%.mod): Set TARGET_OBJ2ELF. + * grub-core/genmod.sh.in: Use ${TARGET_OBJ2ELF} and + not @TARGET_OBJ2ELF@. + * util/grub-pe2elf.c (write_symbol_table): Use pe_symtab->type and not + type to determine whether aux is to be used. + 2011-01-12 Vladimir Serbinenko * util/ieee1275/ofpath.c (grub_util_devname_to_ofpath): Use the diff --git a/conf/Makefile.common b/conf/Makefile.common index 2df8465c0..32ca76d08 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -67,7 +67,11 @@ CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib -Wl,-N -static-libgcc CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) +if COND_CYGWIN +STRIPFLAGS_KERNEL = -F elf32-i386 -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve +else STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment +endif CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib -Wl,-N,-r,-d diff --git a/conf/i386-pc-cygwin-img-ld.sc b/conf/i386-pc-cygwin-img-ld.sc index a41cac75e..3b579d344 100644 --- a/conf/i386-pc-cygwin-img-ld.sc +++ b/conf/i386-pc-cygwin-img-ld.sc @@ -13,15 +13,9 @@ SECTIONS __data_start__ = . ; *(.data) __data_end__ = . ; - } - .rdata : - { __rdata_start__ = . ; *(.rdata) __rdata_end__ = . ; - } - .pdata : - { *(.pdata) edata = . ; } diff --git a/configure.ac b/configure.ac index 055c65e67..0b9207ea2 100644 --- a/configure.ac +++ b/configure.ac @@ -454,7 +454,7 @@ fi # For platforms where ELF is not the default link format. AC_MSG_CHECKING([for command to convert module to ELF format]) case "${host_os}" in - cygwin) TARGET_OBJ2ELF='$(grub_utildir)/grub-pe2elf'; + cygwin) TARGET_OBJ2ELF='$(top_builddir)/grub-pe2elf'; # FIXME: put proper test here NEED_REGISTER_FRAME_INFO=1 ;; @@ -964,6 +964,7 @@ AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1]) AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes]) AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1]) +AM_CONDITIONAL([COND_CYGWIN], [test x$host_os = xcygwin]) # Output files. grub_CHECK_LINK_DIR diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index fcf3fc42d..94f7f3ffe 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -303,7 +303,7 @@ platform_DATA += moddep.lst CLEANFILES += config.log syminfo.lst moddep.lst $(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) - sh $^ $@ + TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@ platform_DATA += $(MOD_FILES) CLEANFILES += $(MOD_FILES) diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index b97f3e1c7..023cd1062 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -52,8 +52,8 @@ fi rm -f $t1 $t2 if test x@TARGET_APPLE_CC@ != x1; then - if ! test -z "@TARGET_OBJ2ELF@"; then - ./@TARGET_OBJ2ELF@ $tmpfile || exit 1 + if ! test -z "${TARGET_OBJ2ELF}"; then + ./${TARGET_OBJ2ELF} $tmpfile || exit 1 fi if test x@platform@ != xemu; then @STRIP@ --strip-unneeded \ diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c index f370bbfa8..cf690841f 100644 --- a/util/grub-pe2elf.c +++ b/util/grub-pe2elf.c @@ -337,7 +337,7 @@ write_symbol_table (FILE* fp, char *image, else bind = STB_LOCAL; - if ((type != STT_FUNC) && (pe_symtab->num_aux)) + if ((pe_symtab->type != GRUB_PE32_DT_FUNCTION) && (pe_symtab->num_aux)) { if (! pe_symtab->value) type = STT_SECTION; From 4fbf185232d53acc65599720b6d304acb012e968 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 13 Jan 2011 22:25:56 +0100 Subject: [PATCH 105/276] * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Quote bootpath and diskdevid. --- ChangeLog | 5 +++++ grub-core/fs/zfs/zfsinfo.c | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 696da1215..b57c6f229 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-13 Vladimir Serbinenko + + * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Quote bootpath and + diskdevid. + 2011-01-13 Vladimir Serbinenko Fix compilation on cygwin. diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c index 5a7b5ec44..224a97792 100644 --- a/grub-core/fs/zfs/zfsinfo.c +++ b/grub-core/fs/zfs/zfsinfo.c @@ -364,12 +364,14 @@ grub_cmd_zfs_bootfs (grub_command_t cmd __attribute__ ((unused)), int argc, grub_free (nv); grub_free (nvlist); - bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu%s%s%s%s", + bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu%s%s%s%s%s%s", poolname, (unsigned long long) mdnobj, - bootpath ? ",bootpath=" : "", - bootpath ? : "", - devid ? ",diskdevid=" : "", - devid ? : ""); + bootpath ? ",bootpath=\"" : "", + bootpath ? : "", + bootpath ? "\"" : "", + devid ? ",diskdevid=\"" : "", + devid ? : "", + devid ? "\"" : ""); if (!bootfs) return grub_errno; if (argc >= 2) From 1d955d0098b02d77ccec93cd425568a7fa95c913 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 14 Jan 2011 19:21:06 +0100 Subject: [PATCH 106/276] * grub-core/Makefile.core.def (fwstart): Add lost LDFLAGS. --- ChangeLog | 4 ++++ grub-core/Makefile.core.def | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index b57c6f229..4822910dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-13 Vladimir Serbinenko + + * grub-core/Makefile.core.def (fwstart): Add lost LDFLAGS. + 2011-01-13 Vladimir Serbinenko * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Quote bootpath and diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2cca4fa95..ce7d0b0c2 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -324,6 +324,7 @@ image = { name = fwstart; mips_yeeloong = boot/mips/yeeloong/fwstart.S; objcopyflags = '-O binary'; + ldflags = '-static-libgcc -lgcc -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; enable = mips_yeeloong; }; From 46c9db88cda310ec22344fcf4cfb055c1a317a28 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 14 Jan 2011 19:23:34 +0100 Subject: [PATCH 107/276] * grub-core/kern/mips/yeeloong/init.c (grub_machine_init): Init boot module. --- ChangeLog | 7 ++++++- grub-core/kern/mips/yeeloong/init.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4822910dd..69534abe2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2011-01-13 Vladimir Serbinenko +2011-01-14 Vladimir Serbinenko + + * grub-core/kern/mips/yeeloong/init.c (grub_machine_init): Init boot + module. + +2011-01-14 Vladimir Serbinenko * grub-core/Makefile.core.def (fwstart): Add lost LDFLAGS. diff --git a/grub-core/kern/mips/yeeloong/init.c b/grub-core/kern/mips/yeeloong/init.c index cadb10773..7a48d69f5 100644 --- a/grub-core/kern/mips/yeeloong/init.c +++ b/grub-core/kern/mips/yeeloong/init.c @@ -41,6 +41,7 @@ extern void grub_at_keyboard_init (void); extern void grub_serial_init (void); extern void grub_terminfo_init (void); extern void grub_keylayouts_init (void); +extern void grub_boot_init (void); /* FIXME: use interrupt to count high. */ grub_uint64_t @@ -210,6 +211,8 @@ grub_machine_init (void) grub_terminfo_init (); grub_serial_init (); + + grub_boot_init (); } void From 043603376e933098adea34156b0898814221c734 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 15 Jan 2011 21:58:21 +0100 Subject: [PATCH 108/276] * util/grub-mkimage.c (generate_image): Check fwstart.img checksum for safety. --- ChangeLog | 5 +++++ util/grub-mkimage.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ChangeLog b/ChangeLog index 69534abe2..d275fd9b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-15 Vladimir Serbinenko + + * util/grub-mkimage.c (generate_image): Check fwstart.img checksum + for safety. + 2011-01-14 Vladimir Serbinenko * grub-core/kern/mips/yeeloong/init.c (grub_machine_init): Init boot diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index 53e867602..0375d3ed5 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -1167,11 +1168,34 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], size_t rom_size; char *boot_path, *boot_img; size_t boot_size; + grub_uint8_t context[GRUB_MD_SHA512->contextsize]; + /* fwstart.img is the only part which can't be testes by using *-elf + target. Check it against the checksum. This checksum is obtained with + sha512sum utility after compiling on Gnewsense. + */ + const grub_uint8_t fwstart_good_hash[] = + { 0x75, 0xbf, 0xa3, 0x0e, 0x7c, 0xd1, 0x03, 0x82, + 0xe1, 0x34, 0x55, 0xd7, 0x09, 0x1e, 0x6c, 0xcc, + 0xef, 0x08, 0x61, 0xc1, 0x3c, 0xd8, 0xc7, 0x9f, + 0xe8, 0x2d, 0x3d, 0xb2, 0xda, 0x41, 0xd3, 0x83, + 0xd7, 0xb8, 0xe3, 0xd7, 0x13, 0xec, 0x9b, 0xf6, + 0xf6, 0xae, 0x6b, 0x32, 0x29, 0xc1, 0x69, 0x82, + 0xfa, 0x65, 0x2d, 0x97, 0x3e, 0x83, 0x6e, 0x6c, + 0xce, 0x34, 0x10, 0x59, 0x74, 0x0e, 0x96, 0x26 }; boot_path = grub_util_get_path (dir, "fwstart.img"); boot_size = grub_util_get_image_size (boot_path); boot_img = grub_util_read_image (boot_path); + grub_memset (context, 0, sizeof (context)); + GRUB_MD_SHA512->init (context); + GRUB_MD_SHA512->write (context, boot_img, boot_size); + GRUB_MD_SHA512->final (context); + if (grub_memcmp (GRUB_MD_SHA512->read (context), fwstart_good_hash, + GRUB_MD_SHA512->mdlen) != 0) + grub_util_warn ("fwstart.img doesn't match the known good version. " + "Proceed at your own risk"); + rom_size = ALIGN_UP (core_size + boot_size, 512 * 1024); rom_img = xmalloc (rom_size); From 646ada34d11f26484ffe33e0cc80bcd06219ec8c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 16 Jan 2011 12:54:03 +0100 Subject: [PATCH 109/276] * configure.ac: Bump version to 1.99~rc1. --- ChangeLog | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d275fd9b6..8c39f7ba5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-16 Vladimir Serbinenko + + * configure.ac: Bump version to 1.99~rc1. + 2011-01-15 Vladimir Serbinenko * util/grub-mkimage.c (generate_image): Check fwstart.img checksum diff --git a/configure.ac b/configure.ac index 0b9207ea2..c660ac41e 100644 --- a/configure.ac +++ b/configure.ac @@ -32,7 +32,7 @@ dnl type, so there is no conflict. Variables with the prefix "TARGET_" dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target dnl type. -AC_INIT([GRUB],[1.99~beta0],[bug-grub@gnu.org]) +AC_INIT([GRUB],[1.99~rc1],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) From 5e79d66a547bd1e616defefef4cc5ab44d198a1e Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 17 Jan 2011 12:48:07 +0000 Subject: [PATCH 110/276] * .bzrignore: Remove nonexistent grub-pbkdf2. --- .bzrignore | 1 - ChangeLog | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.bzrignore b/.bzrignore index 0cbb3f17f..a3e6f9dd2 100644 --- a/.bzrignore +++ b/.bzrignore @@ -44,7 +44,6 @@ grub-kbdcomp grub-macho2img grub-menulst2cfg grub-mk* -grub-pbkdf2 grub-pe2elf grub-probe grub_probe_init.c diff --git a/ChangeLog b/ChangeLog index 8c39f7ba5..a2d11d828 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-17 Colin Watson + + * .bzrignore: Remove nonexistent grub-pbkdf2. + 2011-01-16 Vladimir Serbinenko * configure.ac: Bump version to 1.99~rc1. From 81431e2b020371b57f747e2b3decdfbb00ed183e Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 22 Jan 2011 01:11:56 +0000 Subject: [PATCH 111/276] * docs/grub.texi (Simple configuration): Document GRUB_PRELOAD_MODULES. --- ChangeLog | 5 +++++ docs/grub.texi | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index a2d11d828..75c713b9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-22 Colin Watson + + * docs/grub.texi (Simple configuration): Document + GRUB_PRELOAD_MODULES. + 2011-01-17 Colin Watson * .bzrignore: Remove nonexistent grub-pbkdf2. diff --git a/docs/grub.texi b/docs/grub.texi index daf48da13..a47389f1e 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1181,6 +1181,11 @@ directly to @ref{play}. If this option is set, GRUB will issue a @ref{badram} command to filter out specified regions of RAM. +@item GRUB_PRELOAD_MODULES +This option may be set to a list of GRUB module names separated by spaces. +Each module will be loaded as early as possible, at the start of +@file{grub.cfg}. + @end table For more detailed customisation of @command{grub-mkconfig}'s output, you may From 96e0a6ea9795fd2068d8f8e308d398fd3cb0e314 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 22 Jan 2011 01:26:49 +0000 Subject: [PATCH 112/276] * util/grub-mkconfig_lib.in (is_path_readable_by_grub): Consider a path unreadable if `grub-probe -t abstraction' fails, for example if memberlist fails on an LVM volume group. Reported by: Darius Jahandarie. --- ChangeLog | 7 +++++++ util/grub-mkconfig_lib.in | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index 75c713b9d..062f3c5a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-22 Colin Watson + + * util/grub-mkconfig_lib.in (is_path_readable_by_grub): Consider a + path unreadable if `grub-probe -t abstraction' fails, for example if + memberlist fails on an LVM volume group. + Reported by: Darius Jahandarie. + 2011-01-22 Colin Watson * docs/grub.texi (Simple configuration): Document diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 2a48fb260..628ea34d4 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -61,6 +61,12 @@ is_path_readable_by_grub () return 1 fi + # ... or if we can't figure out the abstraction module, for example if + # memberlist fails on an LVM volume group. + if ${grub_probe} -t abstraction $path > /dev/null 2>&1 ; then : ; else + return 1 + fi + return 0 } From e489601ad0594bde0dc17257802beb7076976849 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 13:18:05 +0100 Subject: [PATCH 113/276] * grub-core/disk/raid.c (insert_array): Ensure uniqueness of p->number even if some elements have a name. Reported by: Alexander GQ Gerasiov. --- ChangeLog | 6 ++++++ grub-core/disk/raid.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 062f3c5a8..cb499bb01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/disk/raid.c (insert_array): Ensure uniqueness of p->number + even if some elements have a name. + Reported by: Alexander GQ Gerasiov. + 2011-01-22 Colin Watson * util/grub-mkconfig_lib.in (is_path_readable_by_grub): Consider a diff --git a/grub-core/disk/raid.c b/grub-core/disk/raid.c index c789fea50..3972e1632 100644 --- a/grub-core/disk/raid.c +++ b/grub-core/disk/raid.c @@ -570,7 +570,7 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array, { for (p = array_list; p != NULL; p = p->next) { - if (! p->name && p->number == array->number) + if (p->number == array->number) break; } } From 5d4f4dd51b159de457a989c731c0012d0bbbac98 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 13:22:46 +0100 Subject: [PATCH 114/276] * grub-core/disk/scsi.c (grub_scsi_read): Fix binary and check and make logical expression more readable. --- ChangeLog | 5 +++++ grub-core/disk/scsi.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cb499bb01..16be610ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/disk/scsi.c (grub_scsi_read): Fix binary and check and make + logical expression more readable. + 2011-01-22 Vladimir Serbinenko * grub-core/disk/raid.c (insert_array): Ensure uniqueness of p->number diff --git a/grub-core/disk/scsi.c b/grub-core/disk/scsi.c index 902ab12c3..a40de278f 100644 --- a/grub-core/disk/scsi.c +++ b/grub-core/disk/scsi.c @@ -506,7 +506,7 @@ grub_scsi_read (grub_disk_t disk, grub_disk_addr_t sector, if (scsi->blocksize != GRUB_DISK_SECTOR_SIZE) { unsigned spb = scsi->blocksize >> GRUB_DISK_SECTOR_BITS; - if (! (spb != 0 && (scsi->blocksize & GRUB_DISK_SECTOR_SIZE) == 0)) + if (spb == 0 || (scsi->blocksize & (GRUB_DISK_SECTOR_SIZE - 1)) != 0) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "unsupported SCSI block size"); From 80f23be71fa11304d11e3dc549f1a20d0a492673 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 14:11:19 +0100 Subject: [PATCH 115/276] * grub-core/script/argv.c (round_up_exp): unsigned is 32-bit on all supported platforms. Put a compile time assert for this rather than generate a warning with 32-bit shift. --- ChangeLog | 6 ++++++ grub-core/script/argv.c | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16be610ea..9e4ea21dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/script/argv.c (round_up_exp): unsigned is 32-bit on all + supported platforms. Put a compile time assert for this rather than + generate a warning with 32-bit shift. + 2011-01-22 Vladimir Serbinenko * grub-core/disk/scsi.c (grub_scsi_read): Fix binary and check and make diff --git a/grub-core/script/argv.c b/grub-core/script/argv.c index 50f810fcf..856828d7b 100644 --- a/grub-core/script/argv.c +++ b/grub-core/script/argv.c @@ -25,6 +25,8 @@ static unsigned round_up_exp (unsigned v) { + COMPILE_TIME_ASSERT (sizeof (v) == 4); + v--; v |= v >> 1; v |= v >> 2; @@ -32,9 +34,6 @@ round_up_exp (unsigned v) v |= v >> 8; v |= v >> 16; - if (sizeof (v) > 4) - v |= v >> 32; - v++; v += (v == 0); From ffc8f4d8bce3586d4dcd714c84eea558c902c8a8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 14:15:17 +0100 Subject: [PATCH 116/276] * grub-core/partmap/bsdlabel.c: Include grub/emu/misc.h and not grub/util/misc.h. (iterate_real): Don't rely on partition being non-NULL. --- ChangeLog | 5 +++++ grub-core/partmap/bsdlabel.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e4ea21dd..6593c4891 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/partmap/bsdlabel.c: Include grub/emu/misc.h and not grub/util/misc.h. + (iterate_real): Don't rely on partition being non-NULL. + 2011-01-22 Vladimir Serbinenko * grub-core/script/argv.c (round_up_exp): unsigned is 32-bit on all diff --git a/grub-core/partmap/bsdlabel.c b/grub-core/partmap/bsdlabel.c index 09ecd935a..4dec3851c 100644 --- a/grub-core/partmap/bsdlabel.c +++ b/grub-core/partmap/bsdlabel.c @@ -26,7 +26,7 @@ #include #ifdef GRUB_UTIL -#include +#include #endif static struct grub_partition_map grub_bsdlabel_partition_map; @@ -101,7 +101,8 @@ iterate_real (grub_disk_t disk, grub_disk_addr_t sector, int freebsd, #ifdef GRUB_UTIL char *partname; /* disk->partition != NULL as 0 < delta */ - partname = grub_partition_get_name (disk->partition); + partname = disk->partition ? grub_partition_get_name (disk->partition) + : ""; grub_util_warn ("Discarding improperly nested partition (%s,%s,%s%d)", disk->name, partname, p.partmap->name, p.number + 1); grub_free (partname); From 03a4ccb5134770375d5b8ed95e11ef6bfc296730 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 14:26:18 +0100 Subject: [PATCH 117/276] * grub-core/bus/bonito.c (write_bases): Fix direction of the shift. --- ChangeLog | 4 ++++ grub-core/bus/bonito.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6593c4891..f44a91c6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/bus/bonito.c (write_bases): Fix direction of the shift. + 2011-01-22 Vladimir Serbinenko * grub-core/partmap/bsdlabel.c: Include grub/emu/misc.h and not grub/util/misc.h. diff --git a/grub-core/bus/bonito.c b/grub-core/bus/bonito.c index 3f794c45a..c2e0cd6ff 100644 --- a/grub-core/bus/bonito.c +++ b/grub-core/bus/bonito.c @@ -38,7 +38,7 @@ write_bases (void) for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++) reg |= (((base_win[i] >> GRUB_MACHINE_PCI_WIN_SHIFT) & GRUB_MACHINE_PCI_WIN_MASK) - >> (i * GRUB_MACHINE_PCI_WIN_MASK_SIZE)); + << (i * GRUB_MACHINE_PCI_WIN_MASK_SIZE)); GRUB_MACHINE_PCI_IO_CTRL_REG = reg; } From 37f4f60828307e35cac458e5b832d4a36aaa0471 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 15:10:29 +0100 Subject: [PATCH 118/276] * util/grub-install.in: Ignore install device on platforms where it doesn't make sense. Always use UUIDs except on pc, efi and sparc64. Reported by: Daniel Kahn Gillmor. --- ChangeLog | 7 +++++++ util/grub-install.in | 26 ++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index f44a91c6b..ce6b6f7cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-01-22 Vladimir Serbinenko + + * util/grub-install.in: Ignore install device on platforms + where it doesn't make sense. Always use UUIDs except on pc, efi and + sparc64. + Reported by: Daniel Kahn Gillmor. + 2011-01-22 Vladimir Serbinenko * grub-core/bus/bonito.c (write_bases): Fix direction of the shift. diff --git a/util/grub-install.in b/util/grub-install.in index 90360c279..1ae00b2fd 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -270,6 +270,11 @@ if test "x$install_device" = x && ([ "${target_cpu}-${platform}" = "i386-pc" ] \ exit 1 fi +if ! ([ "${target_cpu}-${platform}" = "i386-pc" ] \ + || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then + install_device= +fi + # If the debugging feature is enabled, print commands. setup_verbose= if test x"$debug" = xyes; then @@ -516,27 +521,24 @@ if [ "x${devabstraction_module}" = "x" ] ; then # Strip partition number grub_partition="`echo "${grub_drive}" | sed -e 's/^[^,]*[,)]//; s/)$//'`" grub_drive="`echo "${grub_drive}" | sed -e s/,[a-z0-9,]*//g`" - if [ "$disk_module" = ata ] ; then + if [ "$disk_module" = ata ] || [ "x${grub_drive}" != "x${install_drive}" ] || ([ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]) ; then # generic method (used on coreboot and ata mod) uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`" if [ "x${uuid}" = "x" ] ; then - echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 + if [ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]; then + echo "UUID needed with $platform, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 + elif [ "$disk_module" = ata ]; then + echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 + else + echo "UUID needed with cross-disk installs, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 + fi + exit 1 fi echo "search.fs_uuid ${uuid} root " >> "${grubdir}/load.cfg" echo 'set prefix=($root)'"${relative_grubdir}" >> "${grubdir}/load.cfg" config_opt="-c ${grubdir}/load.cfg " modules="$modules search_fs_uuid" - elif [ "x${grub_drive}" != "x${install_drive}" ] ; then - uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`" - if [ "x${uuid}" = "x" ] ; then - echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 - exit 1 - fi - echo "search.fs_uuid ${uuid} root " >> ${grubdir}/load.cfg - echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg - config_opt="-c ${grubdir}/load.cfg " - modules="$modules search_fs_uuid" elif [ "x$platform" = xefi ] || [ "x$platform" = xpc ]; then # we need to hardcode the partition number in the core image's prefix. if [ x"$grub_partition" = x ]; then From 5d4c5f891446f913ced217af1712a8d903449fe0 Mon Sep 17 00:00:00 2001 From: Anthony DeRobertis Date: Sat, 22 Jan 2011 15:20:08 +0100 Subject: [PATCH 119/276] * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Check super_offset field. --- grub-core/disk/mdraid1x_linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c index 155210df3..f2e7555cb 100644 --- a/grub-core/disk/mdraid1x_linux.c +++ b/grub-core/disk/mdraid1x_linux.c @@ -143,7 +143,8 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, &sb)) return grub_errno; - if (grub_le_to_cpu32 (sb.magic) != SB_MAGIC) + if (grub_le_to_cpu32 (sb.magic) != SB_MAGIC + || grub_le_to_cpu64 (sb.super_offset) != sector) continue; { From 73ae4f4ff55b39739352daf133ac4e9562e7f98e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 15:30:48 +0100 Subject: [PATCH 120/276] Add missing ChangeLog entry --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index ce6b6f7cf..ba611afad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-22 Anthony DeRobertis + + * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Check + super_offset field. + 2011-01-22 Vladimir Serbinenko * util/grub-install.in: Ignore install device on platforms From 3533413cd5efc9630436511b57d77f24c6afd0a3 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 22 Jan 2011 15:37:05 +0100 Subject: [PATCH 121/276] * grub-core/kern/emu/getroot.c: Include config-util.h explicitly. --- ChangeLog | 4 ++++ grub-core/kern/emu/getroot.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index ba611afad..edb7d46f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-01-22 Vladimir Serbinenko + + * grub-core/kern/emu/getroot.c: Include config-util.h explicitly. + 2011-01-22 Anthony DeRobertis * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Check diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index aedef9e0e..110e58b14 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -17,7 +17,9 @@ * along with GRUB. If not, see . */ +#include #include + #include #include #include From 3281d3d6d43ac50dab55cbed9b337ac4d8e17dac Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 24 Jan 2011 02:44:27 +0100 Subject: [PATCH 122/276] * util/grub-mkimage.c (generate_image): Refuse to create the images bigger than the actual flash (512K) in Loongson machines. 512K is also the biggest chip supported by them. --- ChangeLog | 6 ++++++ util/grub-mkimage.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index edb7d46f7..514ce4ef8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-24 Vladimir Serbinenko + + * util/grub-mkimage.c (generate_image): Refuse to create the images + bigger than the actual flash (512K) in Loongson machines. 512K is also + the biggest chip supported by them. + 2011-01-22 Vladimir Serbinenko * grub-core/kern/emu/getroot.c: Include config-util.h explicitly. diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index 0375d3ed5..876e9c9b2 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -1196,7 +1196,9 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], grub_util_warn ("fwstart.img doesn't match the known good version. " "Proceed at your own risk"); - rom_size = ALIGN_UP (core_size + boot_size, 512 * 1024); + if (core_size + boot_size > 512 * 1024) + grub_util_error ("firmware image is too big"); + rom_size = 512 * 1024; rom_img = xmalloc (rom_size); memset (rom_img, 0, rom_size); From 800f188183cf4d45bbd13eb94e1c2419888b76b2 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 28 Jan 2011 17:01:28 +0000 Subject: [PATCH 123/276] * docs/grub.texi (Making a GRUB bootable CD-ROM): Update to describe grub-mkrescue. --- ChangeLog | 5 +++++ docs/grub.texi | 48 +++++++++++++++++++++++------------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 514ce4ef8..019a6746c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-01-28 Colin Watson + + * docs/grub.texi (Making a GRUB bootable CD-ROM): Update to describe + grub-mkrescue. + 2011-01-24 Vladimir Serbinenko * util/grub-mkimage.c (generate_image): Refuse to create the images diff --git a/docs/grub.texi b/docs/grub.texi index a47389f1e..c815bcbbe 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -651,15 +651,22 @@ using BIOS functions.}. This means that you can use the whole CD-ROM from GRUB and you don't have to make a floppy or hard disk image file, which can cause compatibility problems. -For booting from a CD-ROM, GRUB uses a special Stage 2 called -@file{stage2_eltorito}. The only GRUB files you need to have in your -bootable CD-ROM are this @file{stage2_eltorito} and optionally a config file -@file{grub.cfg}. You don't need to use @file{stage1} or @file{stage2}, -because El Torito is quite different from the standard boot process. +For booting from a CD-ROM, GRUB uses a special image called +@file{cdboot.img}, which is concatenated with @file{core.img}. The +@file{core.img} used for this should be built with at least the +@samp{iso9660} and @samp{biosdisk} modules. Your bootable CD-ROM will +usually also need to include a configuration file @file{grub.cfg} and some +other GRUB modules. -Here is an example of procedures to make a bootable CD-ROM -image. First, make a top directory for the bootable image, say, -@samp{iso}: +To make a simple generic GRUB rescue CD, you can use the +@command{grub-mkrescue} program: + +@example +$ @kbd{grub-mkrescue -o grub.iso} +@end example + +You will often need to include other files in your image. To do this, first +make a top directory for the bootable image, say, @samp{iso}: @example $ @kbd{mkdir iso} @@ -671,33 +678,24 @@ Make a directory for GRUB: $ @kbd{mkdir -p iso/boot/grub} @end example -Copy the file @file{stage2_eltorito}: - -@example -$ @kbd{cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub} -@end example - If desired, make the config file @file{grub.cfg} under @file{iso/boot/grub} (@pxref{Configuration}), and copy any files and directories for the disc to the directory @file{iso/}. -Finally, make a ISO9660 image file like this: +Finally, make the image: @example -$ @kbd{mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \ - -boot-load-size 4 -boot-info-table -o grub.iso iso} +$ @kbd{grub-mkrescue -o grub.iso iso} @end example This produces a file named @file{grub.iso}, which then can be burned -into a CD (or a DVD). @kbd{mkisofs} has already set up the disc to boot -from the @kbd{boot/grub/stage2_eltorito} file, so there is no need to -setup GRUB on the disc. (Note that the @kbd{-boot-load-size 4} bit is -required for compatibility with the BIOS on many older machines.) +into a CD (or a DVD), or written to a USB mass storage device. -You can use the device @samp{(cd)} to access a CD-ROM in your -config file. This is not required; GRUB automatically sets the root device -to @samp{(cd)} when booted from a CD-ROM. It is only necessary to refer to -@samp{(cd)} if you want to access other drives as well. +The root device will be set up appropriately on entering your +@file{grub.cfg} configuration file, so you can refer to file names on the CD +without needing to use an explicit device name. This makes it easier to +produce rescue images that will work on both optical drives and USB mass +storage devices. @node Device map From 8c2c4ff2f533cf37c2025655497f3dfc8cfd5eef Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 4 Feb 2011 13:33:16 +0000 Subject: [PATCH 124/276] Handle empty dir passed to grub_find_root_device_from_mountinfo; fixes grub-mkrelpath on btrfs subvolumes. --- grub-core/kern/emu/getroot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index 92ff971e5..c1ed35b2d 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -111,6 +111,8 @@ grub_find_root_device_from_mountinfo (const char *dir, char **relroot) size_t len = 0; char *ret = NULL; + if (! *dir) + dir = "/"; if (relroot) *relroot = NULL; From 5870a4a06f11059defad9ff546b7b2811a838873 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 4 Feb 2011 16:35:07 +0000 Subject: [PATCH 125/276] typo --- grub-core/fs/btrfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index b7c59065c..ac90c055a 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -729,7 +729,7 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t paddr; stripe = (struct grub_btrfs_chunk_stripe *) (chunk + 1); - /* Right now the redundancy handlind is easy. + /* Right now the redundancy handling is easy. With RAID5-like it will be more difficult. */ stripe += stripen + i; From 7e735e4349c2c408dd5420882ed206d8d34d78ce Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 8 Feb 2011 13:21:13 +0000 Subject: [PATCH 126/276] * include/grub/file.h (not_easly_seekable): Rename to ... (not_easily_seekable): ... this. Update all users. --- ChangeLog | 5 +++++ grub-core/fs/i386/pc/pxe.c | 2 +- grub-core/io/bufio.c | 2 +- grub-core/io/gzio.c | 2 +- grub-core/io/xzio.c | 2 +- include/grub/file.h | 6 +++--- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 019a6746c..d3325ac6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-02-08 Colin Watson + + * include/grub/file.h (not_easly_seekable): Rename to ... + (not_easily_seekable): ... this. Update all users. + 2011-01-28 Colin Watson * docs/grub.texi (Making a GRUB bootable CD-ROM): Update to describe diff --git a/grub-core/fs/i386/pc/pxe.c b/grub-core/fs/i386/pc/pxe.c index e2b53d637..a3b055f3d 100644 --- a/grub-core/fs/i386/pc/pxe.c +++ b/grub-core/fs/i386/pc/pxe.c @@ -281,7 +281,7 @@ grub_pxefs_open (struct grub_file *file, const char *name) } file->data = data; - file->not_easly_seekable = 1; + file->not_easily_seekable = 1; grub_memcpy (file_int, file, sizeof (struct grub_file)); curr_file = file_int; diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c index 8a72ecd79..891fb78e9 100644 --- a/grub-core/io/bufio.c +++ b/grub-core/io/bufio.c @@ -74,7 +74,7 @@ grub_bufio_open (grub_file_t io, int size) file->data = bufio; file->read_hook = 0; file->fs = &grub_bufio_fs; - file->not_easly_seekable = io->not_easly_seekable; + file->not_easily_seekable = io->not_easily_seekable; return file; } diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c index f563d7b92..47df23833 100644 --- a/grub-core/io/gzio.c +++ b/grub-core/io/gzio.c @@ -1136,7 +1136,7 @@ grub_gzio_open (grub_file_t io) file->data = gzio; file->read_hook = 0; file->fs = &grub_gzio_fs; - file->not_easly_seekable = 1; + file->not_easily_seekable = 1; if (! test_header (file)) { diff --git a/grub-core/io/xzio.c b/grub-core/io/xzio.c index 37be1790f..3daf6a3fe 100644 --- a/grub-core/io/xzio.c +++ b/grub-core/io/xzio.c @@ -200,7 +200,7 @@ grub_xzio_open (grub_file_t io) file->read_hook = 0; file->fs = &grub_xzio_fs; file->size = GRUB_FILE_SIZE_UNKNOWN; - file->not_easly_seekable = 1; + file->not_easily_seekable = 1; if (grub_file_tell (xzio->file) != 0) grub_file_seek (xzio->file, 0); diff --git a/include/grub/file.h b/include/grub/file.h index 72cd45468..3adb1706f 100644 --- a/include/grub/file.h +++ b/include/grub/file.h @@ -39,8 +39,8 @@ struct grub_file /* The file size. */ grub_off_t size; - /* If file is not easly seekable. Should be set by underlying layer. */ - int not_easly_seekable; + /* If file is not easily seekable. Should be set by underlying layer. */ + int not_easily_seekable; /* Filesystem-specific data. */ void *data; @@ -123,7 +123,7 @@ grub_file_tell (const grub_file_t file) static inline int grub_file_seekable (const grub_file_t file) { - return !file->not_easly_seekable; + return !file->not_easily_seekable; } #endif /* ! GRUB_FILE_HEADER */ From 22b28eb3fe78a38e1be478d70bd8da1a75f784de Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 9 Feb 2011 11:23:11 +0000 Subject: [PATCH 127/276] * util/grub-install.in: Remove unnecessary brackets from tr arguments. * util/grub.d/10_hurd.in: Likewise. * util/grub.d/10_kfreebsd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/grub.d/20_linux_xen.in: Likewise. Reported by: Jamie Heilman. Fixes Debian bug #612564. --- ChangeLog | 10 ++++++++++ util/grub-install.in | 2 +- util/grub.d/10_hurd.in | 2 +- util/grub.d/10_kfreebsd.in | 2 +- util/grub.d/10_linux.in | 2 +- util/grub.d/20_linux_xen.in | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3325ac6b..6517450ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-02-09 Colin Watson + + * util/grub-install.in: Remove unnecessary brackets from tr + arguments. + * util/grub.d/10_hurd.in: Likewise. + * util/grub.d/10_kfreebsd.in: Likewise. + * util/grub.d/10_linux.in: Likewise. + * util/grub.d/20_linux_xen.in: Likewise. + Reported by: Jamie Heilman. Fixes Debian bug #612564. + 2011-02-08 Colin Watson * include/grub/file.h (not_easly_seekable): Rename to ... diff --git a/util/grub-install.in b/util/grub-install.in index 1ae00b2fd..af3034e03 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -64,7 +64,7 @@ if test -f "${sysconfdir}/default/grub" ; then . "${sysconfdir}/default/grub" fi -bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr '[A-Z]' '[a-z]' | cut -d' ' -f1)" +bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr 'A-Z' 'a-z' | cut -d' ' -f1)" if test -z "$bootloader_id"; then bootloader_id=grub fi diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index eeb441aa4..8c54eab97 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -28,7 +28,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU else OS="${GRUB_DISTRIBUTOR} GNU/Hurd" - CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}" + CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}" fi at_least_one=false diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index b026812a7..dce5e945c 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -31,7 +31,7 @@ CLASS="--class os" case "${GRUB_DISTRIBUTOR}" in Debian) OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" - CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}" + CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}" ;; *) OS="FreeBSD" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index a09c3e687..491d2b5ce 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -32,7 +32,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU/Linux else OS="${GRUB_DISTRIBUTOR} GNU/Linux" - CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}" + CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}" fi # loop-AES arranges things so that /dev/loop/X can be our root device, but diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index ee49cd903..356219e1d 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -32,7 +32,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU/Linux else OS="${GRUB_DISTRIBUTOR} GNU/Linux" - CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}" + CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}" fi # loop-AES arranges things so that /dev/loop/X can be our root device, but From 97286eb54770ce840063ee0740c4a4923aaa28de Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 9 Feb 2011 12:14:10 +0000 Subject: [PATCH 128/276] * docs/grub.texi (Kernel): Add reference to grub-mkrescue. (Making a GRUB bootable CD-ROM): Likewise. (Invoking grub-mkrescue): New section. Reported by: Yann Dirson. Fixes Debian bug #612585. --- ChangeLog | 7 ++++++ docs/grub.texi | 62 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6517450ce..56498af1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-02-09 Colin Watson + + * docs/grub.texi (Kernel): Add reference to grub-mkrescue. + (Making a GRUB bootable CD-ROM): Likewise. + (Invoking grub-mkrescue): New section. + Reported by: Yann Dirson. Fixes Debian bug #612585. + 2011-02-09 Colin Watson * util/grub-install.in: Remove unnecessary brackets from tr diff --git a/docs/grub.texi b/docs/grub.texi index c815bcbbe..590e6afb7 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -36,6 +36,7 @@ Invariant Sections. * grub-install: (grub)Invoking grub-install. Install GRUB on your drive * grub-mkconfig: (grub)Invoking grub-mkconfig. Generate GRUB configuration * grub-mkpasswd-pbkdf2: (grub)Invoking grub-mkpasswd-pbkdf2. +* grub-mkrescue: (grub)Invoking grub-mkrescue. Make a GRUB rescue image @end direntry @setchapternewpage odd @@ -94,6 +95,7 @@ This edition documents version @value{VERSION}. * Invoking grub-mkconfig:: Generate a GRUB configuration file * Invoking grub-mkpasswd-pbkdf2:: Generate GRUB password hashes +* Invoking grub-mkrescue:: Make a GRUB rescue image * Obtaining and Building GRUB:: How to obtain and build GRUB * Reporting bugs:: Where you should send a bug report * Future:: Some future plans on GRUB @@ -659,7 +661,7 @@ usually also need to include a configuration file @file{grub.cfg} and some other GRUB modules. To make a simple generic GRUB rescue CD, you can use the -@command{grub-mkrescue} program: +@command{grub-mkrescue} program (@pxref{Invoking grub-mkrescue}): @example $ @kbd{grub-mkrescue -o grub.iso} @@ -3609,6 +3611,64 @@ Length of the salt. Defaults to 64. @end table +@node Invoking grub-mkrescue +@chapter Invoking grub-mkrescue + +The program @command{grub-mkrescue} generates a bootable GRUB rescue image +(@pxref{Making a GRUB bootable CD-ROM}). + +@example +grub-mkrescue -o grub.iso +@end example + +All arguments not explicitly listed as @command{grub-mkrescue} options are +passed on directly to @command{xorriso} in @command{mkisofs} emulation mode. +Options passed to @command{xorriso} will normally be interpreted as +@command{mkisofs} options; if the option @samp{--} is used, then anything +after that will be interpreted as native @command{xorriso} options. + +Non-option arguments specify additional source directories. This is +commonly used to add extra files to the image: + +@example +mkdir -p disk/boot/grub +@r{(add extra files to @file{disk/boot/grub})} +grub-mkrescue -o grub.iso disk +@end example + +@command{grub-mkrescue} accepts the following options: + +@table @option +@item --help +Print a summary of the command-line options and exit. + +@item --version +Print the version number of GRUB and exit. + +@item -o @var{file} +@itemx --output=@var{file} +Save output in @var{file}. This "option" is required. + +@item --modules=@var{modules} +Pre-load the named GRUB modules in the image. Multiple entries in +@var{modules} should be separated by whitespace (so you will probably need +to quote this for your shell). + +@item --rom-directory=@var{dir} +If generating images for the QEMU or Coreboot platforms, copy the resulting +@file{qemu.img} or @file{coreboot.elf} files respectively to the @var{dir} +directory as well as including them in the image. + +@item --xorriso=@var{file} +Use @var{file} as the @command{xorriso} program, rather than the built-in +default. + +@item --grub-mkimage=@var{file} +Use @var{file} as the @command{grub-mkimage} program, rather than the +built-in default. +@end table + + @node Obtaining and Building GRUB @appendix How to obtain and build GRUB From fee7cdd4e1bdc0618e01307477e5c115ee76a6dc Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 11 Feb 2011 13:00:54 +0000 Subject: [PATCH 129/276] * util/grub.d/20_linux_xen.in: Bail out early if linux_list is empty, since in that case we can only generate either nothing or a syntactically invalid configuration file. Reported by: Michal Suchanek. Fixes Debian bug #612898. --- ChangeLog | 7 +++++++ util/grub.d/20_linux_xen.in | 3 +++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 56498af1b..6e9ab5758 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-02-11 Colin Watson + + * util/grub.d/20_linux_xen.in: Bail out early if linux_list is + empty, since in that case we can only generate either nothing or a + syntactically invalid configuration file. + Reported by: Michal Suchanek. Fixes Debian bug #612898. + 2011-02-09 Colin Watson * docs/grub.texi (Kernel): Add reference to grub-mkrescue. diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 356219e1d..e71fc1458 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -98,6 +98,9 @@ linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do version=$(echo $basename | sed -e "s,^[^0-9]*-,,g") if grub_file_is_not_garbage "$i" && grep -qx "CONFIG_XEN_DOM0=y" /boot/config-${version} 2> /dev/null ; then echo -n "$i " ; fi done` +if [ "x${linux_list}" = "x" ] ; then + exit 0 +fi xen_list=`for i in /boot/xen*; do if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi done` From d998657dcf8be2a6d4e93f004519e63b66af22cd Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 12 Feb 2011 09:59:04 +0300 Subject: [PATCH 130/276] * grub-core/partmap/msdos.c (pc_partition_map_embed): Fix off by one error. --- ChangeLog | 5 +++++ grub-core/partmap/msdos.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e9ab5758..3a695b25a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-02-12 Vladimir Serbinenko + + * grub-core/partmap/msdos.c (pc_partition_map_embed): Fix off by one + error. + 2011-02-11 Colin Watson * util/grub.d/20_linux_xen.in: Bail out early if linux_list is diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c index d411c4405..31a0a0707 100644 --- a/grub-core/partmap/msdos.c +++ b/grub-core/partmap/msdos.c @@ -232,10 +232,10 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, break; } - if (end >= *nsectors + 1) + if (end >= *nsectors + 2) { unsigned i; - *nsectors = end - 1; + *nsectors = end - 2; *sectors = grub_malloc (*nsectors * sizeof (**sectors)); if (!*sectors) return grub_errno; From 028501a0e06877f14e2445f73a8969bced63c10f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 12 Feb 2011 10:22:55 +0300 Subject: [PATCH 131/276] Workaround yet another IEEE1275 bug. * include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): New enum value GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS. * grub-core/kern/ieee1275/mmap.c (grub_machine_mmap_iterate): Ignore adress_cells and size:cells if GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS is set. * grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS on powermacs. --- ChangeLog | 12 ++++++++++++ grub-core/kern/ieee1275/cmain.c | 3 +++ grub-core/kern/ieee1275/mmap.c | 6 ++++++ include/grub/ieee1275/ieee1275.h | 6 ++++++ 4 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3a695b25a..72d718b08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-02-12 Vladimir Serbinenko + + Workaround yet another IEEE1275 bug. + + * include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): New enum value + GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS. + * grub-core/kern/ieee1275/mmap.c (grub_machine_mmap_iterate): Ignore + adress_cells and size:cells if GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS + is set. + * grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set + GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS on powermacs. + 2011-02-12 Vladimir Serbinenko * grub-core/partmap/msdos.c (pc_partition_map_embed): Fix off by one diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c index 30eacbbdd..2fbe809b2 100644 --- a/grub-core/kern/ieee1275/cmain.c +++ b/grub-core/kern/ieee1275/cmain.c @@ -84,6 +84,9 @@ grub_ieee1275_find_options (void) if (rc >= 0 && !grub_strcmp (tmp, "Emulated PC")) is_qemu = 1; + if (grub_strncmp (tmp, "PowerMac", sizeof ("PowerMac") - 1) == 0) + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS); + if (is_smartfirmware) { /* Broken in all versions */ diff --git a/grub-core/kern/ieee1275/mmap.c b/grub-core/kern/ieee1275/mmap.c index 942e5a354..2e4e085bb 100644 --- a/grub-core/kern/ieee1275/mmap.c +++ b/grub-core/kern/ieee1275/mmap.c @@ -50,6 +50,12 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't examine /memory/available property"); + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS)) + { + address_cells = 1; + size_cells = 1; + } + /* Decode each entry and call `hook'. */ i = 0; available_size /= sizeof (grub_uint32_t); diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 2592dd348..4c56cc20f 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -106,6 +106,12 @@ enum grub_ieee1275_flag /* OLPC / XO firmware has the cursor ON/OFF routines. */ GRUB_IEEE1275_FLAG_HAS_CURSORONOFF, + + /* Some PowerMacs claim to use 2 address cells but in fact use only 1. + Other PowerMacs claim to use only 1 and really do so. Always assume + 1 address cell is used on PowerMacs. + */ + GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); From 57d75699d6eff414d65bd0cc704c2b86be518c94 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 7 Mar 2011 22:23:06 +0100 Subject: [PATCH 132/276] 2011-03-07 Szymon Janc * grub-core/fs/zfs/zfs.c (zap_leaf_lookup): Set-but-not-used variable removed. --- ChangeLog | 5 +++++ grub-core/fs/zfs/zfs.c | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 72d718b08..d8a8d1fc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-07 Szymon Janc + + * grub-core/fs/zfs/zfs.c (zap_leaf_lookup): + Set-but-not-used variable removed. + 2011-02-12 Vladimir Serbinenko Workaround yet another IEEE1275 bug. diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 5b575f369..3a94d8874 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -837,14 +837,12 @@ zap_leaf_lookup (zap_leaf_phys_t * l, grub_zfs_endian_t endian, name)) { struct zap_leaf_array *la; - grub_uint8_t *ip; if (le->le_int_size != 8 || le->le_value_length != 1) return grub_error (GRUB_ERR_BAD_FS, "invalid leaf chunk entry"); /* get the uint64_t property value */ la = &ZAP_LEAF_CHUNK (l, blksft, le->le_value_chunk).l_array; - ip = la->la_array; *value = grub_be_to_cpu64 (la->la_array64); From 83a3c48d3749b64eda1708f2d76efd18f2d6e487 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 9 Mar 2011 17:35:16 +0000 Subject: [PATCH 133/276] * docs/grub.texi (Simple configuration): Tidy up formatting. --- ChangeLog | 4 ++++ docs/grub.texi | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8a8d1fc2..103706af0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-09 Colin Watson + + * docs/grub.texi (Simple configuration): Tidy up formatting. + 2011-03-07 Szymon Janc * grub-core/fs/zfs/zfs.c (zap_leaf_lookup): diff --git a/docs/grub.texi b/docs/grub.texi index 590e6afb7..83bd80023 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1036,8 +1036,8 @@ it as a new default entry for use by future runs of GRUB. This is only useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because @samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with @command{grub-set-default} or @command{grub-reboot}. Unset by default. -The remarks of @pxref{Changes from GRUB Legacy} on the availability -of @samp{save_env} apply. +@samp{save_env} may not be available in all situations +(@pxref{Changes from GRUB Legacy}). @item GRUB_TIMEOUT Boot the default entry this many seconds after the menu is displayed, unless From be1a7ce0cfdd3ada7298abae16168a16bc551e96 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 9 Mar 2011 17:38:31 +0000 Subject: [PATCH 134/276] * grub-core/loader/i386/linux.c (find_efi_mmap_size): Page-align cached mmap_size, so that this works correctly when called multiple times. Reported by: Daniel Kahn Gillmor. Should fix Debian bug #616638. --- ChangeLog | 7 +++++++ grub-core/loader/i386/linux.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 103706af0..0406cf91f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-03-09 Colin Watson + + * grub-core/loader/i386/linux.c (find_efi_mmap_size): Page-align + cached mmap_size, so that this works correctly when called multiple + times. + Reported by: Daniel Kahn Gillmor. Should fix Debian bug #616638. + 2011-03-09 Colin Watson * docs/grub.texi (Simple configuration): Tidy up formatting. diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 80960570b..0178e2fd4 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -136,7 +136,8 @@ find_efi_mmap_size (void) later, and EFI itself may allocate more. */ mmap_size += (1 << 12); - return page_align (mmap_size); + mmap_size = page_align (mmap_size); + return mmap_size; } #endif From 9b43bf396a61b60a0ee4b8a1591634b1120b8906 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 11 Mar 2011 11:51:10 +0000 Subject: [PATCH 135/276] * grub-core/boot/i386/pc/lnxboot.S (real_code_2): Ensure that the initial chunk read from the kernel always includes GRUB's multiboot header, which is now outside the first sector. --- ChangeLog | 6 ++++++ grub-core/boot/i386/pc/lnxboot.S | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0406cf91f..08b937dcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-11 Colin Watson + + * grub-core/boot/i386/pc/lnxboot.S (real_code_2): Ensure that the + initial chunk read from the kernel always includes GRUB's multiboot + header, which is now outside the first sector. + 2011-03-09 Colin Watson * grub-core/loader/i386/linux.c (find_efi_mmap_size): Page-align diff --git a/grub-core/boot/i386/pc/lnxboot.S b/grub-core/boot/i386/pc/lnxboot.S index 9a599c261..2c7596026 100644 --- a/grub-core/boot/i386/pc/lnxboot.S +++ b/grub-core/boot/i386/pc/lnxboot.S @@ -178,8 +178,13 @@ real_code_2: pushw %es popw %ds +#if GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4 < 0x200 movl $0x200, %ecx addl %ecx, %esi +#else + movl $(GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4), %ecx + addl $0x200, %esi +#endif movl $DATA_ADDR, %edi call LOCAL(move_memory) @@ -196,7 +201,11 @@ real_code_2: 1: movl %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE), %ecx +#if GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4 < 0x200 addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx +#else + addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - (GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4)), %ecx +#endif 2: call LOCAL(move_memory) From 2da48d28d998f8d85868fae5debd238d2b3994d4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 11:52:04 +0100 Subject: [PATCH 136/276] * util/grub-install.in: Correct the x86-64 name as x86_64. --- ChangeLog | 4 ++++ util/grub-install.in | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08b937dcb..6218e9f12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-23 Vladimir Serbinenko + + * util/grub-install.in: Correct the x86-64 name as x86_64. + 2011-03-11 Colin Watson * grub-core/boot/i386/pc/lnxboot.S (real_code_2): Ensure that the diff --git a/util/grub-install.in b/util/grub-install.in index af3034e03..b4a4b3f26 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -367,7 +367,7 @@ if [ x"$platform" = xefi ]; then case "$target_cpu" in i386) efi_file=BOOTIA32.EFI ;; - x86-64) + x86_64) efi_file=BOOTX64.EFI ;; # GRUB does not yet support these architectures, but they're defined # by the specification so we include them here to ease future @@ -381,7 +381,7 @@ if [ x"$platform" = xefi ]; then case "$target_cpu" in i386) efi_file=grubia32.efi ;; - x86-64) + x86_64) efi_file=grubx64.efi ;; # GRUB does not yet support these architectures, but they're defined # by the specification so we include them here to ease future From 40fc46599d1421ed892d9eb2cd0277850791ef35 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 11:54:58 +0100 Subject: [PATCH 137/276] * grub-core/video/bochs.c (grub_video_bochs_setup): Use grub_video_mode_type_t. * grub-core/video/cirrus.c (grub_video_cirrus_setup): Likewise. * grub-core/video/i386/pc/vbe.c (grub_video_vbe_setup): Likewise. * grub-core/video/i386/pc/vga.c (grub_video_vga_setup): Likewise. --- ChangeLog | 8 ++++++++ grub-core/video/bochs.c | 3 ++- grub-core/video/cirrus.c | 3 ++- grub-core/video/i386/pc/vbe.c | 3 ++- grub-core/video/i386/pc/vga.c | 3 ++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6218e9f12..20fdfc86c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-03-23 Vladimir Serbinenko + + * grub-core/video/bochs.c (grub_video_bochs_setup): Use + grub_video_mode_type_t. + * grub-core/video/cirrus.c (grub_video_cirrus_setup): Likewise. + * grub-core/video/i386/pc/vbe.c (grub_video_vbe_setup): Likewise. + * grub-core/video/i386/pc/vga.c (grub_video_vga_setup): Likewise. + 2011-03-23 Vladimir Serbinenko * util/grub-install.in: Correct the x86-64 name as x86_64. diff --git a/grub-core/video/bochs.c b/grub-core/video/bochs.c index 5def0985b..832cd9903 100644 --- a/grub-core/video/bochs.c +++ b/grub-core/video/bochs.c @@ -199,7 +199,8 @@ grub_video_bochs_set_palette (unsigned int start, unsigned int count, static grub_err_t grub_video_bochs_setup (unsigned int width, unsigned int height, - unsigned int mode_type, unsigned int mode_mask) + grub_video_mode_type_t mode_type, + grub_video_mode_type_t mode_mask) { int depth; grub_err_t err; diff --git a/grub-core/video/cirrus.c b/grub-core/video/cirrus.c index b8b0142ad..a964c85cd 100644 --- a/grub-core/video/cirrus.c +++ b/grub-core/video/cirrus.c @@ -235,7 +235,8 @@ grub_video_cirrus_set_palette (unsigned int start, unsigned int count, static grub_err_t grub_video_cirrus_setup (unsigned int width, unsigned int height, - unsigned int mode_type, unsigned int mode_mask) + grub_video_mode_type_t mode_type, + grub_video_mode_type_t mode_mask) { int depth; grub_err_t err; diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c index 2ddb4ca80..08bf124b6 100644 --- a/grub-core/video/i386/pc/vbe.c +++ b/grub-core/video/i386/pc/vbe.c @@ -688,7 +688,8 @@ grub_video_vbe_iterate (int (*hook) (const struct grub_video_mode_info *info)) static grub_err_t grub_video_vbe_setup (unsigned int width, unsigned int height, - unsigned int mode_type, unsigned int mode_mask) + grub_video_mode_type_t mode_type, + grub_video_mode_type_t mode_mask) { grub_uint16_t *p; struct grub_vbe_mode_info_block vbe_mode_info; diff --git a/grub-core/video/i386/pc/vga.c b/grub-core/video/i386/pc/vga.c index 41b8d3eb1..19770ce0a 100644 --- a/grub-core/video/i386/pc/vga.c +++ b/grub-core/video/i386/pc/vga.c @@ -116,7 +116,8 @@ grub_video_vga_init (void) static grub_err_t grub_video_vga_setup (unsigned int width, unsigned int height, - unsigned int mode_type, unsigned int mode_mask) + grub_video_mode_type_t mode_type, + grub_video_mode_type_t mode_mask) { grub_err_t err; From 7d4e39d65a7102579e219ba52dccbb3830617ede Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 12:05:13 +0100 Subject: [PATCH 138/276] * grub-core/bus/usb/usb.c (attach_hooks): Make static. * grub-core/bus/usb/usbhub.c (hubs): Likewise. * grub-core/commands/hashsum.c (aliases): Likewise. * grub-core/commands/setpci.c (pci_registers): Likewise. * grub-core/disk/usbms.c (attach_hook): Likewise. * grub-core/fs/zfs/zfs.c (decomp_table): Likewise. (zio_checksum_table): Likewise. * grub-core/gettext/gettext.c (grub_gettext_msg_list): Likewise. * grub-core/gfxmenu/gfxmenu.c (cached_view): Likewise. * grub-core/lib/legacy_parse.c (legacy_commands): Likewise. * grub-core/lib/relocator.c (leftovers): Likewise. (extra_blocks): Likewise. * grub-core/loader/i386/bsd.c (relocator): Likewise. * grub-core/loader/i386/multiboot_mbi.c (modules): Likewise. (modules_last): Likewise. * grub-core/loader/i386/xnu.c (table_aliases): Likewise. (devices): Likewise. * grub-core/loader/multiboot_mbi2.c (modules): Likewise. (modules_last): Likewise. * grub-core/normal/auth.c (users): Likewise. * grub-core/normal/context.c (initial_menu): Likewise. (current_menu): Likewise. * grub-core/normal/crypto.c (crypto_specs): Likewise. * grub-core/term/serial.c (grub_serial_ports): Likewise. (grub_serial_terminfo_input_template): Likewise. (grub_serial_terminfo_output_template): Likewise. (grub_serial_terminfo_input): Likewise. (grub_serial_terminfo_output): Likewise. (registered): Likewise. * grub-core/term/usb_keyboard.c (attach_hook): Likewise. --- ChangeLog | 33 +++++++++++++++++++++++++++ grub-core/bus/usb/usb.c | 2 +- grub-core/bus/usb/usbhub.c | 2 +- grub-core/commands/hashsum.c | 2 +- grub-core/commands/setpci.c | 2 +- grub-core/disk/usbms.c | 2 +- grub-core/fs/zfs/zfs.c | 4 ++-- grub-core/gettext/gettext.c | 2 +- grub-core/gfxmenu/gfxmenu.c | 2 +- grub-core/lib/legacy_parse.c | 2 +- grub-core/lib/relocator.c | 4 ++-- grub-core/loader/i386/bsd.c | 2 +- grub-core/loader/i386/multiboot_mbi.c | 2 +- grub-core/loader/i386/xnu.c | 4 ++-- grub-core/loader/multiboot_mbi2.c | 2 +- grub-core/normal/auth.c | 2 +- grub-core/normal/context.c | 4 ++-- grub-core/normal/crypto.c | 2 +- grub-core/term/serial.c | 12 +++++----- grub-core/term/usb_keyboard.c | 2 +- 20 files changed, 61 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20fdfc86c..9527a6e8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2011-03-23 Vladimir Serbinenko + + * grub-core/bus/usb/usb.c (attach_hooks): Make static. + * grub-core/bus/usb/usbhub.c (hubs): Likewise. + * grub-core/commands/hashsum.c (aliases): Likewise. + * grub-core/commands/setpci.c (pci_registers): Likewise. + * grub-core/disk/usbms.c (attach_hook): Likewise. + * grub-core/fs/zfs/zfs.c (decomp_table): Likewise. + (zio_checksum_table): Likewise. + * grub-core/gettext/gettext.c (grub_gettext_msg_list): Likewise. + * grub-core/gfxmenu/gfxmenu.c (cached_view): Likewise. + * grub-core/lib/legacy_parse.c (legacy_commands): Likewise. + * grub-core/lib/relocator.c (leftovers): Likewise. + (extra_blocks): Likewise. + * grub-core/loader/i386/bsd.c (relocator): Likewise. + * grub-core/loader/i386/multiboot_mbi.c (modules): Likewise. + (modules_last): Likewise. + * grub-core/loader/i386/xnu.c (table_aliases): Likewise. + (devices): Likewise. + * grub-core/loader/multiboot_mbi2.c (modules): Likewise. + (modules_last): Likewise. + * grub-core/normal/auth.c (users): Likewise. + * grub-core/normal/context.c (initial_menu): Likewise. + (current_menu): Likewise. + * grub-core/normal/crypto.c (crypto_specs): Likewise. + * grub-core/term/serial.c (grub_serial_ports): Likewise. + (grub_serial_terminfo_input_template): Likewise. + (grub_serial_terminfo_output_template): Likewise. + (grub_serial_terminfo_input): Likewise. + (grub_serial_terminfo_output): Likewise. + (registered): Likewise. + * grub-core/term/usb_keyboard.c (attach_hook): Likewise. + 2011-03-23 Vladimir Serbinenko * grub-core/video/bochs.c (grub_video_bochs_setup): Use diff --git a/grub-core/bus/usb/usb.c b/grub-core/bus/usb/usb.c index 2bd805ef2..70173b7ea 100644 --- a/grub-core/bus/usb/usb.c +++ b/grub-core/bus/usb/usb.c @@ -25,7 +25,7 @@ #include static grub_usb_controller_dev_t grub_usb_list; -struct grub_usb_attach_desc *attach_hooks; +static struct grub_usb_attach_desc *attach_hooks; void grub_usb_controller_dev_register (grub_usb_controller_dev_t usb) diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c index f08910d2b..492be914c 100644 --- a/grub-core/bus/usb/usbhub.c +++ b/grub-core/bus/usb/usbhub.c @@ -39,7 +39,7 @@ struct grub_usb_hub grub_usb_device_t dev; }; -struct grub_usb_hub *hubs; +static struct grub_usb_hub *hubs; /* Add a device that currently has device number 0 and resides on CONTROLLER, the Hub reported that the device speed is SPEED. */ diff --git a/grub-core/commands/hashsum.c b/grub-core/commands/hashsum.c index 8b6806e45..664fe9c24 100644 --- a/grub-core/commands/hashsum.c +++ b/grub-core/commands/hashsum.c @@ -36,7 +36,7 @@ static const struct grub_arg_option options[] = { {0, 0, 0, 0, 0, 0} }; -struct { const char *name; const char *hashname; } aliases[] = +static struct { const char *name; const char *hashname; } aliases[] = { {"sha256sum", "sha256"}, {"sha512sum", "sha512"}, diff --git a/grub-core/commands/setpci.c b/grub-core/commands/setpci.c index 7b194ed17..88dfa4c08 100644 --- a/grub-core/commands/setpci.c +++ b/grub-core/commands/setpci.c @@ -32,7 +32,7 @@ struct pci_register unsigned size; }; -struct pci_register pci_registers[] = +static struct pci_register pci_registers[] = { {"VENDOR_ID", GRUB_PCI_REG_VENDOR , 2}, {"DEVICE_ID", GRUB_PCI_REG_DEVICE , 2}, diff --git a/grub-core/disk/usbms.c b/grub-core/disk/usbms.c index e63105ccc..2e5d2459a 100644 --- a/grub-core/disk/usbms.c +++ b/grub-core/disk/usbms.c @@ -408,7 +408,7 @@ static struct grub_scsi_dev grub_usbms_dev = .write = grub_usbms_write }; -struct grub_usb_attach_desc attach_hook = +static struct grub_usb_attach_desc attach_hook = { .class = GRUB_USB_CLASS_MASS_STORAGE, .hook = grub_usbms_attach diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 3a94d8874..8e83ea0b5 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -161,7 +161,7 @@ struct grub_zfs_data grub_disk_addr_t vdev_phys_sector; }; -decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = { +static decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = { {"inherit", NULL}, /* ZIO_COMPRESS_INHERIT */ {"on", lzjb_decompress}, /* ZIO_COMPRESS_ON */ {"off", NULL}, /* ZIO_COMPRESS_OFF */ @@ -201,7 +201,7 @@ zio_checksum_off (const void *buf __attribute__ ((unused)), } /* Checksum Table and Values */ -zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = { +static zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = { {NULL, 0, 0, "inherit"}, {NULL, 0, 0, "on"}, {zio_checksum_off, 0, 0, "off"}, diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c index 5c7db4408..84937f19b 100644 --- a/grub-core/gettext/gettext.c +++ b/grub-core/gettext/gettext.c @@ -49,7 +49,7 @@ struct grub_gettext_msg const char *translated; }; -struct grub_gettext_msg *grub_gettext_msg_list = NULL; +static struct grub_gettext_msg *grub_gettext_msg_list = NULL; #define GETTEXT_MAGIC_NUMBER 0 #define GETTEXT_FILE_FORMAT 4 diff --git a/grub-core/gfxmenu/gfxmenu.c b/grub-core/gfxmenu/gfxmenu.c index 1acab9ca7..76d83c44b 100644 --- a/grub-core/gfxmenu/gfxmenu.c +++ b/grub-core/gfxmenu/gfxmenu.c @@ -37,7 +37,7 @@ #include #include -grub_gfxmenu_view_t cached_view; +static grub_gfxmenu_view_t cached_view; static void grub_gfxmenu_viewer_fini (void *data __attribute__ ((unused))) diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c index fe421af35..fb1a52bf8 100644 --- a/grub-core/lib/legacy_parse.c +++ b/grub-core/lib/legacy_parse.c @@ -58,7 +58,7 @@ struct legacy_command const char *longdesc; }; -struct legacy_command legacy_commands[] = +static struct legacy_command legacy_commands[] = { {"blocklist", "blocklist '%s'\n", NULL, 0, 1, {TYPE_FILE}, 0, "FILE", "Print the blocklist notation of the file FILE."}, diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index dbd5fe4d0..e1bb7b7ea 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -77,10 +77,10 @@ struct grub_relocator_fw_leftover grub_uint8_t freebytes[GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT / 8]; }; -struct grub_relocator_fw_leftover *leftovers; +static struct grub_relocator_fw_leftover *leftovers; #endif -struct grub_relocator_extra_block *extra_blocks; +static struct grub_relocator_extra_block *extra_blocks; void * get_virtual_current_address (grub_relocator_chunk_t in) diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index 08cdcda37..ecd5bd5cd 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -65,7 +65,7 @@ static void *kern_chunk_src; static grub_uint32_t bootflags; static int is_elf_kernel, is_64bit; static grub_uint32_t openbsd_root; -struct grub_relocator *relocator = NULL; +static struct grub_relocator *relocator = NULL; static struct grub_openbsd_ramdisk_descriptor openbsd_ramdisk; struct bsd_tag diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index b98bda223..14db50bcd 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -46,7 +46,7 @@ struct module int cmdline_size; }; -struct module *modules, *modules_last; +static struct module *modules, *modules_last; static grub_size_t cmdline_size; static grub_size_t total_modcmd; static unsigned modcnt; diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index a0df6f4aa..b877b0ea5 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -49,7 +49,7 @@ struct tbl_alias char *name; }; -struct tbl_alias table_aliases[] = +static struct tbl_alias table_aliases[] = { {GRUB_EFI_ACPI_20_TABLE_GUID, "ACPI_20"}, {GRUB_EFI_ACPI_TABLE_GUID, "ACPI"}, @@ -219,7 +219,7 @@ struct property_descriptor void *data; }; -struct grub_xnu_devprop_device_descriptor *devices = 0; +static struct grub_xnu_devprop_device_descriptor *devices = 0; grub_err_t grub_xnu_devprop_remove_property (struct grub_xnu_devprop_device_descriptor *dev, diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 3141f0028..05f581bb6 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -54,7 +54,7 @@ struct module int cmdline_size; }; -struct module *modules, *modules_last; +static struct module *modules, *modules_last; static grub_size_t cmdline_size; static grub_size_t total_modcmd; static unsigned modcnt; diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c index e5d187f0e..8e19568e2 100644 --- a/grub-core/normal/auth.c +++ b/grub-core/normal/auth.c @@ -34,7 +34,7 @@ struct grub_auth_user int authenticated; }; -struct grub_auth_user *users = NULL; +static struct grub_auth_user *users = NULL; grub_err_t grub_auth_register_authentication (const char *user, diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c index 108679913..581316603 100644 --- a/grub-core/normal/context.c +++ b/grub-core/normal/context.c @@ -31,8 +31,8 @@ struct menu_pointer struct menu_pointer *prev; }; -struct menu_pointer initial_menu; -struct menu_pointer *current_menu = &initial_menu; +static struct menu_pointer initial_menu; +static struct menu_pointer *current_menu = &initial_menu; void grub_env_unset_menu (void) diff --git a/grub-core/normal/crypto.c b/grub-core/normal/crypto.c index 465c9f81d..19dafd8a7 100644 --- a/grub-core/normal/crypto.c +++ b/grub-core/normal/crypto.c @@ -31,7 +31,7 @@ struct load_spec char *modname; }; -struct load_spec *crypto_specs = NULL; +static struct load_spec *crypto_specs = NULL; static void grub_crypto_autoload (const char *name) diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c index e672a89d6..32628dbae 100644 --- a/grub-core/term/serial.c +++ b/grub-core/term/serial.c @@ -41,7 +41,7 @@ static const struct grub_arg_option options[] = {0, 0, 0, 0, 0, 0} }; -struct grub_serial_port *grub_serial_ports; +static struct grub_serial_port *grub_serial_ports; struct grub_serial_output_state { @@ -69,7 +69,7 @@ serial_fetch (grub_term_input_t term) return data->port->driver->fetch (data->port); } -const struct grub_serial_input_state grub_serial_terminfo_input_template = +static const struct grub_serial_input_state grub_serial_terminfo_input_template = { .tinfo = { @@ -77,7 +77,7 @@ const struct grub_serial_input_state grub_serial_terminfo_input_template = } }; -const struct grub_serial_output_state grub_serial_terminfo_output_template = +static const struct grub_serial_output_state grub_serial_terminfo_output_template = { .tinfo = { @@ -87,11 +87,11 @@ const struct grub_serial_output_state grub_serial_terminfo_output_template = } }; -struct grub_serial_input_state grub_serial_terminfo_input; +static struct grub_serial_input_state grub_serial_terminfo_input; -struct grub_serial_output_state grub_serial_terminfo_output; +static struct grub_serial_output_state grub_serial_terminfo_output; -int registered = 0; +static int registered = 0; static struct grub_term_input grub_serial_term_input = { diff --git a/grub-core/term/usb_keyboard.c b/grub-core/term/usb_keyboard.c index 30ed8f9c2..23c0c10ca 100644 --- a/grub-core/term/usb_keyboard.c +++ b/grub-core/term/usb_keyboard.c @@ -435,7 +435,7 @@ grub_usb_keyboard_getkeystatus (struct grub_term_input *term) return interpret_status (termdata->status) | termdata->mods; } -struct grub_usb_attach_desc attach_hook = +static struct grub_usb_attach_desc attach_hook = { .class = GRUB_USB_CLASS_HID, .hook = grub_usb_keyboard_attach From d1611f0163f1915b1de994c2cc1bd5f315b16dae Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 12:08:33 +0100 Subject: [PATCH 139/276] * grub-core/efiemu/i386/pc/cfgtables.c (grub_machine_efiemu_init_tables): Make declaration a prototype. * grub-core/loader/xnu.c (grub_xnu_lock): Likewise. (grub_xnu_unlock): Likewise. * grub-core/normal/cmdline.c (grub_cmdline_get/cl_set_pos_all): Likewise. --- ChangeLog | 8 ++++++++ grub-core/efiemu/i386/pc/cfgtables.c | 2 +- grub-core/loader/xnu.c | 4 ++-- grub-core/normal/cmdline.c | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9527a6e8e..1f7de420e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-03-23 Vladimir Serbinenko + + * grub-core/efiemu/i386/pc/cfgtables.c + (grub_machine_efiemu_init_tables): Make declaration a prototype. + * grub-core/loader/xnu.c (grub_xnu_lock): Likewise. + (grub_xnu_unlock): Likewise. + * grub-core/normal/cmdline.c (grub_cmdline_get/cl_set_pos_all): Likewise. + 2011-03-23 Vladimir Serbinenko * grub-core/bus/usb/usb.c (attach_hooks): Make static. diff --git a/grub-core/efiemu/i386/pc/cfgtables.c b/grub-core/efiemu/i386/pc/cfgtables.c index 9287d3a94..7b6a40c87 100644 --- a/grub-core/efiemu/i386/pc/cfgtables.c +++ b/grub-core/efiemu/i386/pc/cfgtables.c @@ -24,7 +24,7 @@ #include grub_err_t -grub_machine_efiemu_init_tables () +grub_machine_efiemu_init_tables (void) { grub_uint8_t *ptr; void *table; diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index 5a84dea1c..73158fd10 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -1429,7 +1429,7 @@ grub_cmd_xnu_resume (grub_command_t cmd __attribute__ ((unused)), #endif void -grub_xnu_lock () +grub_xnu_lock (void) { if (!locked) grub_dl_ref (my_mod); @@ -1437,7 +1437,7 @@ grub_xnu_lock () } void -grub_xnu_unlock () +grub_xnu_unlock (void) { if (locked) grub_dl_unref (my_mod); diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c index b8c20d91c..09f2271ea 100644 --- a/grub-core/normal/cmdline.c +++ b/grub-core/normal/cmdline.c @@ -240,7 +240,7 @@ grub_cmdline_get (const char *prompt) grub_term_gotoxy (cl_term->term, cl_term->xpos, cl_term->ypos); } - void cl_set_pos_all () + void cl_set_pos_all (void) { unsigned i; for (i = 0; i < nterms; i++) From ed57e55702eac9ce24a8db0b4b7e5d40794a36a5 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 12:13:39 +0100 Subject: [PATCH 140/276] * grub-core/bus/usb/uhci.c (grub_uhci_detect_dev): Return GRUB_USB_SPEED_NONE in case of failure and not the error code. --- ChangeLog | 5 +++++ grub-core/bus/usb/uhci.c | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1f7de420e..d1d946075 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-23 Vladimir Serbinenko + + * grub-core/bus/usb/uhci.c (grub_uhci_detect_dev): Return + GRUB_USB_SPEED_NONE in case of failure and not the error code. + 2011-03-23 Vladimir Serbinenko * grub-core/efiemu/i386/pc/cfgtables.c diff --git a/grub-core/bus/usb/uhci.c b/grub-core/bus/usb/uhci.c index d082beac4..71142846b 100644 --- a/grub-core/bus/usb/uhci.c +++ b/grub-core/bus/usb/uhci.c @@ -749,8 +749,7 @@ grub_uhci_detect_dev (grub_usb_controller_t dev, int port, int *changed) else if (port == 1) reg = GRUB_UHCI_REG_PORTSC2; else - return grub_error (GRUB_ERR_OUT_OF_RANGE, - "UHCI Root Hub port does not exist"); + return GRUB_USB_SPEED_NONE; status = grub_uhci_readreg16 (u, reg); From 2e3e2e09081afd7b50391182401c7c90f8a9e9c7 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 12:17:05 +0100 Subject: [PATCH 141/276] * grub-core/bus/usb/usbtrans.c (grub_usb_control_msg): Return usb-style error and not grub_errno. * grub-core/bus/usb/usbhub.c (grub_usb_add_hub): Likewise. --- ChangeLog | 6 ++++++ grub-core/bus/usb/usbtrans.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1d946075..87f78e0bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-23 Vladimir Serbinenko + + * grub-core/bus/usb/usbtrans.c (grub_usb_control_msg): Return usb-style + error and not grub_errno. + * grub-core/bus/usb/usbhub.c (grub_usb_add_hub): Likewise. + 2011-03-23 Vladimir Serbinenko * grub-core/bus/usb/uhci.c (grub_uhci_detect_dev): Return diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c index ebb8a2eb6..167fae5a2 100644 --- a/grub-core/bus/usb/usbtrans.c +++ b/grub-core/bus/usb/usbtrans.c @@ -97,7 +97,7 @@ grub_usb_control_msg (grub_usb_device_t dev, if (! transfer) { grub_dma_free (data_chunk); - return grub_errno; + return GRUB_USB_ERR_INTERNAL; } setupdata_chunk = grub_memalign_dma32 (32, sizeof (*setupdata)); @@ -105,7 +105,7 @@ grub_usb_control_msg (grub_usb_device_t dev, { grub_free (transfer); grub_dma_free (data_chunk); - return grub_errno; + return GRUB_USB_ERR_INTERNAL; } setupdata = grub_dma_get_virt (setupdata_chunk); @@ -139,7 +139,7 @@ grub_usb_control_msg (grub_usb_device_t dev, grub_free (transfer); grub_dma_free (setupdata_chunk); grub_dma_free (data_chunk); - return grub_errno; + return GRUB_USB_ERR_INTERNAL; } /* Build a Setup packet. XXX: Endianness. */ From e804e7b099ca8cf2feddd92682ba617423159afa Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 12:18:21 +0100 Subject: [PATCH 142/276] missing file in last change --- grub-core/bus/usb/usbhub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c index 492be914c..82bb2da1c 100644 --- a/grub-core/bus/usb/usbhub.c +++ b/grub-core/bus/usb/usbhub.c @@ -110,7 +110,7 @@ static grub_usb_err_t grub_usb_add_hub (grub_usb_device_t dev) { struct grub_usb_usb_hubdesc hubdesc; - grub_err_t err; + grub_usb_err_t err; int i; err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN From b1d2840445c6b471e600f7d6177b6fc56bffc666 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 12:21:15 +0100 Subject: [PATCH 143/276] * grub-core/disk/usbms.c (grub_usbms_reset): Transform USB-style error into GRUB-style one. --- ChangeLog | 5 +++++ grub-core/disk/usbms.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 87f78e0bd..20a83dd84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-23 Vladimir Serbinenko + + * grub-core/disk/usbms.c (grub_usbms_reset): Transform USB-style error + into GRUB-style one. + 2011-03-23 Vladimir Serbinenko * grub-core/bus/usb/usbtrans.c (grub_usb_control_msg): Return usb-style diff --git a/grub-core/disk/usbms.c b/grub-core/disk/usbms.c index 2e5d2459a..fcfe9e5d4 100644 --- a/grub-core/disk/usbms.c +++ b/grub-core/disk/usbms.c @@ -70,7 +70,11 @@ static int first_available_slot = 0; static grub_err_t grub_usbms_reset (grub_usb_device_t dev, int interface) { - return grub_usb_control_msg (dev, 0x21, 255, 0, interface, 0, 0); + grub_usb_err_t u; + u = grub_usb_control_msg (dev, 0x21, 255, 0, interface, 0, 0); + if (u) + return grub_error (GRUB_ERR_IO, "USB error %d", u); + return GRUB_ERR_NONE; } static void From fa3e01bfb5710c13daf92e0d107ae9ac39991209 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 12:23:42 +0100 Subject: [PATCH 144/276] * grub-core/lib/i386/pc/biosnum.c: Add missing include. --- ChangeLog | 4 ++++ grub-core/lib/i386/pc/biosnum.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 20a83dd84..ac149aeaa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-23 Vladimir Serbinenko + + * grub-core/lib/i386/pc/biosnum.c: Add missing include. + 2011-03-23 Vladimir Serbinenko * grub-core/disk/usbms.c (grub_usbms_reset): Transform USB-style error diff --git a/grub-core/lib/i386/pc/biosnum.c b/grub-core/lib/i386/pc/biosnum.c index 058c9d331..12771085a 100644 --- a/grub-core/lib/i386/pc/biosnum.c +++ b/grub-core/lib/i386/pc/biosnum.c @@ -19,6 +19,7 @@ #include #include #include +#include static int grub_get_root_biosnumber_default (void) From 537dc9bec6da41353c0df219a58cb378f0484091 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 12:40:15 +0100 Subject: [PATCH 145/276] * grub-core/normal/main.c (GRUB_MOD_INIT): Export pager variable. --- ChangeLog | 4 ++++ grub-core/normal/main.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index ac149aeaa..a6afeac29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-23 Vladimir Serbinenko + + * grub-core/normal/main.c (GRUB_MOD_INIT): Export pager variable. + 2011-03-23 Vladimir Serbinenko * grub-core/lib/i386/pc/biosnum.c: Add missing include. diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index 69bf5e6b5..cefb1cb9b 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -496,6 +496,7 @@ GRUB_MOD_INIT(normal) grub_set_history (GRUB_DEFAULT_HISTORY_SIZE); grub_register_variable_hook ("pager", 0, grub_env_write_pager); + grub_env_export ("pager"); /* Register a command "normal" for the rescue mode. */ grub_register_command ("normal", grub_cmd_normal, From bae7fcc1ed5ac86f54f99f8033fa1980ad8a54dd Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 23 Mar 2011 13:01:42 +0100 Subject: [PATCH 146/276] Fix incorrect assert failure reporting. * grub-core/tests/example_functional_test.c (example_test): Add a failure comment. * grub-core/tests/lib/test.c (add_failure): Renamed to ... (failure_start): ...this. Check that malloc succeeded. Don't call xvasprintf. Return failure struct. (failure_append_vtext): New function. (failure_append_text): Likewise. (add_failure): Likewise. (grub_test_assert_helper): Likewise. * include/grub/test.h (grub_test_assert_helper): New declaration. (grub_test_assert): Macro rewritten. --- ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index a6afeac29..99cae9ba5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2011-03-23 Peter Jones + + Fix incorrect assert failure reporting. + + * grub-core/tests/example_functional_test.c (example_test): Add + a failure comment. + * grub-core/tests/lib/test.c (add_failure): Renamed to ... + (failure_start): ...this. Check that malloc succeeded. + Don't call xvasprintf. Return failure struct. + (failure_append_vtext): New function. + (failure_append_text): Likewise. + (add_failure): Likewise. + (grub_test_assert_helper): Likewise. + * include/grub/test.h (grub_test_assert_helper): New declaration. + (grub_test_assert): Macro rewritten. + 2011-03-23 Vladimir Serbinenko * grub-core/normal/main.c (GRUB_MOD_INIT): Export pager variable. From bd4d051a9517992ddcc291110ba52dd9efe743e8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 13:23:50 +0100 Subject: [PATCH 147/276] * grub-core/script/parser.y: Declare "time" as valid argument. --- ChangeLog | 4 ++++ grub-core/script/parser.y | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 99cae9ba5..3330a357b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-23 Vladimir Serbinenko + + * grub-core/script/parser.y: Declare "time" as valid argument. + 2011-03-23 Peter Jones Fix incorrect assert failure reporting. diff --git a/grub-core/script/parser.y b/grub-core/script/parser.y index 88c7fe9e3..683b3ac4b 100644 --- a/grub-core/script/parser.y +++ b/grub-core/script/parser.y @@ -147,6 +147,7 @@ argument : "case" { $$ = grub_script_add_arglist (state, 0, $1); } | "until" { $$ = grub_script_add_arglist (state, 0, $1); } | "while" { $$ = grub_script_add_arglist (state, 0, $1); } | "function" { $$ = grub_script_add_arglist (state, 0, $1); } + | "time" { $$ = grub_script_add_arglist (state, 0, $1); } | word { $$ = $1; } ; From 59e1e5f17ba434d6fbf66de4014471f01c1c00e2 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 14:18:56 +0100 Subject: [PATCH 148/276] * grub-core/normal/menu_entry.c (init_line): Fix off-by-one error. --- ChangeLog | 4 ++++ grub-core/normal/menu_entry.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3330a357b..c7bc69f58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-23 Vladimir Serbinenko + + * grub-core/normal/menu_entry.c (init_line): Fix off-by-one error. + 2011-03-23 Vladimir Serbinenko * grub-core/script/parser.y: Declare "time" as valid argument. diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index e744d8d69..94f6e7f32 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -87,7 +87,7 @@ init_line (struct line *linep) { linep->len = 0; linep->max_len = 80; /* XXX */ - linep->buf = grub_malloc (linep->max_len); + linep->buf = grub_malloc (linep->max_len + 1); if (! linep->buf) return 0; From ebad0b81be1e6cd148688bcb0c4192b1923a51d0 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 23 Mar 2011 14:45:04 +0000 Subject: [PATCH 149/276] remove unused variable --- grub-core/kern/emu/getroot.c | 1 - 1 file changed, 1 deletion(-) diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index 601ac8b04..71b9a3c50 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -131,7 +131,6 @@ grub_find_root_device_from_mountinfo (const char *dir, char **relroot) size_t enc_path_len; const char *sep; char fstype[PATH_MAX], device[PATH_MAX]; - struct stat st; if (sscanf (buf, "%d %d %u:%u %s %s%n", &mnt_id, &parent_mnt_id, &major, &minor, enc_root, enc_path, From 41a85f5508774c85e569917a0e9f6d5371b055a3 Mon Sep 17 00:00:00 2001 From: Alexander Kurtz Date: Wed, 23 Mar 2011 17:08:56 +0100 Subject: [PATCH 150/276] * grub-core/video/bitmap.c (match_extension): Ignore case. --- ChangeLog | 4 ++++ grub-core/video/bitmap.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c7bc69f58..e462dddc0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-23 Alexander Kurtz + + * grub-core/video/bitmap.c (match_extension): Ignore case. + 2011-03-23 Vladimir Serbinenko * grub-core/normal/menu_entry.c (init_line): Fix off-by-one error. diff --git a/grub-core/video/bitmap.c b/grub-core/video/bitmap.c index e06a5b696..659ab9a57 100644 --- a/grub-core/video/bitmap.c +++ b/grub-core/video/bitmap.c @@ -177,7 +177,7 @@ match_extension (const char *filename, const char *ext) pos -= ext_len; - return grub_strcmp (filename + pos, ext) == 0; + return grub_strcasecmp (filename + pos, ext) == 0; } /* Loads bitmap using registered bitmap readers. */ From 5657722c3c59ad45f3bebf9dae1f881a0e5e0186 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 23 Mar 2011 20:29:17 +0100 Subject: [PATCH 151/276] * grub-core/term/gfxterm.c (calculate_normal_character_width): Return 8 if no ASCII character is found to prevent crash. --- ChangeLog | 5 +++++ grub-core/term/gfxterm.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index e462dddc0..6e59b97ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-23 Vladimir Serbinenko + + * grub-core/term/gfxterm.c (calculate_normal_character_width): Return 8 + if no ASCII character is found to prevent crash. + 2011-03-23 Alexander Kurtz * grub-core/video/bitmap.c (match_extension): Ignore case. diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c index 9a10d47b0..321479e0a 100644 --- a/grub-core/term/gfxterm.c +++ b/grub-core/term/gfxterm.c @@ -945,6 +945,8 @@ calculate_normal_character_width (grub_font_t font) if (glyph->device_width > width) width = glyph->device_width; } + if (!width) + return 8; return width; } From 8bc66a2ce617da1b721f7beebe8b0b164e733ae6 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Mar 2011 12:28:22 +0100 Subject: [PATCH 152/276] * grub-core/loader/i386/bsdXX.c (grub_freebsd_load_elfmodule): Account for modules headers when counting the needed allocation size. --- ChangeLog | 5 +++++ grub-core/loader/i386/bsdXX.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6e59b97ae..61adf1e26 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-24 Vladimir Serbinenko + + * grub-core/loader/i386/bsdXX.c (grub_freebsd_load_elfmodule): Account + for modules headers when counting the needed allocation size. + 2011-03-23 Vladimir Serbinenko * grub-core/term/gfxterm.c (calculate_normal_character_width): Return 8 diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 5b9e7689e..92d267534 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -195,6 +195,11 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, chunk_size = s->sh_addr + s->sh_size; } + if (chunk_size < sizeof (e)) + chunk_size = sizeof (e); + chunk_size += e.e_phnum * e.e_phentsize; + chunk_size += e.e_shnum * e.e_shentsize; + { grub_relocator_chunk_t ch; From ef6de21af47aba0485951dac352ea6cadcb18535 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Mar 2011 12:39:48 +0100 Subject: [PATCH 153/276] * grub-core/lib/relocator.c (allocate_inreg): Avoid dprintf unless DEBUG_RELOCATOR is defined since gfxterm can't cope with output when malloc is disabled. --- ChangeLog | 6 ++++++ grub-core/lib/relocator.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 61adf1e26..2cdeb6dc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-24 Vladimir Serbinenko + + * grub-core/lib/relocator.c (allocate_inreg): Avoid dprintf unless + DEBUG_RELOCATOR is defined since gfxterm can't cope with output when + malloc is disabled. + 2011-03-24 Vladimir Serbinenko * grub-core/loader/i386/bsdXX.c (grub_freebsd_load_elfmodule): Account diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index e1bb7b7ea..421054176 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -200,10 +200,12 @@ allocate_inreg (grub_phys_addr_t paddr, grub_size_t size, struct grub_mm_header *foll = NULL; grub_addr_t vaddr = (grub_addr_t) hb + (paddr - grub_vtop (hb)); +#ifdef DEBUG_RELOCATOR grub_dprintf ("relocator", "inreg paddr = 0x%lx, size = %lu," " hb = %p, hbp = %p, rb = %p, vaddr = 0x%lx\n", (unsigned long) paddr, (unsigned long) size, hb, hbp, rb, (unsigned long) vaddr); +#endif if (ALIGN_UP (vaddr + size, GRUB_MM_ALIGN) + GRUB_MM_ALIGN <= (grub_addr_t) (hb + hb->size)) From 3f71cded814d7938bbb4e0d5bfa3b51440e3ffe4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Mar 2011 12:43:28 +0100 Subject: [PATCH 154/276] * include/grub/mm.h (GRUB_MM_CHECK): Rename to ... (grub_mm_check): ... this. MAke a function-like macro and use GRUB_FILE. --- ChangeLog | 5 +++++ include/grub/mm.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2cdeb6dc4..cfce9988b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-24 Vladimir Serbinenko + + * include/grub/mm.h (GRUB_MM_CHECK): Rename to ... + (grub_mm_check): ... this. MAke a function-like macro and use GRUB_FILE. + 2011-03-24 Vladimir Serbinenko * grub-core/lib/relocator.c (allocate_inreg): Avoid dprintf unless diff --git a/include/grub/mm.h b/include/grub/mm.h index cc115907a..047006944 100644 --- a/include/grub/mm.h +++ b/include/grub/mm.h @@ -36,7 +36,7 @@ void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size); void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size); void grub_mm_check_real (char *file, int line); -#define GRUB_MM_CHECK grub_mm_check_real (__FILE__, __LINE__); +#define grub_mm_check() grub_mm_check_real (GRUB_FILE, __LINE__); /* For debugging. */ #if defined(MM_DEBUG) && !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) From c7064d94250a9f9b78e5a08a44837626293fe596 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 24 Mar 2011 12:45:51 +0100 Subject: [PATCH 155/276] * grub-core/lib/relocator.c (grub_relocator_alloc_chunk_addr) [DEBUG_RELOCATOR]: Reuse grub_mm_check. (grub_relocator_alloc_chunk_align) [DEBUG_RELOCATOR]: Likewise. --- ChangeLog | 6 ++++++ grub-core/lib/relocator.c | 39 ++++----------------------------------- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index cfce9988b..8744dbff3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-24 Vladimir Serbinenko + + * grub-core/lib/relocator.c (grub_relocator_alloc_chunk_addr) + [DEBUG_RELOCATOR]: Reuse grub_mm_check. + (grub_relocator_alloc_chunk_align) [DEBUG_RELOCATOR]: Likewise. + 2011-03-24 Vladimir Serbinenko * include/grub/mm.h (GRUB_MM_CHECK): Rename to ... diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index 421054176..7d29ab5cc 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -1284,23 +1284,8 @@ grub_relocator_alloc_chunk_addr (struct grub_relocator *rel, chunk->srcv = grub_map_memory (chunk->src, chunk->size); *out = chunk; #ifdef DEBUG_RELOCATOR - { - grub_mm_region_t r; - grub_mm_header_t p; - grub_memset (chunk->srcv, 0xfa, chunk->size); - for (r = grub_mm_base; r; r = r->next) - { - p = r->first; - do - { - if ((grub_addr_t) p < (grub_addr_t) (r + 1) - || (grub_addr_t) p >= (grub_addr_t) (r + 1) + r->size) - grub_fatal (__FILE__ ":%d: out of range pointer: %p\n", __LINE__, p); - p = p->next; - } - while (p != r->first); - } - } + grub_memset (chunk->srcv, 0xfa, chunk->size); + grub_mm_check (); #endif return GRUB_ERR_NONE; } @@ -1438,24 +1423,8 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel, chunk->srcv = grub_map_memory (chunk->src, chunk->size); *out = chunk; #ifdef DEBUG_RELOCATOR - { - grub_mm_region_t r; - grub_mm_header_t p; - - grub_memset (chunk->srcv, 0xfa, chunk->size); - for (r = grub_mm_base; r; r = r->next) - { - p = r->first; - do - { - if ((grub_addr_t) p < (grub_addr_t) (r + 1) - || (grub_addr_t) p >= (grub_addr_t) (r + 1) + r->size) - grub_fatal (__FILE__ "%d: out of range pointer: %p\n", __LINE__, p); - p = p->next; - } - while (p != r->first); - } - } + grub_memset (chunk->srcv, 0xfa, chunk->size); + grub_mm_check (); #endif return GRUB_ERR_NONE; } From 4c6c9431d2f72d6b7397a39e81e0112a01e3ec97 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 25 Mar 2011 00:03:54 +0000 Subject: [PATCH 156/276] * grub-core/video/fb/video_fb.c (grub_video_fb_get_info_and_fini): Switch back to page zero before loading a kernel, since some kernel drivers expect that. Thanks to: Felix Kuehling. --- ChangeLog | 7 +++++++ grub-core/video/fb/video_fb.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8744dbff3..b556c77e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-03-24 Colin Watson + + * grub-core/video/fb/video_fb.c (grub_video_fb_get_info_and_fini): + Switch back to page zero before loading a kernel, since some kernel + drivers expect that. + Thanks to: Felix Kuehling. + 2011-03-24 Vladimir Serbinenko * grub-core/lib/relocator.c (grub_relocator_alloc_chunk_addr) diff --git a/grub-core/video/fb/video_fb.c b/grub-core/video/fb/video_fb.c index 69626be5c..768b63328 100644 --- a/grub-core/video/fb/video_fb.c +++ b/grub-core/video/fb/video_fb.c @@ -1505,6 +1505,20 @@ grub_video_fb_get_info_and_fini (struct grub_video_mode_info *mode_info, { grub_memcpy (mode_info, &(framebuffer.front_target->mode_info), sizeof (*mode_info)); + + /* We are about to load a kernel. Switch back to page zero, since some + kernel drivers expect that. */ + if ((mode_info->mode_type & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED) + && framebuffer.set_page && framebuffer.displayed_page != 0) + { + /* Ensure both pages are exactly in sync. */ + grub_memcpy (framebuffer.back_target->data, + framebuffer.front_target->data, + framebuffer.back_target->mode_info.pitch + * framebuffer.back_target->mode_info.height); + grub_video_swap_buffers (); + } + *framebuf = framebuffer.front_target->data; grub_video_fb_fini (); From 82fe6c751bb32337045a57a18f2bb1f05c91d47b Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 26 Mar 2011 12:49:34 +0100 Subject: [PATCH 157/276] Fix FreeBSD compilation problem. * grub-core/kern/emu/hostdisk.c (MAJOR) [FreeBSD]: New definition. (FLOPPY_MAJOR) [FreeBSD]: Likewise. --- ChangeLog | 7 +++++++ grub-core/kern/emu/hostdisk.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index b556c77e8..bf69511a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-03-26 Vladimir Serbinenko + + Fix FreeBSD compilation problem. + + * grub-core/kern/emu/hostdisk.c (MAJOR) [FreeBSD]: New definition. + (FLOPPY_MAJOR) [FreeBSD]: Likewise. + 2011-03-24 Colin Watson * grub-core/video/fb/video_fb.c (grub_video_fb_get_info_and_fini): diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 12dbe7469..b4f51da0f 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -92,6 +92,8 @@ struct hd_geometry # include /* DIOCGMEDIASIZE */ # include # include +# define MAJOR(dev) major(dev) +# define FLOPPY_MAJOR 2 #endif #if defined(__APPLE__) From f4727da93f55ba7a959848117b4c9db9afaba3ff Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 26 Mar 2011 12:59:02 +0100 Subject: [PATCH 158/276] Use libgeom on FreeBSD to detect partitions. * Makefile.util.def (grub-mkimage): Add LIBGEOM to ldadd. (grub-mkrelpath): Likewise. (grub-script-check): Likewise. (grub-editenv): Likewise. (grub-mkpasswd-pbkdf2): Likewise. (grub-fstest): Likewise. (grub-mkfont): Likewise. (grub-mkdevicemap): Likewise. (grub-probe): Likewise. (grub-setup): Likewise. (grub-ofpathname): Likewise. (grub-mklayout): Likewise. (example_unit_test): Likewise. (grub-menulst2cfg): Likewise. * grub-core/Makefile.core.def (grub-emu): Likewise. (grub-emu-lite): Likewise. * configure.ac: Check for -lgeom on FreeBSD and set LIBGEOM. * grub-core/kern/emu/hostdisk.c [FreeBSD]: Include libgeom.h. Don't define HAVE_DIOCGDINFO. (follow_geom_up) [FreeBSD]: New function. (find_partition_start) [FreeBSD]: Rewritten using follow_geom_up. (convert_system_partition_to_system_disk) [FreeBSD]: Likewise. (grub_util_biosdisk_get_grub_dev) [FreeBSD]: Use FreeBSD path unconditionally of HAVE_DIOCGDINFO. --- ChangeLog | 29 +++++++++++++ Makefile.util.def | 28 ++++++------ configure.ac | 9 ++++ grub-core/Makefile.core.def | 4 +- grub-core/kern/emu/hostdisk.c | 82 +++++++++++++++++++++++++++++++++-- 5 files changed, 132 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf69511a5..0d902ecd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2011-03-26 Vladimir Serbinenko + + Use libgeom on FreeBSD to detect partitions. + + * Makefile.util.def (grub-mkimage): Add LIBGEOM to ldadd. + (grub-mkrelpath): Likewise. + (grub-script-check): Likewise. + (grub-editenv): Likewise. + (grub-mkpasswd-pbkdf2): Likewise. + (grub-fstest): Likewise. + (grub-mkfont): Likewise. + (grub-mkdevicemap): Likewise. + (grub-probe): Likewise. + (grub-setup): Likewise. + (grub-ofpathname): Likewise. + (grub-mklayout): Likewise. + (example_unit_test): Likewise. + (grub-menulst2cfg): Likewise. + * grub-core/Makefile.core.def (grub-emu): Likewise. + (grub-emu-lite): Likewise. + * configure.ac: Check for -lgeom on FreeBSD and set LIBGEOM. + * grub-core/kern/emu/hostdisk.c [FreeBSD]: Include libgeom.h. Don't + define HAVE_DIOCGDINFO. + (follow_geom_up) [FreeBSD]: New function. + (find_partition_start) [FreeBSD]: Rewritten using follow_geom_up. + (convert_system_partition_to_system_disk) [FreeBSD]: Likewise. + (grub_util_biosdisk_get_grub_dev) [FreeBSD]: Use FreeBSD path + unconditionally of HAVE_DIOCGDINFO. + 2011-03-26 Vladimir Serbinenko Fix FreeBSD compilation problem. diff --git a/Makefile.util.def b/Makefile.util.def index 74984e2e9..303baea3f 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -122,7 +122,7 @@ program = { ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; ldadd = '$(LIBLZMA)'; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; cppflags = '-DGRUB_PKGLIBROOTDIR=\"$(pkglibrootdir)\"'; }; @@ -135,7 +135,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; program = { @@ -147,7 +147,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; program = { @@ -159,7 +159,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; program = { @@ -171,7 +171,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; cflags = '$(CFLAGS_GCRY)'; cppflags = '$(CPPFLAGS_GCRY)'; }; @@ -209,7 +209,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; program = { @@ -224,7 +224,7 @@ program = { ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; ldadd = '$(freetype_libs)'; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; condition = COND_GRUB_MKFONT; }; @@ -243,7 +243,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; program = { @@ -255,7 +255,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; program = { @@ -272,7 +272,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; enable = i386_pc; enable = sparc64_ieee1275; @@ -287,7 +287,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBGEOM)'; enable = sparc64_ieee1275; }; @@ -301,7 +301,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; data = { @@ -611,7 +611,7 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; program = { @@ -624,5 +624,5 @@ program = { ldadd = libgrubmods.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; diff --git a/configure.ac b/configure.ac index c660ac41e..f9e974bca 100644 --- a/configure.ac +++ b/configure.ac @@ -890,6 +890,15 @@ fi AC_SUBST([LIBDEVMAPPER]) +LIBGEOM= +if test x$host_kernel = xkfreebsd; then + AC_CHECK_LIB([geom], [geom_gettree], [], + [AC_MSG_ERROR([Your platform requires libgeom])]) + LIBGEOM="-lgeom" +fi + +AC_SUBST([LIBGEOM]) + AC_CHECK_LIB([lzma], [lzma_code], [LIBLZMA="-llzma" AC_DEFINE([HAVE_LIBLZMA], [1], diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index ce7d0b0c2..7c26b37e9 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -200,7 +200,7 @@ program = { ldadd = 'kernel.img$(EXEEXT)'; ldadd = '$(MODULE_FILES)'; - ldadd = '$(LIBUTIL) $(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBUTIL) $(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; enable = emu; }; @@ -212,7 +212,7 @@ program = { emu_nodist = symlist.c; ldadd = 'kernel.img$(EXEEXT)'; - ldadd = '$(LIBUTIL) $(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)'; + ldadd = '$(LIBUTIL) $(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; enable = emu; }; diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index b4f51da0f..73d023ce9 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -104,7 +104,9 @@ struct hd_geometry # include #endif -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#include +#elif defined(__NetBSD__) # define HAVE_DIOCGDINFO # include # include /* struct disklabel */ @@ -339,7 +341,68 @@ device_is_mapped (const char *dev) } #endif /* HAVE_DEVICE_MAPPER */ -#if defined(__linux__) || defined(__CYGWIN__) || defined(HAVE_DIOCGDINFO) +#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) +/* FIXME: geom actually gives us the whole container hierarchy. + It can be used more efficiently than this. */ +static void +follow_geom_up (const char *name, grub_disk_addr_t *off_out, char **name_out) +{ + struct gmesh mesh; + struct gclass *class; + int error; + struct ggeom *geom; + + grub_util_info ("following geom '%s'", name); + + error = geom_gettree (&mesh); + if (error != 0) + grub_util_error ("couldn't open geom"); + + LIST_FOREACH (class, &mesh.lg_class, lg_class) + if (strcasecmp (class->lg_name, "part") == 0) + break; + if (!class) + grub_util_error ("couldn't open geom part"); + + LIST_FOREACH (geom, &class->lg_geom, lg_geom) + { + struct gprovider *provider; + LIST_FOREACH (provider, &geom->lg_provider, lg_provider) + if (strcmp (provider->lg_name, name) == 0) + { + char *name_tmp = xstrdup (geom->lg_name); + grub_disk_addr_t off = 0; + struct gconfig *config; + grub_util_info ("geom '%s' has parent '%s'", name, geom->lg_name); + + follow_geom_up (name_tmp, &off, name_out); + free (name_tmp); + LIST_FOREACH (config, &provider->lg_config, lg_config) + if (strcasecmp (config->lg_name, "start") == 0) + off += strtoull (config->lg_val, 0, 10); + if (off_out) + *off_out = off; + return; + } + } + grub_util_info ("geom '%s' has no parent", name); + if (name_out) + *name_out = xstrdup (name); + if (off_out) + *off_out = 0; +} + +static grub_disk_addr_t +find_partition_start (const char *dev) +{ + grub_disk_addr_t out; + if (strncmp (dev, "/dev/", sizeof ("/dev/") - 1) != 0) + return 0; + follow_geom_up (dev + sizeof ("/dev/") - 1, &out, NULL); + + return out; +} +#elif defined(__linux__) || defined(__CYGWIN__) || defined(HAVE_DIOCGDINFO) static grub_disk_addr_t find_partition_start (const char *dev) { @@ -1286,7 +1349,17 @@ devmapper_out: path[8] = 0; return path; -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + char *out, *out2; + if (strncmp (os_dev, "/dev/", sizeof ("/dev/") - 1) != 0) + return xstrdup (os_dev); + follow_geom_up (os_dev + sizeof ("/dev/") - 1, NULL, &out); + + out2 = xasprintf ("/dev/%s", out); + free (out); + + return out2; +#elif defined(__APPLE__) char *path = xstrdup (os_dev); if (strncmp ("/dev/", path, 5) == 0) { @@ -1464,7 +1537,8 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) #endif return make_device_name (drive, -1, -1); -#if defined(__linux__) || defined(__CYGWIN__) || defined(HAVE_DIOCGDINFO) +#if defined(__linux__) || defined(__CYGWIN__) || defined(HAVE_DIOCGDINFO) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + /* Linux counts partitions uniformly, whether a BSD partition or a DOS partition, so mapping them to GRUB devices is not trivial. Here, get the start sector of a partition by HDIO_GETGEO, and From 5ee04984d113205aa413eb9b36164d4d2543aa88 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 26 Mar 2011 14:14:59 +0100 Subject: [PATCH 159/276] * grub-core/fs/iso9660.c (grub_iso9660_label): Rtrim the label. --- ChangeLog | 4 ++++ grub-core/fs/iso9660.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0d902ecd6..741f0f013 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-26 Vladimir Serbinenko + + * grub-core/fs/iso9660.c (grub_iso9660_label): Rtrim the label. + 2011-03-26 Vladimir Serbinenko Use libgeom on FreeBSD to detect partitions. diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c index 6dc465f25..f72249d20 100644 --- a/grub-core/fs/iso9660.c +++ b/grub-core/fs/iso9660.c @@ -808,6 +808,15 @@ grub_iso9660_label (grub_device_t device, char **label) ((grub_uint16_t *) &data->voldesc.volname, 16); else *label = grub_strndup ((char *) data->voldesc.volname, 32); + if (*label) + { + char *ptr; + for (ptr = *label; *ptr;ptr++); + ptr--; + while (ptr >= *label && *ptr == ' ') + *ptr-- = 0; + } + grub_free (data); } else From c482ad98b370a53f2eac04eec824903ba1a557e6 Mon Sep 17 00:00:00 2001 From: Seth Goldberg Date: Sat, 26 Mar 2011 23:22:59 +0100 Subject: [PATCH 160/276] * grub-core/kern/emu/getroot.c (find_root_device_from_libzfs): Don't return freed string. --- ChangeLog | 5 +++++ grub-core/kern/emu/getroot.c | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 741f0f013..39ec5742e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-26 Seth Goldberg + + * grub-core/kern/emu/getroot.c (find_root_device_from_libzfs): Don't + return freed string. + 2011-03-26 Vladimir Serbinenko * grub-core/fs/iso9660.c (grub_iso9660_label): Rtrim the label. diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index 110e58b14..1d87442d9 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -184,7 +184,7 @@ find_root_device_from_mountinfo (const char *dir) static char * find_root_device_from_libzfs (const char *dir) { - char *device; + char *device = NULL; char *poolname; char *poolfs; @@ -225,7 +225,10 @@ find_root_device_from_libzfs (const char *dir) struct stat st; if (stat (device, &st) == 0) - break; + { + device = xstrdup (device); + break; + } device = NULL; } From f329eda79eb0340e148f6c827c910c317e083822 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 28 Mar 2011 13:23:54 +0100 Subject: [PATCH 161/276] * grub-core/disk/raid.c (grub_raid_register): Adjust debug message to be specific about what kind of RAID device we're scanning for. --- ChangeLog | 5 +++++ grub-core/disk/raid.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 39ec5742e..24b608417 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-28 Colin Watson + + * grub-core/disk/raid.c (grub_raid_register): Adjust debug message + to be specific about what kind of RAID device we're scanning for. + 2011-03-26 Seth Goldberg * grub-core/kern/emu/getroot.c (find_root_device_from_libzfs): Don't diff --git a/grub-core/disk/raid.c b/grub-core/disk/raid.c index 3972e1632..9d2468b88 100644 --- a/grub-core/disk/raid.c +++ b/grub-core/disk/raid.c @@ -696,7 +696,8 @@ grub_raid_register (grub_raid_t raid) struct grub_raid_array array; grub_disk_addr_t start_sector; - grub_dprintf ("raid", "Scanning for RAID devices on disk %s\n", name); + grub_dprintf ("raid", "Scanning for %s RAID devices on disk %s\n", + grub_raid_list->name, name); disk = grub_disk_open (name); if (!disk) From 24148725381450cc2dd2b4a19a0b496d22a304ba Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 28 Mar 2011 15:17:22 +0100 Subject: [PATCH 162/276] * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Remove stale comment. --- ChangeLog | 5 +++++ grub-core/disk/mdraid1x_linux.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 24b608417..d6afea1d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-28 Colin Watson + + * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Remove stale + comment. + 2011-03-28 Colin Watson * grub-core/disk/raid.c (grub_raid_register): Adjust debug message diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c index f2e7555cb..296d1375b 100644 --- a/grub-core/disk/mdraid1x_linux.c +++ b/grub-core/disk/mdraid1x_linux.c @@ -110,7 +110,6 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, struct grub_raid_super_1x sb; grub_uint8_t minor_version; - /* The sector where the mdraid 0.90 superblock is stored, if available. */ size = grub_disk_get_size (disk); /* Check for an 1.x superblock. From 9f3677d3c1dc361c570d6b20acff9e98563355aa Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Mar 2011 02:20:52 +0200 Subject: [PATCH 163/276] * util/grub-setup.c: Copy the partition table zone if floppy support is disabled, even if no partition table is found. Otherwise, the BIOS on Dell Latitude E series laptops will freeze during POST if an invalid partition table is contained in the PBR of the active partition when GRUB is installed to a partition. --- ChangeLog | 9 +++++++++ util/grub-setup.c | 17 +++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index d6afea1d2..1ea9ca076 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-03-29 Mario Limonciello + + * util/grub-setup.c: Copy the partition table zone if floppy support + is disabled, even if no partition table is found. + + Otherwise, the BIOS on Dell Latitude E series laptops will freeze + during POST if an invalid partition table is contained in the PBR + of the active partition when GRUB is installed to a partition. + 2011-03-28 Colin Watson * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Remove stale diff --git a/util/grub-setup.c b/util/grub-setup.c index b4749b433..c1f2a1f5e 100644 --- a/util/grub-setup.c +++ b/util/grub-setup.c @@ -399,6 +399,15 @@ setup (const char *dir, } #endif + /* Copy the partition table. */ + if (dest_partmap || + (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk))) + memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, + tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, + GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC); + + free (tmp_img); + if (! dest_partmap) { grub_util_warn (_("Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.")); @@ -410,14 +419,6 @@ setup (const char *dir, goto unable_to_embed; } - /* Copy the partition table. */ - if (dest_partmap) - memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, - tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, - GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC); - - free (tmp_img); - if (!dest_partmap->embed) { grub_util_warn ("Partition style '%s' doesn't support embeding", From a1dc717c5869064fda3553fd4055e00af6623d7e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Mar 2011 08:20:19 +0200 Subject: [PATCH 164/276] * grub-core/lib/relocator.c (allocate_regstart) [!DEBUG_RELOCATOR_NOMEM_DPRINTF]: Avoid grub_dprintf since not all terminals are capabple of malloc-free operation. (allocate_inreg) [!DEBUG_RELOCATOR_NOMEM_DPRINTF]: Likewise. (malloc_in_range) [!DEBUG_RELOCATOR_NOMEM_DPRINTF]: Likewise. --- ChangeLog | 8 ++++++++ grub-core/lib/relocator.c | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1ea9ca076..a07eff722 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-03-29 Vladimir Serbinenko + + * grub-core/lib/relocator.c (allocate_regstart) + [!DEBUG_RELOCATOR_NOMEM_DPRINTF]: Avoid grub_dprintf since not all + terminals are capabple of malloc-free operation. + (allocate_inreg) [!DEBUG_RELOCATOR_NOMEM_DPRINTF]: Likewise. + (malloc_in_range) [!DEBUG_RELOCATOR_NOMEM_DPRINTF]: Likewise. + 2011-03-29 Mario Limonciello * util/grub-setup.c: Copy the partition table zone if floppy support diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index 7d29ab5cc..940b9133b 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -134,9 +134,10 @@ allocate_regstart (grub_phys_addr_t addr, grub_size_t size, grub_mm_region_t rb, grub_addr_t newreg_size, newreg_presize; grub_mm_header_t new_header; grub_mm_header_t hb = (grub_mm_header_t) (rb + 1); - - grub_dprintf ("relocator", "ra = %p, rb = %p\n", regancestor, rb); +#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF + grub_dprintf ("relocator", "ra = %p, rb = %p\n", regancestor, rb); +#endif newreg_start = ALIGN_UP (newreg_raw_start, GRUB_MM_ALIGN); newreg_presize = newreg_start - newreg_raw_start; newreg_size = rb->size - (newreg_start - (grub_addr_t) rb); @@ -179,11 +180,12 @@ allocate_regstart (grub_phys_addr_t addr, grub_size_t size, grub_mm_region_t rb, if ((void *) h < (void *) (newreg + 1)) grub_fatal ("Failed to adjust memory region: %p, %p, %p, %p, %p", newreg, newreg->first, h, hp, hb); +#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF if ((void *) h == (void *) (newreg + 1)) grub_dprintf ("relocator", "Free start memory region: %p, %p, %p, %p, %p", newreg, newreg->first, h, hp, hb); - +#endif hp = h; h = h->next; } @@ -200,7 +202,7 @@ allocate_inreg (grub_phys_addr_t paddr, grub_size_t size, struct grub_mm_header *foll = NULL; grub_addr_t vaddr = (grub_addr_t) hb + (paddr - grub_vtop (hb)); -#ifdef DEBUG_RELOCATOR +#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF grub_dprintf ("relocator", "inreg paddr = 0x%lx, size = %lu," " hb = %p, hbp = %p, rb = %p, vaddr = 0x%lx\n", (unsigned long) paddr, (unsigned long) size, hb, hbp, @@ -213,8 +215,10 @@ allocate_inreg (grub_phys_addr_t paddr, grub_size_t size, foll = (void *) ALIGN_UP (vaddr + size, GRUB_MM_ALIGN); foll->magic = GRUB_MM_FREE_MAGIC; foll->size = hb + hb->size - foll; +#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF grub_dprintf ("relocator", "foll = %p, foll->size = %lu\n", foll, (unsigned long) foll->size); +#endif } if (vaddr - (grub_addr_t) hb >= sizeof (*hb)) @@ -821,9 +825,11 @@ malloc_in_range (struct grub_relocator *rel, fend = ALIGN_UP (alloc_end, GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT); +#ifdef DEBUG_RELOCATOR_NOMEM_DPRINTF grub_dprintf ("relocator", "requesting %lx-%lx\n", (unsigned long) fstart, (unsigned long) fend); +#endif /* The failure here can be very expensive. */ if (!grub_relocator_firmware_alloc_region (fstart, fend - fstart)) From ed5587afea4da065b2857906cacde451818c0e82 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Mar 2011 08:33:28 +0200 Subject: [PATCH 165/276] * grub-core/term/gfxterm.c (dirty_region_add): Move core part to ... (dirty_region_add_real): ... this. (dirty_region_add): Don't discard margin refresh when performing scheduled repaint. --- ChangeLog | 7 +++++++ grub-core/term/gfxterm.c | 31 +++++++++++++++++-------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index a07eff722..c353b8fea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-03-29 Vladimir Serbinenko + + * grub-core/term/gfxterm.c (dirty_region_add): Move core part to ... + (dirty_region_add_real): ... this. + (dirty_region_add): Don't discard margin refresh when performing + scheduled repaint. + 2011-03-29 Vladimir Serbinenko * grub-core/lib/relocator.c (allocate_regstart) diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c index 321479e0a..44d1a9be8 100644 --- a/grub-core/term/gfxterm.c +++ b/grub-core/term/gfxterm.c @@ -532,21 +532,8 @@ dirty_region_is_empty (void) } static void -dirty_region_add (int x, int y, unsigned int width, unsigned int height) +dirty_region_add_real (int x, int y, unsigned int width, unsigned int height) { - if ((width == 0) || (height == 0)) - return; - - if (repaint_scheduled) - { - x = virtual_screen.offset_x; - y = virtual_screen.offset_y; - width = virtual_screen.width; - height = virtual_screen.height; - repaint_scheduled = 0; - repaint_was_scheduled = 1; - } - if (dirty_region_is_empty ()) { dirty_region.top_left_x = x; @@ -567,6 +554,22 @@ dirty_region_add (int x, int y, unsigned int width, unsigned int height) } } +static void +dirty_region_add (int x, int y, unsigned int width, unsigned int height) +{ + if ((width == 0) || (height == 0)) + return; + + if (repaint_scheduled) + { + dirty_region_add_real (virtual_screen.offset_x, virtual_screen.offset_y, + virtual_screen.width, virtual_screen.height); + repaint_scheduled = 0; + repaint_was_scheduled = 1; + } + dirty_region_add_real (x, y, width, height); +} + static void dirty_region_add_virtualscreen (void) { From d2e29d81a9fb4f07485a6948c5bb04ff8c0a9c69 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Mar 2011 10:56:14 +0200 Subject: [PATCH 166/276] * grub-core/fs/ext2.c (grub_ext2_read_inode): Fix an overflow. Reported and tested by: Timothy Nikkel. --- ChangeLog | 5 +++++ grub-core/fs/ext2.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c353b8fea..9e90df11e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-29 Vladimir Serbinenko + + * grub-core/fs/ext2.c (grub_ext2_read_inode): Fix an overflow. + Reported and tested by: Timothy Nikkel. + 2011-03-29 Vladimir Serbinenko * grub-core/term/gfxterm.c (dirty_region_add): Move core part to ... diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index ed5fafd4c..9d7bbfd36 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -555,7 +555,7 @@ grub_ext2_read_inode (struct grub_ext2_data *data, /* Read the inode. */ if (grub_disk_read (data->disk, - ((grub_le_to_cpu32 (blkgrp.inode_table_id) + blkno) + (((grub_disk_addr_t) grub_le_to_cpu32 (blkgrp.inode_table_id) + blkno) << LOG2_EXT2_BLOCK_SIZE (data)), EXT2_INODE_SIZE (data) * blkoff, sizeof (struct grub_ext2_inode), inode)) From 35e5f84c18dde153c0671f3cf1f56371cde95631 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Mar 2011 11:25:04 +0200 Subject: [PATCH 167/276] * grub-core/normal/misc.c (grub_normal_print_device_info): Use correct printf clauses for printing size and start. --- ChangeLog | 5 +++++ grub-core/normal/misc.c | 11 +++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e90df11e..8d976d770 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-29 Vladimir Serbinenko + + * grub-core/normal/misc.c (grub_normal_print_device_info): Use correct + printf clauses for printing size and start. + 2011-03-29 Vladimir Serbinenko * grub-core/fs/ext2.c (grub_ext2_read_inode): Fix an overflow. diff --git a/grub-core/normal/misc.c b/grub-core/normal/misc.c index d81b6d26f..4a7e6a3ea 100644 --- a/grub-core/normal/misc.c +++ b/grub-core/normal/misc.c @@ -112,14 +112,13 @@ grub_normal_print_device_info (const char *name) grub_printf ("%s", _("Not a known filesystem")); if (dev->disk->partition) - grub_printf (_(" - Partition start at %u"), - grub_partition_get_start (dev->disk->partition)); + grub_printf (_(" - Partition start at %llu"), + (unsigned long long) grub_partition_get_start (dev->disk->partition)); if (grub_disk_get_size (dev->disk) == GRUB_DISK_SIZE_UNKNOWN) - grub_printf (_(" - Total size unknown"), - grub_disk_get_size (dev->disk)); + grub_puts_ (" - Total size unknown"); else - grub_printf (_(" - Total size %u sectors"), - grub_disk_get_size (dev->disk)); + grub_printf (_(" - Total size %llu sectors"), + (unsigned long long) grub_disk_get_size (dev->disk)); grub_device_close (dev); } From b4db4f39f017cc7cf97890523bd6e6b219a9a326 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 29 Mar 2011 10:51:58 +0100 Subject: [PATCH 168/276] * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): If real_sb->size is zero (e.g. RAID-0), get the disk size from real_sb->data_size instead. Fixes Ubuntu bug #743136. --- ChangeLog | 7 +++++++ grub-core/disk/mdraid1x_linux.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8d976d770..ab5182b8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-03-29 Colin Watson + + * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): If + real_sb->size is zero (e.g. RAID-0), get the disk size from + real_sb->data_size instead. + Fixes Ubuntu bug #743136. + 2011-03-29 Vladimir Serbinenko * grub-core/normal/misc.c (grub_normal_print_device_info): Use correct diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c index 296d1375b..1d08abf5b 100644 --- a/grub-core/disk/mdraid1x_linux.c +++ b/grub-core/disk/mdraid1x_linux.c @@ -192,7 +192,10 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, array->level = grub_le_to_cpu32 (real_sb->level); array->layout = grub_le_to_cpu32 (real_sb->layout); array->total_devs = grub_le_to_cpu32 (real_sb->raid_disks); - array->disk_size = grub_le_to_cpu64 (real_sb->size); + if (real_sb->size) + array->disk_size = grub_le_to_cpu64 (real_sb->size); + else + array->disk_size = grub_le_to_cpu64 (real_sb->data_size); array->chunk_size = grub_le_to_cpu32 (real_sb->chunksize); if (grub_le_to_cpu32 (real_sb->dev_number) >= From a307c0b206aebb15110a5c192ad0e5f2ddcd123f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Mar 2011 12:01:48 +0200 Subject: [PATCH 169/276] * util/grub.d/10_kfreebsd.in: Allow ufs.ko to be missing as it's per default compiled in kernel and prior to 8.0 isn't shipped at all. --- ChangeLog | 5 +++++ util/grub.d/10_kfreebsd.in | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ab5182b8c..8b593f634 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-29 Vladimir Serbinenko + + * util/grub.d/10_kfreebsd.in: Allow ufs.ko to be missing as it's + per default compiled in kernel and prior to 8.0 isn't shipped at all. + 2011-03-29 Colin Watson * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): If diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index dce5e945c..3600c74f9 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -110,7 +110,11 @@ EOF ;; esac - load_kfreebsd_module ${kfreebsd_fs} false + if [ x${kfreebsd_fs} = xufs ]; then + load_kfreebsd_module ${kfreebsd_fs} true + else + load_kfreebsd_module ${kfreebsd_fs} false + fi cat << EOF set kFreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${kfreebsd_device} From 9e4d19e0d362613b566d824cc609b875c630e2b1 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Mar 2011 15:00:23 +0200 Subject: [PATCH 170/276] * grub-core/kern/emu/hostdisk.c (find_partition_start) [HAVE_DIOCGDINFO]: Add safety checks. --- ChangeLog | 5 +++++ grub-core/kern/emu/hostdisk.c | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8b593f634..a7ed9fc94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-29 Vladimir Serbinenko + + * grub-core/kern/emu/hostdisk.c (find_partition_start) + [HAVE_DIOCGDINFO]: Add safety checks. + 2011-03-29 Vladimir Serbinenko * util/grub.d/10_kfreebsd.in: Allow ufs.ko to be missing as it's diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 73d023ce9..9900a79bd 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -518,9 +518,12 @@ devmapper_fail: # if !defined(HAVE_DIOCGDINFO) return hdg.start; # else /* defined(HAVE_DIOCGDINFO) */ - p_index = dev[strlen(dev) - 1] - 'a'; - - if (p_index >= label.d_npartitions) + if (dev[0]) + p_index = dev[strlen(dev) - 1] - 'a'; + else + p_index = -1; + + if (p_index >= label.d_npartitions || p_index < 0) { grub_error (GRUB_ERR_BAD_DEVICE, "no disk label entry for `%s'", dev); From 994b82643247f936e07aa9652451a9d724bda615 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 29 Mar 2011 14:32:38 +0100 Subject: [PATCH 171/276] * docs/grub.texi (BIOS installation): New section, partly based on previous text in other sections. (Installing GRUB using grub-install): Replace BIOS discussion with a cross-reference. (Images): Likewise. --- ChangeLog | 8 ++++ docs/grub.texi | 100 +++++++++++++++++++++++++++++++++++-------------- 2 files changed, 79 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7ed9fc94..552d5dc7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-03-29 Colin Watson + + * docs/grub.texi (BIOS installation): New section, partly based on + previous text in other sections. + (Installing GRUB using grub-install): Replace BIOS discussion with a + cross-reference. + (Images): Likewise. + 2011-03-29 Vladimir Serbinenko * grub-core/kern/emu/hostdisk.c (find_partition_start) diff --git a/docs/grub.texi b/docs/grub.texi index 83bd80023..cac4ffbf3 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -550,6 +550,7 @@ the @dfn{boot directory}. * Installing GRUB using grub-install:: * Making a GRUB bootable CD-ROM:: * Device map:: +* BIOS installation:: @end menu @@ -565,13 +566,8 @@ always. Therefore, GRUB provides you with a map file called the @dfn{device map}, which you must fix if it is wrong. @xref{Device map}, for more details. -On BIOS platforms GRUB has to use a so-called embedding zone. On msdos -partition tables, this is the space between the MBR and the first partition -(called the MBR gap or the boot track), while on GPT partition tables it -uses a BIOS Boot Partition (a partition with GUID -21686148-6449-6e6f-744e656564454649). If you use GRUB on a BIOS system, make -sure that the embedding zone is at least 31 KiB (512KiB or more -recommended). +For information on where GRUB should be installed on PC BIOS platforms, +@pxref{BIOS installation}. If you still do want to install GRUB under a UNIX-like OS (such as @sc{gnu}), invoke the program @command{grub-install} (@pxref{Invoking @@ -744,6 +740,72 @@ comments in the file if needed, as the GRUB utilities assume that a line is just a comment if the first character is @samp{#}. +@node BIOS installation +@section BIOS installation + +@heading MBR + +The partition table format traditionally used on PC BIOS platforms is called +the Master Boot Record (MBR) format; this is the format that allows up to +four primary partitions and additional logical partitions. With this +partition table format, there are two ways to install GRUB: it can be +embedded in the area between the MBR and the first partition (called by +various names, such as the "boot track", "MBR gap", or "embedding area", and +which is usually at least 31 KiB), or the core image can be installed in a +file system and a list of the blocks that make it up can be stored in the +first sector of that partition. + +Each of these has different problems. There is no way to reserve space in +the embedding area with complete safety, and some proprietary software is +known to use it to make it difficult for users to work around licensing +restrictions; and systems are sometimes partitioned without leaving enough +space before the first partition. On the other hand, installing to a +filesystem means that GRUB is vulnerable to its blocks being moved around by +filesystem features such as tail packing, or even by aggressive fsck +implementations, so this approach is quite fragile; and this approach can +only be used if the @file{/boot} filesystem is on the same disk that the +BIOS boots from, so that GRUB does not have to rely on guessing BIOS drive +numbers. + +The GRUB development team generally recommends embedding GRUB before the +first partition, unless you have special requirements. You must ensure that +the first partition starts at least 31 KiB (63 sectors) from the start of +the disk; on modern disks, it is often a performance advantage to align +partitions on larger boundaries anyway, so the first partition might start 1 +MiB from the start of the disk. + +@heading GPT + +Some newer systems use the GUID Partition Table (GPT) format. This was +specified as part of the Extensible Firmware Interface (EFI), but it can +also be used on BIOS platforms if system software supports it; for example, +GRUB and GNU/Linux can be used in this configuration. With this format, it +is possible to reserve a whole partition for GRUB, called the BIOS Boot +Partition. GRUB can then be embedded into that partition without the risk +of being overwritten by other software and without being contained in a +filesystem which might move its blocks around. + +When creating a BIOS Boot Partition on a GPT system, you should make sure +that it is at least 31 KiB in size. (GPT-formatted disks are not usually +particularly small, so we recommend that you make it larger than the bare +minimum, such as 1 MiB, to allow plenty of room for growth.) You must also +make sure that it has the proper partition type. Using GNU Parted, you can +set this using a command such as the following: + +@example +# @kbd{parted /dev/@var{disk} set @var{partition-number} bios_grub on} +@end example + +If you are using gdisk, set the partition type to @samp{0xEF02}. With +partitioning programs that require setting the GUID directly, it should be +@samp{21686148-6449-6e6f-744e656564454649}. + +@strong{Caution:} Be very careful which partition you select! When GRUB +finds a BIOS Boot Partition during installation, it will automatically +overwrite part of it. Make sure that the partition does not contain any +other data. + + @node Booting @chapter Booting @@ -2021,28 +2083,8 @@ target operating systems, and so on) from the file system at run-time. The modular design allows the core image to be kept small, since the areas of disk where it must be installed are often as small as 32KB. -On PC systems using the traditional MBR partition table format, the core -image is usually installed in the "MBR gap" between the master boot record -and the first partition, or sometimes it is installed in a file system and -read directly from that. The latter is not recommended because GRUB needs -to encode the location of all the core image sectors in @file{diskboot.img}, -and if the file system ever moves the core image around (as it is entitled -to do) then GRUB must be reinstalled; it also means that GRUB will not be -able to reliably find the core image if it resides on a different disk than -the one to which @file{boot.img} was installed. - -On PC systems using the more recent GUID Partition Table (GPT) format, the -core image should be installed to a BIOS Boot Partition. This may be -created by GNU Parted using a command such as the following: - -@example -# @kbd{parted /dev/@var{disk} set @var{partition-number} bios_grub on} -@end example - -@strong{Caution:} Be very careful which partition you select! When GRUB -finds a BIOS Boot Partition during installation, it will automatically -overwrite part of it. Make sure that the partition does not contain any -other data. +@xref{BIOS installation}, for details on where the core image can be +installed on PC systems. @item *.mod Everything else in GRUB resides in dynamically loadable modules. These are From 61d7156b947cbb19cad2565b82fb599695a41bb1 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 29 Mar 2011 18:00:23 +0100 Subject: [PATCH 172/276] * grub-core/disk/loopback.c (GRUB_MOD_INIT): Stop documenting removed -p option. --- ChangeLog | 5 +++++ grub-core/disk/loopback.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 552d5dc7c..36ca453f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-29 Colin Watson + + * grub-core/disk/loopback.c (GRUB_MOD_INIT): Stop documenting + removed -p option. + 2011-03-29 Colin Watson * docs/grub.texi (BIOS installation): New section, partly based on diff --git a/grub-core/disk/loopback.c b/grub-core/disk/loopback.c index ae4cb9a9c..b05940a4a 100644 --- a/grub-core/disk/loopback.c +++ b/grub-core/disk/loopback.c @@ -222,7 +222,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(loopback) { cmd = grub_register_extcmd ("loopback", grub_cmd_loopback, 0, - N_("[-d|-p] DEVICENAME FILE."), + N_("[-d] DEVICENAME FILE."), N_("Make a device of a file."), options); grub_disk_dev_register (&grub_loopback_dev); } From 5c650f4c8ea62ea776807b9e1444a496c652608d Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 29 Mar 2011 18:08:23 +0100 Subject: [PATCH 173/276] * docs/grub.texi (loopback): New section. --- ChangeLog | 4 ++++ docs/grub.texi | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 36ca453f1..cf7b1b0d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-29 Colin Watson + + * docs/grub.texi (loopback): New section. + 2011-03-29 Colin Watson * grub-core/disk/loopback.c (GRUB_MOD_INIT): Stop documenting diff --git a/docs/grub.texi b/docs/grub.texi index cac4ffbf3..368d21f1d 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -2589,6 +2589,7 @@ you forget a command, you can run the command @command{help} * keystatus:: Check key modifier status * linux:: Load a Linux kernel * linux16:: Load a Linux kernel (16-bit mode) +* loopback:: Make a device from a filesystem image * ls:: List devices or files * parttool:: Modify partition table entries * password:: Set a clear-text password @@ -2978,6 +2979,23 @@ This command is only available on x86 systems. @end deffn +@node loopback +@subsection loopback + +@deffn Command loopback [@option{-d}] device file +Make the device named @var{device} correspond to the contents of the +filesystem image in @var{file}. For example: + +@example +loopback loop0 /path/to/image +ls (loop0)/ +@end example + +With the @option{-d} option, delete a device previously created using this +command. +@end deffn + + @node ls @subsection ls From fc18f6a3cb15db980e65dda9e305a1d176b14b3a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Mar 2011 19:47:34 +0200 Subject: [PATCH 174/276] * util/grub.d/10_linux.in: Skip vmlinux-* on x86 platforms. --- ChangeLog | 4 + grub-core/disk/lvm.c | 354 ++++++++++++++++++++++++++-------------- include/grub/lvm.h | 13 ++ util/grub.d/10_linux.in | 14 +- 4 files changed, 260 insertions(+), 125 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf7b1b0d6..dcacc600c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-29 Vladimir Serbinenko + + * util/grub.d/10_linux.in: Skip vmlinux-* on x86 platforms. + 2011-03-29 Colin Watson * docs/grub.texi (loopback): New section. diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 39fa84d91..b1a7a50a9 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -45,6 +45,7 @@ grub_lvm_getvalue (char **p, char *str) return grub_strtoul (*p, NULL, 10); } +#if 0 static int grub_lvm_checkvalue (char **p, char *str, char *tmpl) { @@ -57,6 +58,7 @@ grub_lvm_checkvalue (char **p, char *str, char *tmpl) return 0; return (grub_memcmp (*p + 1, tmpl, tmpllen) == 0 && (*p)[tmpllen + 1] == '"'); } +#endif static int grub_lvm_check_flag (char *p, char *str, char *flag) @@ -100,7 +102,7 @@ grub_lvm_iterate (int (*hook) (const char *name)) struct grub_lvm_lv *lv; if (vg->lvs) for (lv = vg->lvs; lv; lv = lv->next) - if (hook (lv->name)) + if (lv->visible && hook (lv->name)) return 1; } @@ -164,11 +166,10 @@ grub_lvm_close (grub_disk_t disk __attribute ((unused))) } static grub_err_t -grub_lvm_read (grub_disk_t disk, grub_disk_addr_t sector, - grub_size_t size, char *buf) +read_lv (struct grub_lvm_lv *lv, grub_disk_addr_t sector, + grub_size_t size, char *buf) { grub_err_t err = 0; - struct grub_lvm_lv *lv = disk->data; struct grub_lvm_vg *vg = lv->vg; struct grub_lvm_segment *seg = lv->segments; struct grub_lvm_pv *pv; @@ -176,6 +177,9 @@ grub_lvm_read (grub_disk_t disk, grub_disk_addr_t sector, grub_uint64_t extent; unsigned int i; + if (!lv) + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume"); + extent = grub_divmod64 (sector, vg->extent_size, NULL); /* Find the right segment. */ @@ -190,59 +194,88 @@ grub_lvm_read (grub_disk_t disk, grub_disk_addr_t sector, seg++; } - if (seg->stripe_count == 1) + if (i == lv->segment_count) + return grub_error (GRUB_ERR_READ_ERROR, "incorrect segment"); + + switch (seg->type) { - /* This segment is linear, so that's easy. We just need to find - out the offset in the physical volume and read SIZE bytes - from that. */ - struct grub_lvm_stripe *stripe = seg->stripes; - grub_uint64_t seg_offset; /* Offset of the segment in PV device. */ + case GRUB_LVM_STRIPED: + if (seg->stripe_count == 1) + { + /* This segment is linear, so that's easy. We just need to find + out the offset in the physical volume and read SIZE bytes + from that. */ + struct grub_lvm_stripe *stripe = seg->stripes; + grub_uint64_t seg_offset; /* Offset of the segment in PV device. */ - pv = stripe->pv; - seg_offset = ((grub_uint64_t) stripe->start - * (grub_uint64_t) vg->extent_size) + pv->start; + pv = stripe->pv; + seg_offset = ((grub_uint64_t) stripe->start + * (grub_uint64_t) vg->extent_size) + pv->start; - offset = sector - ((grub_uint64_t) seg->start_extent - * (grub_uint64_t) vg->extent_size) + seg_offset; + offset = sector - ((grub_uint64_t) seg->start_extent + * (grub_uint64_t) vg->extent_size) + seg_offset; + } + else + { + /* This is a striped segment. We have to find the right PV + similar to RAID0. */ + struct grub_lvm_stripe *stripe = seg->stripes; + grub_uint32_t a, b; + grub_uint64_t seg_offset; /* Offset of the segment in PV device. */ + unsigned int stripenr; + + offset = sector - ((grub_uint64_t) seg->start_extent + * (grub_uint64_t) vg->extent_size); + + a = grub_divmod64 (offset, seg->stripe_size, NULL); + grub_divmod64 (a, seg->stripe_count, &stripenr); + + a = grub_divmod64 (offset, seg->stripe_size * seg->stripe_count, NULL); + grub_divmod64 (offset, seg->stripe_size, &b); + offset = a * seg->stripe_size + b; + + stripe += stripenr; + pv = stripe->pv; + + seg_offset = ((grub_uint64_t) stripe->start + * (grub_uint64_t) vg->extent_size) + pv->start; + + offset += seg_offset; + } + /* Check whether we actually know the physical volume we want to + read from. */ + if (pv->disk) + err = grub_disk_read (pv->disk, offset, 0, + size << GRUB_DISK_SECTOR_BITS, buf); + else + err = grub_error (GRUB_ERR_UNKNOWN_DEVICE, + "physical volume %s not found", pv->name); + + return err; + case GRUB_LVM_MIRROR: + i = 0; + while (1) + { + if (!seg->mirrors[i].lv) + err = grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume '%s'", + seg->mirrors[i].lvname); + else + err = read_lv (seg->mirrors[i].lv, sector, size, buf); + if (!err) + return err; + if (++i >= seg->mirror_count) + return err; + grub_errno = GRUB_ERR_NONE; + } } - else - { - /* This is a striped segment. We have to find the right PV - similar to RAID0. */ - struct grub_lvm_stripe *stripe = seg->stripes; - grub_uint32_t a, b; - grub_uint64_t seg_offset; /* Offset of the segment in PV device. */ - unsigned int stripenr; + return grub_error (GRUB_ERR_IO, "unknown LVM segment"); +} - offset = sector - ((grub_uint64_t) seg->start_extent - * (grub_uint64_t) vg->extent_size); - - a = grub_divmod64 (offset, seg->stripe_size, NULL); - grub_divmod64 (a, seg->stripe_count, &stripenr); - - a = grub_divmod64 (offset, seg->stripe_size * seg->stripe_count, NULL); - grub_divmod64 (offset, seg->stripe_size, &b); - offset = a * seg->stripe_size + b; - - stripe += stripenr; - pv = stripe->pv; - - seg_offset = ((grub_uint64_t) stripe->start - * (grub_uint64_t) vg->extent_size) + pv->start; - - offset += seg_offset; - } - - /* Check whether we actually know the physical volume we want to - read from. */ - if (pv->disk) - err = grub_disk_read (pv->disk, offset, 0, - size << GRUB_DISK_SECTOR_BITS, buf); - else - err = grub_error (GRUB_ERR_UNKNOWN_DEVICE, - "physical volume %s not found", pv->name); - - return err; +static grub_err_t +grub_lvm_read (grub_disk_t disk, grub_disk_addr_t sector, + grub_size_t size, char *buf) +{ + return read_lv (disk->data, sector, size, buf); } static grub_err_t @@ -533,11 +566,7 @@ grub_lvm_scan_device (const char *name) lv->size = 0; - if (!grub_lvm_check_flag (p, "status", "VISIBLE")) - { - skip_lv = 1; - goto lv_parsed; - } + lv->visible = grub_lvm_check_flag (p, "status", "VISIBLE"); lv->segment_count = grub_lvm_getvalue (&p, "segment_count = "); if (p == NULL) @@ -552,7 +581,6 @@ grub_lvm_scan_device (const char *name) for (i = 0; i < lv->segment_count; i++) { - struct grub_lvm_stripe *stripe; p = grub_strstr (p, "segment"); if (p == NULL) @@ -580,78 +608,147 @@ grub_lvm_scan_device (const char *name) goto lvs_segment_fail; } - if (grub_lvm_checkvalue (&p, "type = ", "snapshot")) - { - /* Found a snapshot, give up and move on. */ - skip_lv = 1; - break; - } - - seg->stripe_count = grub_lvm_getvalue (&p, "stripe_count = "); + p = grub_strstr (p, "type = \""); if (p == NULL) - { -#ifdef GRUB_UTIL - grub_util_info ("unknown stripe_count\n"); -#endif - goto lvs_segment_fail; - } + goto lvs_segment_fail; + p += sizeof("type = \"") - 1; lv->size += seg->extent_count * vg->extent_size; - if (seg->stripe_count != 1) - seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = "); + if (grub_memcmp (p, "striped\"", + sizeof ("striped\"") - 1) == 0) + { + struct grub_lvm_stripe *stripe; - seg->stripes = grub_malloc (sizeof (*stripe) - * seg->stripe_count); - stripe = seg->stripes; + seg->type = GRUB_LVM_STRIPED; + seg->stripe_count = grub_lvm_getvalue (&p, "stripe_count = "); + if (p == NULL) + { +#ifdef GRUB_UTIL + grub_util_info ("unknown stripe_count\n"); +#endif + goto lvs_segment_fail; + } - p = grub_strstr (p, "stripes = ["); - if (p == NULL) + if (seg->stripe_count != 1) + seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = "); + + seg->stripes = grub_malloc (sizeof (*stripe) + * seg->stripe_count); + stripe = seg->stripes; + + p = grub_strstr (p, "stripes = ["); + if (p == NULL) + { +#ifdef GRUB_UTIL + grub_util_info ("unknown stripes\n"); +#endif + goto lvs_segment_fail2; + } + p += sizeof("stripes = [") - 1; + + for (j = 0; j < seg->stripe_count; j++) + { + char *pvname; + + p = grub_strchr (p, '"'); + if (p == NULL) + continue; + q = ++p; + while (*q != '"') + q++; + + s = q - p; + + pvname = grub_malloc (s + 1); + if (pvname == NULL) + goto lvs_segment_fail2; + + grub_memcpy (pvname, p, s); + pvname[s] = '\0'; + + if (vg->pvs) + for (pv = vg->pvs; pv; pv = pv->next) + { + if (! grub_strcmp (pvname, pv->name)) + { + stripe->pv = pv; + break; + } + } + + grub_free(pvname); + + stripe->start = grub_lvm_getvalue (&p, ","); + if (p == NULL) + continue; + + stripe++; + } + } + else if (grub_memcmp (p, "mirror\"", sizeof ("mirror\"") - 1) + == 0) + { + seg->type = GRUB_LVM_MIRROR; + seg->mirror_count = grub_lvm_getvalue (&p, "mirror_count = "); + if (p == NULL) + { +#ifdef GRUB_UTIL + grub_util_info ("unknown mirror_count\n"); +#endif + goto lvs_segment_fail; + } + + seg->mirrors = grub_zalloc (sizeof (seg->mirrors[0]) + * seg->mirror_count); + + p = grub_strstr (p, "mirrors = ["); + if (p == NULL) + { +#ifdef GRUB_UTIL + grub_util_info ("unknown mirrors\n"); +#endif + goto lvs_segment_fail2; + } + p += sizeof("mirrors = [") - 1; + + for (j = 0; j < seg->mirror_count; j++) + { + char *lvname; + + p = grub_strchr (p, '"'); + if (p == NULL) + continue; + q = ++p; + while (*q != '"') + q++; + + s = q - p; + + lvname = grub_malloc (s + 1); + if (lvname == NULL) + goto lvs_segment_fail2; + + grub_memcpy (lvname, p, s); + lvname[s] = '\0'; + seg->mirrors[j].lvname = lvname; + p = q + 1; + } + } + else { #ifdef GRUB_UTIL - grub_util_info ("unknown stripes\n"); + char *p2; + p2 = grub_strchr (p, '"'); + if (p2) + *p2 = 0; + grub_util_info ("unknown LVM type %s\n", p); + if (p2) + *p2 ='"'; #endif - goto lvs_segment_fail2; - } - p += sizeof("stripes = [") - 1; - - for (j = 0; j < seg->stripe_count; j++) - { - char *pvname; - - p = grub_strchr (p, '"'); - if (p == NULL) - continue; - q = ++p; - while (*q != '"') - q++; - - s = q - p; - - pvname = grub_malloc (s + 1); - if (pvname == NULL) - goto lvs_segment_fail2; - - grub_memcpy (pvname, p, s); - pvname[s] = '\0'; - - if (vg->pvs) - for (pv = vg->pvs; pv; pv = pv->next) - { - if (! grub_strcmp (pvname, pv->name)) - { - stripe->pv = pv; - break; - } - } - - grub_free(pvname); - - stripe->start = grub_lvm_getvalue (&p, ","); - if (p == NULL) - continue; - - stripe++; + /* Found a non-supported type, give up and move on. */ + skip_lv = 1; + break; } seg++; @@ -663,7 +760,6 @@ grub_lvm_scan_device (const char *name) goto fail4; } - lv_parsed: if (p != NULL) p = grub_strchr (p, '}'); if (p == NULL) @@ -690,6 +786,20 @@ grub_lvm_scan_device (const char *name) } } + /* Match mirrors */ + { + struct grub_lvm_lv *lv1; + struct grub_lvm_lv *lv2; + for (lv1 = vg->lvs; lv1; lv1 = lv1->next) + for (i = 0; i < lv1->segment_count; i++) + if (lv1->segments[i].type == GRUB_LVM_MIRROR) + for (j = 0; j < lv1->segments[i].mirror_count; j++) + for (lv2 = vg->lvs; lv2; lv2 = lv2->next) + if (grub_strcmp (lv2->name + grub_strlen (vg->name) + 1, + lv1->segments[i].mirrors[j].lvname) == 0) + lv1->segments[i].mirrors[j].lv = lv2; + } + vg->next = vg_list; vg_list = vg; } diff --git a/include/grub/lvm.h b/include/grub/lvm.h index a4bf3b288..220517183 100644 --- a/include/grub/lvm.h +++ b/include/grub/lvm.h @@ -47,6 +47,9 @@ struct grub_lvm_lv { unsigned int number; unsigned int segment_count; grub_uint64_t size; + + int visible; + struct grub_lvm_segment *segments; /* Pointer to segment_count segments. */ struct grub_lvm_vg *vg; struct grub_lvm_lv *next; @@ -55,6 +58,11 @@ struct grub_lvm_lv { struct grub_lvm_segment { unsigned int start_extent; unsigned int extent_count; + enum { GRUB_LVM_STRIPED, GRUB_LVM_MIRROR } type; + + unsigned int mirror_count; + struct grub_lvm_mirror *mirrors; + unsigned int stripe_count; unsigned int stripe_size; struct grub_lvm_stripe *stripes; /* Pointer to stripe_count stripes. */ @@ -65,6 +73,11 @@ struct grub_lvm_stripe { struct grub_lvm_pv *pv; }; +struct grub_lvm_mirror { + char *lvname; + struct grub_lvm_lv *lv; +}; + #define GRUB_LVM_LABEL_SIZE GRUB_DISK_SECTOR_SIZE #define GRUB_LVM_LABEL_SCAN_SECTORS 4L diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 491d2b5ce..d12902e33 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -111,9 +111,17 @@ EOF EOF } -list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* ; do - if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi - done` +case x`uname -m` in + xi?86 | xx86_64) + list=`for i in /boot/vmlinuz-* /vmlinuz-* ; do + if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi + done` ;; + *) + list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* ; do + if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi + done` ;; +esac + prepare_boot_cache= while [ "x$list" != "x" ] ; do From 70e75364fa8627e24bb5ed9eead391c778c4504e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Mar 2011 20:33:32 +0200 Subject: [PATCH 175/276] * include/grub/lvm.h (grub_lvm_lv): New field 'visible'. (grub_lvm_segment): New fields 'type', 'mirror_count' and 'mirrors'. (grub_lvm_mirror): New struct. * grub-core/disk/lvm.c (grub_lvm_checkvalue): Commented out. (grub_lvm_iterate): Iterate only visible volumes. (grub_lvm_read): Factor out to .. (read_lv): ... this. Support mirrors. (grub_lvm_read): New wrapper function. (grub_lvm_scan_device): Parse mirrors. Skip everything that isn't stripped or mirrored. --- ChangeLog | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index dcacc600c..e93ffe4c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-03-29 Vladimir Serbinenko + + * include/grub/lvm.h (grub_lvm_lv): New field 'visible'. + (grub_lvm_segment): New fields 'type', 'mirror_count' and 'mirrors'. + (grub_lvm_mirror): New struct. + * grub-core/disk/lvm.c (grub_lvm_checkvalue): Commented out. + (grub_lvm_iterate): Iterate only visible volumes. + (grub_lvm_read): Factor out to .. + (read_lv): ... this. Support mirrors. + (grub_lvm_read): New wrapper function. + (grub_lvm_scan_device): Parse mirrors. Skip everything that isn't + stripped or mirrored. + 2011-03-29 Vladimir Serbinenko * util/grub.d/10_linux.in: Skip vmlinux-* on x86 platforms. From e1eb511d9a069dd09472889322ff53844e56e432 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Mar 2011 21:12:13 +0200 Subject: [PATCH 176/276] * util/grub.d/20_linux_xen.in: Accept old-style xen kernels. --- ChangeLog | 4 ++++ util/grub.d/20_linux_xen.in | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e93ffe4c4..073543c16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-29 Vladimir Serbinenko + + * util/grub.d/20_linux_xen.in: Accept old-style xen kernels. + 2011-03-29 Vladimir Serbinenko * include/grub/lvm.h (grub_lvm_lv): New field 'visible'. diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index e71fc1458..bacd8ffea 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -96,7 +96,7 @@ EOF linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do basename=$(basename $i) version=$(echo $basename | sed -e "s,^[^0-9]*-,,g") - if grub_file_is_not_garbage "$i" && grep -qx "CONFIG_XEN_DOM0=y" /boot/config-${version} 2> /dev/null ; then echo -n "$i " ; fi + if grub_file_is_not_garbage "$i" && (grep -qx "CONFIG_XEN_DOM0=y" /boot/config-${version} 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" /boot/config-${version} 2> /dev/null); then echo -n "$i " ; fi done` if [ "x${linux_list}" = "x" ] ; then exit 0 From fc8584825cb513ffaca12585657b1682ef79a3e5 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 30 Mar 2011 00:05:25 +0200 Subject: [PATCH 177/276] Old macs search for boot.efi rather than for bootia32.efi. * util/grub-install.in: Copy bootia32.efi to boot.efi. * util/grub-mkrescue.in: Likewise. Suggested by: Peter Jones. --- ChangeLog | 8 ++++++++ util/grub-install.in | 4 ++++ util/grub-mkrescue.in | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 073543c16..661f08502 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-03-29 Vladimir Serbinenko + + Old macs search for boot.efi rather than for bootia32.efi. + + * util/grub-install.in: Copy bootia32.efi to boot.efi. + * util/grub-mkrescue.in: Likewise. + Suggested by: Peter Jones. + 2011-03-29 Vladimir Serbinenko * util/grub.d/20_linux_xen.in: Accept old-style xen kernels. diff --git a/util/grub-install.in b/util/grub-install.in index b4a4b3f26..4e78dfadb 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -620,6 +620,10 @@ elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${pla fi elif [ x"$platform" = xefi ]; then cp "${grubdir}/core.${imgext}" "${efidir}/${efi_file}" + # For old macs. Suggested by Peter Jones. + if [ x$target_cpu = xi386 ]; then + cp "${grubdir}/core.${imgext}" "${efidir}/boot.efi" + fi # Try to make this image bootable using the EFI Boot Manager, if available. efibootmgr="`which efibootmgr`" diff --git a/util/grub-mkrescue.in b/util/grub-mkrescue.in index 690bddb30..455534009 100644 --- a/util/grub-mkrescue.in +++ b/util/grub-mkrescue.in @@ -286,6 +286,10 @@ if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then make_image "${efi64_dir}" x86_64-efi "${efi_dir}"/efi/boot/bootx64.efi "" # build bootia32.efi make_image "${efi32_dir}" i386-efi "${efi_dir}"/efi/boot/bootia32.efi "" + if [ -e "${efi_dir}"/efi/boot/bootia32.efi ]; then + # For old macs. Suggested by Peter Jones. + cp "${efi_dir}"/efi/boot/bootia32.efi "${efi_dir}"/efi/boot/boot.efi + fi mformat -C -f 2880 -L 16 -i "${iso9660_dir}"/efi.img :: mcopy -s -i "${iso9660_dir}"/efi.img ${efi_dir}/efi ::/ From e30af0297db09528ca5a9e08aaf31154859e0fe4 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 30 Mar 2011 03:20:09 +0100 Subject: [PATCH 178/276] * docs/grub.texi (Simple configuration): Explain some of the current limitations of grub-mkconfig. --- ChangeLog | 5 +++++ docs/grub.texi | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index 661f08502..35fd04154 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Colin Watson + + * docs/grub.texi (Simple configuration): Explain some of the + current limitations of grub-mkconfig. + 2011-03-29 Vladimir Serbinenko Old macs search for boot.efi rather than for bootia32.efi. diff --git a/docs/grub.texi b/docs/grub.texi index 368d21f1d..9ff72798b 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1066,6 +1066,16 @@ generates @file{grub.cfg} files suitable for most cases. It is suitable for use when upgrading a distribution, and will discover available kernels and attempt to generate menu entries for them. +@command{grub-mkconfig} does have some limitations. While adding extra +custom menu entries to the end of the list can be done by editing +@file{/etc/grub.d/40_custom} or creating @file{/boot/grub/custom.cfg}, +changing the order of menu entries or changing their titles may require +making complex changes to shell scripts stored in @file{/etc/grub.d/}. This +may be improved in the future. In the meantime, those who feel that it +would be easier to write @file{grub.cfg} directly are encouraged to do so +(@pxref{Booting}, and @ref{Shell-like scripting}), and to disable any system +provided by their distribution to automatically run @command{grub-mkconfig}. + The file @file{/etc/default/grub} controls the operation of @command{grub-mkconfig}. It is sourced by a shell script, and so must be valid POSIX shell input; normally, it will just be a sequence of From 8a748df2fdcabe3bbb4f0ca8654654ae55aac422 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 30 Mar 2011 03:22:37 +0100 Subject: [PATCH 179/276] credit --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 35fd04154..3939f1d81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * docs/grub.texi (Simple configuration): Explain some of the current limitations of grub-mkconfig. + Reported by: Leslie Rhorer. 2011-03-29 Vladimir Serbinenko From a7527639063a314a11af11bc11acb681bbc9e724 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 30 Mar 2011 03:26:11 +0100 Subject: [PATCH 180/276] * docs/grub.texi (Changes from GRUB Legacy): Minor proofreading. --- ChangeLog | 6 +++++- docs/grub.texi | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3939f1d81..b34443efc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ -2011-03-30 Colin Watson +2011-03-30 Colin Watson + + * docs/grub.texi (Changes from GRUB Legacy): Minor proofreading. + +2011-03-30 Colin Watson * docs/grub.texi (Simple configuration): Explain some of the current limitations of grub-mkconfig. diff --git a/docs/grub.texi b/docs/grub.texi index 9ff72798b..a07377348 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -229,9 +229,10 @@ scripting language: variables, conditionals, and loops are available. @item A small amount of persistent storage is available across reboots, using the @command{save_env} and @command{load_env} commands in GRUB and the -@command{grub-editenv} utility. For safety reasons this storage is only -available when installed on plain disk (no LVM or RAID), using non-checksumming -filesystem (no ZFS) and using BIOS or EFI functions (no ATA, USB or IEEE1275) +@command{grub-editenv} utility. For safety reasons, this storage is only +available when installed on a plain disk (no LVM or RAID), using a +non-checksumming filesystem (no ZFS), and using BIOS or EFI functions (no +ATA, USB or IEEE1275). @item GRUB 2 has more reliable ways to find its own files and those of target From 2a2da1d030c71912cf11a07dffa8a155673fd4c6 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 30 Mar 2011 03:49:22 +0100 Subject: [PATCH 181/276] * docs/grub.texi (Menu-specific commands): Remove some semantics that were true in GRUB Legacy but not in GRUB 2. (submenu): New section. (false): New section. (read): New section. (true): New section. --- ChangeLog | 9 ++++++++ docs/grub.texi | 59 ++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index b34443efc..9fc7fdcf0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-03-30 Colin Watson + + * docs/grub.texi (Menu-specific commands): Remove some semantics + that were true in GRUB Legacy but not in GRUB 2. + (submenu): New section. + (false): New section. + (read): New section. + (true): New section. + 2011-03-30 Colin Watson * docs/grub.texi (Changes from GRUB Legacy): Minor proofreading. diff --git a/docs/grub.texi b/docs/grub.texi index a07377348..9abf1b174 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -2411,9 +2411,6 @@ In rescue mode, only the @command{insmod} (@pxref{insmod}), @command{ls} The semantics used in parsing the configuration file are the following: @itemize @bullet -@item -The menu-specific commands have to be used before any others. - @item The files @emph{must} be in plain-text format. @@ -2427,20 +2424,13 @@ Options are separated by spaces. @item All numbers can be either decimal or hexadecimal. A hexadecimal number must be preceded by @samp{0x}, and is case-insensitive. - -@item -Extra options or text at the end of the line are ignored unless otherwise -specified. - -@item -Unrecognized commands are added to the current entry, except before entries -start, where they are ignored. @end itemize These commands can only be used in the menu: @menu * menuentry:: Start a menu entry +* submenu:: Group menu entries @end menu @@ -2470,6 +2460,22 @@ The @option{--hotkey} option associates a hotkey with a menu entry. @end deffn +@node submenu +@subsection submenu + +@deffn Command submenu @var{title} @ + [@option{--class=class} @dots{}] [@option{--users=users}] @ + [@option{--hotkey=key}] @ + @{ @var{menu entries} @dots{} @} +This defines a submenu. An entry called @var{title} will be added to the +menu; when that entry is selected, a new menu will be displayed showing all +the entries within this submenu. + +All options are the same as in the @command{menuentry} command +(@pxref{menuentry}). +@end deffn + + @node General commands @section The list of general commands @@ -2590,6 +2596,7 @@ you forget a command, you can run the command @command{help} * drivemap:: Map a drive to another * echo:: Display a line of text * export:: Export an environment variable +* false:: Do nothing, unsuccessfully * gettext:: Translate a string * gptsync:: Fill an MBR based on GPT entries * halt:: Shut down your computer @@ -2607,10 +2614,12 @@ you forget a command, you can run the command @command{help} * password_pbkdf2:: Set a hashed password * play:: Play a tune * pxe_unload:: Unload the PXE environment +* read:: Read user input * reboot:: Reboot your computer * search:: Search devices by file, label, or UUID * sendkey:: Emulate keystrokes * set:: Set an environment variable +* true:: Do nothing, successfully * unset:: Unset an environment variable * uppermem:: Set the upper memory size @end menu @@ -2853,6 +2862,15 @@ to subsidiary configuration files loaded using @command{configfile}. @end deffn +@node false +@subsection false + +@deffn Command false +Do nothing, unsuccessfully. This is mainly useful in control constructs +such as @code{if} and @code{while} (@pxref{Shell-like scripting}). +@end deffn + + @node gettext @subsection gettext @@ -3106,6 +3124,16 @@ This command is only available on PC BIOS systems. @end deffn +@node read +@subsection read + +@deffn Command read [var] +Read a line of input from the user. If an environment variable @var{var} is +given, set that environment variable to the line of input that was read, +with no terminating newline. +@end deffn + + @node reboot @subsection reboot @@ -3294,6 +3322,15 @@ arguments, print all environment variables with their values. @end deffn +@node true +@subsection true + +@deffn Command true +Do nothing, successfully. This is mainly useful in control constructs such +as @code{if} and @code{while} (@pxref{Shell-like scripting}). +@end deffn + + @node unset @subsection unset From 5d8031749e8b8642d31f6f9da510bca3872ffea2 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 30 Mar 2011 09:26:23 +0200 Subject: [PATCH 182/276] * grub-core/term/at_keyboard.c (set_scancodes) [!GRUB_MACHINE_MIPS_YEELOONG && !GRUB_MACHINE_QEMU]: Use scancode set 1. --- ChangeLog | 5 +++++ grub-core/term/at_keyboard.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9fc7fdcf0..778d86145 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Vladimir Serbinenko + + * grub-core/term/at_keyboard.c (set_scancodes) + [!GRUB_MACHINE_MIPS_YEELOONG && !GRUB_MACHINE_QEMU]: Use scancode set 1. + 2011-03-30 Colin Watson * docs/grub.texi (Menu-specific commands): Remove some semantics diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c index 55cb76483..7ce287ecc 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -330,6 +330,11 @@ set_scancodes (void) return; } +#if !(defined (GRUB_MACHINE_MIPS_YEELOONG) || defined (GRUB_MACHINE_QEMU)) + current_set = 1; + return; +#endif + grub_keyboard_controller_write (grub_keyboard_controller_orig & ~KEYBOARD_AT_TRANSLATE); From e1ad0edd11ea71bdb059fd2768a5e2dbe6589315 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 30 Mar 2011 09:35:35 +0200 Subject: [PATCH 183/276] * docs/grub.texi: Correctly use "terminal_input" and not "terminal" in the example. --- ChangeLog | 5 +++++ docs/grub.texi | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 778d86145..c28b07653 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Vladimir Serbinenko + + * docs/grub.texi: Correctly use "terminal_input" and not "terminal" in + the example. + 2011-03-30 Vladimir Serbinenko * grub-core/term/at_keyboard.c (set_scancodes) diff --git a/docs/grub.texi b/docs/grub.texi index 9abf1b174..a347579b3 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1998,7 +1998,7 @@ The commands @command{terminal_input} (@pxref{terminal_input}) and @command{terminal_output} (@pxref{terminal_output}) choose which type of terminal you want to use. In the case above, the terminal will be a serial terminal, but you can also pass @code{console} to the command, -as @samp{terminal serial console}. In this case, a terminal in which +as @samp{terminal_input serial console}. In this case, a terminal in which you press any key will be selected as a GRUB terminal. In the example above, note that you need to put both commands on the same command line, as you will lose the ability to type commands on the console after the first From abf042006ef39370254e3758970d9bcab37218cb Mon Sep 17 00:00:00 2001 From: <> Date: Wed, 30 Mar 2011 11:31:33 +0100 Subject: [PATCH 184/276] * docs/grub.texi (Environment): New chapter. (Changes from GRUB Legacy): Link to "Environment block" section for details of limitations. (Simple configuration): Likewise. Link to documentation of gfxmode and gfxpayload variables from GRUB_GFXMODE and GRUB_GFXPAYLOAD respectively. (Shell-like scripting): Note that normal variables are stored in the environment. (gettext): Link to documentation of lang and locale_dir. (list_env): New section. (load_env): New section. (save_env): New section. (Reporting bugs): Fix typo. --- ChangeLog | 17 ++ docs/grub.texi | 493 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 498 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index c28b07653..61727a1dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2011-03-30 Colin Watson + + * docs/grub.texi (Environment): New chapter. + (Changes from GRUB Legacy): Link to "Environment block" section for + details of limitations. + (Simple configuration): Likewise. Link to documentation of gfxmode + and gfxpayload variables from GRUB_GFXMODE and GRUB_GFXPAYLOAD + respectively. + (Shell-like scripting): Note that normal variables are stored in the + environment. + (gettext): Link to documentation of lang and locale_dir. + (list_env): New section. + (load_env): New section. + (save_env): New section. + + (Reporting bugs): Fix typo. + 2011-03-30 Vladimir Serbinenko * docs/grub.texi: Correctly use "terminal_input" and not "terminal" in diff --git a/docs/grub.texi b/docs/grub.texi index a347579b3..8441dd267 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -87,6 +87,7 @@ This edition documents version @value{VERSION}. * Images:: GRUB image files * Filesystem:: Filesystem syntax and semantics * Interface:: The menu and the command-line +* Environment:: GRUB environment variables * Commands:: The list of available builtin commands * Security:: Authentication and authorisation * Supported kernels:: The list of supported kernels @@ -229,10 +230,8 @@ scripting language: variables, conditionals, and loops are available. @item A small amount of persistent storage is available across reboots, using the @command{save_env} and @command{load_env} commands in GRUB and the -@command{grub-editenv} utility. For safety reasons, this storage is only -available when installed on a plain disk (no LVM or RAID), using a -non-checksumming filesystem (no ZFS), and using BIOS or EFI functions (no -ATA, USB or IEEE1275). +@command{grub-editenv} utility. This is not available in all configurations +(@pxref{Environment block}). @item GRUB 2 has more reliable ways to find its own files and those of target @@ -1109,8 +1108,8 @@ it as a new default entry for use by future runs of GRUB. This is only useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because @samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with @command{grub-set-default} or @command{grub-reboot}. Unset by default. -@samp{save_env} may not be available in all situations -(@pxref{Changes from GRUB Legacy}). +This option relies on the environment block, which may not be available in +all situations (@pxref{Environment block}). @item GRUB_TIMEOUT Boot the default entry this many seconds after the menu is displayed, unless @@ -1215,7 +1214,7 @@ listed in @file{/boot/grub/video.lst}. Set the resolution used on the @samp{gfxterm} graphical terminal. Note that you can only use modes which your graphics card supports via VESA BIOS Extensions (VBE), so for example native LCD panel resolutions may not be -available. The default is @samp{640x480}. +available. The default is @samp{640x480}. @xref{gfxmode}. @item GRUB_BACKGROUND Set a background image for use with the @samp{gfxterm} graphical terminal. @@ -1231,7 +1230,7 @@ Set to @samp{text} to force the Linux kernel to boot in normal text mode, @samp{keep} to preserve the graphics mode set using @samp{GRUB_GFXMODE}, @samp{@var{width}x@var{height}}[@samp{x@var{depth}}] to set a particular graphics mode, or a sequence of these separated by commas or semicolons to -try several modes in sequence. +try several modes in sequence. @xref{gfxpayload}. Depending on your kernel, your distribution, your graphics card, and the phase of the moon, note that using this option may cause GNU/Linux to suffer @@ -1342,7 +1341,8 @@ protect the variable to be expanded from characters immediately following it which could be interpreted as part of the name. Normal variable names begin with an alphabetic character, followed by zero -or more alphanumeric characters. +or more alphanumeric characters. These names refer to entries in the GRUB +environment (@pxref{Environment}). Positional variable names consist of one or more digits. They represent parameters passed to function calls, with @samp{$1} representing the first @@ -2384,6 +2384,437 @@ Although GRUB unfortunately does not support @dfn{undo}, you can do almost the same thing by just returning to the main menu using @key{ESC}. +@node Environment +@chapter GRUB environment variables + +GRUB supports environment variables which are rather like those offered by +all Unix-like systems. Environment variables have a name, which is unique +and is usually a short identifier, and a value, which is an arbitrary string +of characters. They may be set (@pxref{set}), unset (@pxref{unset}), or +looked up (@pxref{Shell-like scripting}) by name. + +A number of environment variables have special meanings to various parts of +GRUB. Others may be used freely in GRUB configuration files. + + +@menu +* Special environment variables:: +* Environment block:: +@end menu + + +@node Special environment variables +@section Special environment variables + +These variables have special meaning to GRUB. + +@menu +* biosnum:: +* chosen:: +* color_highlight:: +* color_normal:: +* debug:: +* default:: +* fallback:: +* gfxmode:: +* gfxpayload:: +* gfxterm_font:: +* icondir:: +* lang:: +* locale_dir:: +* menu_color_highlight:: +* menu_color_normal:: +* net_pxe_boot_file:: +* net_pxe_dhcp_server_name:: +* net_pxe_domain:: +* net_pxe_extensionspath:: +* net_pxe_hostname:: +* net_pxe_ip:: +* net_pxe_mac:: +* net_pxe_rootpath:: +* pager:: +* prefix:: +* pxe_blksize:: +* pxe_default_gateway:: +* pxe_default_server:: +* root:: +* superusers:: +* theme:: +* timeout:: +@end menu + + +@node biosnum +@subsection biosnum + +When chain-loading another boot loader (@pxref{Chain-loading}), GRUB may +need to know what BIOS drive number corresponds to the root device +(@pxref{root}) so that it can set up registers properly. If the +@var{biosnum} variable is set, it overrides GRUB's own means of guessing +this. + +For an alternative approach which also changes BIOS drive mappings for the +chain-loaded system, @pxref{drivemap}. + + +@node chosen +@subsection chosen + +When executing a menu entry, GRUB sets the @var{chosen} variable to the +title of the entry being executed. + +If the menu entry is in one or more submenus, then @var{chosen} is set to +the titles of each of the submenus starting from the top level followed by +the title of the menu entry itself, separated by @samp{>}. + + +@node color_highlight +@subsection color_highlight + +This variable contains the ``highlight'' foreground and background terminal +colors, separated by a slash (@samp{/}). Setting this variable changes +those colors. For the available color names, @pxref{color_normal}. + +The default is @samp{black/white}. + + +@node color_normal +@subsection color_normal + +This variable contains the ``normal'' foreground and background terminal +colors, separated by a slash (@samp{/}). Setting this variable changes +those colors. Each color must be a name from the following list: + +@itemize @bullet +@item black +@item blue +@item green +@item cyan +@item red +@item magenta +@item brown +@item light-gray +@item dark-gray +@item light-blue +@item light-green +@item light-cyan +@item light-red +@item light-magenta +@item yellow +@item white +@end itemize + +The default is @samp{white/black}. + + +@node debug +@subsection debug + +This variable may be set to enable debugging output from various components +of GRUB. The value is a list of debug facility names separated by +whitespace or @samp{,}, or @samp{all} to enable all available debugging +output. + + +@node default +@subsection default + +If this variable is set, it identifies a menu entry that should be selected +by default, possibly after a timeout (@pxref{timeout}). The entry may be +identified by number or by title. + +If the entry is in a submenu, then it must be identified using the titles of +each of the submenus starting from the top level followed by the number or +title of the menu entry itself, separated by @samp{>}. For example, take +the following menu structure: + +@itemize @w +@item Submenu 1 +@itemize @w +@item Menu Entry 1 +@item Menu Entry 2 +@end itemize +@item Submenu 2 +@itemize @w +@item Submenu 3 +@itemize @w +@item Menu Entry 3 +@item Menu Entry 4 +@end itemize +@item Menu Entry 5 +@end itemize +@end itemize + +``Menu Entry 3'' would then be identified as +@samp{Submenu 2>Submenu 3>Menu Entry 3}. + +This variable is often set by @samp{GRUB_DEFAULT} (@pxref{Simple +configuration}), @command{grub-set-default}, or @command{grub-reboot}. + + +@node fallback +@subsection fallback + +If this variable is set, it identifies a menu entry that should be selected +if the default menu entry fails to boot. Entries are identified in the same +way as for @samp{default} (@pxref{default}). + + +@node gfxmode +@subsection gfxmode + +If this variable is set, it sets the resolution used on the @samp{gfxterm} +graphical terminal. Note that you can only use modes which your graphics +card supports via VESA BIOS Extensions (VBE), so for example native LCD +panel resolutions may not be available. The default is @samp{auto}, which +selects a platform-specific default that should look reasonable. + +The resolution may be specified as a sequence of one or more modes, +separated by commas (@samp{,}) or semicolons (@samp{;}); each will be tried +in turn until one is found. Each mode should be either @samp{auto}, +@samp{@var{width}x@var{height}}, or +@samp{@var{width}x@var{height}x@var{depth}}. + + +@node gfxpayload +@subsection gfxpayload + +If this variable is set, it controls the video mode in which the Linux +kernel starts up, replacing the @samp{vga=} boot option (@pxref{linux}). It +may be set to @samp{text} to force the Linux kernel to boot in normal text +mode, @samp{keep} to preserve the graphics mode set using @samp{gfxmode}, or +any of the permitted values for @samp{gfxmode} to set a particular graphics +mode (@pxref{gfxmode}). + +Depending on your kernel, your distribution, your graphics card, and the +phase of the moon, note that using this option may cause GNU/Linux to suffer +from various display problems, particularly during the early part of the +boot sequence. If you have problems, set this variable to @samp{text} and +GRUB will tell Linux to boot in normal text mode. + +The default is platform-specific. On platforms with a native text mode +(such as PC BIOS platforms), the default is @samp{text}. Otherwise the +default may be @samp{auto} or a specific video mode. + +This variable is often set by @samp{GRUB_GFXPAYLOAD_LINUX} (@pxref{Simple +configuration}). + + +@node gfxterm_font +@subsection gfxterm_font + +If this variable is set, it names a font to use for text on the +@samp{gfxterm} graphical terminal. Otherwise, @samp{gfxterm} may use any +available font. + + +@node icondir +@subsection icondir + +If this variable is set, it names a directory in which the GRUB graphical +menu should look for icons after looking in the theme's @samp{icons} +directory. @xref{Theme file format}. + + +@node lang +@subsection lang + +If this variable is set, it names the language code that the +@command{gettext} command (@pxref{gettext}) uses to translate strings. For +example, French would be named as @samp{fr}, and Simplified Chinese as +@samp{zh_CN}. + +@command{grub-mkconfig} (@pxref{Simple configuration}) will try to set a +reasonable default for this variable based on the system locale. + + +@node locale_dir +@subsection locale_dir + +If this variable is set, it names the directory where translation files may +be found (@pxref{gettext}), usually @file{/boot/grub/locale}. Otherwise, +internationalization is disabled. + +@command{grub-mkconfig} (@pxref{Simple configuration}) will set a reasonable +default for this variable if internationalization is needed and any +translation files are available. + + +@node menu_color_highlight +@subsection menu_color_highlight + +This variable contains the foreground and background colors to be used for +the highlighted menu entry, separated by a slash (@samp{/}). Setting this +variable changes those colors. For the available color names, +@pxref{color_normal}. + +The default is the value of @samp{color_highlight} +(@pxref{color_highlight}). + + +@node menu_color_normal +@subsection menu_color_normal + +This variable contains the foreground and background colors to be used for +non-highlighted menu entries, separated by a slash (@samp{/}). Setting this +variable changes those colors. For the available color names, +@pxref{color_normal}. + +The default is the value of @samp{color_normal} (@pxref{color_normal}). + + +@node net_pxe_boot_file +@subsection net_pxe_boot_file + +@xref{Network}. + + +@node net_pxe_dhcp_server_name +@subsection net_pxe_dhcp_server_name + +@xref{Network}. + + +@node net_pxe_domain +@subsection net_pxe_domain + +@xref{Network}. + + +@node net_pxe_extensionspath +@subsection net_pxe_extensionspath + +@xref{Network}. + + +@node net_pxe_hostname +@subsection net_pxe_hostname + +@xref{Network}. + + +@node net_pxe_ip +@subsection net_pxe_ip + +@xref{Network}. + + +@node net_pxe_mac +@subsection net_pxe_mac + +@xref{Network}. + + +@node net_pxe_rootpath +@subsection net_pxe_rootpath + +@xref{Network}. + + +@node pager +@subsection pager + +If set to @samp{1}, pause output after each screenful and wait for keyboard +input. The default is not to pause output. + + +@node prefix +@subsection prefix + +The location of the @samp{/boot/grub} directory as an absolute file name +(@pxref{File name syntax}). This is normally set by GRUB at startup based +on information provided by @command{grub-install}. GRUB modules are +dynamically loaded from this directory, so it must be set correctly in order +for many parts of GRUB to work. + + +@node pxe_blksize +@subsection pxe_blksize + +@xref{Network}. + + +@node pxe_default_gateway +@subsection pxe_default_gateway + +@xref{Network}. + + +@node pxe_default_server +@subsection pxe_default_server + +@xref{Network}. + + +@node root +@subsection root + +The root device name (@pxref{Device syntax}). Any file names that do not +specify an explicit device name are read from this device. The default is +normally set by GRUB at startup based on the value of @samp{prefix} +(@pxref{prefix}). + +For example, if GRUB was installed to the first partition of the first hard +disk, then @samp{prefix} might be set to @samp{(hd0,msdos1)/boot/grub} and +@samp{root} to @samp{hd0,msdos1}. + + +@node superusers +@subsection superusers + +This variable may be set to a list of superuser names to enable +authentication support. @xref{Security}. + + +@node theme +@subsection theme + +This variable may be set to a directory containing a GRUB graphical menu +theme. @xref{Theme file format}. + +This variable is often set by @samp{GRUB_THEME} (@pxref{Simple +configuration}). + + +@node timeout +@subsection timeout + +If this variable is set, it specifies the time in seconds to wait for +keyboard input before booting the default menu entry. A timeout of @samp{0} +means to boot the default entry immediately without displaying the menu; a +timeout of @samp{-1} (or unset) means to wait indefinitely. + +This variable is often set by @samp{GRUB_TIMEOUT} or +@samp{GRUB_HIDDEN_TIMEOUT} (@pxref{Simple configuration}). + + +@node Environment block +@section The GRUB environment block + +It is often useful to be able to remember a small amount of information from +one boot to the next. For example, you might want to set the default menu +entry based on what was selected the last time. GRUB deliberately does not +implement support for writing files in order to minimise the possibility of +the boot loader being responsible for file system corruption, so a GRUB +configuration file cannot just create a file in the ordinary way. However, +GRUB provides an ``environment block'' which can be used to save a small +amount of state. + +The environment block is a preallocated 1024-byte file, which normally lives +in @file{/boot/grub/grubenv} (although you should not assume this). At boot +time, the @command{load_env} command (@pxref{load_env}) loads environment +variables from it, and the @command{save_env} (@pxref{save_env}) command +saves environment variables to it. From a running system, the +@command{grub-editenv} utility can be used to edit the environment block. + +For safety reasons, this storage is only available when installed on a plain +disk (no LVM or RAID), using a non-checksumming filesystem (no ZFS), and +using BIOS or EFI functions (no ATA, USB or IEEE1275). + +@command{grub-mkconfig} uses this facility to implement +@samp{GRUB_SAVEDEFAULT} (@pxref{Simple configuration}). + + @node Commands @chapter The list of available commands @@ -2607,6 +3038,8 @@ you forget a command, you can run the command @command{help} * keystatus:: Check key modifier status * linux:: Load a Linux kernel * linux16:: Load a Linux kernel (16-bit mode) +* list_env:: List variables in environment block +* load_env:: Load variables from environment block * loopback:: Make a device from a filesystem image * ls:: List devices or files * parttool:: Modify partition table entries @@ -2616,6 +3049,7 @@ you forget a command, you can run the command @command{help} * pxe_unload:: Unload the PXE environment * read:: Read user input * reboot:: Reboot your computer +* save_env:: Save variables to environment block * search:: Search devices by file, label, or UUID * sendkey:: Emulate keystrokes * set:: Set an environment variable @@ -2878,8 +3312,8 @@ such as @code{if} and @code{while} (@pxref{Shell-like scripting}). Translate @var{string} into the current language. The current language code is stored in the @samp{lang} variable in GRUB's -environment. Translation files in MO format are read from -@samp{locale_dir}, usually @file{/boot/grub/locale}. +environment (@pxref{lang}). Translation files in MO format are read from +@samp{locale_dir} (@pxref{locale_dir}), usually @file{/boot/grub/locale}. @end deffn @@ -3008,6 +3442,29 @@ This command is only available on x86 systems. @end deffn +@node list_env +@subsection list_env + +@deffn Command list_env [@option{-f} file] +List all variables in the environment block file. @xref{Environment block}. + +The @option{-f} option overrides the default location of the environment +block. +@end deffn + + +@node load_env +@subsection load_env + +@deffn Command load_env [@option{-f} file] +Load all variables from the environment block file into the environment. +@xref{Environment block}. + +The @option{-f} option overrides the default location of the environment +block. +@end deffn + + @node loopback @subsection loopback @@ -3142,6 +3599,18 @@ Reboot the computer. @end deffn +@node save_env +@subsection save_env + +@deffn Command save_env [@option{-f} file] var @dots{} +Save the named variables from the environment to the environment block file. +@xref{Environment block}. + +The @option{-f} option overrides the default location of the environment +block. +@end deffn + + @node search @subsection search @@ -3868,7 +4337,7 @@ for. @item Write down anything that you think might be related. Please understand -that we often need to reproduce the same problem you encounterred in our +that we often need to reproduce the same problem you encountered in our environment. So your information should be sufficient for us to do the same thing---Don't forget that we cannot see your computer directly. If you are not sure whether to state a fact or leave it out, state it! From 3d7ed04e92786d287be33a31aa62daff823e4435 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 30 Mar 2011 11:34:52 +0100 Subject: [PATCH 185/276] * docs/grub.texi (Future): Update. --- ChangeLog | 4 ++++ docs/grub.texi | 11 +++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 61727a1dd..10bb289cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-30 Colin Watson + + * docs/grub.texi (Future): Update. + 2011-03-30 Colin Watson * docs/grub.texi (Environment): New chapter. diff --git a/docs/grub.texi b/docs/grub.texi index 8441dd267..1c21cb67d 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -4357,12 +4357,11 @@ Once we get your report, we will try to fix the bugs. @node Future @appendix Where GRUB will go -We started the next generation of GRUB, GRUB 2. GRUB 2 includes -internationalization, dynamic module loading, real memory management, -multiple architecture support, a scripting language, and many other -nice features. If you are interested in the development of GRUB 2, take -a look at @uref{http://www.gnu.org/software/grub/grub.html, the -homepage}. +GRUB 2 is now quite stable and used in many production systems. We are +currently working towards a 2.0 release. + +If you are interested in the development of GRUB 2, take a look at +@uref{http://www.gnu.org/software/grub/grub.html, the homepage}. @node Internals From 2d5d0333d6982e175edc5982b487cf11514e1fb3 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 30 Mar 2011 11:46:36 +0100 Subject: [PATCH 186/276] * docs/grub.texi (default): Use @example rather than nested itemized lists to avoid breaking gendocs. --- ChangeLog | 5 +++++ docs/grub.texi | 26 ++++++++++---------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 10bb289cc..1e20b132e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Colin Watson + + * docs/grub.texi (default): Use @example rather than nested + itemized lists to avoid breaking gendocs. + 2011-03-30 Colin Watson * docs/grub.texi (Future): Update. diff --git a/docs/grub.texi b/docs/grub.texi index 1c21cb67d..dd3afcf48 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -2528,22 +2528,16 @@ each of the submenus starting from the top level followed by the number or title of the menu entry itself, separated by @samp{>}. For example, take the following menu structure: -@itemize @w -@item Submenu 1 -@itemize @w -@item Menu Entry 1 -@item Menu Entry 2 -@end itemize -@item Submenu 2 -@itemize @w -@item Submenu 3 -@itemize @w -@item Menu Entry 3 -@item Menu Entry 4 -@end itemize -@item Menu Entry 5 -@end itemize -@end itemize +@example +Submenu 1 + Menu Entry 1 + Menu Entry 2 +Submenu 2 + Submenu 3 + Menu Entry 3 + Menu Entry 4 + Menu Entry 5 +@end example ``Menu Entry 3'' would then be identified as @samp{Submenu 2>Submenu 3>Menu Entry 3}. From 87d1aa1927c2e91dcd37341e6e363011a8a48c05 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 30 Mar 2011 13:02:39 +0200 Subject: [PATCH 187/276] * grub-core/disk/lvm.c (grub_lvm_scan_device): Remove spurious \n. --- ChangeLog | 4 ++++ grub-core/disk/lvm.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1e20b132e..103d12189 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,10 @@ (Reporting bugs): Fix typo. +2011-03-30 Vladimir Serbinenko + + * grub-core/disk/lvm.c (grub_lvm_scan_device): Remove spurious \n. + 2011-03-30 Vladimir Serbinenko * docs/grub.texi: Correctly use "terminal_input" and not "terminal" in diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index b1a7a50a9..5a79063da 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -336,7 +336,7 @@ grub_lvm_scan_device (const char *name) if (i == GRUB_LVM_LABEL_SCAN_SECTORS) { #ifdef GRUB_UTIL - grub_util_info ("no LVM signature found\n"); + grub_util_info ("no LVM signature found"); #endif goto fail; } From 5e631b4fcb6cf6a5b47834a55a32c65c1121c905 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 30 Mar 2011 12:07:43 +0100 Subject: [PATCH 188/276] fix ChangeLog ordering --- ChangeLog | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 103d12189..b251826af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-30 Vladimir Serbinenko + + * grub-core/disk/lvm.c (grub_lvm_scan_device): Remove spurious \n. + 2011-03-30 Colin Watson * docs/grub.texi (default): Use @example rather than nested @@ -24,10 +28,6 @@ (Reporting bugs): Fix typo. -2011-03-30 Vladimir Serbinenko - - * grub-core/disk/lvm.c (grub_lvm_scan_device): Remove spurious \n. - 2011-03-30 Vladimir Serbinenko * docs/grub.texi: Correctly use "terminal_input" and not "terminal" in From c871b1c6d0ff9dcb79f7b4b9503eacfa8b405509 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 30 Mar 2011 13:13:25 +0200 Subject: [PATCH 189/276] * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_get_grub_dev): Add few potentially useful grub_util_info. --- ChangeLog | 5 +++++ grub-core/kern/emu/hostdisk.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index b251826af..b93141df6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Vladimir Serbinenko + + * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_get_grub_dev): Add + few potentially useful grub_util_info. + 2011-03-30 Vladimir Serbinenko * grub-core/disk/lvm.c (grub_lvm_scan_device): Remove spurious \n. diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 9900a79bd..d5b0439fb 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -1518,6 +1518,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) if (stat (os_dev, &st) < 0) { grub_error (GRUB_ERR_BAD_DEVICE, "cannot stat `%s'", os_dev); + grub_util_info ("cannot stat `%s'", os_dev); return 0; } @@ -1526,6 +1527,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) { grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no mapping exists for `%s'", os_dev); + grub_util_info ("no mapping exists for `%s'", os_dev); return 0; } From 56445fb2b459f3dce2b7dc8b70cf9db90aae9d88 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 30 Mar 2011 16:37:10 +0200 Subject: [PATCH 190/276] * grub-core/kern/emu/getroot.c (grub_util_get_grub_dev) [__linux__]: Preserve partition number in mdadm code path. --- ChangeLog | 5 +++++ grub-core/kern/emu/getroot.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index b93141df6..0afcadf68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Vladimir Serbinenko + + * grub-core/kern/emu/getroot.c (grub_util_get_grub_dev) [__linux__]: + Preserve partition number in mdadm code path. + 2011-03-30 Vladimir Serbinenko * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_get_grub_dev): Add diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index 1d87442d9..ae066d2f8 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -808,12 +808,30 @@ grub_util_get_grub_dev (const char *os_dev) if (mdadm_name) { char *newname; + char *q; + + for (q = os_dev + strlen (os_dev) - 1; q >= os_dev && isdigit (*q); + q--); + + if (q >= os_dev && *q == 'p') + { + newname = xasprintf ("/dev/md/%sp%s", mdadm_name, q + 1); + if (stat (newname, &st) == 0) + { + free (grub_dev); + grub_dev = xasprintf ("md/%s,%s", mdadm_name, q + 1); + goto done; + } + free (newname); + } newname = xasprintf ("/dev/md/%s", mdadm_name); if (stat (newname, &st) == 0) { free (grub_dev); grub_dev = xasprintf ("md/%s", mdadm_name); } + + done: free (newname); free (mdadm_name); } From 241e41f55c5cb9b05f7f596a8ea039bcb6ebb031 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 30 Mar 2011 16:54:11 +0200 Subject: [PATCH 191/276] * grub-core/disk/raid.c (insert_array): Add few potentially useful grub_util_info. (grub_raid_register): Likewise. --- ChangeLog | 6 ++++++ grub-core/disk/raid.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0afcadf68..35a2de3e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-30 Vladimir Serbinenko + + * grub-core/disk/raid.c (insert_array): Add few potentially + useful grub_util_info. + (grub_raid_register): Likewise. + 2011-03-30 Vladimir Serbinenko * grub-core/kern/emu/getroot.c (grub_util_get_grub_dev) [__linux__]: diff --git a/grub-core/disk/raid.c b/grub-core/disk/raid.c index 9d2468b88..c89ca62a1 100644 --- a/grub-core/disk/raid.c +++ b/grub-core/disk/raid.c @@ -638,6 +638,10 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array, grub_dprintf ("raid", "Found array %s (%s)\n", array->name, scanner_name); +#ifdef GRUB_UTIL + grub_util_info ("Found array %s (%s)", array->name, + scanner_name); +#endif /* Add our new array to the list. */ array->next = array_list; @@ -698,6 +702,10 @@ grub_raid_register (grub_raid_t raid) grub_dprintf ("raid", "Scanning for %s RAID devices on disk %s\n", grub_raid_list->name, name); +#ifdef GRUB_UTIL + grub_util_info ("Scanning for %s RAID devices on disk %s", + grub_raid_list->name, name); +#endif disk = grub_disk_open (name); if (!disk) From baad885c14a5e982e19ad8d8c00177dd8ffda8e4 Mon Sep 17 00:00:00 2001 From: Alexey Shvetsov Date: Wed, 30 Mar 2011 19:22:28 +0200 Subject: [PATCH 192/276] * util/grub.d/10_linux.in: Add gentoo-specific Linux and initrd names. * util/grub.d/20_linux_xen.in: Likewise. --- ChangeLog | 5 +++++ util/grub.d/10_linux.in | 8 +++++--- util/grub.d/20_linux_xen.in | 6 ++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 35a2de3e3..462b15810 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Alexey Shvetsov + + * util/grub.d/10_linux.in: Add gentoo-specific Linux and initrd names. + * util/grub.d/20_linux_xen.in: Likewise. + 2011-03-30 Vladimir Serbinenko * grub-core/disk/raid.c (insert_array): Add few potentially diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index d12902e33..9d13529d6 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -113,11 +113,11 @@ EOF case x`uname -m` in xi?86 | xx86_64) - list=`for i in /boot/vmlinuz-* /vmlinuz-* ; do + list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi done` ;; *) - list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* ; do + list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi done` ;; esac @@ -138,7 +138,9 @@ while [ "x$list" != "x" ] ; do for i in "initrd.img-${version}" "initrd-${version}.img" \ "initrd-${version}" "initramfs-${version}.img" \ "initrd.img-${alt_version}" "initrd-${alt_version}.img" \ - "initrd-${alt_version}" "initramfs-${alt_version}.img"; do + "initrd-${alt_version}" "initramfs-${alt_version}.img" \ + "initramfs-genkernel-${version}" \ + "initramfs-genkernel-${alt_version}"; do if test -e "${dirname}/${i}" ; then initrd="$i" break diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index bacd8ffea..50938d1c7 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -93,7 +93,7 @@ EOF EOF } -linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do +linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do basename=$(basename $i) version=$(echo $basename | sed -e "s,^[^0-9]*-,,g") if grub_file_is_not_garbage "$i" && (grep -qx "CONFIG_XEN_DOM0=y" /boot/config-${version} 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" /boot/config-${version} 2> /dev/null); then echo -n "$i " ; fi @@ -127,7 +127,9 @@ while [ "x${xen_list}" != "x" ] ; do initrd= for i in "initrd.img-${version}" "initrd-${version}.img" \ "initrd-${version}" "initrd.img-${alt_version}" \ - "initrd-${alt_version}.img" "initrd-${alt_version}"; do + "initrd-${alt_version}.img" "initrd-${alt_version}" \ + "initramfs-genkernel-${version}" \ + "initramfs-genkernel-${alt_version}" ; do if test -e "${dirname}/${i}" ; then initrd="$i" break From 090b1b6ac665f656a5f3ba0e3e59d9d138994238 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 30 Mar 2011 20:42:42 +0200 Subject: [PATCH 193/276] * util/grub.d/10_linux.in: Try alternative config filenames where we parse config file. * util/grub.d/20_linux_xen.in: Likewise. --- ChangeLog | 6 ++++++ util/grub.d/10_linux.in | 13 +++++++++---- util/grub.d/20_linux_xen.in | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 462b15810..95e7363a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-30 Vladimir Serbinenko + + * util/grub.d/10_linux.in: Try alternative config filenames where + we parse config file. + * util/grub.d/20_linux_xen.in: Likewise. + 2011-03-30 Alexey Shvetsov * util/grub.d/10_linux.in: Add gentoo-specific Linux and initrd names. diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 9d13529d6..4f8a7927c 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -73,8 +73,8 @@ linux_entry () cat << EOF load_video EOF - if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null \ - && grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" /boot/config-${version} 2> /dev/null; then + if grep -qx "CONFIG_FB_EFI=y" "${config}" 2> /dev/null \ + && grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" "${config}" 2> /dev/null; then cat << EOF set gfxpayload=keep EOF @@ -147,14 +147,19 @@ while [ "x$list" != "x" ] ; do fi done - initramfs= + config= for i in "config-${version}" "config-${alt_version}"; do if test -e "${dirname}/${i}" ; then - initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${dirname}/${i}" | cut -f2 -d= | tr -d \"` + config="${dirname}/${i}" break fi done + initramfs= + if test -n "${config}" ; then + initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"` + fi + if test -n "${initrd}" ; then echo "Found initrd image: ${dirname}/${initrd}" >&2 elif test -z "${initramfs}" ; then diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 50938d1c7..59a953ebb 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -94,10 +94,20 @@ EOF } linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do + if grub_file_is_not_garbage "$i"; then basename=$(basename $i) version=$(echo $basename | sed -e "s,^[^0-9]*-,,g") - if grub_file_is_not_garbage "$i" && (grep -qx "CONFIG_XEN_DOM0=y" /boot/config-${version} 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" /boot/config-${version} 2> /dev/null); then echo -n "$i " ; fi - done` + dirname=$(dirname $i) + config= + for j in "config-${version}" "config-${alt_version}"; do + if test -e "${dirname}/${j}" ; then + config="${dirname}/${j}" + break + fi + done + if (grep -qx "CONFIG_XEN_DOM0=y" "${config}" 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" "${config}" 2> /dev/null); then echo -n "$i " ; fi + fi + done` if [ "x${linux_list}" = "x" ] ; then exit 0 fi From fd7cd914c6763c4aa2810974c69dc0edb3000946 Mon Sep 17 00:00:00 2001 From: Alexey Shvetsov Date: Wed, 30 Mar 2011 20:53:23 +0200 Subject: [PATCH 194/276] * util/grub.d/10_linux.in: Add gentoo-specific config filename. * util/grub.d/20_linux_xen.in: Likewise. --- ChangeLog | 5 +++++ util/grub.d/10_linux.in | 6 +++--- util/grub.d/20_linux_xen.in | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95e7363a2..d0f2acacc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Alexey Shvetsov + + * util/grub.d/10_linux.in: Add gentoo-specific config filename. + * util/grub.d/20_linux_xen.in: Likewise. + 2011-03-30 Vladimir Serbinenko * util/grub.d/10_linux.in: Try alternative config filenames where diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 4f8a7927c..930ce06ef 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -148,9 +148,9 @@ while [ "x$list" != "x" ] ; do done config= - for i in "config-${version}" "config-${alt_version}"; do - if test -e "${dirname}/${i}" ; then - config="${dirname}/${i}" + for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do + if test -e "${i}" ; then + config="${i}" break fi done diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 59a953ebb..858627aa3 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -99,9 +99,9 @@ linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do version=$(echo $basename | sed -e "s,^[^0-9]*-,,g") dirname=$(dirname $i) config= - for j in "config-${version}" "config-${alt_version}"; do - if test -e "${dirname}/${j}" ; then - config="${dirname}/${j}" + for j in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do + if test -e "${j}" ; then + config="${j}" break fi done From 875b67ba09992be7f75534513d84e505789c48b5 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 30 Mar 2011 20:52:26 +0100 Subject: [PATCH 195/276] * docs/grub.texi (Commands): Link to "GRUB only offers a rescue shell". --- ChangeLog | 5 +++++ docs/grub.texi | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d0f2acacc..1a533ae17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Colin Watson + + * docs/grub.texi (Commands): Link to "GRUB only offers a rescue + shell". + 2011-03-30 Alexey Shvetsov * util/grub.d/10_linux.in: Add gentoo-specific config filename. diff --git a/docs/grub.texi b/docs/grub.texi index dd3afcf48..fa38b96ff 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -2821,7 +2821,9 @@ anywhere in the menu or specifically in the menu entries. In rescue mode, only the @command{insmod} (@pxref{insmod}), @command{ls} (@pxref{ls}), @command{set} (@pxref{set}), and @command{unset} -(@pxref{unset}) commands are normally available. +(@pxref{unset}) commands are normally available. If you end up in rescue +mode and do not know what to do, then @pxref{GRUB only offers a rescue +shell}. @menu * Menu-specific commands:: From a826cc7d7e09da20b514f3e2b973f89888d3d994 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 31 Mar 2011 08:46:41 +0100 Subject: [PATCH 196/276] * docs/grub.texi (Simple configuration): Be more explicit about GRUB_DEFAULT, and add an example. Reported by: Leslie Rhorer. --- ChangeLog | 6 ++++++ docs/grub.texi | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a533ae17..ff9582918 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-31 Colin Watson + + * docs/grub.texi (Simple configuration): Be more explicit about + GRUB_DEFAULT, and add an example. + Reported by: Leslie Rhorer. + 2011-03-30 Colin Watson * docs/grub.texi (Commands): Link to "GRUB only offers a rescue diff --git a/docs/grub.texi b/docs/grub.texi index fa38b96ff..0808ded6b 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1091,11 +1091,25 @@ Valid keys in @file{/etc/default/grub} are as follows: @table @samp @item GRUB_DEFAULT The default menu entry. This may be a number, in which case it identifies -the Nth entry in the generated menu counted from zero, or the full name of a -menu entry, or the special string @samp{saved}. Using the full name may be +the Nth entry in the generated menu counted from zero, or the title of a +menu entry, or the special string @samp{saved}. Using the title may be useful if you want to set a menu entry as the default even though there may be a variable number of entries before it. +For example, if you have: + +@verbatim +menuentry 'Example GNU/Linux distribution' --class gnu-linux { + ... +} +@end verbatim + +then you can make this the default using: + +@example +GRUB_DEFAULT='Example GNU/Linux distribution' +@end example + If you set this to @samp{saved}, then the default menu entry will be that saved by @samp{GRUB_SAVEDEFAULT}, @command{grub-set-default}, or @command{grub-reboot}. From a8afc1d12c9f4a10dc107b8a6ab819f879b10883 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 31 Mar 2011 12:25:10 +0100 Subject: [PATCH 197/276] * grub-core/mmap/efi/mmap.c (grub_mmap_unregister): Remove set-but-not-used variable. --- ChangeLog | 5 +++++ grub-core/mmap/efi/mmap.c | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ff9582918..25aa0a496 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-31 Colin Watson + + * grub-core/mmap/efi/mmap.c (grub_mmap_unregister): Remove + set-but-not-used variable. + 2011-03-31 Colin Watson * docs/grub.texi (Simple configuration): Be more explicit about diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c index 5b82a8717..8e5cce0d0 100644 --- a/grub-core/mmap/efi/mmap.c +++ b/grub-core/mmap/efi/mmap.c @@ -194,7 +194,6 @@ grub_mmap_unregister (int handle) { struct overlay *curover, *prevover; grub_efi_boot_services_t *b; - grub_efi_status_t status; b = grub_efi_system_table->boot_services; @@ -204,7 +203,7 @@ grub_mmap_unregister (int handle) { if (curover->handle == handle) { - status = efi_call_2 (b->free_pages, curover->address, curover->pages); + efi_call_2 (b->free_pages, curover->address, curover->pages); if (prevover != 0) prevover->next = curover->next; else From 91dc6073309e5582d3293c6c0a037d7f3457dc32 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 31 Mar 2011 16:48:36 +0200 Subject: [PATCH 198/276] * grub-core/kern/x86_64/efi/callwrap.S (efi_wrap_0): Preserve 16-byte stack alignment. (efi_wrap_1): Likewise. (efi_wrap_2): Likewise. (efi_wrap_3): Likewise. (efi_wrap_4): Likewise. (efi_wrap_5): Likewise. (efi_wrap_6): Likewise. (efi_wrap_10): Likewise. Based on information by: Red Hat/Peter Jones. --- ChangeLog | 13 ++++++++ grub-core/kern/x86_64/efi/callwrap.S | 44 ++++++++++++++-------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25aa0a496..847d04b03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-03-31 Vladimir Serbinenko + + * grub-core/kern/x86_64/efi/callwrap.S (efi_wrap_0): Preserve 16-byte + stack alignment. + (efi_wrap_1): Likewise. + (efi_wrap_2): Likewise. + (efi_wrap_3): Likewise. + (efi_wrap_4): Likewise. + (efi_wrap_5): Likewise. + (efi_wrap_6): Likewise. + (efi_wrap_10): Likewise. + Based on information by: Red Hat/Peter Jones. + 2011-03-31 Colin Watson * grub-core/mmap/efi/mmap.c (grub_mmap_unregister): Remove diff --git a/grub-core/kern/x86_64/efi/callwrap.S b/grub-core/kern/x86_64/efi/callwrap.S index 1946732ae..aae267872 100644 --- a/grub-core/kern/x86_64/efi/callwrap.S +++ b/grub-core/kern/x86_64/efi/callwrap.S @@ -37,80 +37,80 @@ .text FUNCTION(efi_wrap_0) - subq $40, %rsp + subq $48, %rsp call *%rdi - addq $40, %rsp + addq $48, %rsp ret FUNCTION(efi_wrap_1) - subq $40, %rsp + subq $48, %rsp mov %rsi, %rcx call *%rdi - addq $40, %rsp + addq $48, %rsp ret FUNCTION(efi_wrap_2) - subq $40, %rsp + subq $48, %rsp mov %rsi, %rcx call *%rdi - addq $40, %rsp + addq $48, %rsp ret FUNCTION(efi_wrap_3) - subq $40, %rsp + subq $48, %rsp mov %rcx, %r8 mov %rsi, %rcx call *%rdi - addq $40, %rsp + addq $48, %rsp ret FUNCTION(efi_wrap_4) - subq $40, %rsp + subq $48, %rsp mov %r8, %r9 mov %rcx, %r8 mov %rsi, %rcx call *%rdi - addq $40, %rsp + addq $48, %rsp ret FUNCTION(efi_wrap_5) - subq $40, %rsp + subq $48, %rsp mov %r9, 32(%rsp) mov %r8, %r9 mov %rcx, %r8 mov %rsi, %rcx call *%rdi - addq $40, %rsp + addq $48, %rsp ret FUNCTION(efi_wrap_6) - subq $56, %rsp - mov 56+8(%rsp), %rax + subq $64, %rsp + mov 64+8(%rsp), %rax mov %rax, 40(%rsp) mov %r9, 32(%rsp) mov %r8, %r9 mov %rcx, %r8 mov %rsi, %rcx call *%rdi - addq $56, %rsp + addq $64, %rsp ret FUNCTION(efi_wrap_10) - subq $88, %rsp - mov 88+40(%rsp), %rax + subq $96, %rsp + mov 96+40(%rsp), %rax mov %rax, 72(%rsp) - mov 88+32(%rsp), %rax + mov 96+32(%rsp), %rax mov %rax, 64(%rsp) - mov 88+24(%rsp), %rax + mov 96+24(%rsp), %rax mov %rax, 56(%rsp) - mov 88+16(%rsp), %rax + mov 96+16(%rsp), %rax mov %rax, 48(%rsp) - mov 88+8(%rsp), %rax + mov 96+8(%rsp), %rax mov %rax, 40(%rsp) mov %r9, 32(%rsp) mov %r8, %r9 mov %rcx, %r8 mov %rsi, %rcx call *%rdi - addq $88, %rsp + addq $96, %rsp ret From 05d2ed3277a7c7057b77b2e62bda9d0ed8c6ef13 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 1 Apr 2011 11:43:51 +0100 Subject: [PATCH 199/276] * grub-core/normal/menu_entry.c (run): Quieten uninitialised warning. (This was in fact always initialised before use, but GCC wasn't smart enough to prove that.) * grub-core/script/lexer.c (grub_script_lexer_yywrap): Likewise. --- ChangeLog | 7 +++++++ grub-core/normal/menu_entry.c | 2 +- grub-core/script/lexer.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 847d04b03..21fd6b68b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-04-01 Colin Watson + + * grub-core/normal/menu_entry.c (run): Quieten uninitialised + warning. (This was in fact always initialised before use, but GCC + wasn't smart enough to prove that.) + * grub-core/script/lexer.c (grub_script_lexer_yywrap): Likewise. + 2011-03-31 Vladimir Serbinenko * grub-core/kern/x86_64/efi/callwrap.S (efi_wrap_0): Preserve 16-byte diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index 94f6e7f32..a675ff005 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -1165,7 +1165,7 @@ run (struct screen *screen) { char *script; int errs_before; - grub_menu_t menu; + grub_menu_t menu = NULL; char *dummy[1] = { NULL }; auto char * editor_getsource (void); diff --git a/grub-core/script/lexer.c b/grub-core/script/lexer.c index 909b515fa..98279079f 100644 --- a/grub-core/script/lexer.c +++ b/grub-core/script/lexer.c @@ -126,7 +126,7 @@ int grub_script_lexer_yywrap (struct grub_parser_param *parserstate, const char *input) { - int len; + int len = 0; char *p = 0; char *line = 0; YY_BUFFER_STATE buffer; From cfed2ad09766fb9243afe4c6ec4c4d782c75ecef Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 1 Apr 2011 15:53:06 +0200 Subject: [PATCH 200/276] Fix incorrect types in jfs.c. This enables >2TiB disks and fixes some memory corruptions. * grub-core/fs/jfs.c (struct grub_jfs_diropen): Interpret bytes as unsigned. (grub_jfs_lookup_symlink): Make ino a grub_uint32_t rather than int. (grub_jfs_blkno): Use 64-bit quantities for block sectors. (grub_jfs_read_inode): Likewise. (grub_jfs_opendir): Likewise. Remove now useless casts. (grub_jfs_getent): Likewise. Make ino a grub_uint32_t rather than int. (grub_jfs_mount): Ensure that blksize and log2_blksize are consistent. (grub_jfs_read_file): Use 64-bit quantities when necessary. Replace division and module with bit operations. (grub_jfs_find_file): Make ino a grub_uint32_t. (grub_jfs_lookup_symlink): Likewise. Use 64-bit quantities --- ChangeLog | 19 +++++++++++++ grub-core/fs/jfs.c | 69 +++++++++++++++++++++++++--------------------- 2 files changed, 57 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21fd6b68b..044be9d5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2011-04-01 Vladimir Serbinenko + + Fix incorrect types in jfs.c. This enables >2TiB disks and fixes some + memory corruptions. + + * grub-core/fs/jfs.c (struct grub_jfs_diropen): Interpret bytes as + unsigned. + (grub_jfs_lookup_symlink): Make ino a grub_uint32_t rather than int. + (grub_jfs_blkno): Use 64-bit quantities for block sectors. + (grub_jfs_read_inode): Likewise. + (grub_jfs_opendir): Likewise. Remove now useless casts. + (grub_jfs_getent): Likewise. + Make ino a grub_uint32_t rather than int. + (grub_jfs_mount): Ensure that blksize and log2_blksize are consistent. + (grub_jfs_read_file): Use 64-bit quantities when necessary. Replace + division and module with bit operations. + (grub_jfs_find_file): Make ino a grub_uint32_t. + (grub_jfs_lookup_symlink): Likewise. Use 64-bit quantities + 2011-04-01 Colin Watson * grub-core/normal/menu_entry.c (run): Quieten uninitialised diff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c index 76ef2e540..6857c4a2c 100644 --- a/grub-core/fs/jfs.c +++ b/grub-core/fs/jfs.c @@ -217,12 +217,12 @@ struct grub_jfs_diropen struct grub_jfs_tree_dir header; struct grub_jfs_leaf_dirent dirent[0]; struct grub_jfs_leaf_next_dirent next_dirent[0]; - char sorted[0]; + grub_uint8_t sorted[0]; } *dirpage __attribute__ ((packed)); struct grub_jfs_data *data; struct grub_jfs_inode *inode; int count; - char *sorted; + grub_uint8_t *sorted; struct grub_jfs_leaf_dirent *leaf; struct grub_jfs_leaf_next_dirent *next_leaf; @@ -234,13 +234,13 @@ struct grub_jfs_diropen static grub_dl_t my_mod; -static grub_err_t grub_jfs_lookup_symlink (struct grub_jfs_data *data, int ino); +static grub_err_t grub_jfs_lookup_symlink (struct grub_jfs_data *data, grub_uint32_t ino); /* Get the block number for the block BLK in the node INODE in the mounted filesystem DATA. */ -static int +static grub_int64_t grub_jfs_blkno (struct grub_jfs_data *data, struct grub_jfs_inode *inode, - unsigned int blk) + grub_uint64_t blk) { auto int getblk (struct grub_jfs_treehead *treehead, struct grub_jfs_tree_extent *extents); @@ -294,15 +294,15 @@ grub_jfs_blkno (struct grub_jfs_data *data, struct grub_jfs_inode *inode, static grub_err_t -grub_jfs_read_inode (struct grub_jfs_data *data, int ino, +grub_jfs_read_inode (struct grub_jfs_data *data, grub_uint32_t ino, struct grub_jfs_inode *inode) { struct grub_jfs_iag iag; - int iagnum = ino / 4096; - int inoext = (ino % 4096) / 32; - int inonum = (ino % 4096) % 32; - grub_uint32_t iagblk; - grub_uint32_t inoblk; + grub_uint32_t iagnum = ino / 4096; + unsigned inoext = (ino % 4096) / 32; + unsigned inonum = (ino % 4096) % 32; + grub_uint64_t iagblk; + grub_uint64_t inoblk; iagblk = grub_jfs_blkno (data, &data->fileset, iagnum + 1); if (grub_errno) @@ -348,6 +348,13 @@ grub_jfs_mount (grub_disk_t disk) goto fail; } + if (grub_le_to_cpu32 (data->sblock.blksz) + != (1U << grub_le_to_cpu16 (data->sblock.log2_blksz))) + { + grub_error (GRUB_ERR_BAD_FS, "not a JFS filesystem"); + goto fail; + } + data->disk = disk; data->pos = 0; data->linknest = 0; @@ -374,7 +381,7 @@ grub_jfs_opendir (struct grub_jfs_data *data, struct grub_jfs_inode *inode) { struct grub_jfs_internal_dirent *de; struct grub_jfs_diropen *diro; - int blk; + grub_disk_addr_t blk; de = (struct grub_jfs_internal_dirent *) inode->dir.dirents; @@ -397,7 +404,7 @@ grub_jfs_opendir (struct grub_jfs_data *data, struct grub_jfs_inode *inode) { diro->leaf = inode->dir.dirents; diro->next_leaf = (struct grub_jfs_leaf_next_dirent *) de; - diro->sorted = (char *) (inode->dir.header.sorted); + diro->sorted = inode->dir.header.sorted; diro->count = inode->dir.header.count; return diro; @@ -475,7 +482,7 @@ grub_jfs_getent (struct grub_jfs_diropen *diro) /* The last node, read in more. */ if (diro->index == diro->count) { - unsigned int next; + grub_disk_addr_t next; /* If the inode contains the entry tree or if this was the last node, there is nothing to read. */ @@ -499,7 +506,7 @@ grub_jfs_getent (struct grub_jfs_diropen *diro) diro->index = 0; } - leaf = &diro->leaf[(int) diro->sorted[diro->index]]; + leaf = &diro->leaf[diro->sorted[diro->index]]; next_leaf = &diro->next_leaf[diro->index]; len = leaf->len; @@ -540,21 +547,21 @@ static grub_ssize_t grub_jfs_read_file (struct grub_jfs_data *data, void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector, unsigned offset, unsigned length), - int pos, grub_size_t len, char *buf) + grub_uint64_t pos, grub_size_t len, char *buf) { - int i; - int blockcnt; + grub_uint64_t i; + grub_uint64_t blockcnt; - blockcnt = ((len + pos + grub_le_to_cpu32 (data->sblock.blksz) - 1) - / grub_le_to_cpu32 (data->sblock.blksz)); + blockcnt = (len + pos + grub_le_to_cpu32 (data->sblock.blksz) - 1) + >> grub_le_to_cpu16 (data->sblock.log2_blksz); - for (i = pos / grub_le_to_cpu32 (data->sblock.blksz); i < blockcnt; i++) + for (i = pos >> grub_le_to_cpu16 (data->sblock.log2_blksz); i < blockcnt; i++) { - int blknr; - int blockoff = pos % grub_le_to_cpu32 (data->sblock.blksz); - int blockend = grub_le_to_cpu32 (data->sblock.blksz); + grub_disk_addr_t blknr; + grub_uint32_t blockoff = pos & (grub_le_to_cpu32 (data->sblock.blksz) - 1); + grub_uint32_t blockend = grub_le_to_cpu32 (data->sblock.blksz); - int skipfirst = 0; + grub_uint64_t skipfirst = 0; blknr = grub_jfs_blkno (data, &data->currinode, i); if (grub_errno) @@ -563,14 +570,14 @@ grub_jfs_read_file (struct grub_jfs_data *data, /* Last block. */ if (i == blockcnt - 1) { - blockend = (len + pos) % grub_le_to_cpu32 (data->sblock.blksz); + blockend = (len + pos) & (grub_le_to_cpu32 (data->sblock.blksz) - 1); if (!blockend) blockend = grub_le_to_cpu32 (data->sblock.blksz); } /* First block. */ - if (i == (pos / (int) grub_le_to_cpu32 (data->sblock.blksz))) + if (i == (pos >> grub_le_to_cpu16 (data->sblock.log2_blksz))) { skipfirst = blockoff; blockend -= skipfirst; @@ -642,8 +649,8 @@ grub_jfs_find_file (struct grub_jfs_data *data, const char *path) pathname. */ if (!grub_strcmp (name, diro->name)) { - int ino = diro->ino; - int dirino = grub_le_to_cpu32 (data->currinode.inode); + grub_uint32_t ino = diro->ino; + grub_uint32_t dirino = grub_le_to_cpu32 (data->currinode.inode); grub_jfs_closedir (diro); diro = 0; @@ -687,9 +694,9 @@ grub_jfs_find_file (struct grub_jfs_data *data, const char *path) static grub_err_t -grub_jfs_lookup_symlink (struct grub_jfs_data *data, int ino) +grub_jfs_lookup_symlink (struct grub_jfs_data *data, grub_uint32_t ino) { - int size = grub_le_to_cpu64 (data->currinode.size); + grub_uint64_t size = grub_le_to_cpu64 (data->currinode.size); char symlink[size + 1]; if (++data->linknest > GRUB_JFS_MAX_SYMLNK_CNT) From 186ae367af232e0c8faa43abad07085d5787071c Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 1 Apr 2011 15:35:09 +0100 Subject: [PATCH 201/276] * grub-core/disk/loopback.c (grub_cmd_loopback): Fix a memory leak when replacing an existing device. --- ChangeLog | 5 +++++ grub-core/disk/loopback.c | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 044be9d5c..512b61cac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-01 Colin Watson + + * grub-core/disk/loopback.c (grub_cmd_loopback): Fix a memory leak + when replacing an existing device. + 2011-04-01 Vladimir Serbinenko Fix incorrect types in jfs.c. This enables >2TiB disks and fixes some diff --git a/grub-core/disk/loopback.c b/grub-core/disk/loopback.c index b05940a4a..02e6c164f 100644 --- a/grub-core/disk/loopback.c +++ b/grub-core/disk/loopback.c @@ -97,10 +97,6 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args) if (newdev) { - char *newname = grub_strdup (args[1]); - if (! newname) - goto fail; - grub_file_close (newdev->file); newdev->file = file; From 2cccc747acc482e710e3dd23c672ce6151fd59e9 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 1 Apr 2011 17:04:10 +0100 Subject: [PATCH 202/276] Store the loopback device as data on loopback grub_disk structures, rather than the file it points to. This fixes use of freed memory if an existing loopback device is replaced. * grub-core/disk/loopback.c (grub_loopback_open): Store dev in disk->data, not dev->file. (grub_loopback_read): Adjust file assignment to match. Fixes Ubuntu bug #742967. --- ChangeLog | 11 +++++++++++ grub-core/disk/loopback.c | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 512b61cac..fb6875c69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-04-01 Colin Watson + + Store the loopback device as data on loopback grub_disk structures, + rather than the file it points to. This fixes use of freed memory + if an existing loopback device is replaced. + + * grub-core/disk/loopback.c (grub_loopback_open): Store dev in + disk->data, not dev->file. + (grub_loopback_read): Adjust file assignment to match. + Fixes Ubuntu bug #742967. + 2011-04-01 Colin Watson * grub-core/disk/loopback.c (grub_cmd_loopback): Fix a memory leak diff --git a/grub-core/disk/loopback.c b/grub-core/disk/loopback.c index 02e6c164f..939043f01 100644 --- a/grub-core/disk/loopback.c +++ b/grub-core/disk/loopback.c @@ -162,7 +162,7 @@ grub_loopback_open (const char *name, grub_disk_t disk) disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN; disk->id = (unsigned long) dev; - disk->data = dev->file; + disk->data = dev; return 0; } @@ -171,7 +171,7 @@ static grub_err_t grub_loopback_read (grub_disk_t disk, grub_disk_addr_t sector, grub_size_t size, char *buf) { - grub_file_t file = (grub_file_t) disk->data; + grub_file_t file = ((struct grub_loopback *) disk->data)->file; grub_off_t pos; grub_file_seek (file, sector << GRUB_DISK_SECTOR_BITS); From caee5efd313a3f95babb176cc710ff193fcdb81f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 3 Apr 2011 15:30:28 +0200 Subject: [PATCH 203/276] GRUB developper manual based on existing Internals section and contributions by the various authors with active copyright assignment. * docs/Makefile.am (info_TEXINFOS): Add grub-dev.texi. * docs/font_char_metrics.png: New file. * docs/font_char_metrics.txt: Likewise. * docs/grub-dev.texi: Likewise. * docs/grub.texi (Internals): Move from here ... * docs/grub-dev.texi: ... here. --- ChangeLog | 12 + docs/Makefile.am | 2 +- docs/font_char_metrics.png | Bin 0 -> 16443 bytes docs/font_char_metrics.txt | 1 + docs/grub-dev.texi | 1515 ++++++++++++++++++++++++++++++++++++ docs/grub.texi | 106 --- 6 files changed, 1529 insertions(+), 107 deletions(-) create mode 100644 docs/font_char_metrics.png create mode 100644 docs/font_char_metrics.txt create mode 100644 docs/grub-dev.texi diff --git a/ChangeLog b/ChangeLog index fb6875c69..47bb01e7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-04-02 Vladimir Serbinenko + + GRUB developper manual based on existing Internals section and + contributions by the various authors with active copyright assignment. + + * docs/Makefile.am (info_TEXINFOS): Add grub-dev.texi. + * docs/font_char_metrics.png: New file. + * docs/font_char_metrics.txt: Likewise. + * docs/grub-dev.texi: Likewise. + * docs/grub.texi (Internals): Move from here ... + * docs/grub-dev.texi: ... here. + 2011-04-01 Colin Watson Store the loopback device as data on loopback grub_disk structures, diff --git a/docs/Makefile.am b/docs/Makefile.am index 8d9fb8445..6e1500601 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -1,7 +1,7 @@ AUTOMAKE_OPTIONS = subdir-objects # AM_MAKEINFOFLAGS = --no-split --no-validate -info_TEXINFOS = grub.texi +info_TEXINFOS = grub.texi grub-dev.texi grub_TEXINFOS = fdl.texi diff --git a/docs/font_char_metrics.png b/docs/font_char_metrics.png new file mode 100644 index 0000000000000000000000000000000000000000..8d10d1f645e3a22b1535716256adc73f262e56cb GIT binary patch literal 16443 zcmc(`_dlE8|37Z;RcfyyMr~pXswk;dt-VJDwfEjsZGw`TMQQCVC}JxyO6?%1Rl5i^ zKc27mpYZ+Ro7*kPb_{?|aar;wve%qo zs^45(oJB+*o=})5Kf-(bxF3rjhoqQDgX+;E8;z(4Q2_0$AF>W<63{-x-Q9e-!@EC* zzH_@v%QN0bfwL99?gsh#%QGE12aVClBvsCIjWhP?UkVZb9X-y#^ZBpiDfk&Lb-ZdJ z^#4=yjOy7G3-n{UL@^rm)x!-#fsxKG1p=xUzexpaUuun~HF+d@k!qMW7;U^0Pq_uK z<}Fx>C53m%4Q1^JgP&27W3Uc!=>%n317upg39oaB=kbk8qg`KcI4OXQG(J_2@oe?g z+N98Jrr^6dHKyt`VAnZ8!j(gA8fSrdsv-=c8!rL;$AWeI$BxN%IqdUzIW>b~zkX<6 z`X2|3ZD{zU1B&9rpoZ9nI4jt0l8r-N+e#$gNl}zlI3bVW1OWs&WB66Crp9O% z{J4b(stB|wQBIK7?W-Fi(N@?k*H^k(oI65uSBU$2aZ;?&Sbk^CAjzBXd>E`$@AC>Z zA{ep!FHA1EbT@J)k~@+&GM8y%EEC3fDRZ}V!hg&T3@$D0oQd3w42}$^f6N#kPB{Jc zPZjxhsw*p2V*>aD^3GCx#rK$SSqS3SUFsWAj@*y`psDLa1Jqp7@4}A5A`mq7aD#aq zI>YRyu^rxTq~c8A9^n#h{kfxoKV~2dAp+sM5GE1(wvud0k-ENZrB{KKh#!Ok&rWfU zHDtmGL@mmYCkXG)Rj~~OC|o4nNC?ODUB;#0Ur%d&nR{_jY&Z@5AweFYR>rQwtw+cv zUEx6+qEcw2DyywvsCQL8!T@N`M43q63tz$K!BPLc$V8k+9zs>~4~!N^d!ZM#+O$=a zG#yeDDD!ZV2v-O!N$pd{&g=O+jASkXF5M`}3m4XWS0|iCLyUYWpSZGKQuC7T;6{jS zwz!MEddALxhmeBVsmFTl*{9qBZvrL=K9UWUaq|{w4*HNBzfjS@-V=Xi?asQWB;&n* z>9J2@-R9xa`0Anq=Cu@OcS?8GDJ$xF84jp>!zVBGri=@RDMyxQa5VBuZ~d1(2Y+c% zPL^C6WBE7kJm|PJQ=?IqRo)QkT>BJO))9+bSwo&8C9JOGi5dqy9TMN{ADPT?mEWW& zuLW@C;xH7o*I_zlTXz+~SWbJ0Y#Ebh-EZnT&7Kq$VhwICG7y8vZ)ClzIEuDMvt0R$ zBBP^==Ec4DQ!mLvRBQIt5J1@N#t#L)-V?&eMDgn{IPGt>TCum^V&u7tF31l;1pU8@ zbxG#_$|o+|WXqKGllB1DpnNXPdYWN&_BdCJ&tP`!x0hXjN|BtHd_7G(OoT_7=$z7TnPcMMU4(|c}N!_ zcE;qFq#hiK9i4;$_%f{F2S*Z(>p_RtB;(6T6Ccu>G#UCl5tPRR-O`>kUFn~1n%3?w zNEU;#-*wMDWqS_6L@G)1g!(0`4ctUe^?uypf<~}Gaux)jmNtL2_(!KMIgKQsbVD<= zM%dT%j|0Dg3u|Eu0_he~c$ZCW8)oahF1kQxWB(^kdgf_cZrSoLvWJ>jkN+uf6Pj ztL(pZ@kILHPX<#Lx;n7)5dvTFSz?9gOaXjTN~7#qb}V|x(njOzncMmPe*2DhA&F(>RKP^Luj05$m=N)#uMVF0IabO3m7t^L&L zxHXnMvh5gl{S9FhnagdFtVHH8NDpab!4Kijytd?G}eN3JfiZ#8sScm1;rYK!+PL2@5ZbPtz-4Hr4H1O~0eRL18lU-EF%dZ#Os2ky*ypALItE!x0 zEa^?W#{$;0z>dbl6F{Csv<{g7z?C3LtkG&l;bS{dMUIN+n-1xS`@U$W{DK(o@N_z2 zn!e;O9uvK5NEP@Z!$T3+VKRkhomA@Ex7+famnPor zL95#uTSIg;+9hPdK`DgeN<{vFI)E$aTf%$>DUC(K%cqASKpaYjrX(1x>?MG@`M)dX zsb1SG$LB5*2TUSA*7)nktI9g1i;B63HeN*R<*)=bGXFeyuK;}kUKD^=ZBMv99v{n) z7X}9t@G=2z<-V4fo;Meka$aDH8|E~x^k(*U2%!-=WYQ^by>1fd_gIEsaf65`@w?u5 zT;ZX>Hwz$;((my*E}-rz zc#mzE3IZw!4W&gZt<7Hr_;k}m^m%R04V?xX)f8~n-FzZi{ic*4 zLxPYkozmJ2oQ(IVTe>k$e3Pzs`8IoKc_npJO@E*Hzh&7MZPYwTE1P>*Y7XS(v9$af zOLj`_V4*sXJ}}>JuNyp%P@cl|?MMq|+CHrt>Z0_QuEL<`2__guoth=B_n(+euHqYr z7DJyyWMCv$gmVM%HjHzuh^8;A@569w&WAoE+s899;mlOhxVa&_6eYlJTirc_Vn#j< zJ<8sN(1pOo7Gl&}8Z+!q_1E;%0x1+T5PSUt;-{l5&%C)f&nQEqTjOEhF}Eai_4nI@ zbr;d7`P!RXZYUs%&2;Jpeis-bGb-mHPy)x=Xsb5w zxs8>md&$N!sa=R4*CBpTQt35dncxQRQd{|i>qKpU7|Nru=;)FCiv6kaYg>&+>*7^d zsMuWHd^^a5{WyE7Lye`9(UBjT1Sk*ib_qfQ;VVHZXbRwUca2p))$^$;L?CY3we^WU6o1#RhAneNd6M66&9ggeWNwSi7-L@gJ53dNB;+8Y0sx*tSjrTIX#4r z<$)cNdG6oV(WtQRFUn| z-i1@bS!I~uUnz#l{sUIVsMf`HL}A1#cDBR5n}8j}9eW#VJBG+be!Vw{6g>T)pjlZk zzlLuv%|;n`n3)(3wf=^I^S{NqJ8xM%$24(;S8=uuTl z8;KvGE;n=c>jO-IA_P2D0}nkN4>P9s#Ys5=^6@|kO6UpkM)f@w-G>o4qG1X@ zH!%YChYZ4aW?RmY&fKB+#_%l;-zb_fm%`bBAeD!+RBb2mnkR96Q|;=S8io!ff9QRg zAXXk39Z!ZzaNg9`!DnQoRWiJ$TlL%qDO$6Iq%Bn2oCK0Y%-lYiQ>zdMy<;7LsM%$>PFd2wx(E9c$-OBh_*7aq!^?SlqA-1v^*j**QaYBkzOutD&Me}2%%$^4>0E1 z<$_>5_Mj@v;7a?>C)}*qA+>5}ohfNPlec5^!0>J>kGo%}yZdA0u$m5?{dXQGd|+@z z^2s?%8~LFO&%{}!_|wdX)4;d;u9cKnI7C|BhE-{K7u z$sUiQ&jiFS(W7Gp{S>Ag2vYrmF`2y8!S%7jebjyzwK#rn%QCS)`ilWL=MxR1X zCsW|{vnf1aZgoAo-u*LldHS-YD@jH3) zURE%zDH?YB`Ox!>34Fa_(sNIlYJb}WJDC4I`{Y^+r@h;WXh-Ugc624~Y(iCgHY}fI z$x1r?j2Lv>!C9dYS1D!bY9jt9wzO?*f1rKnrvMXw3bJ%J%=!)bTMqb*Jb-pcKdJO~ zWIT4*%&OM_AjU$2yuOO6dlx3>*~@5s0mvhaE6q<#q2yg7%P?RGv_ZM9k%6D-&PcfB z@ocl>Q6#(g@t`HZ^*HrrH+ZQ~x<1A+mx4r}N+?}MllDIPy^PwdFgR{i<-zd3x?zDo zZ5SsA_`YgNTwq(j5%8X_{T=Yyq^Ew!t1O_efJYBIdvEvIyBAYI)tbI>fTD6+K=Wfu z<(YbclZuo=4b!UXNM9^4aKov>*5Pl5uQ+PQqs*lYL`MJGS@U@s-q|m0ZbBMhFp=)Y zyR*LU4Vke-!?+W~Pp$H~TDt+b5uD%~!T3keClV4uNjga0Xj`lGN8rJ7ekjKYHs{l);UG!V+w^Zib{ zF!mGr@k7o1e9Cg8uOQ`QZjh#fnqK z{B$-LItgHdGlbbej0}VXoe-Sac?GfQc}yAwF*;JVZ)^X1sIoE9&%8KuYP0|F>fD(_ z)i`$Fzz_V$bg>9u%s!oR6~S?Nv@o7lHoSX9&fziMJ2aLB#oTzK7svbA2K3A<>dlODLxt-O;%>o1@R1}M5F0+)Cy z?3^wi3Y6|KCJr?xuf=g}>Z_+o&==tI5a4#XKwM?19xKd0L|bfjB7SD_P$>0{D9Qy= zQ{V!s1)QQvi37xEtRykOA*-S3-J5T=xzP>kl8t_l&(qT;21DQg@o5GfiN+JwKT3Mf z)0;^%m((e3-kk!p5@QrN1(64j{QUdrcMr#DgSl8bzNV)&EO34?Gb`AJVvU50``(r}HWEgv&6JVnV}i3>;;R=`|K={xPk_2!hECcm6*gZp z3W>O}^K(=a8P6i}Vxo5(bk}`*?(t@wc!g_9N#k`HeZIpE*q4mRpo$bXqQxUe*9zHO z5vBGYuET028;=ZJuAiabxRO_e|Fi2;R-0NeamcbH*?F{l_(V^O=t~<{9bV1c*x%2v zYKzaXlmQ~q#tiOII^7Q@S(1^s$2ntJ>1X)sv8U09R<6Cw^X@#@a;`j2i1wBh;;(+; zf(YlX{@y)oyxH=)xr!?dC zn4j_E8IZ~IV@Xg0>V@)?Gkgfc=`)6eT?-Xyr6P~mkJiJ`b;EMeoB^hTL?~U&Pqk(nyI8?5GH)ZOv_%7{ z<$Q@9G;rF5-JYyexnfy-_w>W%k3B?s#FTE1>bx{1O4X0u8A|+F zutNeTarbbPZ=2jyvqs1Eza5AFpV;rMF(WFVm_I`>qsvG`^03vS&wu#dUm1|$jyI1zg(wP`#E&G5vBFK*VNe z-2w#`^6&4loY7G&tkQqkVGEzrefeoNzVKQp908&{&6F#jWPL)o5V{keg zL+96!=NaB#&gDSkqsJzpNDM1z&Bdj&BSOzNTpH$VCE|6nS`&=4L5;phx$bQrLVcOA z@dYiY?uWwN%aS|2T~{cRey}dl!pnZh9Af#Uu!c`5&&8DHd&EVQN9+NIbklqcod%xn z8nmn_e3SCj)-axx~7HC%_1-Bxs@OO`AylVg%8mQS3> zJj8Gne9b(C3z#SvzVq4~zqW{wDqcVDOP1JAYZCI{@c`mxz%9vK1f29M{i;q2V(f20 zxFHG+iy9zOO)~X|Xb9(CQy&ig5FLS(&{OtPTvnB_#8_8B3PqjBgAVP1f*20DHG9PO zbOZO^IVJwxFz!&3skxJ*5F4=7ge&3NBj##`7XUlM)s$e@KxO#Kh%i_Q~8?nDH1kdC$0>v|__?d>{!nH9E_bYu1@Z&h3K zuh(!AdtG$>M$f?oOtHZ-9`xS+SO;&DC6-LKFp11=%Ayc9dP{K=EN7z8D9 zA0ymkrV-D(X3G!$&HUk95G5I8&00i0(UUk&y&t8T8`RzC<4~EN<_I{D3PWRc_u= zGl9(og2{ndOqPxxz~5Ey`wG!f1bNmeXTZFyf~a3EVqb;D0)s9;Fmfb8p6F~i5m9+eg0*+1e(I*pFd%ZF@DG%68qa8fu95DE~)q6=N-A)sy zodT)wdltJZK_q3FUFVj?coy`@G|TTDSpKnPy!?rW%v9MKYLECogUDOMv|epS2^-fZ zQ~N_a=Nz%E0%5qF&6mm;PUq|{uCM08y&FCK9%ZoRJWn%x-RIy+tPPLKbYNsBX-kfD z9XP+dI#v2=IHAPag?_qgX0RIZ;nSdkN>4p3a)AHWty8~bS1NDu!Hlm3yI6~VWZTmI zc0~J8C(?MUe-&hR)b0G$Q8KgJiqB79mZkL!R-G}I4VjdD;$#Yr)eQ!7aT|C&OK&oC zP&drCF7GtXomm~ImU^e>YOMUi0~oxFG!;g!_uS-;$u*t{k~uLaM$?<-dgfOTUJje| zy6-$+_g%lhUNSz%|8Bvb2_r&5Agtt7nRq@5c@e9|Y7)QLZpR-XNL*)c*#y6hASg%s3T9e5!H9fN!J5l@oV~zRd^BW{B!q1=6+D%Ul-0ES4%>Eoil| zgNV6V>|K>BbNdmhw+_Qa6N6WEgze(HU;H`&+P42IB=X4L`P3?ylLd+sPX#H zIj4x%;@a5#T=zLhUj@lf9L@bD;6d4n)=>}qkT!~Xm%>-JjdX4n9J+S`TA6lI!UL>HRAl!Fnhc$9L?@zEMYrr>^=6!^n{p)7+`w z(irXaD#+ck&bHIuEgAY6&W71&+aQeMZ{}w8QMjR! zCU4i9I)Dy>+leV>#ou4z7uL|6Wtw>gW1IjA zIR3=%j#InQ}e(dAH0V<_dI z#~Bj}F*H%&c9I2FDr{zz?w(8pCJ$Hmp_!3>h6daU97eEFsKaKYb&_0tzHe z|J+~@RT{LIw+o=T%!DZ{$75?$Km*nZKzD;b5g`za7|@K-%IHeKqZTHF=RzK0I)%xS ztGycqF2}`kxHS;xAuMR!SQwX>gY@U z&~io}g(`|0?#6ERyO$Co9t<9iIc+V)mDq{0G8jBeN8S@{u_~OGBm-BvrY`pNvp})Ssj;0K|dYm_XIEo}72v9rG0t<`1 z>OU?3#GO7bm^y&f5pN@iHetp97QW{+N?J@PT|^gD#|SdzinUp45+kREutfhw_>?@8CTovTo7}K6d%-V ztWU-*+nvgJ=}iqu8H)*??}{CoS9~l((u({SNY3-SsLSkikLp0%e##v z9G0QPVkebGvDkFOD1y3$lie-WtEJe!sD>vkkq+IV`FD4&?77Bo176u^oZx?}2<=>` zdG-ad_+_+kEeT#?xZmj|pb%0-PrTz1Vredv;ae6+BE!JII-(W5V=giDxTf;2%sJsF}zHGb=fN|9#TXMd%qrZT8MLPr<2ZlC;BLLEx39nFGFjp_Ly-= z+$P-VMrH47xgo2DDJvzUTX+5l#%p7o*YOel-7R%3{lavSO0ymBQvY{d7zDEX*Lt6i z<9sSw|Nf@RMUAB{BpmGgV%F&;Sf^K3#j>qMtTE0r z%fP@^ds9)}ca6+7XLggX!Ecuj+EUs%j}E?gE`w{_)^V)`S2RIgwWeUu!}PPf((spZGKFTkQ%q3djI)^1Z52SP`{oEzcoz?RPrNCd zbrwE0$n9hU-iQt=^4!mchEZL8SDktTbrWoOli8G3I?cVzy{iY_2AgtjHGWGd-2|{k zUvH-NS)~j2D6J%q?Q2yspww7LzznwghpZ+CVvEBSwh)I`EQB45qw7ywP6Tw3vSfdg7g1EnBfi8Av%CA4r1HMBEuter=)`ECj>H~BW zXagP|{u4XhvF&zlTu=_Ce)%aLW5Dd*vT(rGKlJCataN5^-}BEh%Behw+YLpPDB@p|2v48s~`vo9)%%mn0PCM5wfIBmgd3CIJD$&X4cdS5KFGTw3+3;Kx?~pS3!e{Q3$iY* zNO?+^eUB6ASAo;GbMax8gS&Lile=ND13YT5{`FpB!qacR;V~qK4CnS)fFzeEspLI$1hcbTmAkOI4vnMg*(HG zlaKCftZUpXjrt`s7nIpq2j#E>$mfMw3Pn(q&ixpJ%^#t31@G?gZn8q`(M2IKykKwe zqTZA;GzH<%IE|Am*m{rPdUvZobw66Egp<2wh*!cb#Ief-{fKi%AYtI0d7J}V{{XI19DtsV^VfuZ?ztwm-KGCkJK~DRqY5AtPU@?)-LIRLoGuFEFxHQ zXxTm{G4r{J%q437P#2JW*o&Ox4dFC)wC*SWmo0-X-~W&WnfLfAyf}W{hr7wF=q&Q* zsEtA?5Z?tWk5#dj@H)9m2=CPiSpd(wgZ(do{~*8pT>~fvbbsB3Zq<|w&s=xl(TvuG18oRcF%x~- zFG{Z7@fuHAd9F41Zq0)O*g6BpTyTL)`8W!BFbi8qCGO}(Z(zqH8w3*uZws@5lxVih zEi$+RnRI{SzP#FdyKjkX8$|l`T18(BT3PwyKc?eth3fxc86s#k_9i>|mZ&4%coMzi z{b2lpZ`7Ilh|p&}-xVJ38gdKq?@k}Iz=lvO=XVJMn)IYg#w<6T&D~OI+sNW*8!bJ& z?gaK$vG?^5zfk7$pfN|ZJ?RuYLN;Dn%vJMQZS0<-6>gdYDciSQsCnDe90Rap4%wA@ zFO&W8muOix?WMi}wxlsqMNN^&WjgWhZ)onq4@e8o9YT&E9G@w!y!#K+UzUjaM4i;N zT95oKX*h|%`z*%(mtjAn$2cFb@%P*#dw&rV!To>h*0=%_VE8jFd7H?4|9&A=ToxNh z^R@X`Q=MM<2uW@s%U9uI)~={$Pf~cMFW)EF5u%(Sny8BPM>kn62U-gP5layU9*wa2 z%ibjbE#aZEAJ*}skij}Y&2?z*k93qFg=;FVVQ=9}()Gr3cZaLJ4+&iR()v>6F=EMs z4j-*b`)UJdE%RSs74py=BvDk#c$^N;JKC@sxIRvDBJ1K~29{lTP!1M^D!H1^xdhY| zSIjjz)r9S@qm|@9cUkh2gSPNLK*Q#r(!>PA|3Y3>tuw?E1_cpV@wO4l;DsX;lPf_4 zF@BB<{u#=w1=k40{$(u@-d2*7+=b4xrx)(#Pqy*T!h!aJL-NQnx z@FKRY-74t@)b(qvzE*nps_{{FV|~4aCSjFtdqC|+6Hf`3j?+2sr?7cty-;6|$&zCY zGjEBfTp>1&1~)%UuT*=gpBeTzH2%~rkgByQnB0DjXCJ<7#)~g;$Mg8wE-;fqNUoV7 zx0e#=7xGhYZKs&mM!Dmj-c#s}ARTq9%q719iC}E)LK8obTAJa*t>O_bTG)%>Wc z?Y68S27c1B1)sG!Q9if07%;kt=)w^+xR80*j!F3q=$|7lNVuu@F=*Bk9UO>%L(I@M z(jBtA`X+I&U3NW)g4EZxFX68Ea1Uv5y6Z}`eNSOn0qgIz+OCGoC#Ugj#3u{JL{#=;axLMrWho-)Ro`RaGEx9@_DpKEO$y?3y2 zO^haAJO^a@FtB-ZzklF*qEcI?9i;22AEF09O;c{$#CrR}U;p&$*Z#y=ob0o>ql0!E zPd)@&X!g9hctNPoqGd^xybx5p$j4CW!TWjsgzfRqp&nXV)Bo=k3J?=~Awm<@R`eXx3o#p+m2h1Frc{BllsOH?G?s z|9F_f>y2Z%gik}!Y))=UD^+(cm&MLWPMO%u#*_{dCIF%MTp@!WE-PqOROFY615e%b zGayJuo7QrWUZ}F65!TE+!Oa8)8b=Zrl=>crgw(rpK6n|ra^i5|Cr(PEIgoc=pq&d( z-QR+RJ#+IEB94FFJ1*#7On+6;Z8GrGEigMNKk0<)-N>CeM%E|J&1w-YPmxjiOMS>s z_FH~e(hI+Ew?l=OYsRa{dnjm9D>YU%bZR}gim_rwQb6*#i`UE>N^OTnWyup?^a;sB zC@*!(ul@wH`p_cxrGWBNNX7R{+U#*64d%q(pX>^P3rTe(RS1C26-$|fDyy;$3+lTm zDlY|HCM4ZokZw`V03W z*$@UsVp^0pE!FcK%iFf7>8dy84i>-K=uJAXau#ORzI%AL=NNOKKa;i8jStQ4(oM|H zoapmrE)L|GjqP`A#Y@olM1!gmt*levVUJR7bQHEh2TKDT0 ztHRwk^LsrNu`l-LnNF{vafs->p^to(&yUTlP{Q zMTbi_r(MkLQ3L+rFR_9jh8()HGA*wKQlNjm(T2>YYCdl&XI=;Zgc65>;_E2_Xi{gy z5H&5sSKOe??H!E2kP|jY`0|6Y)H(H`;>`+LomRcCLb-tMaBcWc>IR+M?YPY8nTy7! z8BiUQO}EWJy^M!W&5G7#=#`gp?n5#=P%N5ZUt1hNBsWJINg7>YM{aI>grCQ^t7C3# zmE=&llUV+#^xVbz_#aI?&G@84MKTEDXQhGTsju417aO}p><+bhcwjN4j!#1Fw# zl_o~G5-$8=^d)lO3-_)Z&Z#?>Um%=th~#w0B8HDN@r%4jEq2Su3R^wSb+Q7fuLmPe z1F-U{cZ#_P3lz5>hwucDc=#y8X1uP=Xxz8XG^A@wq6>$b;EeYB=Lc^lXCwGrKi{U< zQ@DEyF*kX#E*z*>|6ogMbV8Ez@P21VSQ68&k#7sSAcbJyuzYI>Gq(3yZ_wjA)lhK3 zmk<$fz1y#9ILkbFYG)@iKCEtR-zxb&S~EoJ#^#v$WOSC$khxlPZuKxh31D|wPr!38 z^qO&uvTAj3vRJIqIf9VjXTRhYB-mnrq{;#dkbK~`O3X{VL-Y{723}{t4w8aJ+>-W! zy9q$tyGqb5UZ-Yp0UWTIVG^^aLQO5#4QrYKXSTs_RTQh@dn;4ru&%HH-q@rjeGjjh4(2VY)^oq5Bc9R_e zgoe@JdCl4fzCb?$YiFQ8b!$pCfb&=}r~3p?b{hk#Nk?9C@kzm*xPa2s?lf*_VPC)-mur z2{89rF!1Mewc1Su6ps@q_kcG8>$Jm7US?BE0Go=`;GF-wx}+AI*b7PW;* zK4w~#>r#+je^PF%2dJK z+A|u9RW)515r^Ussh`Li$wv2_1t@~vL;i=}<#xA(M|x@QbFFC5mv=;9hc%vOVp`P? zf~XF)q<5*J&TRQ$q6Okrh?Kx zQb9F26QC3VB?_K~R>kH}LC1w0|7@=v&3QP-xDcFiMIJ=hd-)y`2qTuuR>{nw?T*h> ztwv`8Cy;&=e8K0Lm>_* zO3~kathJ`5T&UCQ?Kqw*uPByuI~`C|Eog+j{pP!jKY%UQwiR_k3~9+OJ)pht7w zwA=l{Us^Ay{b$S--cuc-!}rzOcqe=abwWSpVg+6maXjJ#)lIjNH7zU1Bn7J9+_`G; zTlOj~DKI$3h0}P*4@9Qx3?9v$dky6_`?H4W(l=jdTE|9V3WipTFg?}ve-D-^_hGUa zIyd_Jn0GGj1M9L=g<%1|@1)z`)GD9FASfo#JYEQpjBwxIUws6-bpmMHu?c?F zP+G3TVoWBa{`6RD7&)kEniyGMSV*+pRq!p>)qOFli^<)ngk)T@N_}K-PA8b($^8=) z^C0jJ0EMwiOA#4qa^WhbA?6c_JLbds>SM6_M?%lI6cM_lqmPqw6>S@1i@`wd*X2z!%!L6c`uAx2*OM+VeWcj8CePG@ul@%#zkjXb<+yyc5->@E7)oXYae{q4= zI@#|t9Hah6RYKm~BFZ3`fYxgrxgACI*OupL_Rl8>#AEoTs$ViavTZm^`2Mn#k^Qx; z-cRj6P4@@94ZUr14-~K=jZd^PhOh5@$#dS0rF|&Zpqfw*nMbw|VOQJI`PYgz7KrF) z?YHlSkA7Zqoc|U4Vq+*jUM9%3MqIz0ClfK3k#N<*r zbe`-{@l{Yjd2PlXo~}CtTlzMThB8zC>y}3U8wsvIpLy3JAK9;dNt7it``MpS=YWc5Sc!#t07Ho>Af0`Bl8Yuw?O&fd8vj5ZPIp z4T%d)gbkFP|6woy5z`Mww|{>h3``#M#&GQNpeH|{sb-ylJfdK?b)>GfDZy+CE)VJB z_FGl^1fNQG-1`H=IH*)_G{j(&4%pFbw(;%x!clwr12tyjTVjY#uO)TKy3861N!eXTr}njee4ADt!0R}5r)-?K5;F0dLQhAzmz(kpm%v+Ugg3%fAP`S9vyxl zd>2Rz|Anj>YvFPVw5GRy1j_nZ5HZBkB&af96mTnN~)>BzpQ7*RF0|PWLzz{9Sj*blLiXTdLQ~L{W!39@t z8ZdIa81b=4NDrmP#g&uXkOILCs>xbmUW{+5d2MpySt8ZrK1t+eG|763FXf~9Ja#~Y?R>0F`soSZup>;!9_p2qTTVZ!}f;W4qLBE+W10g_jcsM zLrQJ(&$XtR0&_uIN50_i`>No5+8S5mW&hs|xzl}BEBTYnT~v2c&&}PU95fWi%YL2T zGRa7w;FK}0ZfF{4jTmJuxNIDXSPTgH{glq#<*&2jOc#^6HALhsrncYvpHPfhStjQ$ zC%PnH-)OCIO}*ETv_>(IApoGXVlFQq>xZ#B-c9u5P!v!vCXdP*`paFej&?UaMXw%Q zktNleXSuhU)NW*clX1BWq^5&NAK~XyO_IiSlVi8KTm}bCZjcx;OZCB?Jmf)Yk?hC&J{&z`A8)8Ik*ld!Ga{|9$QKEw#NWt1*H&V@l z7*{<&06>VO%4Kt$pBe3LzWiI_fh9H?+W#sb9BjG(4XWn#dHzf~Y2k=6TnW*~752#L za`coX0@jJ+!h(9yI_NtQ{Bm&=sRQvE+}I^qbbR%#mW(FX>ZR;#WGv3O~^mb@>P`z%8w=owt`GA$lXgFNw4Gs$w{p42gb4n2WpGbH4At5rpY% zz@Os3PP46ob2f?tS)$aX#Riz)?| zsd-63n_kVYzMcw!opO1Eda2Og3KpCmQi0hgGIKeM{q+w8puCa3fU%Vq%Q{{ZH9;_n zxg*M)9^N$+8+Q+MOW51>5IZhs!9enSIqC8E#~=k_JG?Vu_~M!Y3Un9%vY!w)>4d?w z`)RVfuu;6bY~cIB3|-5?-++u@TwQRxNB}?wQO(j&8+eU-kL8wjX6?A$jmYM@PFUkZ zd2MooX#fW^70;zbQ+tlH>#o1TZaY&v$@Kn%zI8g~&aF5IW`pUA-WPZT3Wj6(J}qSgD_?L1o;Rz zPXrK3HUR*Uw2m;i!>E#IuRdWLvsx7e%f4}!GG|!*6o~8iR@?-qut)JNWJ2OLtv#l6 z0*f9;NxV^obllw$VssJqwl5VewDd!*Hy)7=!Q6i2rfDu_@}@2;tq)BC*^M|O)W`O_ zqE4M8JINPM0Q+?jU99snNVlU`!4@3Vo{y(BvGaSAF=95fq2-)wEaU%8u);%H-UhyW zJBxUCE1bs>NR7c=CLzh(p@Lwx8@!7p>cOT7Ei*Uz(c({pOVcjpeB@}|7lmPyYHZY8WR4SYIntk6DZBJH|FvR6mS>#Y zr$XprHMv50T!;4$b12>Dt+^=AK9|lOr)17!15www60Ca;4px7hw03js|BUC9=U~|t zvYp-J@5bQW)fo@L;DVPn)>z9NDevC@TQjcvVomrk7byC21qhFL`tB&xJeb^V$l;~g`r*MpjHUb3N`>~~ z5{duG#9ux)4*g#%@!SW?IC*+gE1~eKnySvwNHy=FqpUNgI&xeE&D`b-pt;QU#4=W% z#ncKb{EMDRurs{&z=opcfFiE?*vplI>$^Rw$$JeBvJz)nJ~|h49@oQ^Ih^t)&h)IJi;Y(On8vWFx^=VZ&uT zp!Lsz?_$9*@u46AK&_`?>MkQ&DFGtxGdq|LKma}NQ)?=Mr#RR2wbJ|4IDbAJVex;T z;Xwhyvo2Ua8u8e-KWCGatGsi?~Qu#w5l-7SNTWo(}n#L|Bh{L_S6=BihP-bgXPxm9h8g5LOe;5!N(;R<8jJ( +@c Date: 8 January 2009 + +@menu +* Introduction:: +* File Structure:: +* Font Metrics:: +@end menu + + +@node Introduction +@section Introduction + +The goal of this format is to provide a bitmap font format that is simple to +use, compact, and cleanly supports Unicode. + + +@subsection Goals of the GRUB Font Format + +@itemize +@item Simple to read and use. + Since GRUB will only be reading the font files, + we are more concerned with making the code to read the font simple than we + are with writing the font. + +@item Compact storage. + The fonts will generally be stored in a small boot + partition where GRUB is located, and this may be on a removable storage + device such as a CD or USB flash drive where space is more limited than it + is on most hard drives. + +@item Unicode. + GRUB should not have to deal with multiple character + encodings. The font should always use Unicode character codes for simple + internationalization. +@end itemize + +@subsection Why Another Font Format? + +There are many existing bitmap font formats that GRUB could use. However, +there are aspects of these formats that may make them less than suitable for +use in GRUB at this time: + +@table @samp +@item BDF + Inefficient storage; uses ASCII to describe properties and + hexadecimal numbers in ASCII for the bitmap rows. +@item PCF + Many format variations such as byte order and bitmap padding (rows + padded to byte, word, etc.) would result in more complex code to + handle the font format. +@end table + +@node File Structure +@section File Structure + +A file *section* consists of a 4-byte name, a 32-bit big-endian length (not +including the name or length), and then *length* more section-type-specific +bytes. + +The standard file extension for PFF2 font files is ``.pf2``. + + +@subsection Section Types + +@table @samp +@item FILE + *File type ID* (ASCII string). This must be the first section in the file. It has length 4 + and the contents are the four bytes of the ASCII string ``PFF2``. + +@item NAME + *Font name* (ASCII string). This is the full font name including family, + weight, style, and point size. For instance, "Helvetica Bold Italic 14". + +@item FAMI + *Font family name* (ASCII string). For instance, "Helvetica". This should + be included so that intelligent font substitution can take place. + +@item WEIG + *Font weight* (ASCII string). Valid values are ``bold`` and ``normal``. + This should be included so that intelligent font substitution can take + place. + +@item SLAN + *Font slant* (ASCII string). Valid values are ``italic`` and ``normal``. + This should be included so that intelligent font substitution can take + place. + +@item PTSZ + *Font point size* (uint16be). + +@item MAXW + *Maximum character width in pixels* (uint16be). + +@item MAXH + *Maximum character height in pixels* (uint16be). + +@item ASCE + *Ascent in pixels* (uint16be). See `Font Metrics`_ for details. + +@item DESC + *Descent in pixels* (uint16be). See `Font Metrics`_ for details. + +@item CHIX + *Character index.* + The character index begins with a 32-bit big-endian unsigned integer + indicating the total size of the section, not including this size value. + For each character, there is an instance of the following entry structure: + + @itemize + @item **Unicode code point.** (32-bit big-endian integer.) + + @item **Storage flags.** (byte.) + + @itemize + @item Bits 2..0: + + - If equal to 000 binary, then the character data is stored + uncompressed beginning at the offset indicated by the character's + *offset* value. + + - If equal to 001 binary, then the character data is stored within a + compressed character definition block that begins at the offset + within the file indicated by the character's *offset* value. + @end itemize + @item **Offset.** (32-bit big-endian integer.) + + A marker that indicates the remainder of the file is data accessed via + the character index (CHIX) section. When reading this font file, the rest + of the file can be ignored when scanning the sections. The length should + be set to -1 (0xFFFFFFFF). + + Supported data structures: + + Character definition + Each character definition consists of: + + @itemize + @item **Width.** Width of the bitmap in pixels. The bitmap's extents + represent the glyph's bounding box. *uint16be*. + + @item **Height.** Height of the bitmap in pixels. The bitmap's extents + represent the glyph's bounding box. *uint16be*. + + @item **X offset.** The number of pixels to shift the bitmap by + horizontally before drawing the character. *int16be*. + + @item **Y offset.** The number of pixels to shift the bitmap by + vertically before drawing the character. *int16be*. + + @item **Device width.** The number of pixels to advance horizontally from + this character's origin to the origin of the next character. + *int16be*. + + @item **Bitmap data.** This is encoded as a string of bits. It is + organized as a row-major, top-down, left-to-right bitmap. The most + significant bit of each byte is taken to be the leftmost or uppermost + bit in the byte. For the sake of compact storage, rows are not padded + to byte boundaries (i.e., a single byte may contain bits belonging to + multiple rows). The last byte of the bitmap *is* padded with zero + bits in the bits positions to the right of the last used bit if the + bitmap data does not fill the last byte. + + The length of the *bitmap data* field is (*width* * *height* + 7) / 8 + using integer arithmetic, which is equivalent to ceil(*width* * + *height* / 8) using real number arithmetic. + + It remains to be determined whether bitmap fonts usually make all + glyph bitmaps the same height, or if smaller glyphs are stored with + bitmaps having a lesser height. In the latter case, the baseline + would have to be used to calculate the location the bitmap should be + anchored at on screen. + @end itemize + + @end itemize +@end table + +@node Font Metrics +@section Font Metrics + +@itemize +@item Ascent. + The distance from the baseline to the top of most characters. + Note that in some cases characters may extend above the ascent. + +@item Descent. + The distance from the baseline to the bottom of most characters. Note that + in some cases characters may extend below the descent. + +@item Leading. + The amount of space, in pixels, to leave between the descent of one line of + text and the ascent of the next line. This metrics is not specified in the + current file format; instead, the font rendering engine calculates a + reasonable leading value based on the other font metrics. + +@item Horizonal leading. + The amount of space, in pixels, to leave horizontally between the left and + right edges of two adjacent glyphs. The *device width* field determines + the effective leading value that is used to render the font. + +@end itemize +@image{font_char_metrics,,,,.png} + + An illustration of how the various font metrics apply to characters. + + + +@node Graphical Menu Software Design +@chapter Graphical Menu Software Design + +@c By Colin D. Bennett +@c Date: 17 August 2008 + +@menu +* Introduction_2:: +* Startup Sequence:: +* GUI Components:: +* Command Line Window:: +@end menu + +@node Introduction_2 +@section Introduction + +The ``gfxmenu`` module provides a graphical menu interface for GRUB 2. It +functions as an alternative to the menu interface provided by the ``normal`` +module, which uses the grub terminal interface to display a menu on a +character-oriented terminal. + +The graphical menu uses the GRUB video API, which is currently for the VESA +BIOS extensions (VBE) 2.0+. This is supported on the i386-pc platform. +However, the graphical menu itself does not depend on using VBE, so if another +GRUB video driver were implemented, the ``gfxmenu`` graphical menu would work +on the new video driver as well. + + +@node Startup Sequence +@section Startup Sequence + +@itemize +@item grub_enter_normal_mode [normal/main.c] +@item grub_normal_execute [normal/main.c] +@item read_config_file [normal/main.c] +@item (When ``gfxmenu.mod`` is loaded with ``insmod``, it will call ``grub_menu_viewer_register()`` to register itself.) +@item GRUB_MOD_INIT (gfxmenu) [gfxmenu/gfxmenu.c] +@item grub_menu_viewer_register [kern/menu_viewer.c] +@item grub_menu_viewer_show_menu [kern/menu_viewer.c] +@item get_current_menu_viewer() [kern/menu_viewer.c] +@item show_menu() [gfxmenu/gfxmenu.c] +@item grub_gfxmenu_model_new [gfxmenu/model.c] +@item grub_gfxmenu_view_new [gfxmenu/view.c] +@item set_graphics_mode [gfxmenu/view.c] +@item grub_gfxmenu_view_load_theme [gfxmenu/theme_loader.c] +@end itemize + + +@node GUI Components +@section GUI Components + +The graphical menu implements a GUI component system that supports a +container-based layout system. Components can be added to containers, and +containers (which are a type of component) can then be added to other +containers, to form a tree of components. Currently, the root component of +this tree is a *canvas* component, which allows manual layout of its child +components. + +Components (non-container): + +@itemize +@item label +@item image +@item progress_bar +@item circular_progress +@item list (currently hard coded to be a boot menu list) +@end itemize + +Containers: + +@itemize +@item canvas +@item hbox +@item vbox +@end itemize + +The GUI component instances are created by the theme loader in +``gfxmenu/theme_loader.c`` when a theme is loaded. Theme files specify +statements such as ``+vbox@{ +label @{ text="Hello" @} +label@{ text="World" @} @}`` +to add components to the component tree root. By nesting the component +creation statements in the theme file, the instantiated components are nested +the same way. + +When a component is added to a container, that new child is considered *owned* +by the container. Great care should be taken if the caller retains a +reference to the child component, since it will be destroyed if its parent +container is destroyed. A better choice instead of storing a pointer to the +child component is to use the component ID to find the desired component. +Component IDs do not have to be unique (it is often useful to have multiple +components with an ID of "__timeout__", for instance). + +In order to access and use components in the component tree, there are two +functions (defined in ``gfxmenu/gui_util.c``) that are particularly useful: + +@itemize + +@item ``grub_gui_find_by_id (root, id, callback, userdata)``: + + This function ecursively traverses the component tree rooted at *root*, and + for every component that has an ID equal to *id*, calls the function pointed + to by *callback* with the matching component and the void pointer *userdata* + as arguments. The callback function can do whatever is desired to use the + component passed in. + +@item ``grub_gui_iterate_recursively (root, callback, userdata)``: + + This function calls the function pointed to by *callback* for every + component that is a descendant of *root* in the component tree. When the + callback function is called, the component and the void pointer *userdata* + as arguments. The callback function can do whatever is desired to use the + component passed in. +@end itemize + +@node Command Line Window +@section Command Line Window + +The terminal window used to provide command line access within the graphical +menu is managed by ``gfxmenu/view.c``. The ``gfxterm`` terminal is used, and +it has been modified to allow rendering to an offscreen render target to allow +it to be composed into the double buffering system that the graphical menu +view uses. This is bad for performance, however, so it would probably be a +good idea to make it possible to temporarily disable double buffering as long +as the terminal window is visible. There are still unresolved problems that +occur when commands are executed from the terminal window that change the +graphics mode. It's possible that making ``grub_video_restore()`` return to +the graphics mode that was in use before ``grub_video_setup()`` was called +might fix some of the problems. + + +@node Copying This Manual +@appendix Copying This Manual + +@menu +* GNU Free Documentation License:: License for copying this manual. +@end menu + +@include fdl.texi + + +@node Index +@unnumbered Index + +@c Currently, we use only the Concept Index. +@printindex cp + +@bye diff --git a/docs/grub.texi b/docs/grub.texi index 0808ded6b..45baeafe6 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -100,7 +100,6 @@ This edition documents version @value{VERSION}. * Obtaining and Building GRUB:: How to obtain and build GRUB * Reporting bugs:: Where you should send a bug report * Future:: Some future plans on GRUB -* Internals:: Hacking GRUB * Copying This Manual:: Copying This Manual * Index:: @end menu @@ -4374,111 +4373,6 @@ If you are interested in the development of GRUB 2, take a look at @uref{http://www.gnu.org/software/grub/grub.html, the homepage}. -@node Internals -@appendix Hacking GRUB - -@menu -* Getting the source code:: -* Finding your way around:: -@end menu - - -@node Getting the source code -@section Getting the source code - -GRUB is maintained using the @uref{http://bazaar-vcs.org/, Bazaar revision -control system}. To fetch the primary development branch: - -@example -bzr get http://bzr.savannah.gnu.org/r/grub/trunk/grub -@end example - -The GRUB developers maintain several other branches with work in progress. -Of these, the most interesting is the experimental branch, which is a -staging area for new code which we expect to eventually merge into trunk but -which is not yet ready: - -@example -bzr get http://bzr.savannah.gnu.org/r/grub/branches/experimental -@end example - -Once you have used @kbd{bzr get} to fetch an initial copy of a branch, you -can use @kbd{bzr pull} to keep it up to date. If you have modified your -local version, you may need to resolve conflicts when pulling. - - -@node Finding your way around -@section Finding your way around - -Here is a brief map of the GRUB code base. - -GRUB uses Autoconf, but not (yet) Automake. The top-level build rules are -in @file{configure.ac}, @file{Makefile.in}, and @file{conf/*.rmk}. Each -@file{conf/*.rmk} file represents a particular target configuration, and is -processed into GNU Make rules by @file{genmk.rb} (which you only need to -look at if you are extending the build system). If you are adding a new -module which follows an existing pattern, such as a new command or a new -filesystem implementation, it is usually easiest to grep @file{conf/*.rmk} -for an existing example of that pattern to find out where it should be -added. - -Low-level boot code, such as the MBR implementation on PC BIOS systems, is -in the @file{boot/} directory. - -The GRUB kernel is in @file{kern/}. This contains core facilities such as -the device, disk, and file frameworks, environment variable handling, list -processing, and so on. The kernel should contain enough to get up to a -rescue prompt. Header files for kernel facilities, among others, are in -@file{include/}. - -Terminal implementations are in @file{term/}. - -Disk access code is spread across @file{disk/} (for accessing the disk -devices themselves), @file{partmap/} (for interpreting partition table -data), and @file{fs/} (for accessing filesystems). Note that, with the odd -specialised exception, GRUB only contains code to @emph{read} from -filesystems and tries to avoid containing any code to @emph{write} to -filesystems; this lets us confidently assure users that GRUB cannot be -responsible for filesystem corruption. - -PCI and USB bus handling is in @file{bus/}. - -Video handling code is in @file{video/}. The graphical menu system uses -this heavily, but is in a separate directory, @file{gfxmenu/}. - -Most commands are implemented by files in @file{commands/}, with the -following exceptions: - -@itemize -@item -A few core commands live in @file{kern/corecmd.c}. - -@item -Commands related to normal mode live under @file{normal/}. - -@item -Commands that load and boot kernels live under @file{loader/}. - -@item -The @samp{loopback} command is really a disk device, and so lives in -@file{disk/loopback.c}. - -@item -The @samp{gettext} command lives under @file{gettext/}. - -@item -The @samp{loadfont} and @samp{lsfonts} commands live under @file{font/}. - -@item -The @samp{serial}, @samp{terminfo}, and @samp{background_image} commands -live under @file{term/}. - -@item -The @samp{efiemu_*} commands live under @file{efiemu/}. -@end itemize - -There are a few other special-purpose exceptions; grep for them if they -matter to you. From 67e11623a8a14414342a396c3d0dce7f774018cf Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 3 Apr 2011 15:34:50 +0200 Subject: [PATCH 204/276] * docs/grub.texi (Vendor power-on buttons): Explain how the numbers are obtained. --- ChangeLog | 5 +++++ docs/grub.texi | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/ChangeLog b/ChangeLog index 47bb01e7e..129703971 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-02 Vladimir Serbinenko + + * docs/grub.texi (Vendor power-on buttons): Explain how the numbers + are obtained. + 2011-04-02 Vladimir Serbinenko GRUB developper manual based on existing Internals section and diff --git a/docs/grub.texi b/docs/grub.texi index 45baeafe6..0c59975cd 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -2049,6 +2049,44 @@ model-specific. Values known to the GRUB team are: To take full advantage of this function, install GRUB into the MBR (@pxref{Installing GRUB using grub-install}). +If you have a laptop which has a similar feature and not in the above list +could you figure your address and contribute? +To discover the address do the following: +@itemize +@item boot normally +@item +@example +sudo modprobe nvram +sudo cat /dev/nvram | xxd > normal_button.txt +@end example +@item boot using vendor button +@item +@example +sudo modprobe nvram +sudo cat /dev/nvram | xxd > normal_vendor.txt +@end example +@end itemize + +Then compare these text files and find where a bit was toggled. E.g. in +case of Dell XPS it was: +@example +byte 0x47: 20 --> 28 +@end example +It's a bit number 3 as seen from following table: +@multitable @columnfractions .2 .2 +@item 0 @tab 01 +@item 1 @tab 02 +@item 2 @tab 04 +@item 3 @tab 08 +@item 4 @tab 10 +@item 5 @tab 20 +@item 6 @tab 40 +@item 7 @tab 80 +@end multitable + +0x47 is decimal 71. Linux nvram implementation cuts first 14 bytes of +CMOS. So the real byte address in CMOS is 71+14=85 +So complete address is 85:3 @node Images @chapter GRUB image files From 09ceb9a5923c65b1fc6d9f39a5b64f0e2c2373e3 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 3 Apr 2011 15:37:24 +0200 Subject: [PATCH 205/276] * util/grub-install.in: Add a recommendation to use --recheck before reporting bugs. --- ChangeLog | 5 +++++ util/grub-install.in | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 129703971..54a6d6333 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-02 Vladimir Serbinenko + + * util/grub-install.in: Add a recommendation to use --recheck before + reporting bugs. + 2011-04-02 Vladimir Serbinenko * docs/grub.texi (Vendor power-on buttons): Explain how the numbers diff --git a/util/grub-install.in b/util/grub-install.in index 4e78dfadb..ff8bea87c 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -467,7 +467,8 @@ fi fs_module="`"$grub_probe" --device-map="${device_map}" --target=fs --device "${grub_device}"`" if test "x$fs_module" = x ; then echo "Auto-detection of a filesystem of ${grub_device} failed." 1>&2 - echo "Please report this together with the output of \"$grub_probe --device-map=\"${device_map}\" --target=fs -v ${grubdir}\" to " 1>&2 + echo "Try with --recheck." 1>&2 + echo "If the problem persists please report this together with the output of \"$grub_probe --device-map=\"${device_map}\" --target=fs -v ${grubdir}\" to " 1>&2 exit 1 fi From 829ea451a4b26418d1f413eab57a39620cecd95b Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 3 Apr 2011 15:45:20 +0200 Subject: [PATCH 206/276] * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_read): Don't close on failed seek as it breaks open fd reusage. --- ChangeLog | 5 +++++ grub-core/kern/emu/hostdisk.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 54a6d6333..88a8a7f69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-02 Vladimir Serbinenko + + * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_read): Don't close + on failed seek as it breaks open fd reusage. + 2011-04-02 Vladimir Serbinenko * util/grub-install.in: Add a recommendation to use --recheck before diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index d5b0439fb..50e5a34ad 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -876,7 +876,6 @@ grub_util_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector, if (nread (fd, buf, GRUB_DISK_SECTOR_SIZE) != GRUB_DISK_SECTOR_SIZE) { grub_error (GRUB_ERR_READ_ERROR, "cannot read `%s'", map[disk->id].device); - close (fd); return grub_errno; } From 6f332153941293db9cb28ecb4cbe323f94134d82 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 3 Apr 2011 15:57:44 +0200 Subject: [PATCH 207/276] * grub-core/disk/lvm.c (grub_lvm_scan_device): Print errors on the end of function to allow further scanning for LVMs. --- ChangeLog | 5 +++++ grub-core/disk/lvm.c | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 88a8a7f69..fc6dee2ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-02 Vladimir Serbinenko + + * grub-core/disk/lvm.c (grub_lvm_scan_device): Print errors on the end + of function to allow further scanning for LVMs. + 2011-04-02 Vladimir Serbinenko * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_read): Don't close diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 5a79063da..6b6417f38 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -838,6 +838,7 @@ grub_lvm_scan_device (const char *name) grub_disk_close (disk); if (grub_errno == GRUB_ERR_OUT_OF_RANGE) grub_errno = GRUB_ERR_NONE; + grub_print_error (); return 0; } From 850e937329ab9da72cca06efeb1c10ec2e996a42 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 3 Apr 2011 16:28:14 +0200 Subject: [PATCH 208/276] Increase LVM implementation robustness in order not to crash on configurations like pvmove. Previously code assumed that in some places only lvs or only pvs are used whereas it seems that they are used interchangeably. * grub-core/disk/lvm.c (read_node): New function. (read_lv): Use read_node. (grub_lvm_scan_device): Use only first mirror on pvmove'd lvs. Match volumes only at the end when all lvs are found. Take both pvs (first) and lvs (second) into account. * include/grub/lvm.h (grub_lvm_segment): Merge fields stripe_* and mirror_* into node_*. All users updated. (grub_lvm_stripe): Merge this ... (grub_lvm_mirror): ... and this ... (grub_lvm_node): ... into this. All users updated. --- ChangeLog | 18 ++++++ grub-core/disk/lvm.c | 144 ++++++++++++++++++++++++------------------- include/grub/lvm.h | 15 ++--- 3 files changed, 103 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc6dee2ce..667daad65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2011-04-02 Vladimir Serbinenko + + Increase LVM implementation robustness in order not to crash on + configurations like pvmove. Previously code assumed that in some places + only lvs or only pvs are used whereas it seems that they are used + interchangeably. + + * grub-core/disk/lvm.c (read_node): New function. + (read_lv): Use read_node. + (grub_lvm_scan_device): Use only first mirror on pvmove'd lvs. + Match volumes only at the end when all lvs are found. Take both + pvs (first) and lvs (second) into account. + * include/grub/lvm.h (grub_lvm_segment): Merge fields stripe_* and + mirror_* into node_*. All users updated. + (grub_lvm_stripe): Merge this ... + (grub_lvm_mirror): ... and this ... + (grub_lvm_node): ... into this. All users updated. + 2011-04-02 Vladimir Serbinenko * grub-core/disk/lvm.c (grub_lvm_scan_device): Print errors on the end diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 6b6417f38..00c6d8f9b 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -165,6 +165,31 @@ grub_lvm_close (grub_disk_t disk __attribute ((unused))) return; } +static grub_err_t +read_lv (struct grub_lvm_lv *lv, grub_disk_addr_t sector, + grub_size_t size, char *buf); + +static grub_err_t +read_node (const struct grub_lvm_node *node, grub_disk_addr_t sector, + grub_size_t size, char *buf) +{ + /* Check whether we actually know the physical volume we want to + read from. */ + if (node->pv) + { + if (node->pv->disk) + return grub_disk_read (node->pv->disk, sector + node->pv->start, 0, + size << GRUB_DISK_SECTOR_BITS, buf); + else + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, + "physical volume %s not found", node->pv->name); + + } + if (node->lv) + return read_lv (node->lv, sector, size, buf); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown node '%s'", node->name); +} + static grub_err_t read_lv (struct grub_lvm_lv *lv, grub_disk_addr_t sector, grub_size_t size, char *buf) @@ -172,7 +197,7 @@ read_lv (struct grub_lvm_lv *lv, grub_disk_addr_t sector, grub_err_t err = 0; struct grub_lvm_vg *vg = lv->vg; struct grub_lvm_segment *seg = lv->segments; - struct grub_lvm_pv *pv; + struct grub_lvm_node *node; grub_uint64_t offset; grub_uint64_t extent; unsigned int i; @@ -200,17 +225,17 @@ read_lv (struct grub_lvm_lv *lv, grub_disk_addr_t sector, switch (seg->type) { case GRUB_LVM_STRIPED: - if (seg->stripe_count == 1) + if (seg->node_count == 1) { /* This segment is linear, so that's easy. We just need to find out the offset in the physical volume and read SIZE bytes from that. */ - struct grub_lvm_stripe *stripe = seg->stripes; + struct grub_lvm_node *stripe = seg->nodes; grub_uint64_t seg_offset; /* Offset of the segment in PV device. */ - pv = stripe->pv; + node = stripe; seg_offset = ((grub_uint64_t) stripe->start - * (grub_uint64_t) vg->extent_size) + pv->start; + * (grub_uint64_t) vg->extent_size); offset = sector - ((grub_uint64_t) seg->start_extent * (grub_uint64_t) vg->extent_size) + seg_offset; @@ -219,7 +244,7 @@ read_lv (struct grub_lvm_lv *lv, grub_disk_addr_t sector, { /* This is a striped segment. We have to find the right PV similar to RAID0. */ - struct grub_lvm_stripe *stripe = seg->stripes; + struct grub_lvm_node *stripe = seg->nodes; grub_uint32_t a, b; grub_uint64_t seg_offset; /* Offset of the segment in PV device. */ unsigned int stripenr; @@ -228,42 +253,29 @@ read_lv (struct grub_lvm_lv *lv, grub_disk_addr_t sector, * (grub_uint64_t) vg->extent_size); a = grub_divmod64 (offset, seg->stripe_size, NULL); - grub_divmod64 (a, seg->stripe_count, &stripenr); + grub_divmod64 (a, seg->node_count, &stripenr); - a = grub_divmod64 (offset, seg->stripe_size * seg->stripe_count, NULL); + a = grub_divmod64 (offset, seg->stripe_size * seg->node_count, NULL); grub_divmod64 (offset, seg->stripe_size, &b); offset = a * seg->stripe_size + b; stripe += stripenr; - pv = stripe->pv; + node = stripe; seg_offset = ((grub_uint64_t) stripe->start - * (grub_uint64_t) vg->extent_size) + pv->start; + * (grub_uint64_t) vg->extent_size); offset += seg_offset; } - /* Check whether we actually know the physical volume we want to - read from. */ - if (pv->disk) - err = grub_disk_read (pv->disk, offset, 0, - size << GRUB_DISK_SECTOR_BITS, buf); - else - err = grub_error (GRUB_ERR_UNKNOWN_DEVICE, - "physical volume %s not found", pv->name); - - return err; + return read_node (node, offset, size, buf); case GRUB_LVM_MIRROR: i = 0; while (1) { - if (!seg->mirrors[i].lv) - err = grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume '%s'", - seg->mirrors[i].lvname); - else - err = read_lv (seg->mirrors[i].lv, sector, size, buf); + err = read_node (&seg->nodes[i], sector, size, buf); if (!err) return err; - if (++i >= seg->mirror_count) + if (++i >= seg->node_count) return err; grub_errno = GRUB_ERR_NONE; } @@ -544,6 +556,7 @@ grub_lvm_scan_device (const char *name) int skip_lv = 0; struct grub_lvm_lv *lv; struct grub_lvm_segment *seg; + int is_pvmove; while (grub_isspace (*p)) p++; @@ -567,6 +580,7 @@ grub_lvm_scan_device (const char *name) lv->size = 0; lv->visible = grub_lvm_check_flag (p, "status", "VISIBLE"); + is_pvmove = grub_lvm_check_flag (p, "status", "PVMOVE"); lv->segment_count = grub_lvm_getvalue (&p, "segment_count = "); if (p == NULL) @@ -618,10 +632,10 @@ grub_lvm_scan_device (const char *name) if (grub_memcmp (p, "striped\"", sizeof ("striped\"") - 1) == 0) { - struct grub_lvm_stripe *stripe; + struct grub_lvm_node *stripe; seg->type = GRUB_LVM_STRIPED; - seg->stripe_count = grub_lvm_getvalue (&p, "stripe_count = "); + seg->node_count = grub_lvm_getvalue (&p, "stripe_count = "); if (p == NULL) { #ifdef GRUB_UTIL @@ -630,12 +644,12 @@ grub_lvm_scan_device (const char *name) goto lvs_segment_fail; } - if (seg->stripe_count != 1) + if (seg->node_count != 1) seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = "); - seg->stripes = grub_malloc (sizeof (*stripe) - * seg->stripe_count); - stripe = seg->stripes; + seg->nodes = grub_zalloc (sizeof (*stripe) + * seg->node_count); + stripe = seg->nodes; p = grub_strstr (p, "stripes = ["); if (p == NULL) @@ -647,10 +661,8 @@ grub_lvm_scan_device (const char *name) } p += sizeof("stripes = [") - 1; - for (j = 0; j < seg->stripe_count; j++) + for (j = 0; j < seg->node_count; j++) { - char *pvname; - p = grub_strchr (p, '"'); if (p == NULL) continue; @@ -660,24 +672,12 @@ grub_lvm_scan_device (const char *name) s = q - p; - pvname = grub_malloc (s + 1); - if (pvname == NULL) + stripe->name = grub_malloc (s + 1); + if (stripe->name == NULL) goto lvs_segment_fail2; - grub_memcpy (pvname, p, s); - pvname[s] = '\0'; - - if (vg->pvs) - for (pv = vg->pvs; pv; pv = pv->next) - { - if (! grub_strcmp (pvname, pv->name)) - { - stripe->pv = pv; - break; - } - } - - grub_free(pvname); + grub_memcpy (stripe->name, p, s); + stripe->name[s] = '\0'; stripe->start = grub_lvm_getvalue (&p, ","); if (p == NULL) @@ -690,7 +690,7 @@ grub_lvm_scan_device (const char *name) == 0) { seg->type = GRUB_LVM_MIRROR; - seg->mirror_count = grub_lvm_getvalue (&p, "mirror_count = "); + seg->node_count = grub_lvm_getvalue (&p, "mirror_count = "); if (p == NULL) { #ifdef GRUB_UTIL @@ -699,8 +699,8 @@ grub_lvm_scan_device (const char *name) goto lvs_segment_fail; } - seg->mirrors = grub_zalloc (sizeof (seg->mirrors[0]) - * seg->mirror_count); + seg->nodes = grub_zalloc (sizeof (seg->nodes[0]) + * seg->node_count); p = grub_strstr (p, "mirrors = ["); if (p == NULL) @@ -712,7 +712,7 @@ grub_lvm_scan_device (const char *name) } p += sizeof("mirrors = [") - 1; - for (j = 0; j < seg->mirror_count; j++) + for (j = 0; j < seg->node_count; j++) { char *lvname; @@ -731,9 +731,12 @@ grub_lvm_scan_device (const char *name) grub_memcpy (lvname, p, s); lvname[s] = '\0'; - seg->mirrors[j].lvname = lvname; + seg->nodes[j].name = lvname; p = q + 1; } + /* Only first (original) is ok with in progress pvmove. */ + if (is_pvmove) + seg->node_count = 1; } else { @@ -755,7 +758,7 @@ grub_lvm_scan_device (const char *name) continue; lvs_segment_fail2: - grub_free (seg->stripes); + grub_free (seg->nodes); lvs_segment_fail: goto fail4; } @@ -786,18 +789,31 @@ grub_lvm_scan_device (const char *name) } } - /* Match mirrors */ + /* Match lvs. */ { struct grub_lvm_lv *lv1; struct grub_lvm_lv *lv2; for (lv1 = vg->lvs; lv1; lv1 = lv1->next) for (i = 0; i < lv1->segment_count; i++) - if (lv1->segments[i].type == GRUB_LVM_MIRROR) - for (j = 0; j < lv1->segments[i].mirror_count; j++) - for (lv2 = vg->lvs; lv2; lv2 = lv2->next) - if (grub_strcmp (lv2->name + grub_strlen (vg->name) + 1, - lv1->segments[i].mirrors[j].lvname) == 0) - lv1->segments[i].mirrors[j].lv = lv2; + for (j = 0; j < lv1->segments[i].node_count; j++) + { + if (vg->pvs) + for (pv = vg->pvs; pv; pv = pv->next) + { + if (! grub_strcmp (pv->name, + lv1->segments[i].nodes[j].name)) + { + lv1->segments[i].nodes[j].pv = pv; + break; + } + } + if (lv1->segments[i].nodes[j].pv == NULL) + for (lv2 = vg->lvs; lv2; lv2 = lv2->next) + if (grub_strcmp (lv2->name + grub_strlen (vg->name) + 1, + lv1->segments[i].nodes[j].name) == 0) + lv1->segments[i].nodes[j].lv = lv2; + } + } vg->next = vg_list; diff --git a/include/grub/lvm.h b/include/grub/lvm.h index 220517183..b962dfd6c 100644 --- a/include/grub/lvm.h +++ b/include/grub/lvm.h @@ -60,21 +60,16 @@ struct grub_lvm_segment { unsigned int extent_count; enum { GRUB_LVM_STRIPED, GRUB_LVM_MIRROR } type; - unsigned int mirror_count; - struct grub_lvm_mirror *mirrors; + unsigned int node_count; + struct grub_lvm_node *nodes; - unsigned int stripe_count; unsigned int stripe_size; - struct grub_lvm_stripe *stripes; /* Pointer to stripe_count stripes. */ }; -struct grub_lvm_stripe { - int start; +struct grub_lvm_node { + grub_disk_addr_t start; + char *name; struct grub_lvm_pv *pv; -}; - -struct grub_lvm_mirror { - char *lvname; struct grub_lvm_lv *lv; }; From 246c23696a24dd3e971a9b29b7ee25c905d6ba63 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 6 Apr 2011 12:25:33 +0200 Subject: [PATCH 209/276] Ignore docs/stamp-1 and docs/version-dev.texi --- .bzrignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index a3e6f9dd2..55cbdaeeb 100644 --- a/.bzrignore +++ b/.bzrignore @@ -133,3 +133,5 @@ grub-core/gnulib/wctype.h grub-core/rs_decoder.S widthspec.bin widthspec.h +docs/stamp-1 +docs/version-dev.texi From a562b47916eef29b39ed23115b7bf9af6e3bd179 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 6 Apr 2011 12:29:49 +0200 Subject: [PATCH 210/276] * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Detect spares and report them as not RAID members since they are useless for GRUB. * grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Likewise. --- ChangeLog | 6 ++++++ grub-core/disk/mdraid1x_linux.c | 5 ++++- grub-core/disk/mdraid_linux.c | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 667daad65..81ba177d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-06 Vladimir Serbinenko + + * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Detect spares + and report them as not RAID members since they are useless for GRUB. + * grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Likewise. + 2011-04-02 Vladimir Serbinenko Increase LVM implementation robustness in order not to crash on diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c index 1d08abf5b..e30878365 100644 --- a/grub-core/disk/mdraid1x_linux.c +++ b/grub-core/disk/mdraid1x_linux.c @@ -200,11 +200,14 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, if (grub_le_to_cpu32 (real_sb->dev_number) >= grub_le_to_cpu32 (real_sb->max_dev)) - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + return grub_error (GRUB_ERR_OUT_OF_RANGE, "spares aren't implemented"); array->index = grub_le_to_cpu16 (real_sb->dev_roles[grub_le_to_cpu32 (real_sb->dev_number)]); + if (array->index >= array->total_devs) + return grub_error (GRUB_ERR_OUT_OF_RANGE, + "spares aren't implemented"); array->uuid_len = 16; array->uuid = grub_malloc (16); if (!array->uuid) diff --git a/grub-core/disk/mdraid_linux.c b/grub-core/disk/mdraid_linux.c index 7aa48fd7a..06d3498a8 100644 --- a/grub-core/disk/mdraid_linux.c +++ b/grub-core/disk/mdraid_linux.c @@ -202,7 +202,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array, "unsupported RAID level: %d", level); if (grub_le_to_cpu32 (sb.this_disk.number) == 0xffff || grub_le_to_cpu32 (sb.this_disk.number) == 0xfffe) - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + return grub_error (GRUB_ERR_OUT_OF_RANGE, "spares aren't implemented"); array->name = NULL; From 665900a3892d554c7bcafdfefcff027da35ad709 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 6 Apr 2011 12:33:46 +0200 Subject: [PATCH 211/276] * include/grub/offsets.h (GRUB_KERNEL_I386_PC_RAW_SIZE): Let a bit more space for older compilers. (GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART): Likewise. --- ChangeLog | 6 ++++++ include/grub/offsets.h | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 81ba177d5..a657807bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-06 Vladimir Serbinenko + + * include/grub/offsets.h (GRUB_KERNEL_I386_PC_RAW_SIZE): Let a bit more + space for older compilers. + (GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART): Likewise. + 2011-04-06 Vladimir Serbinenko * grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Detect spares diff --git a/include/grub/offsets.h b/include/grub/offsets.h index 817372b69..31deb5031 100644 --- a/include/grub/offsets.h +++ b/include/grub/offsets.h @@ -38,9 +38,9 @@ #define GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY 0x1c /* The size of the first region which won't be compressed. */ -#define GRUB_KERNEL_I386_PC_RAW_SIZE 0xca4 +#define GRUB_KERNEL_I386_PC_RAW_SIZE 0xcd0 -#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x70c +#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x730 /* The offset of GRUB_PREFIX. */ #define GRUB_KERNEL_I386_PC_PREFIX GRUB_KERNEL_I386_PC_RAW_SIZE From adf594cc44418f7d3e7801b677c73ed93b848129 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 6 Apr 2011 13:00:18 +0200 Subject: [PATCH 212/276] Output errors if theme loading failed. * grub-core/gfxmenu/gfxmenu.c (grub_gfxmenu_try): Move the call to grub_gfxterm_fullscreen on error paths to ... * grub-core/normal/menu.c (menu_init): ...here. Wait after showing theme loading error. --- ChangeLog | 9 ++++++++ grub-core/gfxmenu/gfxmenu.c | 24 +++------------------- grub-core/normal/menu.c | 41 ++++++++++++++++++++++++++++++------- 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index a657807bd..891853f71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-04-06 Vladimir Serbinenko + + Output errors if theme loading failed. + + * grub-core/gfxmenu/gfxmenu.c (grub_gfxmenu_try): Move the call to + grub_gfxterm_fullscreen on error paths to ... + * grub-core/normal/menu.c (menu_init): ...here. Wait after showing + theme loading error. + 2011-04-06 Vladimir Serbinenko * include/grub/offsets.h (GRUB_KERNEL_I386_PC_RAW_SIZE): Let a bit more diff --git a/grub-core/gfxmenu/gfxmenu.c b/grub-core/gfxmenu/gfxmenu.c index 76d83c44b..564a87634 100644 --- a/grub-core/gfxmenu/gfxmenu.c +++ b/grub-core/gfxmenu/gfxmenu.c @@ -56,30 +56,15 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested) theme_path = grub_env_get ("theme"); if (! theme_path) - { - grub_error_push (); - grub_gfxterm_fullscreen (); - grub_error_pop (); - return grub_error (GRUB_ERR_FILE_NOT_FOUND, "no theme specified"); - } + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "no theme specified"); instance = grub_zalloc (sizeof (*instance)); if (!instance) - { - grub_error_push (); - grub_gfxterm_fullscreen (); - grub_error_pop (); - return grub_errno; - } + return grub_errno; err = grub_video_get_info (&mode_info); if (err) - { - grub_error_push (); - grub_gfxterm_fullscreen (); - grub_error_pop (); - return err; - } + return err; if (!cached_view || grub_strcmp (cached_view->theme_path, theme_path) != 0 || cached_view->screen.width != mode_info.width @@ -94,9 +79,6 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested) if (! cached_view) { grub_free (instance); - grub_error_push (); - grub_gfxterm_fullscreen (); - grub_error_pop (); return grub_errno; } diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index e62482122..bfcdd0ac5 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -30,6 +30,7 @@ #include #include #include +#include /* Time to delay after displaying an error message about a default/fallback entry failing to boot. */ @@ -345,18 +346,44 @@ static void menu_init (int entry, grub_menu_t menu, int nested) { struct grub_term_output *term; + int gfxmenu = 0; + + FOR_ACTIVE_TERM_OUTPUTS(term) + if (grub_strcmp (term->name, "gfxterm") == 0) + { + if (grub_env_get ("theme")) + { + if (!grub_gfxmenu_try_hook) + { + grub_dl_load ("gfxmenu"); + grub_print_error (); + } + if (grub_gfxmenu_try_hook) + { + grub_err_t err; + err = grub_gfxmenu_try_hook (entry, menu, nested); + if(!err) + { + gfxmenu = 1; + break; + } + } + else + grub_error (GRUB_ERR_BAD_MODULE, "no gfxmenu found"); + grub_print_error (); + grub_wait_after_message (); + } + grub_errno = GRUB_ERR_NONE; + grub_gfxterm_fullscreen (); + break; + } 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_errno = GRUB_ERR_NONE; - } + if (grub_strcmp (term->name, "gfxterm") == 0 && gfxmenu) + break; err = grub_menu_try_text (term, entry, menu, nested); if(!err) From 2a961775e6ef522a47eaf898806d2f5de785e46e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 6 Apr 2011 13:18:11 +0200 Subject: [PATCH 213/276] * util/grub.d/00_header.in: Don't use LANG unless unifont is available. --- ChangeLog | 4 ++++ util/grub.d/00_header.in | 23 +++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 891853f71..bc9318701 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-06 Vladimir Serbinenko + + * util/grub.d/00_header.in: Don't use LANG unless unifont is available. + 2011-04-06 Vladimir Serbinenko Output errors if theme loading failed. diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 420b3f32c..9da1511f5 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -132,6 +132,19 @@ if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then set gfxmode=${GRUB_GFXMODE} load_video insmod gfxterm +EOF + +# Gettext variables and module +if [ "x${LANG}" != "xC" ] && [ -d "${locale_dir}" ] ; then + prepare_grub_to_access_device $(${grub_probe} --target=device ${locale_dir}) | sed -e "s/^/ /" + cat << EOF + set locale_dir=(\$root)$(make_system_path_relative_to_its_root ${locale_dir}) + set lang=${grub_lang} + insmod gettext +EOF +fi + +cat < Date: Wed, 6 Apr 2011 14:01:12 +0200 Subject: [PATCH 214/276] * include/grub/fs.h (grub_dirhook_info): Use unsigned for 1-bit fields. --- ChangeLog | 4 ++++ include/grub/fs.h | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index bc9318701..84fcc5627 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-06 Vladimir Serbinenko + + * include/grub/fs.h (grub_dirhook_info): Use unsigned for 1-bit fields. + 2011-04-06 Vladimir Serbinenko * util/grub.d/00_header.in: Don't use LANG unless unifont is available. diff --git a/include/grub/fs.h b/include/grub/fs.h index 994eb8080..2c39332a9 100644 --- a/include/grub/fs.h +++ b/include/grub/fs.h @@ -31,9 +31,9 @@ struct grub_file; struct grub_dirhook_info { - int dir:1; - int mtimeset:1; - int case_insensitive:1; + unsigned dir:1; + unsigned mtimeset:1; + unsigned case_insensitive:1; grub_int32_t mtime; }; From 7755f66e64f52e4c551c477dcdfd4f4a9fdd8f74 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 6 Apr 2011 14:04:52 +0200 Subject: [PATCH 215/276] * grub-core/lib/relocator.c (grub_relocator_alloc_chunk_align): Add few useful grub_dprintf's. --- ChangeLog | 5 +++++ grub-core/lib/relocator.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 84fcc5627..b110a9803 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-06 Vladimir Serbinenko + + * grub-core/lib/relocator.c (grub_relocator_alloc_chunk_align): Add few + useful grub_dprintf's. + 2011-04-06 Vladimir Serbinenko * include/grub/fs.h (grub_dirhook_info): Use unsigned for 1-bit fields. diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index 940b9133b..3642de9dc 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -1416,11 +1416,17 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel, break; } + grub_dprintf ("relocator", "relocators_size=%ld\n", + (unsigned long) rel->relocators_size); + if (chunk->src < chunk->target) rel->relocators_size += grub_relocator_backward_size; if (chunk->src > chunk->target) rel->relocators_size += grub_relocator_forward_size; + grub_dprintf ("relocator", "relocators_size=%ld\n", + (unsigned long) rel->relocators_size); + chunk->size = size; chunk->next = rel->chunks; rel->chunks = chunk; From b5ebecfabc1037532c18b42372218d45b237f192 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 6 Apr 2011 14:21:34 +0200 Subject: [PATCH 216/276] * grub-core/video/fb/video_fb.c (grub_video_fb_setup): Silence older gcc warning. --- ChangeLog | 5 +++++ grub-core/video/fb/video_fb.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b110a9803..e495fbf9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-06 Andrey + + * grub-core/video/fb/video_fb.c (grub_video_fb_setup): Silence older + gcc warning. + 2011-04-06 Vladimir Serbinenko * grub-core/lib/relocator.c (grub_relocator_alloc_chunk_align): Add few diff --git a/grub-core/video/fb/video_fb.c b/grub-core/video/fb/video_fb.c index 768b63328..2226d6583 100644 --- a/grub-core/video/fb/video_fb.c +++ b/grub-core/video/fb/video_fb.c @@ -1445,13 +1445,16 @@ grub_video_fb_setup (unsigned int mode_type, unsigned int mode_mask, GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED, 0)) { + /* It was much nicer with the cast directly at function call but + some older gcc versions don't accept it properly.*/ + void *tmp = (void *) page0_ptr; mode_info->mode_type |= (GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED | GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP); err = grub_video_fb_doublebuf_blit_init (&framebuffer.front_target, &framebuffer.back_target, *mode_info, - (void *) page0_ptr); + tmp); if (!err) { From 72a89a54e170ccccf0dd6bd83aaba16692a19ebc Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 11:44:44 +0200 Subject: [PATCH 217/276] * grub-core/kern/emu/getroot.c (grub_util_get_grub_dev): Add missing const attribute and use grub_isdigit. --- ChangeLog | 5 +++++ grub-core/kern/emu/getroot.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e495fbf9a..1c4bbb5ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-08 Vladimir Serbinenko + + * grub-core/kern/emu/getroot.c (grub_util_get_grub_dev): Add missing + const attribute and use grub_isdigit. + 2011-04-06 Andrey * grub-core/video/fb/video_fb.c (grub_video_fb_setup): Silence older diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index ae066d2f8..8f65d92c5 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -808,10 +808,10 @@ grub_util_get_grub_dev (const char *os_dev) if (mdadm_name) { char *newname; - char *q; + const char *q; - for (q = os_dev + strlen (os_dev) - 1; q >= os_dev && isdigit (*q); - q--); + for (q = os_dev + strlen (os_dev) - 1; q >= os_dev + && grub_isdigit (*q); q--); if (q >= os_dev && *q == 'p') { From 478182a83841c912996558900469d34832f8bd2e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 11:49:38 +0200 Subject: [PATCH 218/276] * grub-core/kern/emu/hostdisk.c (open_device): Sync on close and not on open. (grub_util_biosdisk_close): Likewise. --- ChangeLog | 6 ++++++ grub-core/kern/emu/hostdisk.c | 38 ++++++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c4bbb5ab..a9aaa81c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-08 Vladimir Serbinenko + + * grub-core/kern/emu/hostdisk.c (open_device): Sync on close and not + on open. + (grub_util_biosdisk_close): Likewise. + 2011-04-08 Vladimir Serbinenko * grub-core/kern/emu/getroot.c (grub_util_get_grub_dev): Add missing diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 50e5a34ad..7b034e06b 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -664,7 +664,17 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags) { free (data->dev); if (data->fd != -1) - close (data->fd); + { + if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY) + { + fsync (data->fd); +#ifdef __linux__ + ioctl (data->fd, BLKFLSBUF, 0); +#endif + } + + close (data->fd); + } /* Open the partition. */ grub_dprintf ("hostdisk", "opening the device `%s' in open_device()\n", dev); @@ -675,10 +685,6 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags) return -1; } - /* Flush the buffer cache to the physical disk. - XXX: This also empties the buffer cache. */ - ioctl (fd, BLKFLSBUF, 0); - data->dev = xstrdup (dev); data->access_mode = (flags & O_ACCMODE); data->fd = fd; @@ -716,7 +722,16 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags) { free (data->dev); if (data->fd != -1) - close (data->fd); + { + if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY) + { + fsync (data->fd); +#ifdef __linux__ + ioctl (data->fd, BLKFLSBUF, 0); +#endif + } + close (data->fd); + } fd = open (map[disk->id].device, flags); if (fd >= 0) @@ -932,7 +947,16 @@ grub_util_biosdisk_close (struct grub_disk *disk) free (data->dev); if (data->fd != -1) - close (data->fd); + { + if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY) + { + fsync (data->fd); +#ifdef __linux__ + ioctl (data->fd, BLKFLSBUF, 0); +#endif + } + close (data->fd); + } free (data); } From 6d1fa41fb413050d4c7fe6c9b224c655e53b4917 Mon Sep 17 00:00:00 2001 From: Martin Zuther Date: Fri, 8 Apr 2011 11:53:17 +0200 Subject: [PATCH 219/276] * util/grub-mkconfig.in: Ignore emacsen backup. --- ChangeLog | 4 ++++ util/grub-mkconfig.in | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index a9aaa81c1..cce7aa483 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-08 Martin Zuther + + * util/grub-mkconfig.in: Ignore emacsen backup. + 2011-04-08 Vladimir Serbinenko * grub-core/kern/emu/hostdisk.c (open_device): Sync on close and not diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index b041a38d7..afc66f886 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -280,6 +280,8 @@ for i in ${grub_mkconfig_dir}/* ; do case "$i" in # emacsen backup files. FIXME: support other editors *~) ;; + # emacsen autosave files. FIXME: support other editors + \#*\#) ;; *) if grub_file_is_not_garbage "$i" && test -x "$i" ; then echo From 3c0e3f142abf1f336eccc8fbe27e44062b7bcdfc Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 12:06:55 +0200 Subject: [PATCH 220/276] * grub-core/disk/raid.c [GRUB_UTIL]: Add missing include. --- ChangeLog | 4 ++++ grub-core/disk/raid.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index cce7aa483..9c2b6a959 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-08 Vladimir Serbinenko + + * grub-core/disk/raid.c [GRUB_UTIL]: Addmissing include. + 2011-04-08 Martin Zuther * util/grub-mkconfig.in: Ignore emacsen backup. diff --git a/grub-core/disk/raid.c b/grub-core/disk/raid.c index c89ca62a1..ac2b9fefe 100644 --- a/grub-core/disk/raid.c +++ b/grub-core/disk/raid.c @@ -23,6 +23,9 @@ #include #include #include +#ifdef GRUB_UTIL +#include +#endif /* Linked list of RAID arrays. */ static struct grub_raid_array *array_list; From f7148863eb5ae162281d8ff79500dfad77974d08 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 12:12:02 +0200 Subject: [PATCH 221/276] * grub-core/normal/menu.c: Add missing include. --- ChangeLog | 6 +++++- grub-core/normal/menu.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9c2b6a959..7b247ca81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ 2011-04-08 Vladimir Serbinenko - * grub-core/disk/raid.c [GRUB_UTIL]: Addmissing include. + * grub-core/normal/menu.c: Add missing include. + +2011-04-08 Vladimir Serbinenko + + * grub-core/disk/raid.c [GRUB_UTIL]: Add missing include. 2011-04-08 Martin Zuther diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index bfcdd0ac5..5844cb2f0 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -31,6 +31,7 @@ #include #include #include +#include /* Time to delay after displaying an error message about a default/fallback entry failing to boot. */ From 947aa4f886767d0da7a00418672ded6cc4fb52e2 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 12:13:44 +0200 Subject: [PATCH 222/276] * grub-core/Makefile.am: Properly escape parenthesis in sed expressions. Fixes Estonian locale. Reported by: Leho Kraav. --- ChangeLog | 6 ++++++ grub-core/Makefile.am | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b247ca81..fd5cadae5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-08 Vladimir Serbinenko + + * grub-core/Makefile.am: Properly escape parenthesis in sed expressions. + Fixes Estonian locale. + Reported by: Leho Kraav. + 2011-04-08 Vladimir Serbinenko * grub-core/normal/menu.c: Add missing include. diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 94f7f3ffe..9e0ca7cc3 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -200,8 +200,8 @@ noinst_DATA += kernel_syms.lst kernel_syms.lst: $(KERNEL_HEADER_FILES) $(top_builddir)/config.h $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) $(CFLAGS) -DGRUB_SYMBOL_GENERATOR=1 $^ >kernel_syms.input cat kernel_syms.input | grep -v '^#' | sed -n \ - -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \ - -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \ + -e '/EXPORT_FUNC *\([a-zA-Z0-9_]*\)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \ + -e '/EXPORT_VAR *\([a-zA-Z0-9_]*\)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \ | sort -u >$@ rm -f kernel_syms.input CLEANFILES += kernel_syms.lst From cb180fdf06a03ad159b83915572ea60f32073053 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 13:18:27 +0200 Subject: [PATCH 223/276] revert last revision. It's ineffective --- ChangeLog | 6 ------ grub-core/Makefile.am | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd5cadae5..7b247ca81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,3 @@ -2011-04-08 Vladimir Serbinenko - - * grub-core/Makefile.am: Properly escape parenthesis in sed expressions. - Fixes Estonian locale. - Reported by: Leho Kraav. - 2011-04-08 Vladimir Serbinenko * grub-core/normal/menu.c: Add missing include. diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 9e0ca7cc3..94f7f3ffe 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -200,8 +200,8 @@ noinst_DATA += kernel_syms.lst kernel_syms.lst: $(KERNEL_HEADER_FILES) $(top_builddir)/config.h $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) $(CFLAGS) -DGRUB_SYMBOL_GENERATOR=1 $^ >kernel_syms.input cat kernel_syms.input | grep -v '^#' | sed -n \ - -e '/EXPORT_FUNC *\([a-zA-Z0-9_]*\)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \ - -e '/EXPORT_VAR *\([a-zA-Z0-9_]*\)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \ + -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \ + -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \ | sort -u >$@ rm -f kernel_syms.input CLEANFILES += kernel_syms.lst From 18dd6b472d1ef7799d83c0bd7df823dc8f45133d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 8 Apr 2011 13:57:56 +0200 Subject: [PATCH 224/276] * autogen.sh: Ensure that collate and ctype locale is C. * conf/Makefile.common: Likeiwise. Also-By: Colin Watson --- ChangeLog | 6 ++++++ autogen.sh | 4 ++++ conf/Makefile.common | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7b247ca81..1820e3306 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-08 Vladimir Serbinenko +2011-04-08 Colin Watson + + * autogen.sh: Ensure that collate and ctype locale is C. + * conf/Makefile.common: Likeiwise. + 2011-04-08 Vladimir Serbinenko * grub-core/normal/menu.c: Add missing include. diff --git a/autogen.sh b/autogen.sh index 96b1e33e2..d14707aad 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,6 +2,10 @@ set -e +export LC_CTYPE=C +export LC_COLLATE=C +unset LC_ALL + autogen --version >/dev/null || exit 1 echo "Importing unicode..." diff --git a/conf/Makefile.common b/conf/Makefile.common index 32ca76d08..5aa13cdd6 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -2,6 +2,10 @@ CFLAGS_PLATFORM= +export LC_COLLATE := C +export LC_CTYPE := C +unexport LC_ALL + # Platform specific options if COND_i386_pc CFLAGS_PLATFORM += -mrtd -mregparm=3 From 4ed4ce5820f74eb1f908ba8cef90aba743ce3bd9 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 13:59:07 +0200 Subject: [PATCH 225/276] correct Changelog spelling --- ChangeLog | 2 +- grub-core/loader/i386/multiboot_mbi.c | 2 +- include/grub/efiemu/efiemu.h | 5 ++--- include/grub/util/raid.h | 2 +- util/grub-setup.c | 10 +++++++++- util/raid.c | 13 +++---------- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1820e3306..e8b2bf0e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ 2011-04-08 Colin Watson * autogen.sh: Ensure that collate and ctype locale is C. - * conf/Makefile.common: Likeiwise. + * conf/Makefile.common: Likewise. 2011-04-08 Vladimir Serbinenko diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index 14db50bcd..bef534296 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -435,7 +435,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target) bufsize = grub_multiboot_get_mbi_size (); err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, - 0, 0xffffffff - bufsize, + 0x10000, 0x100000 - bufsize, bufsize, 4, GRUB_RELOCATOR_PREFERENCE_NONE); if (err) diff --git a/include/grub/efiemu/efiemu.h b/include/grub/efiemu/efiemu.h index 8eee98b61..9cedc3226 100644 --- a/include/grub/efiemu/efiemu.h +++ b/include/grub/efiemu/efiemu.h @@ -21,6 +21,7 @@ #include #include +#include #define GRUB_EFIEMU_PAGESIZE 4096 @@ -227,9 +228,7 @@ grub_efiemu_finish_boot_services (grub_efi_uintn_t *memory_map_size, grub_efi_uint32_t *descriptor_version); grub_err_t -grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, - grub_uint64_t, - grub_uint32_t)); +grub_efiemu_mmap_iterate (grub_memory_hook_t hook); int grub_efiemu_sizeof_uintn_t (void); grub_err_t grub_efiemu_get_lower_upper_memory (grub_uint64_t *lower, grub_uint64_t *upper); diff --git a/include/grub/util/raid.h b/include/grub/util/raid.h index 67020bb86..4da5eaaa8 100644 --- a/include/grub/util/raid.h +++ b/include/grub/util/raid.h @@ -21,7 +21,7 @@ #define GRUB_RAID_UTIL_HEADER 1 #ifdef __linux__ -char** grub_util_raid_getmembers (char *name); +char** grub_util_raid_getmembers (const char *name); #endif #endif /* ! GRUB_RAID_UTIL_HEADER */ diff --git a/util/grub-setup.c b/util/grub-setup.c index c1f2a1f5e..ed2d63fdd 100644 --- a/util/grub-setup.c +++ b/util/grub-setup.c @@ -973,7 +973,15 @@ main (int argc, char *argv[]) char **devicelist; int i; - devicelist = grub_util_raid_getmembers (dest_dev); + if (arguments.device[0] == '/') + devicelist = grub_util_raid_getmembers (arguments.device); + else + { + char *devname; + devname = xasprintf ("/dev/%s", dest_dev); + devicelist = grub_util_raid_getmembers (dest_dev); + free (devname); + } for (i = 0; devicelist[i]; i++) { diff --git a/util/raid.c b/util/raid.c index dac19a935..a6aa5f95e 100644 --- a/util/raid.c +++ b/util/raid.c @@ -36,25 +36,18 @@ #include char ** -grub_util_raid_getmembers (char *name) +grub_util_raid_getmembers (const char *name) { int fd, ret, i, j; - char *devname; char **devicelist; mdu_version_t version; mdu_array_info_t info; mdu_disk_info_t disk; - devname = xmalloc (strlen (name) + 6); - strcpy (devname, "/dev/"); - strcpy (devname+5, name); - - fd = open (devname, O_RDONLY); + fd = open (name, O_RDONLY); if (fd == -1) - grub_util_error ("can't open %s: %s", devname, strerror (errno)); - - free (devname); + grub_util_error ("can't open %s: %s", name, strerror (errno)); ret = ioctl (fd, RAID_VERSION, &version); if (ret != 0) From 7a3d6cd97bd2f047ce93a6dab1c3094cd0d2eaf8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 14:02:27 +0200 Subject: [PATCH 226/276] * include/grub/efiemu/efiemu.h: Use grub_memory_hook_t type. --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index e8b2bf0e7..df08adb93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-08 Vladimir Serbinenko + + * include/grub/efiemu/efiemu.h: Use grub_memory_hook_t type. + 2011-04-08 Vladimir Serbinenko 2011-04-08 Colin Watson From 10a7a86703946b5f09cff96206a793a6beb449ec Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 14:04:24 +0200 Subject: [PATCH 227/276] * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): Place mbi on low memory for better compatibility. --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index df08adb93..a0ed27b06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-08 Vladimir Serbinenko + + * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): + Place mbi on low memory for better compatibility. + 2011-04-08 Vladimir Serbinenko * include/grub/efiemu/efiemu.h: Use grub_memory_hook_t type. From 2e335e901cd0f45e9610c6441154f9d7a415b1d4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 14:08:55 +0200 Subject: [PATCH 228/276] * include/grub/util/raid.h (grub_util_raid_getmembers): Make argument const. * util/grub-setup.c (main): Reuse md device name if available. * util/raid.c (grub_util_raid_getmembers): Receive device name and not GRUB name as argument. Based on patch by: Florian Wagner . --- ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index a0ed27b06..fdce6dfe0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-04-08 Vladimir Serbinenko + + * include/grub/util/raid.h (grub_util_raid_getmembers): Make argument + const. + * util/grub-setup.c (main): Reuse md device name if available. + * util/raid.c (grub_util_raid_getmembers): Receive device name and + not GRUB name as argument. + Based on patch by: Florian Wagner . + 2011-04-08 Vladimir Serbinenko * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): From 6a6f80587b06170180b899877c54299f5a1c5af5 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 14:25:44 +0200 Subject: [PATCH 229/276] * grub-core/normal/term.c (print_ucs4_terminal): Don't try to put the word on new line if it's too long anyway. Fixes a hang. --- ChangeLog | 5 +++++ grub-core/normal/term.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fdce6dfe0..1b9d768ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-08 Vladimir Serbinenko + + * grub-core/normal/term.c (print_ucs4_terminal): Don't try to put the + word on new line if it's too long anyway. Fixes a hang. + 2011-04-08 Vladimir Serbinenko * include/grub/util/raid.h (grub_util_raid_getmembers): Make argument diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c index a1aa3d783..9c4b491f5 100644 --- a/grub-core/normal/term.c +++ b/grub-core/normal/term.c @@ -552,7 +552,7 @@ print_ucs4_terminal (const grub_uint32_t * str, if (line_width > max_width && last_space > line_start) ptr = last_space; else if (line_width > max_width - && line_start == str && startwidth != 0) + && line_start == str && line_width - lastspacewidth < max_width - 5) { ptr = str; lastspacewidth = startwidth; From 34c09785b674cab9df9be9bd2a6e992fafb67c4b Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 14:28:19 +0200 Subject: [PATCH 230/276] * grub-core/commands/probe.c (options): Argument to set isn't optional. (GRUB_MOD_INIT): DEVICE isn't optional. --- ChangeLog | 5 +++++ grub-core/commands/probe.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1b9d768ce..2bcc1b66b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-08 Vladimir Serbinenko + + * grub-core/commands/probe.c (options): Argument to set isn't optional. + (GRUB_MOD_INIT): DEVICE isn't optional. + 2011-04-08 Vladimir Serbinenko * grub-core/normal/term.c (print_ucs4_terminal): Don't try to put the diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c index abe84895d..3ace596d8 100644 --- a/grub-core/commands/probe.c +++ b/grub-core/commands/probe.c @@ -34,7 +34,7 @@ static const struct grub_arg_option options[] = { - {"set", 's', GRUB_ARG_OPTION_OPTIONAL, + {"set", 's', 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}, @@ -150,7 +150,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT (probe) { - cmd = grub_register_extcmd ("probe", grub_cmd_probe, 0, N_("[DEVICE]"), + cmd = grub_register_extcmd ("probe", grub_cmd_probe, 0, N_("DEVICE"), N_("Retrieve device info."), options); } From 7c2e4909c3cf1a2b23ac096e48269e1e7f694fab Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 14:32:41 +0200 Subject: [PATCH 231/276] * grub-core/lib/legacy_parse.c (legacy_commands): Find doesn't set root on legacy. --- ChangeLog | 5 +++++ grub-core/lib/legacy_parse.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2bcc1b66b..70101ef17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-08 Vladimir Serbinenko + + * grub-core/lib/legacy_parse.c (legacy_commands): Find doesn't set + root on legacy. + 2011-04-08 Vladimir Serbinenko * grub-core/commands/probe.c (options): Argument to set isn't optional. diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c index fb1a52bf8..024849055 100644 --- a/grub-core/lib/legacy_parse.c +++ b/grub-core/lib/legacy_parse.c @@ -116,7 +116,7 @@ static struct legacy_command legacy_commands[] = " immediately starts over using the NUM entry (same numbering as the" " `default' command). This obviously won't help if the machine" " was rebooted by a kernel that GRUB loaded."}, - {"find", "search -sf '%s'\n", NULL, 0, 1, {TYPE_FILE}, 0, "FILENAME", + {"find", "search -f '%s'\n", NULL, 0, 1, {TYPE_FILE}, 0, "FILENAME", "Search for the filename FILENAME in all of partitions and print the list of" " the devices which contain the file."}, /* FIXME: fstest unsupported. */ From d7a565e962b541b8a5ccb2719253a884b2c2b422 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 14:37:13 +0200 Subject: [PATCH 232/276] * grub-core/normal/menu_entry.c (run): Use grub_memcpy rather than grub_strcpy since the lines aren't necessarily 0-terminated. --- ChangeLog | 5 +++++ grub-core/normal/menu_entry.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 70101ef17..7621dc3fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-08 Vladimir Serbinenko + + * grub-core/normal/menu_entry.c (run): Use grub_memcpy rather than + grub_strcpy since the lines aren't necessarily 0-terminated. + 2011-04-08 Vladimir Serbinenko * grub-core/lib/legacy_parse.c (legacy_commands): Find doesn't set diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index a675ff005..30af2c1dc 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -1185,7 +1185,7 @@ run (struct screen *screen) size = 0; for (i = 0; i < screen->num_lines; i++) { - grub_strcpy (source + size, screen->lines[i].buf); + grub_memcpy (source + size, screen->lines[i].buf, screen->lines[i].len); size += screen->lines[i].len; source[size++] = '\n'; } From 2c58372857c7482217006ff9a056915d47bd14a1 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 8 Apr 2011 14:01:51 +0100 Subject: [PATCH 233/276] * docs/grub-dev.texi: Fix spelling of "developer" throughout. * grub-core/fs/i386/pc/pxe.c (parse_dhcp_vendor): Fix spelling of "development". --- ChangeLog | 6 ++++++ docs/grub-dev.texi | 10 +++++----- grub-core/fs/i386/pc/pxe.c | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7621dc3fb..bc44fb078 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-08 Colin Watson + + * docs/grub-dev.texi: Fix spelling of "developer" throughout. + * grub-core/fs/i386/pc/pxe.c (parse_dhcp_vendor): Fix spelling of + "development". + 2011-04-08 Vladimir Serbinenko * grub-core/normal/menu_entry.c (run): Use grub_memcpy rather than diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index f1bfd294b..7c4e3d258 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -3,7 +3,7 @@ @c %**start of header @setfilename grub-dev.info @include version-dev.texi -@settitle GNU GRUB Developpers Manual @value{VERSION} +@settitle GNU GRUB Developers Manual @value{VERSION} @c Unify all our little indices for now. @syncodeindex fn cp @syncodeindex vr cp @@ -17,7 +17,7 @@ @finalout @copying -This developper manual is for GNU GRUB (version @value{VERSION}, +This developer manual is for GNU GRUB (version @value{VERSION}, @value{UPDATED}). Copyright @copyright{} 1999,2000,2001,2002,2004,2005,2006,2008,2009,2010,2011 Free Software Foundation, Inc. @@ -39,7 +39,7 @@ Invariant Sections. @titlepage @sp 10 -@title the GNU GRUB developper manual +@title the GNU GRUB developer manual @subtitle The GRand Unified Bootloader, version @value{VERSION}, @value{UPDATED}. @author Yoshinori K. Okuji @author Colin D Bennett @@ -61,9 +61,9 @@ Invariant Sections. @ifnottex @node Top -@top GNU GRUB developper manual +@top GNU GRUB developer manual -This is the developper documentation of GNU GRUB, the GRand Unified Bootloader, +This is the developer documentation of GNU GRUB, the GRand Unified Bootloader, a flexible and powerful boot loader program for a wide range of architectures. diff --git a/grub-core/fs/i386/pc/pxe.c b/grub-core/fs/i386/pc/pxe.c index a3b055f3d..c800ea2ad 100644 --- a/grub-core/fs/i386/pc/pxe.c +++ b/grub-core/fs/i386/pc/pxe.c @@ -481,7 +481,7 @@ parse_dhcp_vendor (void *vend, int limit) break; /* If you need any other options please contact GRUB - developpement team. */ + development team. */ } ptr += taglength; From 1ec652f4c46b34e833e4c5068176531e54db7ac3 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Apr 2011 16:00:23 +0200 Subject: [PATCH 234/276] * util/grub-mkimage.c (main): Handle special naming of yeeloong directory. --- ChangeLog | 5 +++++ util/grub-mkimage.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index bc44fb078..569060ec8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-08 Vladimir Serbinenko + + * util/grub-mkimage.c (main): Handle special naming of yeeloong + directory. + 2011-04-08 Colin Watson * docs/grub-dev.texi: Fix spelling of "developer" throughout. diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index 876e9c9b2..70c5ef6a9 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -1588,9 +1588,19 @@ main (int argc, char *argv[]) + 1); memcpy (dir, GRUB_PKGLIBROOTDIR, sizeof (GRUB_PKGLIBROOTDIR) - 1); *(dir + sizeof (GRUB_PKGLIBROOTDIR) - 1) = '/'; - memcpy (dir + sizeof (GRUB_PKGLIBROOTDIR), image_target->name, - last - image_target->name); - *(dir + sizeof (GRUB_PKGLIBROOTDIR) + (last - image_target->name)) = 0; + if (strncmp (image_target->name, "mipsel-yeeloong", + last - image_target->name) == 0) + { + memcpy (dir + sizeof (GRUB_PKGLIBROOTDIR), "mips-yeeloong", + sizeof ("mips-yeeloong")); + } + else + { + memcpy (dir + sizeof (GRUB_PKGLIBROOTDIR), image_target->name, + last - image_target->name); + *(dir + sizeof (GRUB_PKGLIBROOTDIR) + (last - image_target->name)) + = 0; + } } generate_image (dir, prefix ? : DEFAULT_DIRECTORY, fp, From 2cf09e3258991b0b1a4d5645d6deaff5ca27ed09 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 9 Apr 2011 03:10:59 +0100 Subject: [PATCH 235/276] * docs/grub-dev.texi: Replace MoinMoin syntax with Texinfo syntax throughout. --- ChangeLog | 5 + docs/grub-dev.texi | 339 +++++++++++++++++++++++---------------------- 2 files changed, 178 insertions(+), 166 deletions(-) diff --git a/ChangeLog b/ChangeLog index 569060ec8..0494fa2c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-09 Colin Watson + + * docs/grub-dev.texi: Replace MoinMoin syntax with Texinfo syntax + throughout. + 2011-04-08 Vladimir Serbinenko * util/grub-mkimage.c (main): Handle special naming of yeeloong diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index 7c4e3d258..a7ab6f71a 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -115,7 +115,7 @@ local version, you may need to resolve conflicts when pulling. @chapter Coding style @c By YoshinoriOkuji, VesaJääskeläinen and ColinBennett -Basically we follow the [http://www.gnu.org/prep/standards_toc.html GNU Coding Standards]. We define additional conventions for GRUB here. +Basically we follow the @uref{http://www.gnu.org/prep/standards_toc.html, GNU Coding Standards}. We define additional conventions for GRUB here. @menu * Naming Conventions:: @@ -167,7 +167,7 @@ If a macro is global, its name must be prefixed with GRUB_ and must consist of o @node Comments @section Comments -All comments shall be C-style comments, of the form `/*` … `*/`. +All comments shall be C-style comments, of the form @samp{/* @dots{} */}. Comments shall be placed only on a line be themselves. They shall not be placed together with code, variable declarations, or other non-comment entities. A comment should be placed immediately preceding the entity it describes. @@ -207,7 +207,7 @@ Unacceptable: * It is long. */ @end example -The opening `/*` and closing `*/` should be placed together on a line with text. +The opening @samp{/*} and closing @samp{*/} should be placed together on a line with text. @node Finding your way around @chapter Finding your way around @@ -320,7 +320,7 @@ anymore. For developers it is recommended always to use the newest development version of GRUB 2. If development takes a long period of time, please remember to keep in sync with newest developments regularly so it is much easier to integrate your change in the future. GRUB 2 is being developed on SVN repository. Please check Savannah's GRUB project page for details how to get newest BZR: -[http://savannah.gnu.org/bzr/?group=grub GRUB 2 BZR Repository] +@uref{http://savannah.gnu.org/bzr/?group=grub, GRUB 2 BZR Repository} @item Compile it and try it out. @@ -368,7 +368,7 @@ what it changes and so on. Please be prepared to receive even discouraging comments about your patch. There is usually at least something that needs to be improved in every patch. -Please use unified diff to make your patch (good match of arguments for diff is ''-pruN''). +Please use unified diff to make your patch (good match of arguments for diff is @samp{-pruN}). @item Respond to received feedback. @@ -419,7 +419,7 @@ project: @enumerate @item You need to create your own account on Savannah. -@item You can submit ''Request for Inclusion'' from ''My Groups'' on Savannah. +@item You can submit ``Request for Inclusion'' from ``My Groups'' on Savannah. @end enumerate Then, one of the admins can approve your request, and you will be a member. @@ -427,7 +427,7 @@ If you don't want to use the Savannah interface to submit a request, you can simply notify the admins by email or something else, alternatively. But you still need to create an account beforehand. -NOTE: we sometimes receive a ''Request for Inclusion'' from an unknown person. +NOTE: we sometimes receive a ``Request for Inclusion'' from an unknown person. In this case, the request would be just discarded, since it is too dangerous to allow a stranger to be a member, which automatically gives him a commit right to the repository, both for a legal reason and for a technical reason. @@ -448,13 +448,13 @@ function does not provide handling of the exception it must return back to it's calling function and so on, until exception is handled. If exception is not handled before prompt is displayed, error message will be shown to user. -Exception information is stored on ''grub_errno'' global variable. If -''grub_errno'' variable contains value ''GRUB_ERR_NONE'', there is no active -exception and application can continue normal processing. When grub_errno has +Exception information is stored on @code{grub_errno} global variable. If +@code{grub_errno} variable contains value @code{GRUB_ERR_NONE}, there is no active +exception and application can continue normal processing. When @code{grub_errno} has other value, it is required that application code either handles this error or -returns instantly to caller. If function is with return type ''grub_err_t'' is -about to return ''GRUB_ERR_NONE'', it should not set ''grub_errno'' to that -value. Only set ''grub_errno'' in cases where there is error situation. +returns instantly to caller. If function is with return type @code{grub_err_t} is +about to return @code{GRUB_ERR_NONE}, it should not set @code{grub_errno} to that +value. Only set @code{grub_errno} in cases where there is error situation. Simple exception forwarder. @example @@ -478,11 +478,11 @@ forwarding_example (void) @end example Error reporting has two components, the actual error code (of type -''grub_err_t'') and textual message that will be displayed to user. List of -valid error codes is listed in header file ''include/grub/err.h''. Textual +@code{grub_err_t}) and textual message that will be displayed to user. List of +valid error codes is listed in header file @file{include/grub/err.h}. Textual error message can contain any textual data. At time of writing, error message can contain up to 256 characters (including terminating NUL). To ease error -reporting there is a helper function ''grub_error'' that allows easier +reporting there is a helper function @code{grub_error} that allows easier formatting of error messages and should be used instead of writing directly to global variables. @@ -499,11 +499,11 @@ failing_example () @end example If there is a special reason that error code does not need to be taken account, -''grub_errno'' can be zeroed back to ''GRUB_ERR_NONE''. In cases like this all +@code{grub_errno} can be zeroed back to @code{GRUB_ERR_NONE}. In cases like this all previous error codes should have been handled correctly. This makes sure that there are no unhandled exceptions. -Example of zeroing ''grub_errno''. +Example of zeroing @code{grub_errno}. @example grub_err_t probe_example () @@ -539,8 +539,8 @@ Some times there is a need to continue processing even if there is a error state in application. In situations like this, there is a needed to save old error state and then call other functions that might fail. To aid in this, there is a error stack implemented. Error state can be pushed to error stack -by calling function ''grub_error_push ()''. When processing has been completed, -''grub_error_pop ()'' can be used to pop error state from stack. Error stack +by calling function @code{grub_error_push ()}. When processing has been completed, +@code{grub_error_pop ()} can be used to pop error state from stack. Error stack contains predefined amount of error stack items. Error stack is proteced for overflow and marks these situations so overflow error does not get unseen. If there is no space available to store error message, it is simply discarded @@ -644,7 +644,7 @@ grub_video_setup (unsigned int width, unsigned int height, unsigned int mode_typ @end example @item Description: -Driver will use information provided to it to select best possible video mode and switch to it. Supported values for ''mode_type'' are ''GRUB_VIDEO_MODE_TYPE_INDEX_COLOR'' for index color modes, ''GRUB_VIDEO_MODE_TYPE_RGB'' for direct RGB color modes and ''GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED'' for double buffering. When requesting RGB mode, highest bits per pixel mode will be selected. When requesting Index color mode, mode with highest number of colors will be selected. If all parameters are specified as zero, video adapter will try to figure out best possible mode and initialize it, platform specific differences are allowed here. If there is no mode matching request, error X will be returned. If there are no problems, function returns ''GRUB_ERR_NONE''. +Driver will use information provided to it to select best possible video mode and switch to it. Supported values for @code{mode_type} are @code{GRUB_VIDEO_MODE_TYPE_INDEX_COLOR} for index color modes, @code{GRUB_VIDEO_MODE_TYPE_RGB} for direct RGB color modes and @code{GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED} for double buffering. When requesting RGB mode, highest bits per pixel mode will be selected. When requesting Index color mode, mode with highest number of colors will be selected. If all parameters are specified as zero, video adapter will try to figure out best possible mode and initialize it, platform specific differences are allowed here. If there is no mode matching request, error X will be returned. If there are no problems, function returns @code{GRUB_ERR_NONE}. This function also performs following task upon succesful mode switch. Active rendering target is changed to screen and viewport is maximized to allow whole screen to be used when performing graphics operations. In RGB modes, emulated palette get's 16 entries containing default values for VGA palette, other colors are defined as black. When switching to Indexed Color mode, driver may set default VGA palette to screen if the video card allows the operation. @@ -712,7 +712,7 @@ struct grub_video_mode_info @end example @item Description: -Software developer can use this function to query properties of active rendering taget. Information provided here can be used by other parts of GRUB, like image loaders to convert loaded images to correct screen format to allow more optimized blitters to be used. If there there is no configured video driver with active screen, error ''GRUB_ERR_BAD_DEVICE'' is returned, otherwise ''mode_info'' is filled with valid information and ''GRUB_ERR_NONE'' is returned. +Software developer can use this function to query properties of active rendering taget. Information provided here can be used by other parts of GRUB, like image loaders to convert loaded images to correct screen format to allow more optimized blitters to be used. If there there is no configured video driver with active screen, error @code{GRUB_ERR_BAD_DEVICE} is returned, otherwise @code{mode_info} is filled with valid information and @code{GRUB_ERR_NONE} is returned. @end itemize @subsection grub_video_get_blit_format @@ -740,7 +740,7 @@ enum grub_video_blit_format @end example @item Description: -Used to query how data could be optimized to suit specified video mode. Returns exact video format type, or a generic one if there is no definition for the type. For generic formats, use ''grub_video_get_info'' to query video color coding settings. +Used to query how data could be optimized to suit specified video mode. Returns exact video format type, or a generic one if there is no definition for the type. For generic formats, use @code{grub_video_get_info} to query video color coding settings. @end itemize @subsection grub_video_set_palette @@ -762,7 +762,7 @@ struct grub_video_palette_data @end example @item Description: -Used to setup indexed color palettes. If mode is RGB mode, colors will be set to emulated palette data. In Indexed Color modes, palettes will be set to hardware. Color values will be converted to suit requirements of the video mode. ''start'' will tell what hardware color index (or emulated color index) will be set to according information in first indice of ''palette_data'', after that both hardware color index and ''palette_data'' index will be incremented until ''count'' number of colors have been set. +Used to setup indexed color palettes. If mode is RGB mode, colors will be set to emulated palette data. In Indexed Color modes, palettes will be set to hardware. Color values will be converted to suit requirements of the video mode. @code{start} will tell what hardware color index (or emulated color index) will be set to according information in first indice of @code{palette_data}, after that both hardware color index and @code{palette_data} index will be incremented until @code{count} number of colors have been set. @end itemize @subsection grub_video_get_palette @@ -784,7 +784,7 @@ struct grub_video_palette_data @end example @item Description: -Used to query indexed color palettes. If mode is RGB mode, colors will be copied from emulated palette data. In Indexed Color modes, palettes will be read from hardware. Color values will be converted to suit structure format. ''start'' will tell what hardware color index (or emulated color index) will be used as a source for first indice of ''palette_data'', after that both hardware color index and ''palette_data'' index will be incremented until ''count'' number of colors have been read. +Used to query indexed color palettes. If mode is RGB mode, colors will be copied from emulated palette data. In Indexed Color modes, palettes will be read from hardware. Color values will be converted to suit structure format. @code{start} will tell what hardware color index (or emulated color index) will be used as a source for first indice of @code{palette_data}, after that both hardware color index and @code{palette_data} index will be incremented until @code{count} number of colors have been read. @end itemize @subsection grub_video_set_viewport @@ -797,7 +797,7 @@ grub_video_set_viewport (unsigned int x, unsigned int y, unsigned int width, uns @end example @item Description: -Used to specify viewport where draw commands are performed. When viewport is set, all draw commands coordinates relate to those specified by ''x'' and ''y''. If draw commands try to draw over viewport, they are clipped. If developer requests larger than possible viewport, width and height will be clamped to fit screen. If ''x'' and ''y'' are out of bounds, all functions drawing to screen will not be displayed. In order to maximize viewport, use grub_video_get_info to query actual screen dimensions and provide that information to this function. +Used to specify viewport where draw commands are performed. When viewport is set, all draw commands coordinates relate to those specified by @code{x} and @code{y}. If draw commands try to draw over viewport, they are clipped. If developer requests larger than possible viewport, width and height will be clamped to fit screen. If @code{x} and @code{y} are out of bounds, all functions drawing to screen will not be displayed. In order to maximize viewport, use @code{grub_video_get_info} to query actual screen dimensions and provide that information to this function. @end itemize @subsection grub_video_get_viewport @@ -823,7 +823,7 @@ grub_video_map_color (grub_uint32_t color_name); @end example @item Description: -Map color can be used to support color themes in GRUB. There will be collection of color names that can be used to query actual screen mapped color data. Examples could be ''GRUB_COLOR_CONSOLE_BACKGROUND'', ''GRUB_COLOR_CONSOLE_TEXT''. The actual color defines are not specified at this point. +Map color can be used to support color themes in GRUB. There will be collection of color names that can be used to query actual screen mapped color data. Examples could be @code{GRUB_COLOR_CONSOLE_BACKGROUND}, @code{GRUB_COLOR_CONSOLE_TEXT}. The actual color defines are not specified at this point. @end itemize @subsection grub_video_map_rgb @@ -862,7 +862,7 @@ grub_video_unmap_color (grub_video_color_t color, grub_uint8_t *red, grub_uint8_ @end example @item Description: -Unmap color value from ''color'' to color channels in ''red'', ''green'', ''blue'' and ''alpha''. Values will be in range 0-255. Active rendering target will be used for color domain. In case alpha information is not available in rendering target, it is assumed to be opaque (having value 255). +Unmap color value from @code{color} to color channels in @code{red}, @code{green}, @code{blue} and @code{alpha}. Values will be in range 0-255. Active rendering target will be used for color domain. In case alpha information is not available in rendering target, it is assumed to be opaque (having value 255). @end itemize @subsection grub_video_fill_rect @@ -877,7 +877,7 @@ grub_video_fill_rect (grub_video_color_t color, int x, int y, unsigned int width Fill specified area limited by given coordinates within specified viewport. Negative coordinates are accepted in order to allow easy moving of rectangle within viewport. If coordinates are negative, area of the rectangle will be shrinken to follow size limits of the viewport. -Software developer should use either ''grub_video_map_color'', ''grub_video_map_rgb'' or ''grub_video_map_rgba'' to map requested color to ''color'' parameter. +Software developer should use either @code{grub_video_map_color}, @code{grub_video_map_rgb} or @code{grub_video_map_rgba} to map requested color to @code{color} parameter. @end itemize @subsection grub_video_blit_glyph @@ -895,7 +895,7 @@ struct grub_font_glyph @{ @end example @item Description: -Used to blit glyph to viewport in specified coodinates. If glyph is at edge of viewport, pixels outside of viewport will be clipped out. Software developer should use either ''grub_video_map_rgb'' or ''grub_video_map_rgba'' to map requested color to ''color'' parameter. +Used to blit glyph to viewport in specified coodinates. If glyph is at edge of viewport, pixels outside of viewport will be clipped out. Software developer should use either @code{grub_video_map_rgb} or @code{grub_video_map_rgba} to map requested color to @code{color} parameter. @end itemize @subsection grub_video_blit_bitmap @@ -920,9 +920,9 @@ enum grub_video_blit_operators @end example @item Description: -Used to blit bitmap to viewport in specified coordinates. If part of bitmap is outside of viewport region, it will be clipped out. Offsets affect bitmap position where data will be copied from. Negative values for both viewport coordinates and bitmap offset coordinates are allowed. If data is looked out of bounds of bitmap, color value will be assumed to be transparent. If viewport coordinates are negative, area of the blitted rectangle will be shrinken to follow size limits of the viewport and bitmap. Blitting operator ''oper'' specifies should source pixel replace data in screen or blend with pixel alpha value. +Used to blit bitmap to viewport in specified coordinates. If part of bitmap is outside of viewport region, it will be clipped out. Offsets affect bitmap position where data will be copied from. Negative values for both viewport coordinates and bitmap offset coordinates are allowed. If data is looked out of bounds of bitmap, color value will be assumed to be transparent. If viewport coordinates are negative, area of the blitted rectangle will be shrinken to follow size limits of the viewport and bitmap. Blitting operator @code{oper} specifies should source pixel replace data in screen or blend with pixel alpha value. -Software developer should use ''grub_video_bitmap_create'' or ''grub_video_bitmap_load'' to create or load bitmap data. +Software developer should use @code{grub_video_bitmap_create} or @code{grub_video_bitmap_load} to create or load bitmap data. @end itemize @subsection grub_video_blit_render_target @@ -946,7 +946,7 @@ enum grub_video_blit_operators @end example @item Description: -Used to blit source render target to viewport in specified coordinates. If part of source render target is outside of viewport region, it will be clipped out. If blitting operator is specified and source contains alpha values, resulting pixel color components will be calculated using formula ((src_color * src_alpha) + (dst_color * (255 - src_alpha)) / 255, if target buffer has alpha, it will be set to src_alpha. Offsets affect render target position where data will be copied from. If data is looked out of bounds of render target, color value will be assumed to be transparent. Blitting operator ''oper'' specifies should source pixel replace data in screen or blend with pixel alpha value. +Used to blit source render target to viewport in specified coordinates. If part of source render target is outside of viewport region, it will be clipped out. If blitting operator is specified and source contains alpha values, resulting pixel color components will be calculated using formula ((src_color * src_alpha) + (dst_color * (255 - src_alpha)) / 255, if target buffer has alpha, it will be set to src_alpha. Offsets affect render target position where data will be copied from. If data is looked out of bounds of render target, color value will be assumed to be transparent. Blitting operator @code{oper} specifies should source pixel replace data in screen or blend with pixel alpha value. @end itemize @subsection grub_video_scroll @@ -990,7 +990,7 @@ struct grub_video_render_target @{ @end example @item Description: -Driver will use information provided to it to create best fitting render target. ''mode_type'' will be used to guide on selecting what features are wanted for render target. Supported values for ''mode_type'' are ''GRUB_VIDEO_MODE_TYPE_INDEX_COLOR'' for index color modes, ''GRUB_VIDEO_MODE_TYPE_RGB'' for direct RGB color modes and ''GRUB_VIDEO_MODE_TYPE_ALPHA'' for alpha component. +Driver will use information provided to it to create best fitting render target. @code{mode_type} will be used to guide on selecting what features are wanted for render target. Supported values for @code{mode_type} are @code{GRUB_VIDEO_MODE_TYPE_INDEX_COLOR} for index color modes, @code{GRUB_VIDEO_MODE_TYPE_RGB} for direct RGB color modes and @code{GRUB_VIDEO_MODE_TYPE_ALPHA} for alpha component. @end itemize @subsection grub_video_delete_render_target @@ -1003,7 +1003,7 @@ grub_video_delete_render_target (struct grub_video_render_target *target); @end example @item Description: -Used to delete previously created render target. If ''target'' contains ''NULL'' pointer, nothing will be done. If render target is correctly destroyed, GRUB_ERR_NONE is returned. +Used to delete previously created render target. If @code{target} contains @code{NULL} pointer, nothing will be done. If render target is correctly destroyed, GRUB_ERR_NONE is returned. @end itemize @subsection grub_video_set_active_render_target @@ -1016,7 +1016,7 @@ grub_video_set_active_render_target (struct grub_video_render_target *target); @end example @item Description: -Set's active render target. If this comand is successful all drawing commands will be done to specified ''target''. There is also special values for target, ''GRUB_VIDEO_RENDER_TARGET_DISPLAY'' used to reference screen's front buffer, ''GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER'' used to reference screen's front buffer (alias for ''GRUB_VIDEO_RENDER_TARGET_DISPLAY'') and ''GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER'' used to reference back buffer (if double buffering is enabled). If render target is correclty switched GRUB_ERR_NONE is returned. In no any event shall there be non drawable active render target. +Set's active render target. If this comand is successful all drawing commands will be done to specified @code{target}. There is also special values for target, @code{GRUB_VIDEO_RENDER_TARGET_DISPLAY} used to reference screen's front buffer, @code{GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER} used to reference screen's front buffer (alias for @code{GRUB_VIDEO_RENDER_TARGET_DISPLAY}) and @code{GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER} used to reference back buffer (if double buffering is enabled). If render target is correclty switched GRUB_ERR_NONE is returned. In no any event shall there be non drawable active render target. @end itemize @subsection grub_video_get_active_render_target @@ -1029,7 +1029,7 @@ grub_video_get_active_render_target (struct grub_video_render_target **target); @end example @item Description: -Returns currently active render target. It returns value in ''target'' that can be subsequently issued back to ''grub_video_set_active_render_target''. +Returns currently active render target. It returns value in @code{target} that can be subsequently issued back to @code{grub_video_set_active_render_target}. @end itemize @node Example usage of Video API @@ -1082,7 +1082,7 @@ grub_err_t grub_video_bitmap_create (struct grub_video_bitmap **bitmap, unsigned @item Description: -Creates a new bitmap with given dimensions and blitting format. Allocated bitmap data can then be modified freely and finally blitted with ''grub_video_blit_bitmap'' to rendering target. +Creates a new bitmap with given dimensions and blitting format. Allocated bitmap data can then be modified freely and finally blitted with @code{grub_video_blit_bitmap} to rendering target. @end itemize @subsection grub_video_bitmap_destroy @@ -1094,7 +1094,7 @@ grub_err_t grub_video_bitmap_destroy (struct grub_video_bitmap *bitmap); @item Description: -When bitmap is no longer needed, it can be freed from memory using this command. ''bitmap'' is previously allocated bitmap with ''grub_video_bitmap_create'' or loaded with ''grub_video_bitmap_load''. +When bitmap is no longer needed, it can be freed from memory using this command. @code{bitmap} is previously allocated bitmap with @code{grub_video_bitmap_create} or loaded with @code{grub_video_bitmap_load}. @end itemize @subsection grub_video_bitmap_load @@ -1106,7 +1106,7 @@ grub_err_t grub_video_bitmap_load (struct grub_video_bitmap **bitmap, const char @item Description: -Tries to load given bitmap (''filename'') using registered bitmap loaders. In case bitmap format is not recognized or supported error ''GRUB_ERR_BAD_FILE_TYPE'' is returned. +Tries to load given bitmap (@code{filename}) using registered bitmap loaders. In case bitmap format is not recognized or supported error @code{GRUB_ERR_BAD_FILE_TYPE} is returned. @end itemize @subsection grub_video_bitmap_get_width @@ -1142,7 +1142,7 @@ void grub_video_bitmap_get_mode_info (struct grub_video_bitmap *bitmap, struct g @item Description: -Returns bitmap format details in form of ''grub_video_mode_info''. +Returns bitmap format details in form of @code{grub_video_mode_info}. @end itemize @subsection grub_video_bitmap_get_data @@ -1181,20 +1181,20 @@ use, compact, and cleanly supports Unicode. @itemize @item Simple to read and use. - Since GRUB will only be reading the font files, - we are more concerned with making the code to read the font simple than we - are with writing the font. +Since GRUB will only be reading the font files, +we are more concerned with making the code to read the font simple than we +are with writing the font. @item Compact storage. - The fonts will generally be stored in a small boot - partition where GRUB is located, and this may be on a removable storage - device such as a CD or USB flash drive where space is more limited than it - is on most hard drives. +The fonts will generally be stored in a small boot +partition where GRUB is located, and this may be on a removable storage +device such as a CD or USB flash drive where space is more limited than it +is on most hard drives. @item Unicode. - GRUB should not have to deal with multiple character - encodings. The font should always use Unicode character codes for simple - internationalization. +GRUB should not have to deal with multiple character +encodings. The font should always use Unicode character codes for simple +internationalization. @end itemize @subsection Why Another Font Format? @@ -1205,136 +1205,143 @@ use in GRUB at this time: @table @samp @item BDF - Inefficient storage; uses ASCII to describe properties and - hexadecimal numbers in ASCII for the bitmap rows. +Inefficient storage; uses ASCII to describe properties and +hexadecimal numbers in ASCII for the bitmap rows. @item PCF - Many format variations such as byte order and bitmap padding (rows - padded to byte, word, etc.) would result in more complex code to - handle the font format. +Many format variations such as byte order and bitmap padding (rows +padded to byte, word, etc.) would result in more complex code to +handle the font format. @end table @node File Structure @section File Structure -A file *section* consists of a 4-byte name, a 32-bit big-endian length (not -including the name or length), and then *length* more section-type-specific +A file @strong{section} consists of a 4-byte name, a 32-bit big-endian length (not +including the name or length), and then @var{length} more section-type-specific bytes. -The standard file extension for PFF2 font files is ``.pf2``. +The standard file extension for PFF2 font files is @file{.pf2}. @subsection Section Types @table @samp @item FILE - *File type ID* (ASCII string). This must be the first section in the file. It has length 4 - and the contents are the four bytes of the ASCII string ``PFF2``. +@strong{File type ID} (ASCII string). This must be the first section in the file. It has length 4 +and the contents are the four bytes of the ASCII string @samp{PFF2}. @item NAME - *Font name* (ASCII string). This is the full font name including family, - weight, style, and point size. For instance, "Helvetica Bold Italic 14". +@strong{Font name} (ASCII string). This is the full font name including family, +weight, style, and point size. For instance, "Helvetica Bold Italic 14". @item FAMI - *Font family name* (ASCII string). For instance, "Helvetica". This should - be included so that intelligent font substitution can take place. +@strong{Font family name} (ASCII string). For instance, "Helvetica". This should +be included so that intelligent font substitution can take place. @item WEIG - *Font weight* (ASCII string). Valid values are ``bold`` and ``normal``. - This should be included so that intelligent font substitution can take - place. +@strong{Font weight} (ASCII string). Valid values are @samp{bold} and @samp{normal}. +This should be included so that intelligent font substitution can take +place. @item SLAN - *Font slant* (ASCII string). Valid values are ``italic`` and ``normal``. - This should be included so that intelligent font substitution can take - place. +@strong{Font slant} (ASCII string). Valid values are @samp{italic} and @samp{normal}. +This should be included so that intelligent font substitution can take +place. @item PTSZ - *Font point size* (uint16be). +@strong{Font point size} (uint16be). @item MAXW - *Maximum character width in pixels* (uint16be). +@strong{Maximum character width in pixels} (uint16be). @item MAXH - *Maximum character height in pixels* (uint16be). +@strong{Maximum character height in pixels} (uint16be). @item ASCE - *Ascent in pixels* (uint16be). See `Font Metrics`_ for details. +@strong{Ascent in pixels} (uint16be). @xref{Font Metrics}, for details. @item DESC - *Descent in pixels* (uint16be). See `Font Metrics`_ for details. +@strong{Descent in pixels} (uint16be). @xref{Font Metrics}, for details. @item CHIX - *Character index.* - The character index begins with a 32-bit big-endian unsigned integer - indicating the total size of the section, not including this size value. - For each character, there is an instance of the following entry structure: +@strong{Character index.} +The character index begins with a 32-bit big-endian unsigned integer +indicating the total size of the section, not including this size value. +For each character, there is an instance of the following entry structure: - @itemize - @item **Unicode code point.** (32-bit big-endian integer.) +@itemize +@item @strong{Unicode code point.} (32-bit big-endian integer.) - @item **Storage flags.** (byte.) +@item @strong{Storage flags.} (byte.) - @itemize - @item Bits 2..0: +@itemize +@item Bits 2..0: - - If equal to 000 binary, then the character data is stored - uncompressed beginning at the offset indicated by the character's - *offset* value. +If equal to 000 binary, then the character data is stored +uncompressed beginning at the offset indicated by the character's +@strong{offset} value. - - If equal to 001 binary, then the character data is stored within a - compressed character definition block that begins at the offset - within the file indicated by the character's *offset* value. - @end itemize - @item **Offset.** (32-bit big-endian integer.) +If equal to 001 binary, then the character data is stored within a +compressed character definition block that begins at the offset +within the file indicated by the character's @strong{offset} value. +@end itemize - A marker that indicates the remainder of the file is data accessed via - the character index (CHIX) section. When reading this font file, the rest - of the file can be ignored when scanning the sections. The length should - be set to -1 (0xFFFFFFFF). +@item @strong{Offset.} (32-bit big-endian integer.) - Supported data structures: +A marker that indicates the remainder of the file is data accessed via +the character index (CHIX) section. When reading this font file, the rest +of the file can be ignored when scanning the sections. The length should +be set to -1 (0xFFFFFFFF). - Character definition - Each character definition consists of: +Supported data structures: - @itemize - @item **Width.** Width of the bitmap in pixels. The bitmap's extents - represent the glyph's bounding box. *uint16be*. +Character definition +Each character definition consists of: - @item **Height.** Height of the bitmap in pixels. The bitmap's extents - represent the glyph's bounding box. *uint16be*. +@itemize +@item @strong{Width.} +Width of the bitmap in pixels. The bitmap's extents +represent the glyph's bounding box. @code{uint16be}. - @item **X offset.** The number of pixels to shift the bitmap by - horizontally before drawing the character. *int16be*. +@item @strong{Height.} +Height of the bitmap in pixels. The bitmap's extents +represent the glyph's bounding box. @code{uint16be}. - @item **Y offset.** The number of pixels to shift the bitmap by - vertically before drawing the character. *int16be*. +@item @strong{X offset.} +The number of pixels to shift the bitmap by +horizontally before drawing the character. @code{int16be}. - @item **Device width.** The number of pixels to advance horizontally from - this character's origin to the origin of the next character. - *int16be*. +@item @strong{Y offset.} +The number of pixels to shift the bitmap by +vertically before drawing the character. @code{int16be}. - @item **Bitmap data.** This is encoded as a string of bits. It is - organized as a row-major, top-down, left-to-right bitmap. The most - significant bit of each byte is taken to be the leftmost or uppermost - bit in the byte. For the sake of compact storage, rows are not padded - to byte boundaries (i.e., a single byte may contain bits belonging to - multiple rows). The last byte of the bitmap *is* padded with zero - bits in the bits positions to the right of the last used bit if the - bitmap data does not fill the last byte. +@item @strong{Device width.} +The number of pixels to advance horizontally from +this character's origin to the origin of the next character. +@code{int16be}. + +@item @strong{Bitmap data.} +This is encoded as a string of bits. It is +organized as a row-major, top-down, left-to-right bitmap. The most +significant bit of each byte is taken to be the leftmost or uppermost +bit in the byte. For the sake of compact storage, rows are not padded +to byte boundaries (i.e., a single byte may contain bits belonging to +multiple rows). The last byte of the bitmap @strong{is} padded with zero +bits in the bits positions to the right of the last used bit if the +bitmap data does not fill the last byte. - The length of the *bitmap data* field is (*width* * *height* + 7) / 8 - using integer arithmetic, which is equivalent to ceil(*width* * - *height* / 8) using real number arithmetic. +The length of the @strong{bitmap data} field is (@var{width} * @var{height} + 7) / 8 +using integer arithmetic, which is equivalent to ceil(@var{width} * +@var{height} / 8) using real number arithmetic. - It remains to be determined whether bitmap fonts usually make all - glyph bitmaps the same height, or if smaller glyphs are stored with - bitmaps having a lesser height. In the latter case, the baseline - would have to be used to calculate the location the bitmap should be - anchored at on screen. - @end itemize +It remains to be determined whether bitmap fonts usually make all +glyph bitmaps the same height, or if smaller glyphs are stored with +bitmaps having a lesser height. In the latter case, the baseline +would have to be used to calculate the location the bitmap should be +anchored at on screen. +@end itemize - @end itemize +@end itemize @end table @node Font Metrics @@ -1342,28 +1349,28 @@ The standard file extension for PFF2 font files is ``.pf2``. @itemize @item Ascent. - The distance from the baseline to the top of most characters. - Note that in some cases characters may extend above the ascent. +The distance from the baseline to the top of most characters. +Note that in some cases characters may extend above the ascent. @item Descent. - The distance from the baseline to the bottom of most characters. Note that - in some cases characters may extend below the descent. +The distance from the baseline to the bottom of most characters. Note that +in some cases characters may extend below the descent. @item Leading. - The amount of space, in pixels, to leave between the descent of one line of - text and the ascent of the next line. This metrics is not specified in the - current file format; instead, the font rendering engine calculates a - reasonable leading value based on the other font metrics. +The amount of space, in pixels, to leave between the descent of one line of +text and the ascent of the next line. This metrics is not specified in the +current file format; instead, the font rendering engine calculates a +reasonable leading value based on the other font metrics. @item Horizonal leading. - The amount of space, in pixels, to leave horizontally between the left and - right edges of two adjacent glyphs. The *device width* field determines - the effective leading value that is used to render the font. +The amount of space, in pixels, to leave horizontally between the left and +right edges of two adjacent glyphs. The @strong{device width} field determines +the effective leading value that is used to render the font. @end itemize @image{font_char_metrics,,,,.png} - An illustration of how the various font metrics apply to characters. +An illustration of how the various font metrics apply to characters. @@ -1383,15 +1390,15 @@ The standard file extension for PFF2 font files is ``.pf2``. @node Introduction_2 @section Introduction -The ``gfxmenu`` module provides a graphical menu interface for GRUB 2. It -functions as an alternative to the menu interface provided by the ``normal`` +The @samp{gfxmenu} module provides a graphical menu interface for GRUB 2. It +functions as an alternative to the menu interface provided by the @samp{normal} module, which uses the grub terminal interface to display a menu on a character-oriented terminal. The graphical menu uses the GRUB video API, which is currently for the VESA BIOS extensions (VBE) 2.0+. This is supported on the i386-pc platform. However, the graphical menu itself does not depend on using VBE, so if another -GRUB video driver were implemented, the ``gfxmenu`` graphical menu would work +GRUB video driver were implemented, the @samp{gfxmenu} graphical menu would work on the new video driver as well. @@ -1402,7 +1409,7 @@ on the new video driver as well. @item grub_enter_normal_mode [normal/main.c] @item grub_normal_execute [normal/main.c] @item read_config_file [normal/main.c] -@item (When ``gfxmenu.mod`` is loaded with ``insmod``, it will call ``grub_menu_viewer_register()`` to register itself.) +@item (When @file{gfxmenu.mod} is loaded with @command{insmod}, it will call @code{grub_menu_viewer_register()} to register itself.) @item GRUB_MOD_INIT (gfxmenu) [gfxmenu/gfxmenu.c] @item grub_menu_viewer_register [kern/menu_viewer.c] @item grub_menu_viewer_show_menu [kern/menu_viewer.c] @@ -1422,7 +1429,7 @@ The graphical menu implements a GUI component system that supports a container-based layout system. Components can be added to containers, and containers (which are a type of component) can then be added to other containers, to form a tree of components. Currently, the root component of -this tree is a *canvas* component, which allows manual layout of its child +this tree is a @samp{canvas} component, which allows manual layout of its child components. Components (non-container): @@ -1444,13 +1451,13 @@ Containers: @end itemize The GUI component instances are created by the theme loader in -``gfxmenu/theme_loader.c`` when a theme is loaded. Theme files specify -statements such as ``+vbox@{ +label @{ text="Hello" @} +label@{ text="World" @} @}`` +@file{gfxmenu/theme_loader.c} when a theme is loaded. Theme files specify +statements such as @samp{+vbox@{ +label @{ text="Hello" @} +label@{ text="World" @} @}} to add components to the component tree root. By nesting the component creation statements in the theme file, the instantiated components are nested the same way. -When a component is added to a container, that new child is considered *owned* +When a component is added to a container, that new child is considered @strong{owned} by the container. Great care should be taken if the caller retains a reference to the child component, since it will be destroyed if its parent container is destroyed. A better choice instead of storing a pointer to the @@ -1459,40 +1466,40 @@ Component IDs do not have to be unique (it is often useful to have multiple components with an ID of "__timeout__", for instance). In order to access and use components in the component tree, there are two -functions (defined in ``gfxmenu/gui_util.c``) that are particularly useful: +functions (defined in @file{gfxmenu/gui_util.c}) that are particularly useful: @itemize -@item ``grub_gui_find_by_id (root, id, callback, userdata)``: +@item @code{grub_gui_find_by_id (root, id, callback, userdata)}: - This function ecursively traverses the component tree rooted at *root*, and - for every component that has an ID equal to *id*, calls the function pointed - to by *callback* with the matching component and the void pointer *userdata* - as arguments. The callback function can do whatever is desired to use the - component passed in. +This function ecursively traverses the component tree rooted at @var{root}, and +for every component that has an ID equal to @var{id}, calls the function pointed +to by @var{callback} with the matching component and the void pointer @var{userdata} +as arguments. The callback function can do whatever is desired to use the +component passed in. -@item ``grub_gui_iterate_recursively (root, callback, userdata)``: +@item @code{grub_gui_iterate_recursively (root, callback, userdata)}: - This function calls the function pointed to by *callback* for every - component that is a descendant of *root* in the component tree. When the - callback function is called, the component and the void pointer *userdata* - as arguments. The callback function can do whatever is desired to use the - component passed in. +This function calls the function pointed to by @var{callback} for every +component that is a descendant of @var{root} in the component tree. When the +callback function is called, the component and the void pointer @var{userdata} +as arguments. The callback function can do whatever is desired to use the +component passed in. @end itemize @node Command Line Window @section Command Line Window The terminal window used to provide command line access within the graphical -menu is managed by ``gfxmenu/view.c``. The ``gfxterm`` terminal is used, and +menu is managed by @file{gfxmenu/view.c}. The @samp{gfxterm} terminal is used, and it has been modified to allow rendering to an offscreen render target to allow it to be composed into the double buffering system that the graphical menu view uses. This is bad for performance, however, so it would probably be a good idea to make it possible to temporarily disable double buffering as long as the terminal window is visible. There are still unresolved problems that occur when commands are executed from the terminal window that change the -graphics mode. It's possible that making ``grub_video_restore()`` return to -the graphics mode that was in use before ``grub_video_setup()`` was called +graphics mode. It's possible that making @code{grub_video_restore()} return to +the graphics mode that was in use before @code{grub_video_setup()} was called might fix some of the problems. From 536ce85a8dc2fafbe6694b8664eb9c77b7d1d08e Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 9 Apr 2011 03:39:47 +0100 Subject: [PATCH 236/276] * docs/grub-dev.texi (Finding your way around): Update for 1.99 build system. (Getting started): GRUB is developed in Bazaar now, not Subversion. (Comment): Fix typo. (Getting started): General copy-editing. (Typical Development Experience): Likewise. (Error Handling): Likewise. (Video API): Likewise. --- ChangeLog | 12 +++++ docs/grub-dev.texi | 117 +++++++++++++++++++++++++-------------------- 2 files changed, 76 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0494fa2c3..4c46f8996 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-04-09 Colin Watson + + * docs/grub-dev.texi (Finding your way around): Update for 1.99 + build system. + (Getting started): GRUB is developed in Bazaar now, not Subversion. + + (Comment): Fix typo. + (Getting started): General copy-editing. + (Typical Development Experience): Likewise. + (Error Handling): Likewise. + (Video API): Likewise. + 2011-04-09 Colin Watson * docs/grub-dev.texi: Replace MoinMoin syntax with Texinfo syntax diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index a7ab6f71a..a45b8b198 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -169,7 +169,7 @@ If a macro is global, its name must be prefixed with GRUB_ and must consist of o All comments shall be C-style comments, of the form @samp{/* @dots{} */}. -Comments shall be placed only on a line be themselves. They shall not be placed together with code, variable declarations, or other non-comment entities. A comment should be placed immediately preceding the entity it describes. +Comments shall be placed only on a line by themselves. They shall not be placed together with code, variable declarations, or other non-comment entities. A comment should be placed immediately preceding the entity it describes. Acceptable: @example @@ -214,74 +214,85 @@ The opening @samp{/*} and closing @samp{*/} should be placed together on a line Here is a brief map of the GRUB code base. -GRUB uses Autoconf, but not (yet) Automake. The top-level build rules are -in @file{configure.ac}, @file{Makefile.in}, and @file{conf/*.rmk}. Each -@file{conf/*.rmk} file represents a particular target configuration, and is -processed into GNU Make rules by @file{genmk.rb} (which you only need to +GRUB uses Autoconf and Automake, with most of the Automake input generated +by AutoGen. The top-level build rules are in @file{configure.ac}, +@file{grub-core/Makefile.core.def}, and @file{Makefile.util.def}. Each +block in a @file{*.def} file represents a build target, and specifies the +source files used to build it on various platforms. The @file{*.def} files +are processed into AutoGen input by @file{gentpl.py} (which you only need to look at if you are extending the build system). If you are adding a new module which follows an existing pattern, such as a new command or a new -filesystem implementation, it is usually easiest to grep @file{conf/*.rmk} -for an existing example of that pattern to find out where it should be -added. +filesystem implementation, it is usually easiest to grep +@file{grub-core/Makefile.core.def} and @file{Makefile.util.def} for an +existing example of that pattern to find out where it should be added. + +In general, code that may be run at boot time is in a subdirectory of +@file{grub-core}, while code that is only run from within a full operating +system is in a subdirectory of the top level. Low-level boot code, such as the MBR implementation on PC BIOS systems, is -in the @file{boot/} directory. +in the @file{grub-core/boot/} directory. -The GRUB kernel is in @file{kern/}. This contains core facilities such as -the device, disk, and file frameworks, environment variable handling, list -processing, and so on. The kernel should contain enough to get up to a -rescue prompt. Header files for kernel facilities, among others, are in -@file{include/}. +The GRUB kernel is in @file{grub-core/kern/}. This contains core facilities +such as the device, disk, and file frameworks, environment variable +handling, list processing, and so on. The kernel should contain enough to +get up to a rescue prompt. Header files for kernel facilities, among +others, are in @file{include/}. -Terminal implementations are in @file{term/}. +Terminal implementations are in @file{grub-core/term/}. -Disk access code is spread across @file{disk/} (for accessing the disk -devices themselves), @file{partmap/} (for interpreting partition table -data), and @file{fs/} (for accessing filesystems). Note that, with the odd -specialised exception, GRUB only contains code to @emph{read} from -filesystems and tries to avoid containing any code to @emph{write} to -filesystems; this lets us confidently assure users that GRUB cannot be -responsible for filesystem corruption. +Disk access code is spread across @file{grub-core/disk/} (for accessing the +disk devices themselves), @file{grub-core/partmap/} (for interpreting +partition table data), and @file{grub-core/fs/} (for accessing filesystems). +Note that, with the odd specialised exception, GRUB only contains code to +@emph{read} from filesystems and tries to avoid containing any code to +@emph{write} to filesystems; this lets us confidently assure users that GRUB +cannot be responsible for filesystem corruption. -PCI and USB bus handling is in @file{bus/}. +PCI and USB bus handling is in @file{grub-core/bus/}. -Video handling code is in @file{video/}. The graphical menu system uses -this heavily, but is in a separate directory, @file{gfxmenu/}. +Video handling code is in @file{grub-core/video/}. The graphical menu +system uses this heavily, but is in a separate directory, +@file{grub-core/gfxmenu/}. -Most commands are implemented by files in @file{commands/}, with the -following exceptions: +Most commands are implemented by files in @file{grub-core/commands/}, with +the following exceptions: @itemize @item -A few core commands live in @file{kern/corecmd.c}. +A few core commands live in @file{grub-core/kern/corecmd.c}. @item -Commands related to normal mode live under @file{normal/}. +Commands related to normal mode live under @file{grub-core/normal/}. @item -Commands that load and boot kernels live under @file{loader/}. +Commands that load and boot kernels live under @file{grub-core/loader/}. @item The @samp{loopback} command is really a disk device, and so lives in -@file{disk/loopback.c}. +@file{grub-core/disk/loopback.c}. @item -The @samp{gettext} command lives under @file{gettext/}. +The @samp{gettext} command lives under @file{grub-core/gettext/}. @item -The @samp{loadfont} and @samp{lsfonts} commands live under @file{font/}. +The @samp{loadfont} and @samp{lsfonts} commands live under +@file{grub-core/font/}. @item The @samp{serial}, @samp{terminfo}, and @samp{background_image} commands -live under @file{term/}. +live under @file{grub-core/term/}. @item -The @samp{efiemu_*} commands live under @file{efiemu/}. +The @samp{efiemu_*} commands live under @file{grub-core/efiemu/}. @end itemize There are a few other special-purpose exceptions; grep for them if they matter to you. +Utility programs meant to be run from a full operating system are in +@file{util/}. + @node Contributing Changes @chapter Contributing changes @c By YoshinoriOkuji, VesaJääskeläinen, ColinWatson @@ -317,10 +328,10 @@ anymore. @itemize @item Always use latest GRUB 2 source code. So get that first. -For developers it is recommended always to use the newest development version of GRUB 2. If development takes a long period of time, please remember to keep in sync with newest developments regularly so it is much easier to integrate your change in the future. GRUB 2 is being developed on SVN repository. +For developers it is recommended always to use the newest development version of GRUB 2. If development takes a long period of time, please remember to keep in sync with newest developments regularly so it is much easier to integrate your change in the future. GRUB 2 is being developed in a Bazaar (bzr) repository. -Please check Savannah's GRUB project page for details how to get newest BZR: -@uref{http://savannah.gnu.org/bzr/?group=grub, GRUB 2 BZR Repository} +Please check Savannah's GRUB project page for details how to get newest bzr: +@uref{http://savannah.gnu.org/bzr/?group=grub, GRUB 2 bzr Repository} @item Compile it and try it out. @@ -342,7 +353,7 @@ be free to develop it. If you have not so far announced your idea on grub-devel mailing list, please do it now. This is to make sure you are not wasting your time working on the solution that will not be integrated to GRUB 2 code base. -You might want to study our coding style before starting to development so you +You might want to study our coding style before starting development so you do not need to change much of the code when your patch is being reviewed. (see @ref{Coding style}) @@ -357,11 +368,11 @@ discuss it beforehand on grub-devel mailing list. @item Test your change. -Test that your change works properly. Try it out couple of times. Preferably on different systems. And try to find problems from it. +Test that your change works properly. Try it out a couple of times, preferably on different systems, and try to find problems with it. @item Publish your change. -When you are happy with your change. First make sure it is compilable with +When you are happy with your change, first make sure it is compilable with latest development version of GRUB 2. After that please send a patch to grub-devel for review. Please describe in your email why you made the change, what it changes and so on. Please be prepared to receive even discouraging @@ -379,15 +390,15 @@ for copyright agreement, process can take some time and is mandatory in order to get your changes integrated. If you are not on grub-devel to respond to questions, most likely your patch -will not be accepted. Also if there comes problems from your changes later on, -it would be preferably that you also fix the problem. So stay around +will not be accepted. Also if problems arise from your changes later on, +it would be preferable that you also fix the problem. So stay around for a while. @item Your patch is accepted. -Good job! Your patch will no be integrated to GRUB 2 main line and if it didn't break a thing it will be publically available when next release will be done. +Good job! Your patch will now be integrated into GRUB 2 mainline, and if it didn't break anything it will be publicly available in the next release. -Now you are welcomed to do further improvements :) +Now you are welcome to do further improvements :) @end itemize @node Typical Developer Experience @@ -400,7 +411,7 @@ The typical experience for a developer in this project is the following: @item You show some result in the mailing list or the IRC. @item You are getting to be known to other developers. @item You accumulate significant amount of contribution, so copyright assignment is processed. -@item You are free to check in your changes by your own, legally speaking. +@item You are free to check in your changes on your own, legally speaking. @end enumerate At this point, it is rather annoying that you ought to ask somebody else every @@ -444,7 +455,7 @@ doesn't direcly support exceptions, exception handling behavior is emulated in software. When exception is raised, function must return to calling function. If calling -function does not provide handling of the exception it must return back to it's +function does not provide handling of the exception it must return back to its calling function and so on, until exception is handled. If exception is not handled before prompt is displayed, error message will be shown to user. @@ -541,11 +552,11 @@ error state and then call other functions that might fail. To aid in this, there is a error stack implemented. Error state can be pushed to error stack by calling function @code{grub_error_push ()}. When processing has been completed, @code{grub_error_pop ()} can be used to pop error state from stack. Error stack -contains predefined amount of error stack items. Error stack is proteced for +contains predefined amount of error stack items. Error stack is protected for overflow and marks these situations so overflow error does not get unseen. If there is no space available to store error message, it is simply discarded and overflow will be marked as happened. When overflow happens, it most likely -will corrupt error stack consistency as for pushed error there is no matching +will corrupt error stack consistency as for pushed error there is no matching pop, but overflow message will be shown to inform user about the situation. Overflow message will be shown at time when prompt is about to be drawn. @@ -646,7 +657,7 @@ grub_video_setup (unsigned int width, unsigned int height, unsigned int mode_typ Driver will use information provided to it to select best possible video mode and switch to it. Supported values for @code{mode_type} are @code{GRUB_VIDEO_MODE_TYPE_INDEX_COLOR} for index color modes, @code{GRUB_VIDEO_MODE_TYPE_RGB} for direct RGB color modes and @code{GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED} for double buffering. When requesting RGB mode, highest bits per pixel mode will be selected. When requesting Index color mode, mode with highest number of colors will be selected. If all parameters are specified as zero, video adapter will try to figure out best possible mode and initialize it, platform specific differences are allowed here. If there is no mode matching request, error X will be returned. If there are no problems, function returns @code{GRUB_ERR_NONE}. -This function also performs following task upon succesful mode switch. Active rendering target is changed to screen and viewport is maximized to allow whole screen to be used when performing graphics operations. In RGB modes, emulated palette get's 16 entries containing default values for VGA palette, other colors are defined as black. When switching to Indexed Color mode, driver may set default VGA palette to screen if the video card allows the operation. +This function also performs following task upon succesful mode switch. Active rendering target is changed to screen and viewport is maximized to allow whole screen to be used when performing graphics operations. In RGB modes, emulated palette gets 16 entries containing default values for VGA palette, other colors are defined as black. When switching to Indexed Color mode, driver may set default VGA palette to screen if the video card allows the operation. @end itemize @@ -836,7 +847,7 @@ grub_video_map_rgb (grub_uint8_t red, grub_uint8_t green, grub_uint8_t blue); @end example @item Description: -Map RGB values to compatible screen color data. Values are excepted to be in range 0-255 and in RGB modes they will be converted to screen color data. In index color modes, index color palette will be searched for specified color and then index is returned. +Map RGB values to compatible screen color data. Values are expected to be in range 0-255 and in RGB modes they will be converted to screen color data. In index color modes, index color palette will be searched for specified color and then index is returned. @end itemize @subsection grub_video_map_rgba @@ -849,7 +860,7 @@ grub_video_map_rgba (grub_uint8_t red, grub_uint8_t green, grub_uint8_t blue, gr @end example @item Description: -Map RGBA values to compatible screen color data. Values are excepted to be in range 0-255. In RGBA modes they will be converted to screen color data. In index color modes, index color palette will be searched for best matching color and it's index is returned. +Map RGBA values to compatible screen color data. Values are expected to be in range 0-255. In RGBA modes they will be converted to screen color data. In index color modes, index color palette will be searched for best matching color and its index is returned. @end itemize @subsection grub_video_unmap_color @@ -1016,7 +1027,7 @@ grub_video_set_active_render_target (struct grub_video_render_target *target); @end example @item Description: -Set's active render target. If this comand is successful all drawing commands will be done to specified @code{target}. There is also special values for target, @code{GRUB_VIDEO_RENDER_TARGET_DISPLAY} used to reference screen's front buffer, @code{GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER} used to reference screen's front buffer (alias for @code{GRUB_VIDEO_RENDER_TARGET_DISPLAY}) and @code{GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER} used to reference back buffer (if double buffering is enabled). If render target is correclty switched GRUB_ERR_NONE is returned. In no any event shall there be non drawable active render target. +Sets active render target. If this comand is successful all drawing commands will be done to specified @code{target}. There is also special values for target, @code{GRUB_VIDEO_RENDER_TARGET_DISPLAY} used to reference screen's front buffer, @code{GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER} used to reference screen's front buffer (alias for @code{GRUB_VIDEO_RENDER_TARGET_DISPLAY}) and @code{GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER} used to reference back buffer (if double buffering is enabled). If render target is correclty switched GRUB_ERR_NONE is returned. In no any event shall there be non drawable active render target. @end itemize @subsection grub_video_get_active_render_target From 099821e9e4d55abe11054380068decda0cec4a17 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 9 Apr 2011 21:55:50 +0200 Subject: [PATCH 237/276] Fix RAID1/duplicated chunk size calculation --- grub-core/fs/btrfs.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index ac90c055a..7632d535c 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -664,13 +664,9 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, case GRUB_BTRFS_CHUNK_TYPE_RAID1: /* FIXME: Use redundancy. */ { - grub_uint32_t stripe_length; - stripe_length = grub_divmod64 (grub_le_to_cpu64 (chunk->size), - grub_le_to_cpu16 (chunk->nstripes), - NULL); stripen = 0; stripe_offset = off; - csize = stripe_length - off; + csize = grub_le_to_cpu64 (chunk->size) - off; redundancy = 2; break; } From 277f955bf115a516fa464fec3e92f919c48f05bf Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 10 Apr 2011 11:57:19 +0200 Subject: [PATCH 238/276] * grub-core/boot/mips/yeeloong/fwstart.S: Fix address to error message. Remove now unused string. --- ChangeLog | 5 +++++ grub-core/boot/mips/yeeloong/fwstart.S | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c46f8996..1bb8cf278 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-10 Vladimir Serbinenko + + * grub-core/boot/mips/yeeloong/fwstart.S: Fix address to error message. + Remove now unused string. + 2011-04-09 Colin Watson * docs/grub-dev.texi (Finding your way around): Update for 1.99 diff --git a/grub-core/boot/mips/yeeloong/fwstart.S b/grub-core/boot/mips/yeeloong/fwstart.S index 425458401..e2aa79759 100644 --- a/grub-core/boot/mips/yeeloong/fwstart.S +++ b/grub-core/boot/mips/yeeloong/fwstart.S @@ -120,7 +120,7 @@ __start: ori $t0, $zero, GRUB_SMBUS_SPD_MEMORY_TYPE_DDR2 lui $a0, %hi(unimplemented_memory_type) bne $t0, $v0, fatal - addiu $a0, $a0, %hi(unimplemented_memory_type) + addiu $a0, $a0, %lo(unimplemented_memory_type) /* And here is our goal: DDR2 controller initialisation. */ lui $t0, %hi(GRUB_CPU_LOONGSON_CORECFG) @@ -379,7 +379,6 @@ read_spd_fail: ori $v0, $v0, 0x100 notification_string: .asciz "GRUB " -no_cs5536: .asciz "No CS5536 found.\n\r" cs5536_found: .asciz "CS5536 at " sm_failed: .asciz "SM transaction failed.\n\r" unhandled_tlb_refill: .asciz "Unhandled TLB refill.\n\r" From 8b8a81fa6a600c743ef0a34122f127671a5a5bfc Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 10 Apr 2011 13:56:23 +0200 Subject: [PATCH 239/276] Dynamically count the number of lines for the lower banner. * grub-core/normal/menu_entry.c (per_term_screen): New member num_entries. (print_down): Use num_entries. (update_screen): Likewise. (grub_menu_entry_run): Set num_entries. * grub-core/normal/menu_text.c (menu_viewer_data): New member num_entries. (grub_print_message_indented): Move real part to ... (grub_print_message_indented_real): ... here. Additional argument dry_run. (draw_border): Additional argument num_entries. (print_message): Additional argument dry_run. (print_entries): Receive menu viewer data. (grub_menu_init_page): New argment num_entries. (menu_text_set_chosen_entry): Use num_entries. (grub_menu_try_text): Likewise. * grub-core/normal/term.c (print_ucs4_terminal): New argument dry_run. All users updated. (grub_ucs4_count_lines): New function. * include/grub/term.h (grub_term_cursor_x): Moved from here .. * grub-core/normal/menu_text.c (grub_term_cursor_x): ... to here. * include/grub/term.h (GRUB_TERM_MESSAGE_HEIGHT): Removed. (grub_term_border_height): Likewise. (grub_term_num_entries): Likewise. --- ChangeLog | 29 +++++++ grub-core/normal/menu_entry.c | 20 ++--- grub-core/normal/menu_text.c | 145 +++++++++++++++++++++------------- grub-core/normal/term.c | 136 +++++++++++++++++++------------ include/grub/normal.h | 7 +- include/grub/term.h | 26 ------ 6 files changed, 225 insertions(+), 138 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1bb8cf278..3f4913ec1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2011-04-10 Vladimir Serbinenko + + Dynamically count the number of lines for the lower banner. + + * grub-core/normal/menu_entry.c (per_term_screen): New member + num_entries. + (print_down): Use num_entries. + (update_screen): Likewise. + (grub_menu_entry_run): Set num_entries. + * grub-core/normal/menu_text.c (menu_viewer_data): New member + num_entries. + (grub_print_message_indented): Move real part to ... + (grub_print_message_indented_real): ... here. Additional argument + dry_run. + (draw_border): Additional argument num_entries. + (print_message): Additional argument dry_run. + (print_entries): Receive menu viewer data. + (grub_menu_init_page): New argment num_entries. + (menu_text_set_chosen_entry): Use num_entries. + (grub_menu_try_text): Likewise. + * grub-core/normal/term.c (print_ucs4_terminal): New argument dry_run. + All users updated. + (grub_ucs4_count_lines): New function. + * include/grub/term.h (grub_term_cursor_x): Moved from here .. + * grub-core/normal/menu_text.c (grub_term_cursor_x): ... to here. + * include/grub/term.h (GRUB_TERM_MESSAGE_HEIGHT): Removed. + (grub_term_border_height): Likewise. + (grub_term_num_entries): Likewise. + 2011-04-10 Vladimir Serbinenko * grub-core/boot/mips/yeeloong/fwstart.S: Fix address to error message. diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index 30af2c1dc..dc5ab528f 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -52,6 +52,8 @@ struct per_term_screen int x; /* The Y coordinate. */ int y; + /* Number of entries. */ + int num_entries; }; struct screen @@ -188,7 +190,7 @@ print_down (int flag, struct per_term_screen *term_screen) 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)); + + term_screen->num_entries); if (flag) grub_putcode (GRUB_UNICODE_DOWNARROW, term_screen->term); @@ -209,13 +211,12 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen, struct line *linep; /* Check if scrolling is necessary. */ - if (term_screen->y < 0 || term_screen->y - >= grub_term_num_entries (term_screen->term)) + if (term_screen->y < 0 || term_screen->y >= term_screen->num_entries) { if (term_screen->y < 0) term_screen->y = 0; else - term_screen->y = grub_term_num_entries (term_screen->term) - 1; + term_screen->y = term_screen->num_entries - 1; region_start = 0; region_column = 0; @@ -251,7 +252,7 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen, for (column = 0; column <= linep->len - && y < grub_term_num_entries (term_screen->term); + && y < term_screen->num_entries; column += grub_term_entry_width (term_screen->term), y++) { if (y < 0) @@ -272,7 +273,7 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen, print_line (linep, column, 0, y, term_screen); } - if (y == grub_term_num_entries (term_screen->term)) + if (y == term_screen->num_entries) { if (column <= linep->len || i + 1 < screen->num_lines) down_flag = 1; @@ -282,11 +283,11 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen, i++; if (mode == ALL_LINES && i == screen->num_lines) - for (; y < grub_term_num_entries (term_screen->term); y++) + for (; y < term_screen->num_entries; y++) print_empty_line (y, term_screen); } - while (y < grub_term_num_entries (term_screen->term)); + while (y < term_screen->num_entries); /* Draw up and down arrows. */ if (up) @@ -1290,7 +1291,8 @@ grub_menu_entry_run (grub_menu_entry_t entry) } /* Draw the screen. */ for (i = 0; i < screen->nterms; i++) - grub_menu_init_page (0, 1, screen->terms[i].term); + grub_menu_init_page (0, 1, &screen->terms[i].num_entries, + 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); diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c index fc4a89196..93f0492bc 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -34,10 +34,19 @@ static grub_uint8_t grub_color_menu_highlight; struct menu_viewer_data { int first, offset; + /* The number of entries shown at a time. */ + int num_entries; grub_menu_t menu; struct grub_term_output *term; }; +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); +} + grub_ssize_t grub_getstringwidth (grub_uint32_t * str, const grub_uint32_t * last_position, struct grub_term_output *term) @@ -53,30 +62,45 @@ grub_getstringwidth (grub_uint32_t * str, const grub_uint32_t * last_position, return width; } -void -grub_print_message_indented (const char *msg, int margin_left, int margin_right, - struct grub_term_output *term) +static int +grub_print_message_indented_real (const char *msg, int margin_left, + int margin_right, + struct grub_term_output *term, int dry_run) { grub_uint32_t *unicode_msg; grub_uint32_t *last_position; int msg_len; + int ret = 0; msg_len = grub_utf8_to_ucs4_alloc (msg, &unicode_msg, &last_position); if (msg_len < 0) { - return; + return 0; } - grub_print_ucs4 (unicode_msg, last_position, margin_left, margin_right, term); + if (dry_run) + ret = grub_ucs4_count_lines (unicode_msg, last_position, margin_left, + margin_right, term); + else + grub_print_ucs4 (unicode_msg, last_position, margin_left, + margin_right, term); grub_free (unicode_msg); + + return ret; } +void +grub_print_message_indented (const char *msg, int margin_left, int margin_right, + struct grub_term_output *term) +{ + grub_print_message_indented_real (msg, margin_left, margin_right, term, 0); +} static void -draw_border (struct grub_term_output *term) +draw_border (struct grub_term_output *term, int num_entries) { unsigned i; @@ -88,7 +112,7 @@ draw_border (struct grub_term_output *term) grub_putcode (GRUB_UNICODE_HLINE, term); grub_putcode (GRUB_UNICODE_CORNER_UR, term); - for (i = 0; i < (unsigned) grub_term_num_entries (term); i++) + for (i = 0; i < (unsigned) num_entries; i++) { grub_term_gotoxy (term, GRUB_TERM_MARGIN, GRUB_TERM_TOP_BORDER_Y + i + 1); grub_putcode (GRUB_UNICODE_VLINE, term); @@ -99,7 +123,7 @@ draw_border (struct grub_term_output *term) } grub_term_gotoxy (term, GRUB_TERM_MARGIN, - GRUB_TERM_TOP_BORDER_Y + grub_term_num_entries (term) + 1); + GRUB_TERM_TOP_BORDER_Y + num_entries + 1); grub_putcode (GRUB_UNICODE_CORNER_LL, term); for (i = 0; i < (unsigned) grub_term_border_width (term) - 2; i++) grub_putcode (GRUB_UNICODE_HLINE, term); @@ -108,22 +132,27 @@ draw_border (struct grub_term_output *term) grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); grub_term_gotoxy (term, GRUB_TERM_MARGIN, - (GRUB_TERM_TOP_BORDER_Y + grub_term_num_entries (term) + (GRUB_TERM_TOP_BORDER_Y + num_entries + GRUB_TERM_MARGIN + 1)); } -static void -print_message (int nested, int edit, struct grub_term_output *term) +static int +print_message (int nested, int edit, struct grub_term_output *term, int dry_run) { + int ret = 0; grub_term_setcolorstate (term, GRUB_TERM_COLOR_NORMAL); if (edit) { - grub_putcode ('\n', term); - grub_print_message_indented (_("Minimum Emacs-like screen editing is \ + if(dry_run) + ret++; + else + grub_putcode ('\n', term); + ret += grub_print_message_indented_real (_("Minimum Emacs-like screen editing is \ supported. TAB lists completions. Press Ctrl-x or F10 to boot, Ctrl-c or F2 for a \ command-line or ESC to discard edits and return to the GRUB menu."), - STANDARD_MARGIN, STANDARD_MARGIN, term); + STANDARD_MARGIN, STANDARD_MARGIN, + term, dry_run); } else { @@ -134,30 +163,34 @@ command-line or ESC to discard edits and return to the GRUB menu."), msg_translated = grub_xasprintf (msg, GRUB_UNICODE_UPARROW, GRUB_UNICODE_DOWNARROW); if (!msg_translated) - return; - grub_putcode ('\n', term); - grub_print_message_indented (msg_translated, STANDARD_MARGIN, - STANDARD_MARGIN, term); + return 0; + if(dry_run) + ret++; + else + grub_putcode ('\n', term); + ret += grub_print_message_indented_real (msg_translated, STANDARD_MARGIN, + STANDARD_MARGIN, term, dry_run); grub_free (msg_translated); if (nested) { - grub_print_message_indented + ret += grub_print_message_indented_real (_("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); + STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run); } else { - grub_print_message_indented + ret += grub_print_message_indented_real (_("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); + STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run); } } + return ret; } static void @@ -256,52 +289,56 @@ print_entry (int y, int highlight, grub_menu_entry_t entry, } static void -print_entries (grub_menu_t menu, int first, int offset, - struct grub_term_output *term) +print_entries (grub_menu_t menu, const struct menu_viewer_data *data) { grub_menu_entry_t e; int i; - grub_term_gotoxy (term, - GRUB_TERM_LEFT_BORDER_X + grub_term_border_width (term), + grub_term_gotoxy (data->term, + GRUB_TERM_LEFT_BORDER_X + grub_term_border_width (data->term), GRUB_TERM_FIRST_ENTRY_Y); - if (first) - grub_putcode (GRUB_UNICODE_UPARROW, term); + if (data->first) + grub_putcode (GRUB_UNICODE_UPARROW, data->term); else - grub_putcode (' ', term); + grub_putcode (' ', data->term); - e = grub_menu_get_entry (menu, first); + e = grub_menu_get_entry (menu, data->first); - for (i = 0; i < grub_term_num_entries (term); i++) + for (i = 0; i < data->num_entries; i++) { - print_entry (GRUB_TERM_FIRST_ENTRY_Y + i, offset == i, e, term); + print_entry (GRUB_TERM_FIRST_ENTRY_Y + i, data->offset == i, + e, data->term); if (e) e = e->next; } - grub_term_gotoxy (term, GRUB_TERM_LEFT_BORDER_X - + grub_term_border_width (term), - GRUB_TERM_TOP_BORDER_Y + grub_term_num_entries (term)); + grub_term_gotoxy (data->term, GRUB_TERM_LEFT_BORDER_X + + grub_term_border_width (data->term), + GRUB_TERM_TOP_BORDER_Y + data->num_entries); if (e) - grub_putcode (GRUB_UNICODE_DOWNARROW, term); + grub_putcode (GRUB_UNICODE_DOWNARROW, data->term); else - grub_putcode (' ', term); + grub_putcode (' ', data->term); - grub_term_gotoxy (term, grub_term_cursor_x (term), - GRUB_TERM_FIRST_ENTRY_Y + offset); + grub_term_gotoxy (data->term, grub_term_cursor_x (data->term), + GRUB_TERM_FIRST_ENTRY_Y + data->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, int *num_entries, struct grub_term_output *term) { grub_uint8_t old_color_normal, old_color_highlight; + /* 3 lines for timeout message and bottom margin. 2 lines for the border. */ + *num_entries = grub_term_height (term) - GRUB_TERM_TOP_BORDER_Y + - (print_message (nested, edit, term, 1) + 3) - 2; + grub_term_getcolor (term, &old_color_normal, &old_color_highlight); /* By default, use the same colors for the menu. */ @@ -316,9 +353,9 @@ grub_menu_init_page (int nested, int edit, grub_normal_init_page (term); grub_term_setcolor (term, grub_color_menu_normal, grub_color_menu_highlight); - draw_border (term); + draw_border (term, *num_entries); grub_term_setcolor (term, old_color_normal, old_color_highlight); - print_message (nested, edit, term); + print_message (nested, edit, term, 0); } static void @@ -359,10 +396,10 @@ menu_text_set_chosen_entry (int entry, void *dataptr) int complete_redraw = 0; data->offset = entry - data->first; - if (data->offset > grub_term_num_entries (data->term) - 1) + if (data->offset > data->num_entries - 1) { - data->first = entry - (grub_term_num_entries (data->term) - 1); - data->offset = grub_term_num_entries (data->term) - 1; + data->first = entry - (data->num_entries - 1); + data->offset = data->num_entries - 1; complete_redraw = 1; } if (data->offset < 0) @@ -372,7 +409,7 @@ menu_text_set_chosen_entry (int entry, void *dataptr) complete_redraw = 1; } if (complete_redraw) - print_entries (data->menu, data->first, data->offset, data->term); + print_entries (data->menu, data); else { print_entry (GRUB_TERM_FIRST_ENTRY_Y + oldoffset, 0, @@ -436,15 +473,17 @@ grub_menu_try_text (struct grub_term_output *term, 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_menu_init_page (nested, 0, &data->num_entries, data->term); + + if (data->offset > data->num_entries - 1) + { + data->first = data->offset - (data->num_entries - 1); + data->offset = data->num_entries - 1; + } + + print_entries (menu, data); grub_term_refresh (data->term); grub_menu_register_viewer (instance); diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c index 9c4b491f5..a8b9e6683 100644 --- a/grub-core/normal/term.c +++ b/grub-core/normal/term.c @@ -515,14 +515,16 @@ print_ucs4_terminal (const grub_uint32_t * str, const grub_uint32_t * last_position, int margin_left, int margin_right, struct grub_term_output *term, - struct term_state *state) + struct term_state *state, + int dry_run) { const grub_uint32_t *ptr; - grub_ssize_t startwidth = get_startwidth (term, margin_left); + grub_ssize_t startwidth = dry_run ? 0 : get_startwidth (term, margin_left); grub_ssize_t line_width = startwidth; grub_ssize_t lastspacewidth = 0; grub_ssize_t max_width = get_maxwidth (term, margin_left, margin_right); const grub_uint32_t *line_start = str, *last_space = str - 1; + int lines = 0; for (ptr = str; ptr < last_position; ptr++) { @@ -560,50 +562,59 @@ print_ucs4_terminal (const grub_uint32_t * str, else lastspacewidth = line_width - last_width; - for (ptr2 = line_start; ptr2 < ptr; ptr2++) - { - /* Skip combining characters on non-UTF8 terminals. */ - if ((term->flags & GRUB_TERM_CODE_TYPE_MASK) - != GRUB_TERM_CODE_TYPE_UTF8_LOGICAL - && grub_unicode_get_comb_type (*ptr2) - != GRUB_UNICODE_COMB_NONE) - continue; - putcode_real (*ptr2, term); - } + lines++; - grub_print_spaces (term, margin_right); - grub_putcode ('\n', term); - if (state && ++state->num_lines - >= (grub_ssize_t) grub_term_height (term) - 2) + if (!dry_run) { - state->backlog_ucs4 = (ptr == last_space || *ptr == '\n') - ? ptr + 1 : ptr; - state->backlog_len = last_position - state->backlog_ucs4; - return 1; + for (ptr2 = line_start; ptr2 < ptr; ptr2++) + { + /* Skip combining characters on non-UTF8 terminals. */ + if ((term->flags & GRUB_TERM_CODE_TYPE_MASK) + != GRUB_TERM_CODE_TYPE_UTF8_LOGICAL + && grub_unicode_get_comb_type (*ptr2) + != GRUB_UNICODE_COMB_NONE) + continue; + putcode_real (*ptr2, term); + } + + grub_print_spaces (term, margin_right); + grub_putcode ('\n', term); + if (state && ++state->num_lines + >= (grub_ssize_t) grub_term_height (term) - 2) + { + state->backlog_ucs4 = (ptr == last_space || *ptr == '\n') + ? ptr + 1 : ptr; + state->backlog_len = last_position - state->backlog_ucs4; + return 1; + } } line_width -= lastspacewidth; - grub_print_spaces (term, margin_left); + if (!dry_run) + grub_print_spaces (term, margin_left); if (ptr == last_space || *ptr == '\n') ptr++; line_start = ptr; } } - { - const grub_uint32_t *ptr2; - for (ptr2 = line_start; ptr2 < last_position; ptr2++) - { - /* Skip combining characters on non-UTF8 terminals. */ - if ((term->flags & GRUB_TERM_CODE_TYPE_MASK) - != GRUB_TERM_CODE_TYPE_UTF8_LOGICAL - && grub_unicode_get_comb_type (*ptr2) - != GRUB_UNICODE_COMB_NONE) - continue; - putcode_real (*ptr2, term); - } - } - return 0; + if (line_start < last_position) + lines++; + if (!dry_run) + { + const grub_uint32_t *ptr2; + for (ptr2 = line_start; ptr2 < last_position; ptr2++) + { + /* Skip combining characters on non-UTF8 terminals. */ + if ((term->flags & GRUB_TERM_CODE_TYPE_MASK) + != GRUB_TERM_CODE_TYPE_UTF8_LOGICAL + && grub_unicode_get_comb_type (*ptr2) + != GRUB_UNICODE_COMB_NONE) + continue; + putcode_real (*ptr2, term); + } + } + return dry_run ? lines : 0; } static struct term_state * @@ -672,7 +683,7 @@ print_backlog (struct grub_term_output *term, int ret; ret = print_ucs4_terminal (state->backlog_ucs4, state->backlog_ucs4 + state->backlog_len, - margin_left, margin_right, term, state); + margin_left, margin_right, term, state, 0); if (!ret) { grub_free (state->free); @@ -706,15 +717,19 @@ static int print_ucs4_real (const grub_uint32_t * str, const grub_uint32_t * last_position, int margin_left, int margin_right, - struct grub_term_output *term, int backlog) + struct grub_term_output *term, int backlog, + int dry_run) { struct term_state *state = NULL; - if (backlog) - state = find_term_state (term); + if (!dry_run) + { + if (backlog) + state = find_term_state (term); - if (((term->getxy (term) >> 8) & 0xff) < margin_left) - grub_print_spaces (term, margin_left - ((term->getxy (term) >> 8) & 0xff)); + if (((term->getxy (term) >> 8) & 0xff) < margin_left) + grub_print_spaces (term, margin_left - ((term->getxy (term) >> 8) & 0xff)); + } if ((term->flags & GRUB_TERM_CODE_TYPE_MASK) == GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS @@ -743,16 +758,30 @@ print_ucs4_real (const grub_uint32_t * str, grub_print_error (); return 0; } - ret = put_glyphs_terminal (visual, visual_len, margin_left, margin_right, - term, state); - if (!ret) - grub_free (visual); + if (dry_run) + { + struct grub_unicode_glyph *vptr; + ret = 0; + for (vptr = visual; vptr < visual + visual_len; vptr++) + if (vptr->base == '\n') + ret++; + if (visual_len && visual[visual_len - 1].base != '\n') + ret++; + grub_free (visual); + } else - state->free = visual; + { + ret = put_glyphs_terminal (visual, visual_len, margin_left, + margin_right, term, state); + if (!ret) + grub_free (visual); + else + state->free = visual; + } return ret; } return print_ucs4_terminal (str, last_position, margin_left, margin_right, - term, state); + term, state, dry_run); } void @@ -762,9 +791,18 @@ grub_print_ucs4 (const grub_uint32_t * str, struct grub_term_output *term) { print_ucs4_real (str, last_position, margin_left, margin_right, - term, 0); + term, 0, 0); } +int +grub_ucs4_count_lines (const grub_uint32_t * str, + const grub_uint32_t * last_position, + int margin_left, int margin_right, + struct grub_term_output *term) +{ + return print_ucs4_real (str, last_position, margin_left, margin_right, + term, 0, 1); +} void grub_xputs_normal (const char *str) @@ -813,7 +851,7 @@ grub_xputs_normal (const char *str) { int cur; cur = print_ucs4_real (unicode_str, unicode_last_position, 0, 0, - term, grub_more); + term, grub_more, 0); if (cur) backlog = 1; } diff --git a/include/grub/normal.h b/include/grub/normal.h index 3b99e073a..08c14d209 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -51,7 +51,7 @@ extern int grub_normal_exit_level; /* 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, +void grub_menu_init_page (int nested, int edit, int *num_entries, struct grub_term_output *term); void grub_normal_init_page (struct grub_term_output *term); char *grub_file_getline (grub_file_t file); @@ -80,6 +80,11 @@ grub_print_ucs4 (const grub_uint32_t * str, const grub_uint32_t * last_position, int margin_left, int margin_right, struct grub_term_output *term); +int +grub_ucs4_count_lines (const grub_uint32_t * str, + const grub_uint32_t * last_position, + int margin_left, int margin_right, + struct grub_term_output *term); grub_ssize_t grub_getstringwidth (grub_uint32_t * str, const grub_uint32_t * last_position, struct grub_term_output *term); diff --git a/include/grub/term.h b/include/grub/term.h index dbcb2f52c..726c84dbf 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -140,9 +140,6 @@ grub_term_color_state; /* The X position of the left border. */ #define GRUB_TERM_LEFT_BORDER_X GRUB_TERM_MARGIN -/* The number of lines of messages at the bottom. */ -#define GRUB_TERM_MESSAGE_HEIGHT 8 - /* The Y position of the first entry. */ #define GRUB_TERM_FIRST_ENTRY_Y (GRUB_TERM_TOP_BORDER_Y + 1) @@ -339,29 +336,6 @@ 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) { From 088cdb65eb49582b71fa3ef2065406a37e5f1672 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 10 Apr 2011 15:25:52 +0200 Subject: [PATCH 240/276] * grub-core/gnulib/argp-parse.c (__argp_input): Don't crash if pstate is NULL. --- ChangeLog | 5 +++++ grub-core/gnulib/argp-parse.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3f4913ec1..b5ca76ac6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-10 Colin Watson + + * grub-core/gnulib/argp-parse.c (__argp_input): Don't crash if pstate + is NULL. + 2011-04-10 Vladimir Serbinenko Dynamically count the number of lines for the lower banner. diff --git a/grub-core/gnulib/argp-parse.c b/grub-core/gnulib/argp-parse.c index a1cbf884e..9c054653c 100644 --- a/grub-core/gnulib/argp-parse.c +++ b/grub-core/gnulib/argp-parse.c @@ -935,7 +935,7 @@ weak_alias (__argp_parse, argp_parse) void * __argp_input (const struct argp *argp, const struct argp_state *state) { - if (state) + if (state && state->pstate) { struct group *group; struct parser *parser = state->pstate; From cbac5b1eceb008ec6a97f22a88318c1afd17a343 Mon Sep 17 00:00:00 2001 From: Alexander Kurtz Date: Sun, 10 Apr 2011 15:30:45 +0200 Subject: [PATCH 241/276] * util/grub-mkconfig_lib.in: Add missing quotes. --- ChangeLog | 4 ++ util/grub-mkconfig_lib.in | 86 +++++++++++++++++++-------------------- 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index b5ca76ac6..c86adedb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-10 Alexander Kurtz + + * util/grub-mkconfig_lib.in: Add missing quotes. + 2011-04-10 Colin Watson * grub-core/gnulib/argp-parse.c (__argp_input): Don't crash if pstate diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 628ea34d4..2c5fd8c6f 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -16,19 +16,19 @@ transform="@program_transform_name@" -prefix=@prefix@ -exec_prefix=@exec_prefix@ -datarootdir=@datarootdir@ -datadir=@datadir@ -bindir=@bindir@ -sbindir=@sbindir@ -pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"` +prefix="@prefix@" +exec_prefix="@exec_prefix@" +datarootdir="@datarootdir@" +datadir="@datadir@" +bindir="@bindir@" +sbindir="@sbindir@" +pkgdatadir="${datadir}/`echo "@PACKAGE_TARNAME@" | sed "${transform}"`" if test "x$grub_probe" = x; then - grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` + grub_probe="${sbindir}/`echo grub-probe | sed "${transform}"`" fi if test "x$grub_mkrelpath" = x; then - grub_mkrelpath=${bindir}/`echo grub-mkrelpath | sed ${transform}` + grub_mkrelpath="${bindir}/`echo grub-mkrelpath | sed "${transform}"`" fi if $(which gettext >/dev/null 2>/dev/null) ; then @@ -44,20 +44,20 @@ grub_warn () make_system_path_relative_to_its_root () { - ${grub_mkrelpath} $1 + "${grub_mkrelpath}" "$1" } is_path_readable_by_grub () { - path=$1 + path="$1" # abort if path doesn't exist - if test -e $path ; then : ;else + if test -e "$path" ; then : ;else return 1 fi # abort if file is in a filesystem we can't read - if ${grub_probe} -t fs $path > /dev/null 2>&1 ; then : ; else + if "${grub_probe}" -t fs "$path" > /dev/null 2>&1 ; then : ; else return 1 fi @@ -72,24 +72,24 @@ is_path_readable_by_grub () convert_system_path_to_grub_path () { - path=$1 + path="$1" grub_warn "convert_system_path_to_grub_path() is deprecated. Use prepare_grub_to_access_device() instead." # abort if GRUB can't access the path - if is_path_readable_by_grub ${path} ; then : ; else + if is_path_readable_by_grub "${path}" ; then : ; else return 1 fi - if drive=`${grub_probe} -t drive $path` ; then : ; else + if drive="`"${grub_probe}" -t drive "$path"`" ; then : ; else return 1 fi - if relative_path=`make_system_path_relative_to_its_root $path` ; then : ; else + if relative_path="`make_system_path_relative_to_its_root "$path"`" ; then : ; else return 1 fi - echo ${drive}${relative_path} + echo "${drive}${relative_path}" } save_default_entry () @@ -103,15 +103,15 @@ EOF prepare_grub_to_access_device () { - device=$1 + device="$1" # Abstraction modules aren't auto-loaded. - abstraction="`${grub_probe} --device ${device} --target=abstraction`" + abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`" for module in ${abstraction} ; do echo "insmod ${module}" done - partmap="`${grub_probe} --device ${device} --target=partmap`" + partmap="`"${grub_probe}" --device "${device}" --target=partmap`" for module in ${partmap} ; do case "${module}" in netbsd | openbsd) @@ -121,15 +121,15 @@ prepare_grub_to_access_device () esac done - fs="`${grub_probe} --device ${device} --target=fs`" + fs="`"${grub_probe}" --device "${device}" --target=fs`" for module in ${fs} ; do echo "insmod ${module}" done # If there's a filesystem UUID that GRUB is capable of identifying, use it; # otherwise set root as per value in device.map. - echo "set root='`${grub_probe} --device ${device} --target=drive`'" - if fs_uuid="`${grub_probe} --device ${device} --target=fs_uuid 2> /dev/null`" ; then + echo "set root='`"${grub_probe}" --device "${device}" --target=drive`'" + if fs_uuid="`"${grub_probe}" --device "${device}" --target=fs_uuid 2> /dev/null`" ; then echo "search --no-floppy --fs-uuid --set=root ${fs_uuid}" fi } @@ -149,21 +149,21 @@ grub_file_is_not_garbage () version_test_numeric () { - local a=$1 - local cmp=$2 - local b=$3 + local a="$1" + local cmp="$2" + local b="$3" if [ "$a" = "$b" ] ; then - case $cmp in + case "$cmp" in ge|eq|le) return 0 ;; gt|lt) return 1 ;; esac fi if [ "$cmp" = "lt" ] ; then - c=$a - a=$b - b=$c + c="$a" + a="$b" + b="$c" fi - if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then + if (echo "$a" ; echo "$b") | sort -n | head -n 1 | grep -qx "$b" ; then return 0 else return 1 @@ -172,25 +172,25 @@ version_test_numeric () version_test_gt () { - local a=`echo $1 | sed -e "s/[^-]*-//"` - local b=`echo $2 | sed -e "s/[^-]*-//"` + local a="`echo "$1" | sed -e "s/[^-]*-//"`" + local b="`echo "$2" | sed -e "s/[^-]*-//"`" local cmp=gt if [ "x$b" = "x" ] ; then return 0 fi - case $a:$b in + case "$a:$b" in *.old:*.old) ;; - *.old:*) a=`echo -n $a | sed -e s/\.old$//` ; cmp=gt ;; - *:*.old) b=`echo -n $b | sed -e s/\.old$//` ; cmp=ge ;; + *.old:*) a="`echo -n "$a" | sed -e 's/\.old$//'`" ; cmp=gt ;; + *:*.old) b="`echo -n "$b" | sed -e 's/\.old$//'`" ; cmp=ge ;; esac - version_test_numeric $a $cmp $b - return $? + version_test_numeric "$a" "$cmp" "$b" + return "$?" } version_find_latest () { local a="" - for i in $@ ; do + for i in "$@" ; do if version_test_gt "$i" "$a" ; then a="$i" fi @@ -202,7 +202,7 @@ version_find_latest () # printf; so this turns ' into \'. Note that you must use the output of # this function in a printf format string. gettext_quoted () { - $gettext "$@" | sed "s/'/'\\\\\\\\''/g" + "$gettext" "$@" | sed "s/'/'\\\\\\\\''/g" } # Run the first argument through gettext_quoted, and then pass that and all @@ -215,9 +215,9 @@ gettext_printf () { } uses_abstraction () { - device=$1 + device="$1" - abstraction="`${grub_probe} --device ${device} --target=abstraction`" + abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`" for module in ${abstraction}; do if test "x${module}" = "x$2"; then return 0 From 5ca1a64de674ccc1f03f91ed7a2115140c1f2826 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 10 Apr 2011 16:08:58 +0200 Subject: [PATCH 242/276] * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_data): New member is_disk. (grub_util_biosdisk_open): Don't apply ioctl on non-disk devices. (open_device) Likewise. (grub_util_biosdisk_close): Likewise. Reported by: Mark Korenberger. --- ChangeLog | 9 +++++++++ grub-core/kern/emu/hostdisk.c | 12 +++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c86adedb0..a7e73f461 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-04-10 Vladimir Serbinenko + + * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_data): New member + is_disk. + (grub_util_biosdisk_open): Don't apply ioctl on non-disk devices. + (open_device) Likewise. + (grub_util_biosdisk_close): Likewise. + Reported by: Mark Korenberger. + 2011-04-10 Alexander Kurtz * util/grub-mkconfig_lib.in: Add missing quotes. diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 7b034e06b..f01e21aa0 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -138,6 +138,7 @@ struct grub_util_biosdisk_data char *dev; int access_mode; int fd; + int is_disk; }; #ifdef __linux__ @@ -239,6 +240,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) data->dev = NULL; data->access_mode = 0; data->fd = -1; + data->is_disk = 0; /* Get the size. */ #if defined(__MINGW32__) @@ -279,6 +281,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) close (fd); goto fail; } + data->is_disk = 1; # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) if (ioctl (fd, DIOCGMEDIASIZE, &nr)) @@ -669,7 +672,8 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags) { fsync (data->fd); #ifdef __linux__ - ioctl (data->fd, BLKFLSBUF, 0); + if (data->is_disk) + ioctl (data->fd, BLKFLSBUF, 0); #endif } @@ -727,7 +731,8 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags) { fsync (data->fd); #ifdef __linux__ - ioctl (data->fd, BLKFLSBUF, 0); + if (data->is_disk) + ioctl (data->fd, BLKFLSBUF, 0); #endif } close (data->fd); @@ -952,7 +957,8 @@ grub_util_biosdisk_close (struct grub_disk *disk) { fsync (data->fd); #ifdef __linux__ - ioctl (data->fd, BLKFLSBUF, 0); + if (data->is_disk) + ioctl (data->fd, BLKFLSBUF, 0); #endif } close (data->fd); From 335bda1e57c9c5a7325d00817f990e658152161c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 10 Apr 2011 16:12:31 +0200 Subject: [PATCH 243/276] * grub-core/boot/mips/yeeloong/fwstart.S (no_cs5536): Put back improperly removed string. --- ChangeLog | 5 +++++ grub-core/boot/mips/yeeloong/fwstart.S | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index a7e73f461..65f42dd6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-10 Vladimir Serbinenko + + * grub-core/boot/mips/yeeloong/fwstart.S (no_cs5536): Put back + improperly removed string. + 2011-04-10 Vladimir Serbinenko * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_data): New member diff --git a/grub-core/boot/mips/yeeloong/fwstart.S b/grub-core/boot/mips/yeeloong/fwstart.S index e2aa79759..9e81df192 100644 --- a/grub-core/boot/mips/yeeloong/fwstart.S +++ b/grub-core/boot/mips/yeeloong/fwstart.S @@ -379,6 +379,7 @@ read_spd_fail: ori $v0, $v0, 0x100 notification_string: .asciz "GRUB " +no_cs5536: .asciz "No CS5536 found.\n\r" cs5536_found: .asciz "CS5536 at " sm_failed: .asciz "SM transaction failed.\n\r" unhandled_tlb_refill: .asciz "Unhandled TLB refill.\n\r" From b01abe3e1679ed31a03a3203e3b9127c847e8d1a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 10 Apr 2011 16:44:11 +0200 Subject: [PATCH 244/276] * grub-core/loader/mips/linux.c (grub_cmd_initrd): Use correct limits rather than trying to put initrd way too high. Reported by: Ryan Lortie --- ChangeLog | 6 ++++++ grub-core/loader/mips/linux.c | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65f42dd6a..f3050ef73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-10 Vladimir Serbinenko + + * grub-core/loader/mips/linux.c (grub_cmd_initrd): Use correct limits + rather than trying to put initrd way too high. + Reported by: Ryan Lortie + 2011-04-10 Vladimir Serbinenko * grub-core/boot/mips/yeeloong/fwstart.S (no_cs5536): Put back diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c index 6ae2a9321..9accfc270 100644 --- a/grub-core/loader/mips/linux.c +++ b/grub-core/loader/mips/linux.c @@ -379,8 +379,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_relocator_chunk_t ch; err = grub_relocator_alloc_chunk_align (relocator, &ch, - target_addr + linux_size + 0x10000, - (0xffffffff - size) + 1, + (target_addr & 0x1fffffff) + + linux_size + 0x10000, + (0x10000000 - size), size, 0x10000, GRUB_RELOCATOR_PREFERENCE_NONE); From 9ee8d94faa182cb25eac7b5a15e29e122fe7fbc2 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 11 Apr 2011 07:38:42 +0200 Subject: [PATCH 245/276] * grub-core/kern/file.c (grub_file_open): Don't take into account the parenthesis in the middle of the filename. --- ChangeLog | 5 +++++ grub-core/kern/file.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f3050ef73..46f683cb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-11 Vladimir Serbinenko + + * grub-core/kern/file.c (grub_file_open): Don't take into account the + parenthesis in the middle of the filename. + 2011-04-10 Vladimir Serbinenko * grub-core/loader/mips/linux.c (grub_cmd_initrd): Use correct limits diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c index c93fbf737..9d5a51c48 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -68,7 +68,7 @@ grub_file_open (const char *name) goto fail; /* Get the file part of NAME. */ - file_name = grub_strchr (name, ')'); + file_name = (name[0] == '(') ? grub_strchr (name, ')') : NULL; if (file_name) file_name++; else From af869a4ab9755cdc3fbbcaf639b88b386bbe395d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 11 Apr 2011 07:40:53 +0200 Subject: [PATCH 246/276] * util/grub-fstest.c (read_file): Report GRUB error if file opening failed. --- ChangeLog | 5 +++++ util/grub-fstest.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 46f683cb6..cbb77c14c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-11 Vladimir Serbinenko + + * util/grub-fstest.c (read_file): Report GRUB error if file opening + failed. + 2011-04-11 Vladimir Serbinenko * grub-core/kern/file.c (grub_file_open): Don't take into account the diff --git a/util/grub-fstest.c b/util/grub-fstest.c index 2fcde4ab0..51c1a3a52 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -111,7 +111,8 @@ 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:%s"), pathname, + grub_errmsg); return; } From 8a3bc88ea740221ae56afdd1545327f45280f112 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 11 Apr 2011 07:41:59 +0200 Subject: [PATCH 247/276] * util/grub-fstest.c (cmd_cmp): Check that sizes match. --- ChangeLog | 4 ++++ util/grub-fstest.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index cbb77c14c..dbcbb9651 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-11 Vladimir Serbinenko + + * util/grub-fstest.c (cmd_cmp): Check that sizes match. + 2011-04-11 Vladimir Serbinenko * util/grub-fstest.c (read_file): Report GRUB error if file opening diff --git a/util/grub-fstest.c b/util/grub-fstest.c index 51c1a3a52..293bdf74a 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -222,6 +222,14 @@ cmd_cmp (char *src, char *dest) grub_util_error (_("seek error")); read_file (src, cmp_hook); + + { + grub_uint64_t pre; + pre = ftell (ff); + fseek (ff, 0, SEEK_END); + if (pre != ftell (ff)) + grub_util_error (_("unexpected end of file")); + } fclose (ff); } From e8980227e8e3df225dfecd9bb98d5ea515d7b041 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 11 Apr 2011 07:49:26 +0200 Subject: [PATCH 248/276] Remove stale comment about redundancy --- grub-core/fs/btrfs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 7632d535c..16aa0742a 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -662,7 +662,6 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, } case GRUB_BTRFS_CHUNK_TYPE_DUPLICATED: case GRUB_BTRFS_CHUNK_TYPE_RAID1: - /* FIXME: Use redundancy. */ { stripen = 0; stripe_offset = off; @@ -686,7 +685,6 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, break; } case GRUB_BTRFS_CHUNK_TYPE_RAID10: - /* FIXME: Use redundancy. */ { grub_uint64_t middle, high; grub_uint32_t low; From ec25b87d2904ef8ea1417bb0e61397c008e1b7f1 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 11 Apr 2011 07:50:22 +0200 Subject: [PATCH 249/276] Add dprintfs to report chunk lookups --- grub-core/fs/btrfs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 16aa0742a..fb7469b67 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -589,6 +589,8 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, struct grub_btrfs_key key_out; int challoc = 0; grub_device_t dev; + grub_dprintf ("btrfs", "searching for laddr %" PRIxGRUB_UINT64_T "\n", + addr); for (ptr = data->sblock.bootstrap_mapping; ptr < data->sblock.bootstrap_mapping + sizeof (data->sblock.bootstrap_mapping) @@ -647,6 +649,16 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, unsigned redundancy = 1; unsigned i, j; + grub_dprintf ("btrfs", "chunk 0x%" PRIxGRUB_UINT64_T + "+0x%" PRIxGRUB_UINT64_T + " (%d stripes (%d substripes) of %" + PRIxGRUB_UINT64_T ")\n", + grub_le_to_cpu64 (key->offset), + grub_le_to_cpu64 (chunk->size), + grub_le_to_cpu16 (chunk->nstripes), + grub_le_to_cpu16 (chunk->nsubstripes), + grub_le_to_cpu64 (chunk->stripe_length)); + switch (grub_le_to_cpu64 (chunk->type) & ~GRUB_BTRFS_CHUNK_TYPE_BITS_DONTCARE) { From 228f95a2502a35a5a2e9a8a8eab0e66fa2c515ad Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 11 Apr 2011 07:51:15 +0200 Subject: [PATCH 250/276] Fix filename comparison --- grub-core/fs/btrfs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index fb7469b67..add590dfb 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -1103,12 +1103,9 @@ find_path (struct grub_btrfs_data *data, + grub_le_to_cpu16 (cdirel->n) + grub_le_to_cpu16 (cdirel->m))) { - char c; - c = cdirel->name[grub_le_to_cpu16 (cdirel->n)]; - cdirel->name[grub_le_to_cpu16 (cdirel->n)] = 0; - if (grub_strncmp (cdirel->name, ctoken, ctokenlen) == 0) + if (ctokenlen == grub_le_to_cpu16 (cdirel->n) + && grub_memcmp (cdirel->name, ctoken, ctokenlen) == 0) break; - cdirel->name[grub_le_to_cpu16 (cdirel->n)] = c; } if ((grub_uint8_t *) cdirel - (grub_uint8_t *) direl >= (grub_ssize_t) elemsize) From 565f0763118ac5d7789f4a85075e8f013f13ac69 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 11 Apr 2011 07:52:39 +0200 Subject: [PATCH 251/276] Take extent offset in account on uncompressed extents --- grub-core/fs/btrfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index add590dfb..7b1888502 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -989,6 +989,7 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data, } err = grub_btrfs_read_logical (data, grub_le_to_cpu64 (data->extent->laddr) + + grub_le_to_cpu64 (data->extent->offset) + extoff, buf, csize); if (err) From 6a01f54affc70b25a0a0507775ba159423402387 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 11 Apr 2011 07:53:21 +0200 Subject: [PATCH 252/276] use actually filled extent size if available --- grub-core/fs/btrfs.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 7b1888502..0b0e5259c 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -83,6 +83,7 @@ struct grub_btrfs_data /* Cached extent data. */ grub_uint64_t extstart; + grub_uint64_t extend; grub_uint64_t extino; grub_uint64_t exttree; grub_size_t extsize; @@ -202,6 +203,7 @@ struct grub_btrfs_extent_data grub_uint64_t laddr; grub_uint64_t compressed_size; grub_uint64_t offset; + grub_uint64_t filled; }; }; } __attribute__ ((packed)); @@ -872,12 +874,12 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data, grub_err_t err; grub_off_t extoff; if (!data->extent || data->extstart > pos || data->extino != ino - || data->exttree != tree - || grub_le_to_cpu64 (data->extent->size) + data->extstart <= pos) + || data->exttree != tree || data->extend <= pos) { struct grub_btrfs_key key_in, key_out; grub_disk_addr_t elemaddr; grub_size_t elemsize; + grub_free (data->extent); key_in.object_id = ino; key_in.type = GRUB_BTRFS_ITEM_TYPE_EXTENT_ITEM; @@ -904,15 +906,29 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data, data->extent, elemsize); if (err) return err; - if (grub_le_to_cpu64 (data->extent->size) + data->extstart <= pos) - return grub_error (GRUB_ERR_BAD_FS, "extent not found"); + + data->extend = data->extstart + + grub_le_to_cpu64 (data->extent->size); + if (data->extent->type == GRUB_BTRFS_EXTENT_REGULAR + && (char *) &data->extent + elemsize + >= (char *) &data->extent->filled + + sizeof (data->extent->filled)) + data->extend = data->extstart + + grub_le_to_cpu64 (data->extent->filled); + grub_dprintf ("btrfs", "extent 0x%" PRIxGRUB_UINT64_T "+0x%" - PRIxGRUB_UINT64_T "\n", + PRIxGRUB_UINT64_T " (0x%" + PRIxGRUB_UINT64_T ")\n", grub_le_to_cpu64 (key_out.offset), - grub_le_to_cpu64 (data->extent->size)); + grub_le_to_cpu64 (data->extent->size), + grub_le_to_cpu64 (data->extent->filled)); + if (data->extend <= pos) + { + grub_error (GRUB_ERR_BAD_FS, "extent not found"); + return -1; + } } - csize = grub_le_to_cpu64 (data->extent->size) - + grub_le_to_cpu64 (data->extstart) - pos; + csize = data->extend - pos; extoff = pos - data->extstart; if (csize > len) csize = len; From 2a9bc0169eced59e03dde36de0958c4d3bf06ee0 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 11 Apr 2011 16:06:37 +0100 Subject: [PATCH 253/276] * grub-core/fs/btrfs.c (grub_btrfs_fs) [GRUB_UTIL]: Set reserved_first_sector to 1. btrfs reserves plenty of space for boot loaders. Reported by: Gene Cumm. Fixes Ubuntu bug #757446. --- ChangeLog | 7 +++++++ grub-core/fs/btrfs.c | 3 +++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index dbcbb9651..295a23d1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-04-11 Colin Watson + + * grub-core/fs/btrfs.c (grub_btrfs_fs) [GRUB_UTIL]: Set + reserved_first_sector to 1. btrfs reserves plenty of space for boot + loaders. + Reported by: Gene Cumm. Fixes Ubuntu bug #757446. + 2011-04-11 Vladimir Serbinenko * util/grub-fstest.c (cmd_cmp): Check that sizes match. diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 179891da8..11b8dba33 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -122,6 +122,9 @@ static struct grub_fs grub_btrfs_fs = .dir = grub_btrfs_dir, .open = grub_btrfs_open, .uuid = grub_btrfs_uuid, +#ifdef GRUB_UTIL + .reserved_first_sector = 1, +#endif }; GRUB_MOD_INIT(btrfs) From e745cf0ca64f94fa072d777cde8186aca2b78c1f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 11 Apr 2011 23:01:51 +0200 Subject: [PATCH 254/276] Implement automatic module license checking according to new GNU guidelines. * grub-core/kern/dl.c (grub_dl_check_license): New function. (grub_dl_load_core): Use grub_dl_check_license. * include/grub/dl.h (GRUB_MOD_SECTION): New macro. (GRUB_MOD_LICENSE): Likewise. (GRUB_MOD_DUAL_LICENSE): Likewise. All modules updated. --- ChangeLog | 12 +++++++ grub-core/bus/cs5536.c | 4 +++ grub-core/bus/pci.c | 2 ++ grub-core/bus/usb/emu/usb.c | 2 ++ grub-core/bus/usb/ohci.c | 2 ++ grub-core/bus/usb/serial/common.c | 3 ++ grub-core/bus/usb/serial/ftdi.c | 2 ++ grub-core/bus/usb/serial/pl2303.c | 2 ++ grub-core/bus/usb/uhci.c | 2 ++ grub-core/bus/usb/usb.c | 2 ++ grub-core/commands/acpi.c | 2 ++ grub-core/commands/blocklist.c | 2 ++ grub-core/commands/boot.c | 2 ++ grub-core/commands/cat.c | 2 ++ grub-core/commands/cmp.c | 2 ++ grub-core/commands/configfile.c | 2 ++ grub-core/commands/date.c | 2 ++ grub-core/commands/echo.c | 2 ++ grub-core/commands/efi/fixvideo.c | 2 ++ grub-core/commands/efi/loadbios.c | 2 ++ grub-core/commands/efi/lsefimmap.c | 2 ++ grub-core/commands/efi/lsefisystab.c | 3 ++ grub-core/commands/efi/lssal.c | 3 ++ grub-core/commands/extcmd.c | 3 ++ grub-core/commands/gptsync.c | 2 ++ grub-core/commands/halt.c | 2 ++ grub-core/commands/hashsum.c | 2 ++ grub-core/commands/hdparm.c | 2 ++ grub-core/commands/help.c | 2 ++ grub-core/commands/hexdump.c | 2 ++ grub-core/commands/i386/cmostest.c | 2 ++ grub-core/commands/i386/cpuid.c | 2 ++ grub-core/commands/i386/pc/drivemap.c | 1 + grub-core/commands/i386/pc/halt.c | 2 ++ grub-core/commands/i386/pc/lsapm.c | 2 ++ grub-core/commands/i386/pc/play.c | 2 ++ grub-core/commands/i386/pc/pxecmd.c | 2 ++ grub-core/commands/i386/pc/sendkey.c | 2 ++ grub-core/commands/ieee1275/suspend.c | 2 ++ grub-core/commands/iorw.c | 2 ++ grub-core/commands/keylayouts.c | 2 ++ grub-core/commands/keystatus.c | 2 ++ grub-core/commands/legacycfg.c | 2 ++ grub-core/commands/loadenv.c | 2 ++ grub-core/commands/ls.c | 2 ++ grub-core/commands/lsacpi.c | 2 ++ grub-core/commands/lsmmap.c | 2 ++ grub-core/commands/lspci.c | 2 ++ grub-core/commands/memrw.c | 2 ++ grub-core/commands/minicmd.c | 2 ++ grub-core/commands/mips/yeeloong/lsspd.c | 2 ++ grub-core/commands/parttool.c | 2 ++ grub-core/commands/password.c | 2 ++ grub-core/commands/password_pbkdf2.c | 2 ++ grub-core/commands/probe.c | 2 ++ grub-core/commands/read.c | 2 ++ grub-core/commands/reboot.c | 2 ++ grub-core/commands/regexp.c | 2 ++ grub-core/commands/search.c | 2 ++ grub-core/commands/search_wrap.c | 2 ++ grub-core/commands/setpci.c | 2 ++ grub-core/commands/sleep.c | 2 ++ grub-core/commands/terminal.c | 2 ++ grub-core/commands/test.c | 2 ++ grub-core/commands/testload.c | 2 ++ grub-core/commands/true.c | 2 ++ grub-core/commands/usbtest.c | 2 ++ grub-core/commands/videoinfo.c | 2 ++ grub-core/commands/videotest.c | 2 ++ grub-core/commands/xnu_uuid.c | 2 ++ grub-core/disk/ata.c | 2 ++ grub-core/disk/ata_pthru.c | 1 + grub-core/disk/dmraid_nvidia.c | 2 ++ grub-core/disk/i386/pc/biosdisk.c | 2 ++ grub-core/disk/ieee1275/nand.c | 2 ++ grub-core/disk/loopback.c | 2 ++ grub-core/disk/lvm.c | 2 ++ grub-core/disk/mdraid1x_linux.c | 2 ++ grub-core/disk/mdraid_linux.c | 2 ++ grub-core/disk/memdisk.c | 2 ++ grub-core/disk/raid.c | 2 ++ grub-core/disk/raid5_recover.c | 2 ++ grub-core/disk/raid6_recover.c | 2 ++ grub-core/disk/scsi.c | 2 ++ grub-core/disk/usbms.c | 2 ++ grub-core/efiemu/main.c | 2 ++ grub-core/font/font.c | 2 ++ grub-core/fs/affs.c | 2 ++ grub-core/fs/afs.c | 2 ++ grub-core/fs/btrfs.c | 2 ++ grub-core/fs/cpio.c | 2 ++ grub-core/fs/ext2.c | 2 ++ grub-core/fs/fat.c | 2 ++ grub-core/fs/fshelp.c | 2 ++ grub-core/fs/hfs.c | 2 ++ grub-core/fs/hfsplus.c | 2 ++ grub-core/fs/i386/pc/pxe.c | 2 ++ grub-core/fs/iso9660.c | 2 ++ grub-core/fs/jfs.c | 2 ++ grub-core/fs/minix.c | 2 ++ grub-core/fs/nilfs2.c | 2 ++ grub-core/fs/ntfs.c | 2 ++ grub-core/fs/ntfscomp.c | 2 ++ grub-core/fs/reiserfs.c | 2 ++ grub-core/fs/sfs.c | 2 ++ grub-core/fs/udf.c | 2 ++ grub-core/fs/ufs.c | 2 ++ grub-core/fs/xfs.c | 2 ++ grub-core/fs/zfs/zfs.c | 2 ++ grub-core/fs/zfs/zfsinfo.c | 2 ++ grub-core/gentrigtables.c | 8 +++++ grub-core/gettext/gettext.c | 2 ++ grub-core/gfxmenu/gfxmenu.c | 2 ++ grub-core/gnulib/regex.c | 3 ++ grub-core/hello/hello.c | 2 ++ grub-core/hook/datehook.c | 2 ++ grub-core/io/bufio.c | 3 ++ grub-core/io/gzio.c | 2 ++ grub-core/io/xzio.c | 2 ++ grub-core/kern/dl.c | 43 ++++++++++++++++++++++- grub-core/kern/elf.c | 3 ++ grub-core/lib/cmos_datetime.c | 3 ++ grub-core/lib/crypto.c | 3 ++ grub-core/lib/pbkdf2.c | 3 ++ grub-core/lib/relocator.c | 3 ++ grub-core/loader/aout.c | 2 ++ grub-core/loader/efi/appleloader.c | 2 ++ grub-core/loader/efi/chainloader.c | 2 ++ grub-core/loader/i386/bsd.c | 2 ++ grub-core/loader/i386/linux.c | 2 ++ grub-core/loader/i386/pc/chainloader.c | 2 ++ grub-core/loader/i386/pc/linux.c | 2 ++ grub-core/loader/i386/pc/ntldr.c | 2 ++ grub-core/loader/mips/linux.c | 2 ++ grub-core/loader/multiboot.c | 2 ++ grub-core/loader/powerpc/ieee1275/linux.c | 2 ++ grub-core/loader/sparc64/ieee1275/linux.c | 2 ++ grub-core/loader/xnu.c | 2 ++ grub-core/mmap/mmap.c | 2 ++ grub-core/normal/main.c | 2 ++ grub-core/partmap/acorn.c | 2 ++ grub-core/partmap/amiga.c | 2 ++ grub-core/partmap/apple.c | 2 ++ grub-core/partmap/bsdlabel.c | 2 ++ grub-core/partmap/gpt.c | 2 ++ grub-core/partmap/msdos.c | 2 ++ grub-core/partmap/sun.c | 2 ++ grub-core/partmap/sunpc.c | 2 ++ grub-core/parttool/msdospart.c | 2 ++ grub-core/term/at_keyboard.c | 2 ++ grub-core/term/gfxterm.c | 2 ++ grub-core/term/i386/pc/vga_text.c | 2 ++ grub-core/term/serial.c | 2 ++ grub-core/term/terminfo.c | 2 ++ grub-core/term/usb_keyboard.c | 2 ++ grub-core/tests/example_functional_test.c | 3 ++ grub-core/tests/lib/functional_test.c | 3 ++ grub-core/tests/test_blockarg.c | 2 ++ grub-core/video/bitmap.c | 2 ++ grub-core/video/bitmap_scale.c | 3 ++ grub-core/video/bochs.c | 2 ++ grub-core/video/cirrus.c | 2 ++ grub-core/video/efi_gop.c | 2 ++ grub-core/video/efi_uga.c | 2 ++ grub-core/video/emu/sdl.c | 2 ++ grub-core/video/fb/video_fb.c | 3 ++ grub-core/video/i386/pc/vbe.c | 2 ++ grub-core/video/i386/pc/vga.c | 2 ++ grub-core/video/ieee1275.c | 2 ++ grub-core/video/readers/jpeg.c | 2 ++ grub-core/video/readers/png.c | 2 ++ grub-core/video/readers/tga.c | 2 ++ grub-core/video/video.c | 2 ++ include/grub/dl.h | 24 +++++++++++++ util/import_gcry.py | 7 +++- 175 files changed, 447 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 295a23d1a..a3d1e7f92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-04-11 Vladimir Serbinenko + + Implement automatic module license checking according to new GNU + guidelines. + + * grub-core/kern/dl.c (grub_dl_check_license): New function. + (grub_dl_load_core): Use grub_dl_check_license. + * include/grub/dl.h (GRUB_MOD_SECTION): New macro. + (GRUB_MOD_LICENSE): Likewise. + (GRUB_MOD_DUAL_LICENSE): Likewise. + All modules updated. + 2011-04-11 Colin Watson * grub-core/fs/btrfs.c (grub_btrfs_fs) [GRUB_UTIL]: Set diff --git a/grub-core/bus/cs5536.c b/grub-core/bus/cs5536.c index 088f4dfc1..fbcb83cfe 100644 --- a/grub-core/bus/cs5536.c +++ b/grub-core/bus/cs5536.c @@ -22,6 +22,10 @@ #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + int grub_cs5536_find (grub_pci_device_t *devp) { diff --git a/grub-core/bus/pci.c b/grub-core/bus/pci.c index 11101d42b..07d20e3f5 100644 --- a/grub-core/bus/pci.c +++ b/grub-core/bus/pci.c @@ -21,6 +21,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* FIXME: correctly support 64-bit architectures. */ /* #if GRUB_TARGET_SIZEOF_VOID_P == 4 */ struct grub_pci_dma_chunk * diff --git a/grub-core/bus/usb/emu/usb.c b/grub-core/bus/usb/emu/usb.c index 7d52decb2..38c5f01f1 100644 --- a/grub-core/bus/usb/emu/usb.c +++ b/grub-core/bus/usb/emu/usb.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static struct grub_usb_controller_dev usb_controller = { diff --git a/grub-core/bus/usb/ohci.c b/grub-core/bus/usb/ohci.c index 8adaee6e0..df0d0f4af 100644 --- a/grub-core/bus/usb/ohci.c +++ b/grub-core/bus/usb/ohci.c @@ -29,6 +29,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + struct grub_ohci_hcca { /* Pointers to Interrupt Endpoint Descriptors. Not used by diff --git a/grub-core/bus/usb/serial/common.c b/grub-core/bus/usb/serial/common.c index ee8794de0..55d1884cc 100644 --- a/grub-core/bus/usb/serial/common.c +++ b/grub-core/bus/usb/serial/common.c @@ -18,6 +18,9 @@ #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); void grub_usbserial_fini (struct grub_serial_port *port) diff --git a/grub-core/bus/usb/serial/ftdi.c b/grub-core/bus/usb/serial/ftdi.c index bd1713b27..07ac7ac52 100644 --- a/grub-core/bus/usb/serial/ftdi.c +++ b/grub-core/bus/usb/serial/ftdi.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + enum { GRUB_FTDI_MODEM_CTRL = 0x01, diff --git a/grub-core/bus/usb/serial/pl2303.c b/grub-core/bus/usb/serial/pl2303.c index 9e3b9ae7e..b9954116b 100644 --- a/grub-core/bus/usb/serial/pl2303.c +++ b/grub-core/bus/usb/serial/pl2303.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* Convert speed to divisor. */ static grub_uint32_t is_speed_supported (unsigned int speed) diff --git a/grub-core/bus/usb/uhci.c b/grub-core/bus/usb/uhci.c index 71142846b..99e597f6d 100644 --- a/grub-core/bus/usb/uhci.c +++ b/grub-core/bus/usb/uhci.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_UHCI_IOMASK (0x7FF << 5) #define N_QH 256 diff --git a/grub-core/bus/usb/usb.c b/grub-core/bus/usb/usb.c index 70173b7ea..005d3bcf0 100644 --- a/grub-core/bus/usb/usb.c +++ b/grub-core/bus/usb/usb.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_usb_controller_dev_t grub_usb_list; static struct grub_usb_attach_desc *attach_hooks; diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index 4f03997e0..8f4429627 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -33,6 +33,8 @@ #include #endif +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"exclude", 'x', 0, N_("Don't load host tables specified by comma-separated list."), diff --git a/grub-core/commands/blocklist.c b/grub-core/commands/blocklist.c index 4651fb32a..5eb12e434 100644 --- a/grub-core/commands/blocklist.c +++ b/grub-core/commands/blocklist.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) diff --git a/grub-core/commands/boot.c b/grub-core/commands/boot.c index 1ec1e6f77..7714011bf 100644 --- a/grub-core/commands/boot.c +++ b/grub-core/commands/boot.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t (*grub_loader_boot_func) (void); static grub_err_t (*grub_loader_unload_func) (void); static int grub_loader_noreturn; diff --git a/grub-core/commands/cat.c b/grub-core/commands/cat.c index 79ecf75c7..9be6cbc8f 100644 --- a/grub-core/commands/cat.c +++ b/grub-core/commands/cat.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"dos", -1, 0, N_("Accept DOS-style CR/NL line endings."), 0, 0}, diff --git a/grub-core/commands/cmp.c b/grub-core/commands/cmp.c index d9e76a4d7..0222927b6 100644 --- a/grub-core/commands/cmp.c +++ b/grub-core/commands/cmp.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define BUFFER_SIZE 512 static grub_err_t diff --git a/grub-core/commands/configfile.c b/grub-core/commands/configfile.c index 2568b7ee6..124a09a9e 100644 --- a/grub-core/commands/configfile.c +++ b/grub-core/commands/configfile.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_source (grub_command_t cmd, int argc, char **args) { diff --git a/grub-core/commands/date.c b/grub-core/commands/date.c index 623db4943..d27162077 100644 --- a/grub-core/commands/date.c +++ b/grub-core/commands/date.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_DATETIME_SET_YEAR 1 #define GRUB_DATETIME_SET_MONTH 2 #define GRUB_DATETIME_SET_DAY 4 diff --git a/grub-core/commands/echo.c b/grub-core/commands/echo.c index 93a452fc8..81ba50d68 100644 --- a/grub-core/commands/echo.c +++ b/grub-core/commands/echo.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {0, 'n', 0, N_("Do not output the trailing newline."), 0, 0}, diff --git a/grub-core/commands/efi/fixvideo.c b/grub-core/commands/efi/fixvideo.c index 6430be5e3..c53e47d8a 100644 --- a/grub-core/commands/efi/fixvideo.c +++ b/grub-core/commands/efi/fixvideo.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static struct grub_video_patch { const char *name; diff --git a/grub-core/commands/efi/loadbios.c b/grub-core/commands/efi/loadbios.c index 8c7c25abd..138311222 100644 --- a/grub-core/commands/efi/loadbios.c +++ b/grub-core/commands/efi/loadbios.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + 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; static grub_efi_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID; diff --git a/grub-core/commands/efi/lsefimmap.c b/grub-core/commands/efi/lsefimmap.c index 2bb5dcb5d..215b45bff 100644 --- a/grub-core/commands/efi/lsefimmap.c +++ b/grub-core/commands/efi/lsefimmap.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define ADD_MEMORY_DESCRIPTOR(desc, size) \ ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size))) diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c index aa3e05aee..b2359253a 100644 --- a/grub-core/commands/efi/lsefisystab.c +++ b/grub-core/commands/efi/lsefisystab.c @@ -18,12 +18,15 @@ */ #include #include +#include #include #include #include #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + struct guid_mapping { grub_efi_guid_t guid; diff --git a/grub-core/commands/efi/lssal.c b/grub-core/commands/efi/lssal.c index 2ee993033..fa8005b88 100644 --- a/grub-core/commands/efi/lssal.c +++ b/grub-core/commands/efi/lssal.c @@ -23,6 +23,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); static void disp_sal (void *table) diff --git a/grub-core/commands/extcmd.c b/grub-core/commands/extcmd.c index e9274fbab..69574e2b0 100644 --- a/grub-core/commands/extcmd.c +++ b/grub-core/commands/extcmd.c @@ -22,6 +22,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); grub_err_t grub_extcmd_dispatcher (struct grub_command *cmd, int argc, char **args, diff --git a/grub-core/commands/gptsync.c b/grub-core/commands/gptsync.c index 6364c13f7..e92dc20ec 100644 --- a/grub-core/commands/gptsync.c +++ b/grub-core/commands/gptsync.c @@ -29,6 +29,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* Convert a LBA address to a CHS address in the INT 13 format. */ /* Taken from grub1. */ /* XXX: use hardcoded geometry of C = 1024, H = 255, S = 63. diff --git a/grub-core/commands/halt.c b/grub-core/commands/halt.c index 3400115a0..317f7753f 100644 --- a/grub-core/commands/halt.c +++ b/grub-core/commands/halt.c @@ -22,6 +22,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_halt (grub_command_t cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), diff --git a/grub-core/commands/hashsum.c b/grub-core/commands/hashsum.c index 664fe9c24..6825d4811 100644 --- a/grub-core/commands/hashsum.c +++ b/grub-core/commands/hashsum.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING}, {"check", 'c', 0, N_("Check hash list file."), N_("FILE"), ARG_TYPE_STRING}, diff --git a/grub-core/commands/hdparm.c b/grub-core/commands/hdparm.c index b6ab78755..0c12b8814 100644 --- a/grub-core/commands/hdparm.c +++ b/grub-core/commands/hdparm.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"apm", 'B', 0, N_("Set Advanced Power Management\n" "(1=low, ..., 254=high, 255=off)."), diff --git a/grub-core/commands/help.c b/grub-core/commands/help.c index ff6d7ed2e..82f3200c7 100644 --- a/grub-core/commands/help.c +++ b/grub-core/commands/help.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_help (grub_extcmd_context_t ctxt __attribute__ ((unused)), int argc, char **args) diff --git a/grub-core/commands/hexdump.c b/grub-core/commands/hexdump.c index 629f2a069..9ba83598a 100644 --- a/grub-core/commands/hexdump.c +++ b/grub-core/commands/hexdump.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"skip", 's', 0, N_("Skip offset bytes from the beginning of file."), 0, ARG_TYPE_INT}, diff --git a/grub-core/commands/i386/cmostest.c b/grub-core/commands/i386/cmostest.c index 994da11b0..c79bd0387 100644 --- a/grub-core/commands/i386/cmostest.c +++ b/grub-core/commands/i386/cmostest.c @@ -21,6 +21,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t parse_args (int argc, char *argv[], int *byte, int *bit) { diff --git a/grub-core/commands/i386/cpuid.c b/grub-core/commands/i386/cpuid.c index f5f0f15a8..6a771ba74 100644 --- a/grub-core/commands/i386/cpuid.c +++ b/grub-core/commands/i386/cpuid.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define cpuid(num,a,b,c,d) \ asm volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1" \ : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ diff --git a/grub-core/commands/i386/pc/drivemap.c b/grub-core/commands/i386/pc/drivemap.c index ed4211cca..c9c8881b4 100644 --- a/grub-core/commands/i386/pc/drivemap.c +++ b/grub-core/commands/i386/pc/drivemap.c @@ -29,6 +29,7 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); /* Real mode IVT slot (seg:off far pointer) for interrupt 0x13. */ static grub_uint32_t *const int13slot = UINT_TO_PTR (4 * 0x13); diff --git a/grub-core/commands/i386/pc/halt.c b/grub-core/commands/i386/pc/halt.c index 81eb6a1bb..e7c191de3 100644 --- a/grub-core/commands/i386/pc/halt.c +++ b/grub-core/commands/i386/pc/halt.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"no-apm", 'n', 0, N_("Do not use APM to halt the computer."), 0, 0}, diff --git a/grub-core/commands/i386/pc/lsapm.c b/grub-core/commands/i386/pc/lsapm.c index 30475d2ec..17bcfd6eb 100644 --- a/grub-core/commands/i386/pc/lsapm.c +++ b/grub-core/commands/i386/pc/lsapm.c @@ -22,6 +22,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + int grub_apm_get_info (struct grub_apm_info *info) { diff --git a/grub-core/commands/i386/pc/play.c b/grub-core/commands/i386/pc/play.c index 4ed937d4a..57980eb92 100644 --- a/grub-core/commands/i386/pc/play.c +++ b/grub-core/commands/i386/pc/play.c @@ -29,6 +29,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define BASE_TEMPO (60 * GRUB_TICKS_PER_SECOND) /* The speaker port. */ diff --git a/grub-core/commands/i386/pc/pxecmd.c b/grub-core/commands/i386/pc/pxecmd.c index b576a8ea4..dffa15a3a 100644 --- a/grub-core/commands/i386/pc/pxecmd.c +++ b/grub-core/commands/i386/pc/pxecmd.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_pxe_unload (grub_command_t cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), diff --git a/grub-core/commands/i386/pc/sendkey.c b/grub-core/commands/i386/pc/sendkey.c index c777ea60a..a55d17bd0 100644 --- a/grub-core/commands/i386/pc/sendkey.c +++ b/grub-core/commands/i386/pc/sendkey.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv2+"); + static char sendkey[0x20]; /* Length of sendkey. */ static int keylen = 0; diff --git a/grub-core/commands/ieee1275/suspend.c b/grub-core/commands/ieee1275/suspend.c index f096cc9ba..de068951d 100644 --- a/grub-core/commands/ieee1275/suspend.c +++ b/grub-core/commands/ieee1275/suspend.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_suspend (grub_command_t cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), diff --git a/grub-core/commands/iorw.c b/grub-core/commands/iorw.c index 20d203e92..e7035b528 100644 --- a/grub-core/commands/iorw.c +++ b/grub-core/commands/iorw.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + 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; diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c index deb482a85..6c5913a54 100644 --- a/grub-core/commands/keylayouts.c +++ b/grub-core/commands/keylayouts.c @@ -28,6 +28,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static struct grub_keyboard_layout layout_us = { .keyboard_map = { /* Keyboard errors. Handled by driver. */ diff --git a/grub-core/commands/keystatus.c b/grub-core/commands/keystatus.c index 9e1486c9d..f3a669942 100644 --- a/grub-core/commands/keystatus.c +++ b/grub-core/commands/keystatus.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"shift", 's', 0, N_("Check Shift key."), 0, 0}, diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index 23c1c1908..e68b3315a 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -33,6 +33,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t legacy_file (const char *filename) { diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c index 38b3a84c6..5d53a8e66 100644 --- a/grub-core/commands/loadenv.c +++ b/grub-core/commands/loadenv.c @@ -28,6 +28,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"file", 'f', 0, N_("Specify filename."), 0, ARG_TYPE_PATHNAME}, diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c index 481d17db0..5fc648a9b 100644 --- a/grub-core/commands/ls.c +++ b/grub-core/commands/ls.c @@ -32,6 +32,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"long", 'l', 0, N_("Show a long list with more detailed information."), 0, 0}, diff --git a/grub-core/commands/lsacpi.c b/grub-core/commands/lsacpi.c index 64b559665..fd19e380a 100644 --- a/grub-core/commands/lsacpi.c +++ b/grub-core/commands/lsacpi.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static void print_strn (grub_uint8_t *str, grub_size_t len) { diff --git a/grub-core/commands/lsmmap.c b/grub-core/commands/lsmmap.c index 657f81387..44598f0df 100644 --- a/grub-core/commands/lsmmap.c +++ b/grub-core/commands/lsmmap.c @@ -22,6 +22,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const char *names[] = { [GRUB_MEMORY_AVAILABLE] = "available", diff --git a/grub-core/commands/lspci.c b/grub-core/commands/lspci.c index fd2d4eaf2..03541df6c 100644 --- a/grub-core/commands/lspci.c +++ b/grub-core/commands/lspci.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + struct grub_pci_classname { int class; diff --git a/grub-core/commands/memrw.c b/grub-core/commands/memrw.c index 28aac7d81..3b51189d6 100644 --- a/grub-core/commands/memrw.c +++ b/grub-core/commands/memrw.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + 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; diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c index 5cf109fde..c7d1ec4f5 100644 --- a/grub-core/commands/minicmd.c +++ b/grub-core/commands/minicmd.c @@ -29,6 +29,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* cat FILE */ static grub_err_t grub_mini_cmd_cat (struct grub_command *cmd __attribute__ ((unused)), diff --git a/grub-core/commands/mips/yeeloong/lsspd.c b/grub-core/commands/mips/yeeloong/lsspd.c index 539cda34c..c1c5e2ef7 100644 --- a/grub-core/commands/mips/yeeloong/lsspd.c +++ b/grub-core/commands/mips/yeeloong/lsspd.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_lsspd (grub_command_t cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c index 31e768553..a54286161 100644 --- a/grub-core/commands/parttool.c +++ b/grub-core/commands/parttool.c @@ -31,6 +31,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv2+"); + static struct grub_parttool *parts = 0; static int curhandle = 0; static grub_dl_t mymod; diff --git a/grub-core/commands/password.c b/grub-core/commands/password.c index db5951cbb..8821607b8 100644 --- a/grub-core/commands/password.c +++ b/grub-core/commands/password.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_dl_t my_mod; static grub_err_t diff --git a/grub-core/commands/password_pbkdf2.c b/grub-core/commands/password_pbkdf2.c index 6886987da..05a627219 100644 --- a/grub-core/commands/password_pbkdf2.c +++ b/grub-core/commands/password_pbkdf2.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_dl_t my_mod; struct pbkdf2_password diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c index 3ace596d8..c5f946340 100644 --- a/grub-core/commands/probe.c +++ b/grub-core/commands/probe.c @@ -32,6 +32,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"set", 's', 0, diff --git a/grub-core/commands/read.c b/grub-core/commands/read.c index 6a187fc3e..fe3e88b15 100644 --- a/grub-core/commands/read.c +++ b/grub-core/commands/read.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static char * grub_getline (void) { diff --git a/grub-core/commands/reboot.c b/grub-core/commands/reboot.c index eedd53c91..8e18083c0 100644 --- a/grub-core/commands/reboot.c +++ b/grub-core/commands/reboot.c @@ -22,6 +22,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_reboot (grub_command_t cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), diff --git a/grub-core/commands/regexp.c b/grub-core/commands/regexp.c index 83c0d8d43..1e8a6f309 100644 --- a/grub-core/commands/regexp.c +++ b/grub-core/commands/regexp.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { { "set", 's', GRUB_ARG_OPTION_REPEATABLE, diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c index f265f86d6..ba80d80ef 100644 --- a/grub-core/commands/search.c +++ b/grub-core/commands/search.c @@ -31,6 +31,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + void FUNC_NAME (const char *key, const char *var, int no_floppy, char **hints, unsigned nhints) diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c index 80741d7ab..7b0a99565 100644 --- a/grub-core/commands/search_wrap.c +++ b/grub-core/commands/search_wrap.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"file", 'f', 0, N_("Search devices by a file."), 0, 0}, diff --git a/grub-core/commands/setpci.c b/grub-core/commands/setpci.c index 88dfa4c08..70f5bcdad 100644 --- a/grub-core/commands/setpci.c +++ b/grub-core/commands/setpci.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + struct pci_register { const char *name; diff --git a/grub-core/commands/sleep.c b/grub-core/commands/sleep.c index da642fcd9..97e7a40a6 100644 --- a/grub-core/commands/sleep.c +++ b/grub-core/commands/sleep.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const struct grub_arg_option options[] = { {"verbose", 'v', 0, N_("Verbose countdown."), 0, 0}, diff --git a/grub-core/commands/terminal.c b/grub-core/commands/terminal.c index c2d9550f6..0adfd3d2e 100644 --- a/grub-core/commands/terminal.c +++ b/grub-core/commands/terminal.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + struct grub_term_autoload *grub_term_input_autoload = NULL; struct grub_term_autoload *grub_term_output_autoload = NULL; diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c index e981c945a..50d5aba5e 100644 --- a/grub-core/commands/test.c +++ b/grub-core/commands/test.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* A simple implementation for signed numbers. */ static int grub_strtosl (char *arg, char **end, int base) diff --git a/grub-core/commands/testload.c b/grub-core/commands/testload.c index 86b8a9253..fe06f3d1e 100644 --- a/grub-core/commands/testload.c +++ b/grub-core/commands/testload.c @@ -29,6 +29,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_testload (struct grub_command *cmd __attribute__ ((unused)), int argc, char *argv[]) diff --git a/grub-core/commands/true.c b/grub-core/commands/true.c index aa8125853..82775e7ef 100644 --- a/grub-core/commands/true.c +++ b/grub-core/commands/true.c @@ -21,6 +21,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_true (struct grub_command *cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), diff --git a/grub-core/commands/usbtest.c b/grub-core/commands/usbtest.c index 7f00c8856..4a051ad1f 100644 --- a/grub-core/commands/usbtest.c +++ b/grub-core/commands/usbtest.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static const char *usb_classes[] = { "Unknown", diff --git a/grub-core/commands/videoinfo.c b/grub-core/commands/videoinfo.c index 10f77915b..3e0c1a12e 100644 --- a/grub-core/commands/videoinfo.c +++ b/grub-core/commands/videoinfo.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static unsigned height, width, depth; static int diff --git a/grub-core/commands/videotest.c b/grub-core/commands/videotest.c index 435ac2937..dc7a6485f 100644 --- a/grub-core/commands/videotest.c +++ b/grub-core/commands/videotest.c @@ -28,6 +28,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) diff --git a/grub-core/commands/xnu_uuid.c b/grub-core/commands/xnu_uuid.c index 382d3196b..f618b4ec0 100644 --- a/grub-core/commands/xnu_uuid.c +++ b/grub-core/commands/xnu_uuid.c @@ -34,6 +34,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* This prefix is used by xnu and boot-132 to hash together with volume serial. */ static grub_uint8_t hash_prefix[16] diff --git a/grub-core/disk/ata.c b/grub-core/disk/ata.c index fe677e2a0..7f261560d 100644 --- a/grub-core/disk/ata.c +++ b/grub-core/disk/ata.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* At the moment, only two IDE ports are supported. */ static const grub_port_t grub_ata_ioaddress[] = { GRUB_ATA_CH0_PORT1, GRUB_ATA_CH1_PORT1 }; diff --git a/grub-core/disk/ata_pthru.c b/grub-core/disk/ata_pthru.c index f52725a49..eb9cb5f85 100644 --- a/grub-core/disk/ata_pthru.c +++ b/grub-core/disk/ata_pthru.c @@ -22,6 +22,7 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); /* ATA pass through support, used by hdparm.mod. */ static grub_err_t diff --git a/grub-core/disk/dmraid_nvidia.c b/grub-core/disk/dmraid_nvidia.c index d3f45935c..154193eb0 100644 --- a/grub-core/disk/dmraid_nvidia.c +++ b/grub-core/disk/dmraid_nvidia.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define NV_SIGNATURES 4 #define NV_IDLE 0 diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c index 069bb0b59..1d47dc727 100644 --- a/grub-core/disk/i386/pc/biosdisk.c +++ b/grub-core/disk/i386/pc/biosdisk.c @@ -28,6 +28,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static int cd_drive = 0; static int grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap); diff --git a/grub-core/disk/ieee1275/nand.c b/grub-core/disk/ieee1275/nand.c index a2c717cdb..e9450167e 100644 --- a/grub-core/disk/ieee1275/nand.c +++ b/grub-core/disk/ieee1275/nand.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + struct grub_nand_data { grub_ieee1275_ihandle_t handle; diff --git a/grub-core/disk/loopback.c b/grub-core/disk/loopback.c index 939043f01..d50f353b1 100644 --- a/grub-core/disk/loopback.c +++ b/grub-core/disk/loopback.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + struct grub_loopback { char *devname; diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 00c6d8f9b..206e3e220 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -28,6 +28,8 @@ #include #endif +GRUB_MOD_LICENSE ("GPLv3+"); + static struct grub_lvm_vg *vg_list; static int lv_count; diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c index e30878365..19c43f455 100644 --- a/grub-core/disk/mdraid1x_linux.c +++ b/grub-core/disk/mdraid1x_linux.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* Linux RAID on disk structures and constants, copied from include/linux/raid/md_p.h. */ diff --git a/grub-core/disk/mdraid_linux.c b/grub-core/disk/mdraid_linux.c index 06d3498a8..691d100b8 100644 --- a/grub-core/disk/mdraid_linux.c +++ b/grub-core/disk/mdraid_linux.c @@ -27,6 +27,8 @@ /* Linux RAID on disk structures and constants, copied from include/linux/raid/md_p.h. */ +GRUB_MOD_LICENSE ("GPLv3+"); + #define RESERVED_BYTES (64 * 1024) #define RESERVED_SECTORS (RESERVED_BYTES / 512) diff --git a/grub-core/disk/memdisk.c b/grub-core/disk/memdisk.c index e00280dd7..114ac0d9e 100644 --- a/grub-core/disk/memdisk.c +++ b/grub-core/disk/memdisk.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static char *memdisk_addr; static grub_off_t memdisk_size = 0; diff --git a/grub-core/disk/raid.c b/grub-core/disk/raid.c index ac2b9fefe..3c74bba99 100644 --- a/grub-core/disk/raid.c +++ b/grub-core/disk/raid.c @@ -27,6 +27,8 @@ #include #endif +GRUB_MOD_LICENSE ("GPLv3+"); + /* Linked list of RAID arrays. */ static struct grub_raid_array *array_list; grub_raid5_recover_func_t grub_raid5_recover_func; diff --git a/grub-core/disk/raid5_recover.c b/grub-core/disk/raid5_recover.c index 349eb0291..c26d05e94 100644 --- a/grub-core/disk/raid5_recover.c +++ b/grub-core/disk/raid5_recover.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_raid5_recover (struct grub_raid_array *array, int disknr, char *buf, grub_disk_addr_t sector, int size) diff --git a/grub-core/disk/raid6_recover.c b/grub-core/disk/raid6_recover.c index dfaa60ea4..25b50eb6b 100644 --- a/grub-core/disk/raid6_recover.c +++ b/grub-core/disk/raid6_recover.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_uint8_t raid6_table1[256][256]; static grub_uint8_t raid6_table2[256][256]; diff --git a/grub-core/disk/scsi.c b/grub-core/disk/scsi.c index a40de278f..25f0e3aea 100644 --- a/grub-core/disk/scsi.c +++ b/grub-core/disk/scsi.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_scsi_dev_t grub_scsi_dev_list; diff --git a/grub-core/disk/usbms.c b/grub-core/disk/usbms.c index fcfe9e5d4..2f1dbd487 100644 --- a/grub-core/disk/usbms.c +++ b/grub-core/disk/usbms.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_USBMS_DIRECTION_BIT 7 /* The USB Mass Storage Command Block Wrapper. */ diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c index da813b00d..772db2956 100644 --- a/grub-core/efiemu/main.c +++ b/grub-core/efiemu/main.c @@ -32,6 +32,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* System table. Two version depending on mode */ grub_efi_system_table32_t *grub_efiemu_system_table32 = 0; grub_efi_system_table64_t *grub_efiemu_system_table64 = 0; diff --git a/grub-core/font/font.c b/grub-core/font/font.c index b5ec43bb2..ef6caf77b 100644 --- a/grub-core/font/font.c +++ b/grub-core/font/font.c @@ -30,6 +30,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #ifdef USE_ASCII_FAILBACK #include "ascii.h" #endif diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c index 40be4b2f6..1c4f80ec0 100644 --- a/grub-core/fs/affs.c +++ b/grub-core/fs/affs.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* The affs bootblock. */ struct grub_affs_bblock { diff --git a/grub-core/fs/afs.c b/grub-core/fs/afs.c index cd61f4db9..35ef49937 100644 --- a/grub-core/fs/afs.c +++ b/grub-core/fs/afs.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #ifdef MODE_BIGENDIAN #define GRUB_AFS_FSNAME_SUFFIX "_be" #else diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 11b8dba33..3e73837d9 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define BTRFS_SIGNATURE "_BHRfS_M" struct btrfs_superblock diff --git a/grub-core/fs/cpio.c b/grub-core/fs/cpio.c index 2c92404c3..a7ccfbded 100644 --- a/grub-core/fs/cpio.c +++ b/grub-core/fs/cpio.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #ifndef MODE_USTAR /* cpio support */ #define MAGIC_BCPIO 070707 diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index 9d7bbfd36..0fdf151a2 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -51,6 +51,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* Log2 size of ext2 block in 512 blocks. */ #define LOG2_EXT2_BLOCK_SIZE(data) \ (grub_le_to_cpu32 (data->sblock.log2_block_size) + 1) diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index 89050943c..76b9c52d7 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_FAT_DIR_ENTRY_SIZE 32 #define GRUB_FAT_ATTR_READ_ONLY 0x01 diff --git a/grub-core/fs/fshelp.c b/grub-core/fs/fshelp.c index d0b1e493e..f879885ac 100644 --- a/grub-core/fs/fshelp.c +++ b/grub-core/fs/fshelp.c @@ -22,7 +22,9 @@ #include #include #include +#include +GRUB_MOD_LICENSE ("GPLv3+"); /* Lookup the node PATH. The node ROOTNODE describes the root of the directory tree. The node found is returned in FOUNDNODE, which is diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index cef856326..1f67ea155 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -29,6 +29,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_HFS_SBLOCK 2 #define GRUB_HFS_EMBED_HFSPLUS_SIG 0x482B diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index 7d7115ce3..304b32126 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -30,6 +30,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_HFSPLUS_MAGIC 0x482B #define GRUB_HFSPLUSX_MAGIC 0x4858 #define GRUB_HFSPLUS_SBLOCK 2 diff --git a/grub-core/fs/i386/pc/pxe.c b/grub-core/fs/i386/pc/pxe.c index c800ea2ad..d6dc2c22d 100644 --- a/grub-core/fs/i386/pc/pxe.c +++ b/grub-core/fs/i386/pc/pxe.c @@ -30,6 +30,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define SEGMENT(x) ((x) >> 4) #define OFFSET(x) ((x) & 0xF) #define SEGOFS(x) ((SEGMENT(x) << 16) + OFFSET(x)) diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c index f72249d20..a9a17fef8 100644 --- a/grub-core/fs/iso9660.c +++ b/grub-core/fs/iso9660.c @@ -28,6 +28,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_ISO9660_FSTYPE_DIR 0040000 #define GRUB_ISO9660_FSTYPE_REG 0100000 #define GRUB_ISO9660_FSTYPE_SYMLINK 0120000 diff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c index 6857c4a2c..72e6adc74 100644 --- a/grub-core/fs/jfs.c +++ b/grub-core/fs/jfs.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_JFS_MAX_SYMLNK_CNT 8 #define GRUB_JFS_FILETYPE_MASK 0170000 #define GRUB_JFS_FILETYPE_REG 0100000 diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c index 679e1ec51..523e6e616 100644 --- a/grub-core/fs/minix.c +++ b/grub-core/fs/minix.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #ifdef MODE_MINIX2 #define GRUB_MINIX_MAGIC 0x2468 #define GRUB_MINIX_MAGIC_30 0x2478 diff --git a/grub-core/fs/nilfs2.c b/grub-core/fs/nilfs2.c index e529775f4..4c8d7633c 100644 --- a/grub-core/fs/nilfs2.c +++ b/grub-core/fs/nilfs2.c @@ -35,6 +35,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define NILFS_INODE_BMAP_SIZE 7 #define NILFS_SUPORT_REV 2 diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c index 414f6513d..e01ce34c2 100644 --- a/grub-core/fs/ntfs.c +++ b/grub-core/fs/ntfs.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_dl_t my_mod; ntfscomp_func_t grub_ntfscomp_func; diff --git a/grub-core/fs/ntfscomp.c b/grub-core/fs/ntfscomp.c index c29979edc..d2893cb99 100644 --- a/grub-core/fs/ntfscomp.c +++ b/grub-core/fs/ntfscomp.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t decomp_nextvcn (struct grub_ntfs_comp *cc) { diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c index e92279554..f2984f845 100644 --- a/grub-core/fs/reiserfs.c +++ b/grub-core/fs/reiserfs.c @@ -39,6 +39,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define MIN(a, b) \ ({ typeof (a) _a = (a); \ typeof (b) _b = (b); \ diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c index b49420de1..455743117 100644 --- a/grub-core/fs/sfs.c +++ b/grub-core/fs/sfs.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* The common header for a block. */ struct grub_sfs_bheader { diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c index 1672aab1b..5842d5d12 100644 --- a/grub-core/fs/udf.c +++ b/grub-core/fs/udf.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_UDF_MAX_PDS 2 #define GRUB_UDF_MAX_PMS 6 diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c index 2b1021db6..86fe8af65 100644 --- a/grub-core/fs/ufs.c +++ b/grub-core/fs/ufs.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #ifdef MODE_UFS2 #define GRUB_UFS_MAGIC 0x19540119 #else diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 9f8dc28de..2eadc3768 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define XFS_INODE_EXTENTS 9 #define XFS_INODE_FORMAT_INO 1 diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 8e83ea0b5..8d86cf9e5 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -52,6 +52,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define ZPOOL_PROP_BOOTFS "bootfs" #define MIN(a,b) (((a) < (b)) ? (a) : (b)) diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c index 224a97792..1968ed554 100644 --- a/grub-core/fs/zfs/zfsinfo.c +++ b/grub-core/fs/zfs/zfsinfo.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static inline void print_tabs (int n) { diff --git a/grub-core/gentrigtables.c b/grub-core/gentrigtables.c index bef2b083c..8c039570d 100644 --- a/grub-core/gentrigtables.c +++ b/grub-core/gentrigtables.c @@ -30,6 +30,14 @@ main (int argc __attribute__ ((unused)), int i; printf ("#include \n"); + printf ("#include \n"); + printf ("\n"); + + printf ("/* Under copyright legislature such automated output isn't\n"); + printf ("covered by any copyright. Hence it's public domain. Public\n"); + printf ("domain works can be dual-licenced with any license. */\n"); + printf ("GRUB_MOD_LICENSE (\"GPLv3+\");"); + printf ("GRUB_MOD_DUAL_LICENSE (\"Public Domain\");"); #define TAB(op) \ printf ("grub_int16_t grub_trig_" #op "tab[] =\n{"); \ diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c index 84937f19b..cca8b901f 100644 --- a/grub-core/gettext/gettext.c +++ b/grub-core/gettext/gettext.c @@ -28,6 +28,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* .mo file information from: http://www.gnu.org/software/autoconf/manual/gettext/MO-Files.html . diff --git a/grub-core/gfxmenu/gfxmenu.c b/grub-core/gfxmenu/gfxmenu.c index 564a87634..2f210e02b 100644 --- a/grub-core/gfxmenu/gfxmenu.c +++ b/grub-core/gfxmenu/gfxmenu.c @@ -37,6 +37,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_gfxmenu_view_t cached_view; static void diff --git a/grub-core/gnulib/regex.c b/grub-core/gnulib/regex.c index ba0eebee7..4c2243f64 100644 --- a/grub-core/gnulib/regex.c +++ b/grub-core/gnulib/regex.c @@ -19,6 +19,9 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); /* Make sure noone compiles this code with a C++ compiler. */ #if defined __cplusplus && defined _LIBC diff --git a/grub-core/hello/hello.c b/grub-core/hello/hello.c index 77c4c96b1..2c9e90f72 100644 --- a/grub-core/hello/hello.c +++ b/grub-core/hello/hello.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_cmd_hello (grub_extcmd_context_t ctxt __attribute__ ((unused)), int argc __attribute__ ((unused)), diff --git a/grub-core/hook/datehook.c b/grub-core/hook/datehook.c index d855311d3..f64fac074 100644 --- a/grub-core/hook/datehook.c +++ b/grub-core/hook/datehook.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static char *grub_datetime_names[] = { "YEAR", diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c index 891fb78e9..3b456c1d2 100644 --- a/grub-core/io/bufio.c +++ b/grub-core/io/bufio.c @@ -23,6 +23,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); #define GRUB_BUFIO_DEF_SIZE 8192 #define GRUB_BUFIO_MAX_SIZE 1048576 diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c index 47df23833..ad185dcab 100644 --- a/grub-core/io/gzio.c +++ b/grub-core/io/gzio.c @@ -42,6 +42,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* * Window Size * diff --git a/grub-core/io/xzio.c b/grub-core/io/xzio.c index 3daf6a3fe..1f42cd242 100644 --- a/grub-core/io/xzio.c +++ b/grub-core/io/xzio.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #include "xz.h" #include "xz_stream.h" diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index 02d785b9b..c5e2888cd 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -373,6 +373,38 @@ grub_dl_call_init (grub_dl_t mod) (mod->init) (mod); } +/* Me, Vladimir Serbinenko, hereby I add this module check as per new + GNU module policy. Note that this license check is informative only. + Modules have to be licensed under GPLv3 or GPLv3+ (optionally + multi-licensed under other licences as well) independently of the + presence of this check and solely by linking (module loading in GRUB + constitutes linking) and GRUB core being licensed under GPLv3+. + Be sure to understand your license obligations. +*/ +static grub_err_t +grub_dl_check_license (Elf_Ehdr *e) +{ + Elf_Shdr *s; + const char *str; + unsigned i; + + s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize); + str = (char *) e + s->sh_offset; + + for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); + i < e->e_shnum; + i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) + if (grub_strcmp (str + s->sh_name, ".module_license") == 0) + { + if (grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3") == 0 + || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3+") == 0 + || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0) + return GRUB_ERR_NONE; + } + + return grub_error (GRUB_ERR_BAD_MODULE, "incompatible license"); +} + static grub_err_t grub_dl_resolve_name (grub_dl_t mod, Elf_Ehdr *e) { @@ -519,7 +551,16 @@ grub_dl_load_core (void *addr, grub_size_t size) mod->ref_count = 1; grub_dprintf ("modules", "relocating to %p\n", mod); - if (grub_dl_resolve_name (mod, e) + /* Me, Vladimir Serbinenko, hereby I add this module check as per new + GNU module policy. Note that this license check is informative only. + Modules have to be licensed under GPLv3 or GPLv3+ (optionally + multi-licensed under other licences as well) independently of the + presence of this check and solely by linking (module loading in GRUB + constitutes linking) and GRUB core being licensed under GPLv3+. + Be sure to understand your license obligations. + */ + if (grub_dl_check_license (e) + || grub_dl_resolve_name (mod, e) || grub_dl_resolve_dependencies (mod, e) || grub_dl_load_segments (mod, e) || grub_dl_resolve_symbols (mod, e) diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c index 56218b4e4..9c7b8cec2 100644 --- a/grub-core/kern/elf.c +++ b/grub-core/kern/elf.c @@ -23,6 +23,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); /* Check if EHDR is a valid ELF header. */ static grub_err_t diff --git a/grub-core/lib/cmos_datetime.c b/grub-core/lib/cmos_datetime.c index 8db60b48c..73c5a03c0 100644 --- a/grub-core/lib/cmos_datetime.c +++ b/grub-core/lib/cmos_datetime.c @@ -19,6 +19,9 @@ #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); grub_err_t grub_get_datetime (struct grub_datetime *datetime) diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c index f5768b8b5..ad1bfc4d3 100644 --- a/grub-core/lib/crypto.c +++ b/grub-core/lib/crypto.c @@ -21,6 +21,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); struct grub_crypto_hmac_handle { diff --git a/grub-core/lib/pbkdf2.c b/grub-core/lib/pbkdf2.c index 083446ab9..09b8c7360 100644 --- a/grub-core/lib/pbkdf2.c +++ b/grub-core/lib/pbkdf2.c @@ -21,6 +21,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv2+"); /* 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/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index 3642de9dc..6eb20b865 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -22,6 +22,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); struct grub_relocator { diff --git a/grub-core/loader/aout.c b/grub-core/loader/aout.c index 611960f92..69bf6e6ad 100644 --- a/grub-core/loader/aout.c +++ b/grub-core/loader/aout.c @@ -21,6 +21,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + int grub_aout_get_type (union grub_aout_header *header) { diff --git a/grub-core/loader/efi/appleloader.c b/grub-core/loader/efi/appleloader.c index dc42683a6..847750dc0 100644 --- a/grub-core/loader/efi/appleloader.c +++ b/grub-core/loader/efi/appleloader.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_dl_t my_mod; static grub_efi_handle_t image_handle; diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c index a095ad931..869b64ced 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -35,6 +35,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_dl_t my_mod; static grub_efi_physical_address_t address; diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index ecd5bd5cd..6487dc3df 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -34,6 +34,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #include #ifdef GRUB_MACHINE_PCBIOS #include diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 0178e2fd4..241eaa5e7 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -35,6 +35,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #ifdef GRUB_MACHINE_PCBIOS #include #endif diff --git a/grub-core/loader/i386/pc/chainloader.c b/grub-core/loader/i386/pc/chainloader.c index fd99c81d5..794316b34 100644 --- a/grub-core/loader/i386/pc/chainloader.c +++ b/grub-core/loader/i386/pc/chainloader.c @@ -38,6 +38,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_dl_t my_mod; static int boot_drive; static void *boot_part_addr; diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index 96d00f927..c6e6b67d1 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -36,6 +36,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_LINUX_CL_OFFSET 0x9000 #define GRUB_LINUX_CL_END_OFFSET 0x90FF diff --git a/grub-core/loader/i386/pc/ntldr.c b/grub-core/loader/i386/pc/ntldr.c index 0c33a0680..4a08b54f2 100644 --- a/grub-core/loader/i386/pc/ntldr.c +++ b/grub-core/loader/i386/pc/ntldr.c @@ -33,6 +33,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_dl_t my_mod; static struct grub_relocator *rel; static grub_uint32_t edx = 0xffffffff; diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c index 9accfc270..0bf7b1f8e 100644 --- a/grub-core/loader/mips/linux.c +++ b/grub-core/loader/mips/linux.c @@ -28,6 +28,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* For frequencies. */ #include #include diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index 4bfc2c191..d9e74b3c7 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -43,6 +43,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #ifdef GRUB_MACHINE_EFI #include #endif diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c index 0cf0eb825..12a3fa9f6 100644 --- a/grub-core/loader/powerpc/ieee1275/linux.c +++ b/grub-core/loader/powerpc/ieee1275/linux.c @@ -29,6 +29,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define ELF32_LOADMASK (0xc0000000UL) #define ELF64_LOADMASK (0xc000000000000000ULL) diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index a262049a7..8ed61f8bf 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -29,6 +29,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_dl_t my_mod; static int loaded; diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index 73158fd10..a98d60c20 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -34,6 +34,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #if defined (__i386) && !defined (GRUB_MACHINE_EFI) #include #endif diff --git a/grub-core/mmap/mmap.c b/grub-core/mmap/mmap.c index 1c1825490..07a71336b 100644 --- a/grub-core/mmap/mmap.c +++ b/grub-core/mmap/mmap.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #ifndef GRUB_MMAP_REGISTER_BY_FIRMWARE struct grub_mmap_region *grub_mmap_overlays = 0; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index cefb1cb9b..837fcb960 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -33,6 +33,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_DEFAULT_HISTORY_SIZE 50 static int nested_level = 0; diff --git a/grub-core/partmap/acorn.c b/grub-core/partmap/acorn.c index 677ec61d5..9a68ddd92 100644 --- a/grub-core/partmap/acorn.c +++ b/grub-core/partmap/acorn.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define LINUX_NATIVE_MAGIC grub_cpu_to_le32 (0xdeafa1de) #define LINUX_SWAP_MAGIC grub_cpu_to_le32 (0xdeafab1e) #define LINUX_MAP_ENTRIES (512 / 12) diff --git a/grub-core/partmap/amiga.c b/grub-core/partmap/amiga.c index 1e0f23402..f3ba950aa 100644 --- a/grub-core/partmap/amiga.c +++ b/grub-core/partmap/amiga.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + struct grub_amiga_rdsk { /* "RDSK". */ diff --git a/grub-core/partmap/apple.c b/grub-core/partmap/apple.c index e162d18d7..c08cae589 100644 --- a/grub-core/partmap/apple.c +++ b/grub-core/partmap/apple.c @@ -22,6 +22,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_APPLE_HEADER_MAGIC 0x4552 #define GRUB_APPLE_PART_MAGIC 0x504D diff --git a/grub-core/partmap/bsdlabel.c b/grub-core/partmap/bsdlabel.c index 4dec3851c..888100aa2 100644 --- a/grub-core/partmap/bsdlabel.c +++ b/grub-core/partmap/bsdlabel.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #ifdef GRUB_UTIL #include #endif diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c index 7f2c36143..73a1c3b19 100644 --- a/grub-core/partmap/gpt.c +++ b/grub-core/partmap/gpt.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_uint8_t grub_gpt_magic[8] = { 0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54 diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c index 31a0a0707..1b71c69ab 100644 --- a/grub-core/partmap/msdos.c +++ b/grub-core/partmap/msdos.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static struct grub_partition_map grub_msdos_partition_map; diff --git a/grub-core/partmap/sun.c b/grub-core/partmap/sun.c index 7af95c939..c7ef681c4 100644 --- a/grub-core/partmap/sun.c +++ b/grub-core/partmap/sun.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_PARTMAP_SUN_MAGIC 0xDABE #define GRUB_PARTMAP_SUN_MAX_PARTS 8 #define GRUB_PARTMAP_SUN_WHOLE_DISK_ID 0x05 diff --git a/grub-core/partmap/sunpc.c b/grub-core/partmap/sunpc.c index ea69c28b9..28dc4f5be 100644 --- a/grub-core/partmap/sunpc.c +++ b/grub-core/partmap/sunpc.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define GRUB_PARTMAP_SUN_PC_MAGIC 0xDABE #define GRUB_PARTMAP_SUN_PC_MAX_PARTS 16 #define GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID 0x05 diff --git a/grub-core/parttool/msdospart.c b/grub-core/parttool/msdospart.c index 006a87def..ecaca140a 100644 --- a/grub-core/parttool/msdospart.c +++ b/grub-core/parttool/msdospart.c @@ -28,6 +28,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv2+"); + static int activate_table_handle = -1; static int type_table_handle = -1; diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c index 7ce287ecc..210ac21cc 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -26,6 +26,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static short at_keyboard_status = 0; static int e0_received = 0; static int f0_received = 0; diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c index 44d1a9be8..0ade65f27 100644 --- a/grub-core/term/gfxterm.c +++ b/grub-core/term/gfxterm.c @@ -31,6 +31,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define DEFAULT_VIDEO_MODE "auto" #define DEFAULT_BORDER_WIDTH 10 diff --git a/grub-core/term/i386/pc/vga_text.c b/grub-core/term/i386/pc/vga_text.c index fbb65ae0c..1816bfae2 100644 --- a/grub-core/term/i386/pc/vga_text.c +++ b/grub-core/term/i386/pc/vga_text.c @@ -22,6 +22,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define COLS 80 #define ROWS 25 diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c index 32628dbae..073c27aed 100644 --- a/grub-core/term/serial.c +++ b/grub-core/term/serial.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define FOR_SERIAL_PORTS(var) FOR_LIST_ELEMENTS((var), (grub_serial_ports)) /* Argument options. */ diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c index 0a8c75c74..16158139d 100644 --- a/grub-core/term/terminfo.c +++ b/grub-core/term/terminfo.c @@ -34,6 +34,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static struct grub_term_output *terminfo_outputs; /* Get current terminfo name. */ diff --git a/grub-core/term/usb_keyboard.c b/grub-core/term/usb_keyboard.c index 23c0c10ca..ae00936b8 100644 --- a/grub-core/term/usb_keyboard.c +++ b/grub-core/term/usb_keyboard.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + enum diff --git a/grub-core/tests/example_functional_test.c b/grub-core/tests/example_functional_test.c index 525988145..802088791 100644 --- a/grub-core/tests/example_functional_test.c +++ b/grub-core/tests/example_functional_test.c @@ -18,6 +18,9 @@ /* All tests need to include test.h for GRUB testing framework. */ #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); /* Functional test main method. */ static void diff --git a/grub-core/tests/lib/functional_test.c b/grub-core/tests/lib/functional_test.c index 521f4ad22..fd199bd63 100644 --- a/grub-core/tests/lib/functional_test.c +++ b/grub-core/tests/lib/functional_test.c @@ -20,6 +20,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); static grub_err_t grub_functional_test (grub_extcmd_context_t ctxt __attribute__ ((unused)), diff --git a/grub-core/tests/test_blockarg.c b/grub-core/tests/test_blockarg.c index 41460fb7e..ddd46e1f6 100644 --- a/grub-core/tests/test_blockarg.c +++ b/grub-core/tests/test_blockarg.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t test_blockarg (grub_extcmd_context_t ctxt, int argc, char **args) { diff --git a/grub-core/video/bitmap.c b/grub-core/video/bitmap.c index 659ab9a57..32e9358a3 100644 --- a/grub-core/video/bitmap.c +++ b/grub-core/video/bitmap.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* List of bitmap readers registered to system. */ static grub_video_bitmap_reader_t bitmap_readers_list; diff --git a/grub-core/video/bitmap_scale.c b/grub-core/video/bitmap_scale.c index 6f8ff247e..8da5697f8 100644 --- a/grub-core/video/bitmap_scale.c +++ b/grub-core/video/bitmap_scale.c @@ -23,6 +23,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); /* Prototypes for module-local functions. */ static grub_err_t scale_nn (struct grub_video_bitmap *dst, diff --git a/grub-core/video/bochs.c b/grub-core/video/bochs.c index 832cd9903..79cae6547 100644 --- a/grub-core/video/bochs.c +++ b/grub-core/video/bochs.c @@ -28,6 +28,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static struct { struct grub_video_mode_info mode_info; diff --git a/grub-core/video/cirrus.c b/grub-core/video/cirrus.c index a964c85cd..7fad50e5b 100644 --- a/grub-core/video/cirrus.c +++ b/grub-core/video/cirrus.c @@ -28,6 +28,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static struct { struct grub_video_mode_info mode_info; diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c index f02dc9cb6..d14ae98d2 100644 --- a/grub-core/video/efi_gop.c +++ b/grub-core/video/efi_gop.c @@ -29,6 +29,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_efi_guid_t graphics_output_guid = GRUB_EFI_GOP_GUID; static struct grub_efi_gop *gop; static unsigned old_mode; diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c index a8f70edea..1e709a52d 100644 --- a/grub-core/video/efi_uga.c +++ b/grub-core/video/efi_uga.c @@ -30,6 +30,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_efi_guid_t uga_draw_guid = GRUB_EFI_UGA_DRAW_GUID; static struct grub_efi_uga_draw_protocol *uga; static grub_uint32_t uga_fb; diff --git a/grub-core/video/emu/sdl.c b/grub-core/video/emu/sdl.c index d66b8b0c0..f4c1a6ab6 100644 --- a/grub-core/video/emu/sdl.c +++ b/grub-core/video/emu/sdl.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static SDL_Surface *window = 0; static struct grub_video_render_target *sdl_render_target; static struct grub_video_mode_info mode_info; diff --git a/grub-core/video/fb/video_fb.c b/grub-core/video/fb/video_fb.c index 2226d6583..2cffcb3d9 100644 --- a/grub-core/video/fb/video_fb.c +++ b/grub-core/video/fb/video_fb.c @@ -24,6 +24,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); static struct { diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c index 08bf124b6..a109bcf43 100644 --- a/grub-core/video/i386/pc/vbe.c +++ b/grub-core/video/i386/pc/vbe.c @@ -30,6 +30,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static int vbe_detected = -1; static struct grub_vbe_info_block controller_info; diff --git a/grub-core/video/i386/pc/vga.c b/grub-core/video/i386/pc/vga.c index 19770ce0a..fe387a26b 100644 --- a/grub-core/video/i386/pc/vga.c +++ b/grub-core/video/i386/pc/vga.c @@ -30,6 +30,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + #define VGA_WIDTH 640 #define VGA_HEIGHT 350 #define VGA_MEM ((grub_uint8_t *) GRUB_MEMORY_MACHINE_VGA_ADDR) diff --git a/grub-core/video/ieee1275.c b/grub-core/video/ieee1275.c index 501ba7c2f..913ea8376 100644 --- a/grub-core/video/ieee1275.c +++ b/grub-core/video/ieee1275.c @@ -27,6 +27,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* Only 8-bit indexed color is supported for now. */ static unsigned old_width, old_height; diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c index 9d88163bd..8cdb2f61d 100644 --- a/grub-core/video/readers/jpeg.c +++ b/grub-core/video/readers/jpeg.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* Uncomment following define to enable JPEG debug. */ //#define JPEG_DEBUG diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c index 2cec49e2f..5728651e0 100644 --- a/grub-core/video/readers/png.c +++ b/grub-core/video/readers/png.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* Uncomment following define to enable PNG debug. */ //#define PNG_DEBUG diff --git a/grub-core/video/readers/tga.c b/grub-core/video/readers/tga.c index 6c9e9d691..84be68a0a 100644 --- a/grub-core/video/readers/tga.c +++ b/grub-core/video/readers/tga.c @@ -24,6 +24,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* Uncomment following define to enable TGA debug. */ //#define TGA_DEBUG diff --git a/grub-core/video/video.c b/grub-core/video/video.c index 7a1a446e4..6a1d47304 100644 --- a/grub-core/video/video.c +++ b/grub-core/video/video.c @@ -22,6 +22,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + /* The list of video adapters registered to system. */ grub_video_adapter_t grub_video_adapter_list = NULL; diff --git a/include/grub/dl.h b/include/grub/dl.h index afc4af41a..71db90c8b 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -63,8 +63,32 @@ __asm__ (".section .modname\n.asciz \"" #name "\"\n") #define GRUB_MOD_DEP(name) \ __asm__ (".section .moddeps\n.asciz \"" #name "\"\n") + #endif +#ifdef APPLE_CC +#define GRUB_MOD_SECTION(x) "_" x ", _" x "" +#else +#define GRUB_MOD_SECTION(x) "." x +#endif + +/* Me, Vladimir Serbinenko, hereby I add this module check as per new + GNU module policy. Note that this license check is informative only. + Modules have to be licensed under GPLv3 or GPLv3+ (optionally + multi-licensed under other licences as well) independently of the + presence of this check and solely by linking (module loading in GRUB + constitutes linking) and GRUB core being licensed under GPLv3+. + Be sure to understand your license obligations. +*/ +#define GRUB_MOD_LICENSE(license) \ + static char grub_module_license[] __attribute__ ((section (GRUB_MOD_SECTION ("module_license")), used)) = "LICENSE=" license; + +/* Under GPL license obligations you have to distribute your module + under GPLv3(+). However, you can also distribute the same code under + another license as long as GPLv3(+) version is provided. +*/ +#define GRUB_MOD_DUAL_LICENSE(x) + struct grub_dl_segment { struct grub_dl_segment *next; diff --git a/util/import_gcry.py b/util/import_gcry.py index 494a4ae7b..54c178dbf 100644 --- a/util/import_gcry.py +++ b/util/import_gcry.py @@ -91,7 +91,12 @@ for cipher_file in cipher_files: 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"); + fw.write (" import_gcry.py. Please don't modify it */\n") + fw.write ("#include \n") + # Whole libgcrypt is distributedunder GPLv3+ or compatible + if isc: + fw.write ("GRUB_MOD_LICENSE (\"GPLv3+\");\n") + ciphernames = [] mdnames = [] hold = False From ec9f5e0d7387817ca986a33de79c9323d35beabb Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 11 Apr 2011 23:30:15 +0200 Subject: [PATCH 255/276] * NEWS: Add btrfs support. --- ChangeLog | 4 ++++ NEWS | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 29dbceec0..6112407bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-11 Vladimir Serbinenko + + * NEWS: Add btrfs support. + 2011-04-11 Vladimir Serbinenko 2011-04-11 Colin Watson diff --git a/NEWS b/NEWS index 36e3f25bf..81b6ecb2d 100644 --- a/NEWS +++ b/NEWS @@ -29,7 +29,7 @@ New in 1.99: * New `lsacpi' command. -* Basic btrfs support (detection and UUID). +* Btrfs support. * New `--boot-directory' option to `grub-install', `grub-reboot', and `grub-set-default', with clearer semantics than the previous From 0c6769339490388a44e3b782a16443c0219029fe Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 12 Apr 2011 11:39:17 +0100 Subject: [PATCH 256/276] * util/import_gcry.py: Fix typo. --- ChangeLog | 4 ++++ util/import_gcry.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6112407bc..63c6ec58d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-12 Colin Watson + + * util/import_gcry.py: Fix typo. + 2011-04-11 Vladimir Serbinenko * NEWS: Add btrfs support. diff --git a/util/import_gcry.py b/util/import_gcry.py index 54c178dbf..b2a0a5451 100644 --- a/util/import_gcry.py +++ b/util/import_gcry.py @@ -93,7 +93,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") fw.write ("#include \n") - # Whole libgcrypt is distributedunder GPLv3+ or compatible + # Whole libgcrypt is distributed under GPLv3+ or compatible if isc: fw.write ("GRUB_MOD_LICENSE (\"GPLv3+\");\n") From 09a9d66f1d670be91aab7915284c18e67e8602e3 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 12 Apr 2011 11:44:35 +0100 Subject: [PATCH 257/276] * NEWS: Drop obsolete entry about probe-only btrfs support. --- ChangeLog | 4 ++++ NEWS | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63c6ec58d..cf6fa18c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-12 Colin Watson + + * NEWS: Drop obsolete entry about probe-only btrfs support. + 2011-04-12 Colin Watson * util/import_gcry.py: Fix typo. diff --git a/NEWS b/NEWS index 81b6ecb2d..2a93c2526 100644 --- a/NEWS +++ b/NEWS @@ -83,10 +83,6 @@ New in 1.99: * Extensive updates to the Texinfo documentation. -* Add `grub-probe' support for the btrfs filesystem, permitting / to - reside on btrfs as long as /boot is on a filesystem natively supported - by GRUB. - * Handle symbolic links under /dev/mapper on GNU/Linux. * Handle installation across multiple partition table types. From 9d5f81622cd2bc422d6165b6d7a1b022495ecfc4 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 12 Apr 2011 13:23:19 +0100 Subject: [PATCH 258/276] * docs/grub.texi (normal): New section. (normal_exit): New section. (Embedded configuration): Add reference to normal. (GRUB only offers a rescue shell): Likewise. * docs/grub-dev.texi (Error Handling): Fix typo. --- ChangeLog | 8 ++++++++ docs/grub-dev.texi | 2 +- docs/grub.texi | 48 +++++++++++++++++++++++++++++++++++++--------- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf6fa18c9..c1ee7cf9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-04-12 Colin Watson + + * docs/grub.texi (normal): New section. + (normal_exit): New section. + (Embedded configuration): Add reference to normal. + (GRUB only offers a rescue shell): Likewise. + * docs/grub-dev.texi (Error Handling): Fix typo. + 2011-04-12 Colin Watson * NEWS: Drop obsolete entry about probe-only btrfs support. diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index a45b8b198..93d2bdb4d 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -451,7 +451,7 @@ request. Instead, please subscribe to the mailing list, and communicate first @chapter Error Handling Error handling in GRUB 2 is based on exception handling model. As C language -doesn't direcly support exceptions, exception handling behavior is emulated +doesn't directly support exceptions, exception handling behavior is emulated in software. When exception is raised, function must return to calling function. If calling diff --git a/docs/grub.texi b/docs/grub.texi index 0c59975cd..8d2223fb4 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1486,14 +1486,14 @@ reside anywhere on the file system, and may be removed after running @command{grub-mkimage}. After the embedded configuration file (if any) is executed, GRUB will load -the @samp{normal} module, which will then read the real configuration file -from @file{$prefix/grub.cfg}. By this point, the @code{root} variable will -also have been set to the root device name. For example, @code{prefix} -might be set to @samp{(hd0,1)/boot/grub}, and @code{root} might be set to -@samp{hd0,1}. Thus, in most cases, the embedded configuration file only -needs to set the @code{prefix} and @code{root} variables, and then drop -through to GRUB's normal processing. A typical example of this might look -like this: +the @samp{normal} module (@pxref{normal}), which will then read the real +configuration file from @file{$prefix/grub.cfg}. By this point, the +@code{root} variable will also have been set to the root device name. For +example, @code{prefix} might be set to @samp{(hd0,1)/boot/grub}, and +@code{root} might be set to @samp{hd0,1}. Thus, in most cases, the embedded +configuration file only needs to set the @code{prefix} and @code{root} +variables, and then drop through to GRUB's normal processing. A typical +example of this might look like this: @example @group @@ -3089,6 +3089,8 @@ you forget a command, you can run the command @command{help} * load_env:: Load variables from environment block * loopback:: Make a device from a filesystem image * ls:: List devices or files +* normal:: Enter normal mode +* normal_exit:: Exit from normal mode * parttool:: Modify partition table entries * password:: Set a clear-text password * password_pbkdf2:: Set a hashed password @@ -3545,6 +3547,34 @@ name syntax}), then list the contents of that directory. @end deffn +@node normal +@subsection normal + +@deffn Command normal [file] +Enter normal mode and display the GRUB menu. + +In normal mode, commands, filesystem modules, and cryptography modules are +automatically loaded, and the full GRUB script parser is available. Other +modules may be explicitly loaded using @command{insmod} (@pxref{insmod}). + +If a @var{file} is given, then commands will be read from that file. +Otherwise, they will be read from @file{$prefix/grub.cfg} if it exists. + +@command{normal} may be called from within normal mode, creating a nested +environment. It is more usual to use @command{configfile} +(@pxref{configfile}) for this. +@end deffn + + +@node normal_exit +@subsection normal_exit + +@deffn Command normal_exit +Exit normal mode (@pxref{normal}). If this instance of normal mode was not +nested within another one, then return to rescue mode. +@end deffn + + @node parttool @subsection parttool @@ -4082,7 +4112,7 @@ GRUB's normal start-up procedure involves setting the @samp{prefix} environment variable to a value set in the core image by @command{grub-install}, setting the @samp{root} variable to match, loading the @samp{normal} module from the prefix, and running the @samp{normal} -command. This command is responsible for reading +command (@pxref{normal}). This command is responsible for reading @file{/boot/grub/grub.cfg}, running the menu, and doing all the useful things GRUB is supposed to do. From 78fa584f67811a331de065dc1cca39e65a40b21e Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 13 Apr 2011 12:36:04 +0100 Subject: [PATCH 259/276] Rewrite /proc/self/mountinfo handling to cope with bind-mounts and move-mounts appearing out of order. Fixes Ubuntu bug #738345. * grub-core/kern/emu/getroot.c (find_root_device_from_mountinfo): Build a list of relevant visible mounts using the mnt_id and parent_mnt_id fields, and then scan that list at the end. --- ChangeLog | 9 ++++ grub-core/kern/emu/getroot.c | 100 ++++++++++++++++++++++++++++------- 2 files changed, 90 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1ee7cf9d..d0269c905 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-04-13 Colin Watson + + Rewrite /proc/self/mountinfo handling to cope with bind-mounts and + move-mounts appearing out of order. Fixes Ubuntu bug #738345. + + * grub-core/kern/emu/getroot.c (find_root_device_from_mountinfo): + Build a list of relevant visible mounts using the mnt_id and + parent_mnt_id fields, and then scan that list at the end. + 2011-04-12 Colin Watson * docs/grub.texi (normal): New section. diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index c4cbb9c18..17da9070f 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -98,6 +98,14 @@ xgetcwd (void) #ifdef __linux__ +struct mountinfo_entry +{ + int id; + int major, minor; + char enc_root[PATH_MAX], enc_path[PATH_MAX]; + char fstype[PATH_MAX], device[PATH_MAX]; +}; + /* Statting something on a btrfs filesystem always returns a virtual device major/minor pair rather than the real underlying device, because btrfs can span multiple underlying devices (and even if it's currently only @@ -112,6 +120,10 @@ grub_find_root_device_from_mountinfo (const char *dir, char **relroot) char *buf = NULL; size_t len = 0; char *ret = NULL; + int entry_len = 0, entry_max = 4; + struct mountinfo_entry *entries; + struct mountinfo_entry parent_entry = { 0, 0, 0, "", "", "", "" }; + int i; if (! *dir) dir = "/"; @@ -122,52 +134,102 @@ grub_find_root_device_from_mountinfo (const char *dir, char **relroot) if (! fp) return NULL; /* fall through to other methods */ + entries = xmalloc (entry_max * sizeof (*entries)); + + /* First, build a list of relevant visible mounts. */ while (getline (&buf, &len, fp) > 0) { - int mnt_id, parent_mnt_id; - unsigned int major, minor; - char enc_root[PATH_MAX], enc_path[PATH_MAX]; + struct mountinfo_entry entry; int count; size_t enc_path_len; const char *sep; - char fstype[PATH_MAX], device[PATH_MAX]; if (sscanf (buf, "%d %d %u:%u %s %s%n", - &mnt_id, &parent_mnt_id, &major, &minor, enc_root, enc_path, - &count) < 6) + &entry.id, &parent_entry.id, &entry.major, &entry.minor, + entry.enc_root, entry.enc_path, &count) < 6) continue; - enc_path_len = strlen (enc_path); + enc_path_len = strlen (entry.enc_path); /* Check that enc_path is a prefix of dir. The prefix must either be the entire string, or end with a slash, or be immediately followed by a slash. */ - if (strncmp (dir, enc_path, enc_path_len) != 0 || + if (strncmp (dir, entry.enc_path, enc_path_len) != 0 || (enc_path_len && dir[enc_path_len - 1] != '/' && dir[enc_path_len] && dir[enc_path_len] != '/')) continue; - /* This is a parent of the requested directory. /proc/self/mountinfo - is in mount order, so it must be the closest parent we've - encountered so far. If it's virtual, return its device node; - otherwise, carry on to try to find something closer. */ - - free (ret); - ret = NULL; - sep = strstr (buf + count, " - "); if (!sep) continue; sep += sizeof (" - ") - 1; - if (sscanf (sep, "%s %s", fstype, device) != 2) + if (sscanf (sep, "%s %s", entry.fstype, entry.device) != 2) continue; - ret = strdup (device); + /* Using the mount IDs, find out where this fits in the list of + visible mount entries we've seen so far. There are three + interesting cases. Firstly, it may be inserted at the end: this is + the usual case of /foo/bar being mounted after /foo. Secondly, it + may be inserted at the start: for example, this can happen for + filesystems that are mounted before / and later moved under it. + Thirdly, it may occlude part or all of the existing filesystem + tree, in which case the end of the list needs to be pruned and this + new entry will be inserted at the end. */ + if (entry_len >= entry_max) + { + entry_max <<= 1; + entries = xrealloc (entries, entry_max * sizeof (*entries)); + } + + if (!entry_len) + { + /* Initialise list. */ + entry_len = 2; + entries[0] = parent_entry; + entries[1] = entry; + } + else + { + for (i = entry_len - 1; i >= 0; i--) + { + if (entries[i].id == parent_entry.id) + { + /* Insert at end, pruning anything previously above this. */ + entry_len = i + 2; + entries[i + 1] = entry; + break; + } + else if (i == 0 && entries[i].id == entry.id) + { + /* Insert at start. */ + entry_len++; + memmove (entries + 1, entries, + (entry_len - 1) * sizeof (*entries)); + entries[0] = parent_entry; + entries[1] = entry; + break; + } + } + } + } + + /* Now scan visible mounts for the ones we're interested in. */ + for (i = entry_len - 1; i >= 0; i--) + { + if (entries[i].major != 0) + continue; /* not a virtual device */ + + if (!*entries[i].device) + continue; + + ret = strdup (entries[i].device); if (relroot) - *relroot = strdup (enc_root); + *relroot = strdup (entries[i].enc_root); + break; } free (buf); + free (entries); fclose (fp); return ret; } From e74c31125d2466db7d5a190f924b1abee6094947 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 13 Apr 2011 12:57:26 +0100 Subject: [PATCH 260/276] * util/grub.d/10_linux.in: Add rootflags=subvol= if / is on a btrfs subvolume. * util/grub.d/20_linux_xen.in: Likewise. --- ChangeLog | 6 ++++++ util/grub.d/10_linux.in | 8 ++++++++ util/grub.d/20_linux_xen.in | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index d0269c905..47935890d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-13 Colin Watson + + * util/grub.d/10_linux.in: Add rootflags=subvol= if / is on a + btrfs subvolume. + * util/grub.d/20_linux_xen.in: Likewise. + 2011-04-13 Colin Watson Rewrite /proc/self/mountinfo handling to cope with bind-mounts and diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 930ce06ef..1dbcad90c 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -51,6 +51,14 @@ else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} fi +if [ "x`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`" = xbtrfs ]; then + rootsubvol="`make_system_path_relative_to_its_root /`" + rootsubvol="${rootsubvol#/}" + if [ "x${rootsubvol}" != x ]; then + GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" + fi +fi + linux_entry () { os="$1" diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 858627aa3..a9007603d 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -51,6 +51,14 @@ else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} fi +if [ "x`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`" = xbtrfs ]; then + rootsubvol="`make_system_path_relative_to_its_root /`" + rootsubvol="${rootsubvol#/}" + if [ "x${rootsubvol}" != x ]; then + GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" + fi +fi + linux_entry () { os="$1" From e03f7bea4526068566c7c305e90b4614132129dc Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 16 Apr 2011 09:16:44 +0200 Subject: [PATCH 261/276] * grub-core/gfxmenu/gui_image.c (rescale_image): Don't attempt to scale to negative size. --- ChangeLog | 5 +++++ grub-core/gfxmenu/gui_image.c | 17 ++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47935890d..572d49a13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-16 Vladimir Serbinenko + + * grub-core/gfxmenu/gui_image.c (rescale_image): Don't attempt to scale + to negative size. + 2011-04-13 Colin Watson * util/grub.d/10_linux.in: Add rootflags=subvol= if / is on a diff --git a/grub-core/gfxmenu/gui_image.c b/grub-core/gfxmenu/gui_image.c index 3988f4ba8..60e4a46de 100644 --- a/grub-core/gfxmenu/gui_image.c +++ b/grub-core/gfxmenu/gui_image.c @@ -101,6 +101,9 @@ image_get_parent (void *vself) static grub_err_t rescale_image (grub_gui_image_t self) { + signed width; + signed height; + if (! self->raw_bitmap) { if (self->bitmap) @@ -111,12 +114,12 @@ rescale_image (grub_gui_image_t self) return grub_errno; } - unsigned width = self->bounds.width; - unsigned height = self->bounds.height; + width = self->bounds.width; + height = self->bounds.height; if (self->bitmap - && (grub_video_bitmap_get_width (self->bitmap) == width) - && (grub_video_bitmap_get_height (self->bitmap) == height)) + && ((signed) grub_video_bitmap_get_width (self->bitmap) == width) + && ((signed) grub_video_bitmap_get_height (self->bitmap) == height)) { /* Nothing to do; already the right size. */ return grub_errno; @@ -131,15 +134,15 @@ rescale_image (grub_gui_image_t self) /* Create a scaled bitmap, unless the requested size is the same as the raw size -- in that case a reference is made. */ - if (grub_video_bitmap_get_width (self->raw_bitmap) == width - && grub_video_bitmap_get_height (self->raw_bitmap) == height) + if ((signed) grub_video_bitmap_get_width (self->raw_bitmap) == width + && (signed) grub_video_bitmap_get_height (self->raw_bitmap) == height) { self->bitmap = self->raw_bitmap; return grub_errno; } /* Don't scale to an invalid size. */ - if (width == 0 || height == 0) + if (width <= 0 || height <= 0) return grub_errno; /* Create the scaled bitmap. */ From 50d2cc5ae5712101b2307d5b8df2d1e05a63ea41 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 16 Apr 2011 15:27:35 +0200 Subject: [PATCH 262/276] Identify RAID by its UUID rather than (guessed) name. * grub-core/disk/raid.c (ascii2hex): New function. (grub_raid_open): Accept mduuid/%s specification. * grub-core/kern/emu/getroot.c (get_mdadm_name): Revamped into ... (get_mdadm_uuid): ... this. (grub_util_get_grub_dev): Use mduuid/%s if UUID is available. --- ChangeLog | 10 +++++++++ grub-core/disk/raid.c | 39 ++++++++++++++++++++++++++++---- grub-core/kern/emu/getroot.c | 43 ++++++++++++++---------------------- 3 files changed, 62 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 572d49a13..84840a9a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-04-17 Vladimir Serbinenko + + Identify RAID by its UUID rather than (guessed) name. + + * grub-core/disk/raid.c (ascii2hex): New function. + (grub_raid_open): Accept mduuid/%s specification. + * grub-core/kern/emu/getroot.c (get_mdadm_name): Revamped into ... + (get_mdadm_uuid): ... this. + (grub_util_get_grub_dev): Use mduuid/%s if UUID is available. + 2011-04-16 Vladimir Serbinenko * grub-core/gfxmenu/gui_image.c (rescale_image): Don't attempt to scale diff --git a/grub-core/disk/raid.c b/grub-core/disk/raid.c index 3c74bba99..946e6d2c2 100644 --- a/grub-core/disk/raid.c +++ b/grub-core/disk/raid.c @@ -122,18 +122,49 @@ grub_raid_getname (struct grub_disk *disk) } #endif +static inline int +ascii2hex (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 0; +} + static grub_err_t grub_raid_open (const char *name, grub_disk_t disk) { struct grub_raid_array *array; unsigned n; - for (array = array_list; array != NULL; array = array->next) + if (grub_memcmp (name, "mduuid/", sizeof ("mduuid/") - 1) == 0) { - if (!grub_strcmp (array->name, name)) - if (grub_is_array_readable (array)) - break; + const char *uuidstr = name + sizeof ("mduuid/") - 1; + grub_size_t uuid_len = grub_strlen (uuidstr) / 2; + grub_uint8_t uuidbin[uuid_len]; + unsigned i; + for (i = 0; i < uuid_len; i++) + uuidbin[i] = ascii2hex (uuidstr[2 * i + 1]) + | (ascii2hex (uuidstr[2 * i]) << 4); + + for (array = array_list; array != NULL; array = array->next) + { + if (uuid_len == (unsigned) array->uuid_len + && grub_memcmp (uuidbin, array->uuid, uuid_len) == 0) + if (grub_is_array_readable (array)) + break; + } } + else + for (array = array_list; array != NULL; array = array->next) + { + if (!grub_strcmp (array->name, name)) + if (grub_is_array_readable (array)) + break; + } if (!array) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown RAID device %s", diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index 17da9070f..f836a6625 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -690,7 +690,7 @@ grub_util_get_dev_abstraction (const char *os_dev __attribute__((unused))) #ifdef __linux__ static char * -get_mdadm_name (const char *os_dev) +get_mdadm_uuid (const char *os_dev) { int mdadm_pipe[2]; pid_t mdadm_pid; @@ -742,19 +742,21 @@ get_mdadm_name (const char *os_dev) while (getline (&buf, &len, mdadm) > 0) { - if (strncmp (buf, "MD_NAME=", sizeof ("MD_NAME=") - 1) == 0) + if (strncmp (buf, "MD_UUID=", sizeof ("MD_UUID=") - 1) == 0) { - char *name_start, *colon; + char *name_start, *ptri, *ptro; size_t name_len; free (name); - name_start = buf + sizeof ("MD_NAME=") - 1; - /* Strip off the homehost if present. */ - colon = strchr (name_start, ':'); - name = strdup (colon ? colon + 1 : name_start); - name_len = strlen (name); - if (name[name_len - 1] == '\n') - name[name_len - 1] = '\0'; + name_start = buf + sizeof ("MD_UUID=") - 1; + ptro = name = xmalloc (strlen (name_start) + 1); + for (ptri = name_start; *ptri && *ptri != '\n' && *ptri != '\r'; + ptri++) + if ((*ptri >= '0' && *ptri <= '9') + || (*ptri >= 'a' && *ptri <= 'f') + || (*ptri >= 'A' && *ptri <= 'F')) + *ptro++ = *ptri; + *ptro = 0; } } @@ -870,37 +872,26 @@ grub_util_get_grub_dev (const char *os_dev) #ifdef __linux__ { - char *mdadm_name = get_mdadm_name (os_dev); + char *mdadm_name = get_mdadm_uuid (os_dev); struct stat st; if (mdadm_name) { - char *newname; const char *q; for (q = os_dev + strlen (os_dev) - 1; q >= os_dev && grub_isdigit (*q); q--); if (q >= os_dev && *q == 'p') - { - newname = xasprintf ("/dev/md/%sp%s", mdadm_name, q + 1); - if (stat (newname, &st) == 0) - { - free (grub_dev); - grub_dev = xasprintf ("md/%s,%s", mdadm_name, q + 1); - goto done; - } - free (newname); - } - newname = xasprintf ("/dev/md/%s", mdadm_name); - if (stat (newname, &st) == 0) { free (grub_dev); - grub_dev = xasprintf ("md/%s", mdadm_name); + grub_dev = xasprintf ("mduuid/%s,%s", mdadm_name, q + 1); + goto done; } + free (grub_dev); + grub_dev = xasprintf ("mduuid/%s", mdadm_name); done: - free (newname); free (mdadm_name); } } From 9ac718b06128f3d55ebdd704cec668347e06af2b Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 16 Apr 2011 17:24:47 +0200 Subject: [PATCH 263/276] * Makefile.am (multiboot.elf): Add -Wl,--build-id=none. (kfreebsd.elf): Likewise. (pc-chainloader.elf): Likewise. (ntldr.elf): Likewise. --- ChangeLog | 7 +++++++ Makefile.am | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 84840a9a7..859f337ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-04-17 Vladimir Serbinenko + + * Makefile.am (multiboot.elf): Add -Wl,--build-id=none. + (kfreebsd.elf): Likewise. + (pc-chainloader.elf): Likewise. + (ntldr.elf): Likewise. + 2011-04-17 Vladimir Serbinenko Identify RAID by its UUID rather than (guessed) name. diff --git a/Makefile.am b/Makefile.am index 60e041a8d..9301c91a5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -147,28 +147,28 @@ linux.init.i386: $(srcdir)/grub-core/tests/boot/linux.init-i386.S $(TARGET_CC) -o $@ $< -m32 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" multiboot.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S - $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -DTARGET_MULTIBOOT=1 -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include + $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -DTARGET_MULTIBOOT=1 -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include kfreebsd.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S - $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include + $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include kfreebsd.aout: kfreebsd.elf $(OBJCOPY) -O a.out-i386-linux $< $@ -R .note.gnu.build-id pc-chainloader.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S - $(TARGET_CC) -o $@ $< -DTARGET_CHAINLOADER=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,-N -Wl,-Ttext,0x7c00 -m32 + $(TARGET_CC) -o $@ $< -DTARGET_CHAINLOADER=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x7c00 -m32 pc-chainloader.bin: pc-chainloader.elf $(OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn $< $@; ntldr.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S - $(TARGET_CC) -o $@ $< -DTARGET_NTLDR=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,-N -Wl,-Ttext,0 -m32 + $(TARGET_CC) -o $@ $< -DTARGET_NTLDR=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0 -m32 ntldr.bin: ntldr.elf $(OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn $< $@; multiboot2.elf: $(srcdir)/grub-core/tests/boot/kernel-i386.S - $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include -DTARGET_MULTIBOOT2=1 + $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include -DTARGET_MULTIBOOT2=1 kfreebsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kfreebsd.init-x86_64.S $(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" && freebsd-brandelf -t FreeBSD $@ From f3fb7b36df4c729f001bc245a64304a5a34e30d6 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 18 Apr 2011 09:31:13 +0200 Subject: [PATCH 264/276] * util/grub-mkimage.c (generate_image): Update fwstart.img hash after performing the necessary test. --- ChangeLog | 5 +++++ util/grub-mkimage.c | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 859f337ac..a29a5b694 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-18 Vladimir Serbinenko + + * util/grub-mkimage.c (generate_image): Update fwstart.img hash after + performing the necessary test. + 2011-04-17 Vladimir Serbinenko * Makefile.am (multiboot.elf): Add -Wl,--build-id=none. diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index 70c5ef6a9..c07f43af2 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -1174,14 +1174,16 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], sha512sum utility after compiling on Gnewsense. */ const grub_uint8_t fwstart_good_hash[] = - { 0x75, 0xbf, 0xa3, 0x0e, 0x7c, 0xd1, 0x03, 0x82, - 0xe1, 0x34, 0x55, 0xd7, 0x09, 0x1e, 0x6c, 0xcc, - 0xef, 0x08, 0x61, 0xc1, 0x3c, 0xd8, 0xc7, 0x9f, - 0xe8, 0x2d, 0x3d, 0xb2, 0xda, 0x41, 0xd3, 0x83, - 0xd7, 0xb8, 0xe3, 0xd7, 0x13, 0xec, 0x9b, 0xf6, - 0xf6, 0xae, 0x6b, 0x32, 0x29, 0xc1, 0x69, 0x82, - 0xfa, 0x65, 0x2d, 0x97, 0x3e, 0x83, 0x6e, 0x6c, - 0xce, 0x34, 0x10, 0x59, 0x74, 0x0e, 0x96, 0x26 }; + { + 0x9f, 0x7f, 0x79, 0x47, 0x68, 0x91, 0x61, 0xb3 + 0x16, 0x7b, 0xf0, 0x27, 0x1c, 0xf7, 0xaf, 0x05, + 0x6c, 0xc1, 0x6f, 0xd2, 0xe7, 0xd1, 0xe9, 0xec, + 0x08, 0x87, 0xe5, 0xc8, 0x29, 0xa2, 0x5b, 0x84, + 0xf8, 0xa6, 0xec, 0x08, 0xf7, 0xcb, 0x7b, 0x6c, + 0xfe, 0x01, 0xfd, 0x5d, 0xba, 0xbf, 0x0d, 0x0f, + 0x2e, 0xef, 0xed, 0x7b, 0xfe, 0xc9, 0x4a, 0x85, + 0xcf, 0xac, 0x20, 0xd7, 0x01, 0xc5, 0xc5, 0x9c + }; boot_path = grub_util_get_path (dir, "fwstart.img"); boot_size = grub_util_get_image_size (boot_path); From a5102d9433ca39c8f73615b757b2b35225c2d165 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 18 Apr 2011 17:47:21 +0200 Subject: [PATCH 265/276] * util/grub-mkimage.c (generate_image): Add forgotten comma. --- ChangeLog | 4 ++++ util/grub-mkimage.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a29a5b694..f9cfcdb46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-18 Vladimir Serbinenko + + * util/grub-mkimage.c (generate_image): Add forgotten comma. + 2011-04-18 Vladimir Serbinenko * util/grub-mkimage.c (generate_image): Update fwstart.img hash after diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index c07f43af2..2ba351596 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -1175,7 +1175,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], */ const grub_uint8_t fwstart_good_hash[] = { - 0x9f, 0x7f, 0x79, 0x47, 0x68, 0x91, 0x61, 0xb3 + 0x9f, 0x7f, 0x79, 0x47, 0x68, 0x91, 0x61, 0xb3, 0x16, 0x7b, 0xf0, 0x27, 0x1c, 0xf7, 0xaf, 0x05, 0x6c, 0xc1, 0x6f, 0xd2, 0xe7, 0xd1, 0xe9, 0xec, 0x08, 0x87, 0xe5, 0xc8, 0x29, 0xa2, 0x5b, 0x84, From 93a777e38840ad59105cd6552c9a787e61b6f338 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 18 Apr 2011 23:03:52 +0200 Subject: [PATCH 266/276] Complete 64-bit division support. * grub-core/kern/misc.c (grub_divmod64): Rename to ... (grub_divmod64_full): ... this. Support 64-bit divisor and reminder. * include/grub/misc.h (grub_divmod64): Rename to ... (grub_divmod64_full): ... this. (grub_divmod64): New inline function. --- ChangeLog | 10 ++++++++++ grub-core/kern/misc.c | 14 +++++++------- include/grub/misc.h | 16 ++++++++++++++-- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9cfcdb46..f46277405 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-04-18 Vladimir Serbinenko + + Complete 64-bit division support. + + * grub-core/kern/misc.c (grub_divmod64): Rename to ... + (grub_divmod64_full): ... this. Support 64-bit divisor and reminder. + * include/grub/misc.h (grub_divmod64): Rename to ... + (grub_divmod64_full): ... this. + (grub_divmod64): New inline function. + 2011-04-18 Vladimir Serbinenko * util/grub-mkimage.c (generate_image): Add forgotten comma. diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 37ce8decd..1b4cdec66 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -597,23 +597,23 @@ grub_reverse (char *str) /* Divide N by D, return the quotient, and store the remainder in *R. */ grub_uint64_t -grub_divmod64 (grub_uint64_t n, grub_uint32_t d, grub_uint32_t *r) +grub_divmod64_full (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) { /* This algorithm is typically implemented by hardware. The idea is to get the highest bit in N, 64 times, by keeping - upper(N * 2^i) = upper((Q * 10 + M) * 2^i), where upper + upper(N * 2^i) = (Q * D + M), where upper represents the high 64 bits in 128-bits space. */ unsigned bits = 64; - unsigned long long q = 0; - unsigned m = 0; + grub_uint64_t q = 0; + grub_uint64_t m = 0; /* Skip the slow computation if 32-bit arithmetic is possible. */ - if (n < 0xffffffff) + if (n < 0xffffffff && d < 0xffffffff) { if (r) - *r = ((grub_uint32_t) n) % d; + *r = ((grub_uint32_t) n) % (grub_uint32_t) d; - return ((grub_uint32_t) n) / d; + return ((grub_uint32_t) n) / (grub_uint32_t) d; } while (bits--) diff --git a/include/grub/misc.h b/include/grub/misc.h index 6fcaa148b..80588be33 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -287,8 +287,20 @@ char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...) char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) __attribute__ ((warn_unused_result)); void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn)); -grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, - grub_uint32_t d, grub_uint32_t *r); +grub_uint64_t EXPORT_FUNC(grub_divmod64_full) (grub_uint64_t n, + grub_uint64_t d, + grub_uint64_t *r); +static inline grub_uint64_t grub_divmod64 (grub_uint64_t n, + grub_uint32_t d, + grub_uint32_t *r) +{ + grub_uint64_t ret, rr; + + ret = grub_divmod64_full (n, d, &rr); + if (r) + *r = rr; + return ret; +} #if NEED_ENABLE_EXECUTE_STACK && !defined(GRUB_UTIL) void EXPORT_FUNC(__enable_execute_stack) (void *addr); From 34faa5955af9527d6d12cca5bf22b613b98586a0 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 18 Apr 2011 23:10:19 +0200 Subject: [PATCH 267/276] * grub-core/fs/btrfs.c (grub_btrfs_read_logical): Support huge chunks. * include/grub/err.h (grub_err_t): New enum value GRUB_ERR_BUG. --- ChangeLog | 6 ++++++ grub-core/fs/btrfs.c | 29 ++++++++++++++++++++--------- include/grub/err.h | 3 ++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index f46277405..676c374aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-18 Vladimir Serbinenko + + * grub-core/fs/btrfs.c (grub_btrfs_read_logical): Support huge + chunks. + * include/grub/err.h (grub_err_t): New enum value GRUB_ERR_BUG. + 2011-04-18 Vladimir Serbinenko Complete 64-bit division support. diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index bbb326b98..42aa257d9 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -588,7 +588,7 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_uint8_t *ptr; struct grub_btrfs_key *key; struct grub_btrfs_chunk_item *chunk; - grub_ssize_t csize; + grub_uint64_t csize; grub_err_t err; struct grub_btrfs_key key_out; int challoc = 0; @@ -648,11 +648,18 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, chunk_found: { grub_uint32_t stripen; - grub_uint32_t stripe_offset; + grub_uint64_t stripe_offset; grub_uint64_t off = addr - grub_le_to_cpu64 (key->offset); unsigned redundancy = 1; unsigned i, j; + if (grub_le_to_cpu64 (chunk->size) <= off) + { + grub_dprintf ("btrfs", "no chunk\n"); + return grub_error (GRUB_ERR_BAD_FS, + "couldn't find the chunk descriptor"); + } + grub_dprintf ("btrfs", "chunk 0x%" PRIxGRUB_UINT64_T "+0x%" PRIxGRUB_UINT64_T " (%d stripes (%d substripes) of %" @@ -668,17 +675,19 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, { case GRUB_BTRFS_CHUNK_TYPE_SINGLE: { - grub_uint32_t stripe_length; - stripe_length = grub_divmod64 (grub_le_to_cpu64 (chunk->size), - grub_le_to_cpu16 (chunk->nstripes), - NULL); - stripen = grub_divmod64 (off, stripe_length, &stripe_offset); + grub_uint64_t stripe_length; + grub_dprintf ("btrfs", "single\n"); + stripe_length = grub_divmod64_full (grub_le_to_cpu64 (chunk->size), + grub_le_to_cpu16 (chunk->nstripes), + NULL); + stripen = grub_divmod64_full (off, stripe_length, &stripe_offset); csize = (stripen + 1) * stripe_length - off; break; } case GRUB_BTRFS_CHUNK_TYPE_DUPLICATED: case GRUB_BTRFS_CHUNK_TYPE_RAID1: { + grub_dprintf ("btrfs", "RAID1\n"); stripen = 0; stripe_offset = off; csize = grub_le_to_cpu64 (chunk->size) - off; @@ -689,6 +698,7 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, { grub_uint64_t middle, high; grub_uint32_t low; + grub_dprintf ("btrfs", "RAID0\n"); middle = grub_divmod64 (off, grub_le_to_cpu64 (chunk->stripe_length), &low); @@ -721,12 +731,13 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, break; } default: + grub_dprintf ("btrfs", "unsupported RAID\n"); return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "unsupported RAID flags %" PRIxGRUB_UINT64_T, grub_le_to_cpu64 (chunk->type)); } - if (csize <= 0) - return grub_error (GRUB_ERR_BAD_FS, + if (csize == 0) + return grub_error (GRUB_ERR_BUG, "couldn't find the chunk descriptor"); if ((grub_size_t) csize > size) csize = size; diff --git a/include/grub/err.h b/include/grub/err.h index 22334038d..69bc6ec79 100644 --- a/include/grub/err.h +++ b/include/grub/err.h @@ -55,7 +55,8 @@ typedef enum GRUB_ERR_TIMEOUT, GRUB_ERR_IO, GRUB_ERR_ACCESS_DENIED, - GRUB_ERR_EXTRACTOR + GRUB_ERR_EXTRACTOR, + GRUB_ERR_BUG } grub_err_t; From e74b3947af1d11b8279706e07302ed0debe82779 Mon Sep 17 00:00:00 2001 From: Endres Puschner Date: Mon, 18 Apr 2011 23:24:41 +0200 Subject: [PATCH 268/276] * grub-core/gfxmenu/icon_manager.c (grub_gfxmenu_icon_manager_get_icon): Don't skip first class. --- ChangeLog | 5 +++++ grub-core/gfxmenu/icon_manager.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 676c374aa..8c00f7849 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-18 Endres Puschner + + * grub-core/gfxmenu/icon_manager.c (grub_gfxmenu_icon_manager_get_icon): + Don't skip first class. + 2011-04-18 Vladimir Serbinenko * grub-core/fs/btrfs.c (grub_btrfs_read_logical): Support huge diff --git a/grub-core/gfxmenu/icon_manager.c b/grub-core/gfxmenu/icon_manager.c index 0c304ede0..6990d05d4 100644 --- a/grub-core/gfxmenu/icon_manager.c +++ b/grub-core/gfxmenu/icon_manager.c @@ -257,7 +257,7 @@ grub_gfxmenu_icon_manager_get_icon (grub_gfxmenu_icon_manager_t mgr, /* Try each class in succession. */ icon = 0; - for (c = entry->classes->next; c && ! icon; c = c->next) + for (c = entry->classes; c && ! icon; c = c->next) icon = get_icon_by_class (mgr, c->name); return icon; } From abc474ef4bb79cd21e5510c302309ab87008ef65 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 19 Apr 2011 00:44:53 +0200 Subject: [PATCH 269/276] Take into account the decorations the computing menu entry width. * grub-core/gfxmenu/widget-box.c (get_border_width): New function. (grub_gfxmenu_create_box): Register get_border_width. * grub-core/gfxmenu/gui_list.c (draw_menu): Use get_border_width if available. * include/grub/gfxwidgets.h (grub_gfxmenu_box): New member get_border_width. --- ChangeLog | 11 +++++++++++ grub-core/gfxmenu/gui_list.c | 6 ++++-- grub-core/gfxmenu/widget-box.c | 9 +++++++++ include/grub/gfxwidgets.h | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c00f7849..79d868f86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-04-19 Vladimir Serbinenko + + Take into account the decorations the computing menu entry width. + + * grub-core/gfxmenu/widget-box.c (get_border_width): New function. + (grub_gfxmenu_create_box): Register get_border_width. + * grub-core/gfxmenu/gui_list.c (draw_menu): Use get_border_width + if available. + * include/grub/gfxwidgets.h (grub_gfxmenu_box): New member + get_border_width. + 2011-04-18 Endres Puschner * grub-core/gfxmenu/icon_manager.c (grub_gfxmenu_icon_manager_get_icon): diff --git a/grub-core/gfxmenu/gui_list.c b/grub-core/gfxmenu/gui_list.c index b6b07dfd6..e5d6fc2a1 100644 --- a/grub-core/gfxmenu/gui_list.c +++ b/grub-core/gfxmenu/gui_list.c @@ -248,8 +248,10 @@ draw_menu (list_impl_t self, int num_shown_items) if (is_selected) { - selbox->set_content_size (selbox, oviewport.width - 2 * boxpad - 2, - item_height - 1); + int cwidth = oviewport.width - 2 * boxpad - 2; + if (selbox->get_border_width) + cwidth -= selbox->get_border_width (selbox); + selbox->set_content_size (selbox, cwidth, item_height - 1); selbox->draw (selbox, 0, item_top - sel_toppad); } diff --git a/grub-core/gfxmenu/widget-box.c b/grub-core/gfxmenu/widget-box.c index 244fe1e6c..41ca7f536 100644 --- a/grub-core/gfxmenu/widget-box.c +++ b/grub-core/gfxmenu/widget-box.c @@ -178,6 +178,13 @@ set_content_size (grub_gfxmenu_box_t self, return; } +static int +get_border_width (grub_gfxmenu_box_t self) +{ + return (get_width (self->raw_pixmaps[BOX_PIXMAP_E]) + + get_width (self->raw_pixmaps[BOX_PIXMAP_W])); +} + static int get_left_pad (grub_gfxmenu_box_t self) { @@ -288,6 +295,8 @@ grub_gfxmenu_create_box (const char *pixmaps_prefix, box->draw = draw; box->set_content_size = set_content_size; + box->get_border_width = get_border_width; + box->get_left_pad = get_left_pad; box->get_top_pad = get_top_pad; box->get_right_pad = get_right_pad; diff --git a/include/grub/gfxwidgets.h b/include/grub/gfxwidgets.h index f9678bf9e..8ce666c5c 100644 --- a/include/grub/gfxwidgets.h +++ b/include/grub/gfxwidgets.h @@ -36,6 +36,7 @@ struct grub_gfxmenu_box void (*draw) (grub_gfxmenu_box_t self, int x, int y); void (*set_content_size) (grub_gfxmenu_box_t self, int width, int height); + int (*get_border_width) (grub_gfxmenu_box_t self); int (*get_left_pad) (grub_gfxmenu_box_t self); int (*get_top_pad) (grub_gfxmenu_box_t self); int (*get_right_pad) (grub_gfxmenu_box_t self); From bba79a1502b433c013ac034ed931da93f30802d4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 19 Apr 2011 22:31:50 +0200 Subject: [PATCH 270/276] * grub-core/term/gfxterm.c (grub_gfxterm_fullscreen): Preserve previous bitmap. (grub_gfxterm_term_init): Likewise. --- ChangeLog | 6 ++++++ grub-core/term/gfxterm.c | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79d868f86..2eade534d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-19 Vladimir Serbinenko + + * grub-core/term/gfxterm.c (grub_gfxterm_fullscreen): Preserve previous + bitmap. + (grub_gfxterm_term_init): Likewise. + 2011-04-19 Vladimir Serbinenko Take into account the decorations the computing menu entry width. diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c index 0ade65f27..e58d6722d 100644 --- a/grub-core/term/gfxterm.c +++ b/grub-core/term/gfxterm.c @@ -345,7 +345,6 @@ grub_gfxterm_fullscreen (void) grub_video_swap_buffers (); grub_video_fill_rect (color, 0, 0, mode_info.width, mode_info.height); } - bitmap = 0; /* Select the font to use. */ font_name = grub_env_get ("gfxterm_font"); @@ -394,12 +393,6 @@ grub_gfxterm_term_init (struct grub_term_output *term __attribute__ ((unused))) static void destroy_window (void) { - if (bitmap) - { - grub_video_bitmap_destroy (bitmap); - bitmap = 0; - } - repaint_callback = 0; grub_virtual_screen_free (); } From e8f28d4c0e8af4103e50776a0614cd2c73a98136 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 19 Apr 2011 22:39:14 +0200 Subject: [PATCH 271/276] * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_flush): New function. (grub_util_biosdisk_close): Use grub_util_biosdisk_flush. * include/grub/emu/hostdisk.h (grub_util_biosdisk_flush): New proto. * util/grub-setup.c (setup): Use grub_util_biosdisk_flush. --- ChangeLog | 8 ++++++++ grub-core/kern/emu/hostdisk.c | 29 ++++++++++++++++++++++------- include/grub/emu/hostdisk.h | 1 + util/grub-setup.c | 10 ++++------ 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2eade534d..1eff73ca3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-04-19 Vladimir Serbinenko + + * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_flush): + New function. + (grub_util_biosdisk_close): Use grub_util_biosdisk_flush. + * include/grub/emu/hostdisk.h (grub_util_biosdisk_flush): New proto. + * util/grub-setup.c (setup): Use grub_util_biosdisk_flush. + 2011-04-19 Vladimir Serbinenko * grub-core/term/gfxterm.c (grub_gfxterm_fullscreen): Preserve previous diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index f01e21aa0..63bca37ee 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -945,6 +945,27 @@ grub_util_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector, return grub_errno; } +grub_err_t +grub_util_biosdisk_flush (struct grub_disk *disk) +{ + struct grub_util_biosdisk_data *data = disk->data; + + if (disk->dev->id != GRUB_DISK_DEVICE_BIOSDISK_ID) + return GRUB_ERR_NONE; + if (data->fd == -1) + { + data->fd = open_device (disk, 0, O_RDONLY); + if (data->fd < 0) + return grub_errno; + } + fsync (data->fd); +#ifdef __linux__ + if (data->is_disk) + ioctl (data->fd, BLKFLSBUF, 0); +#endif + return GRUB_ERR_NONE; +} + static void grub_util_biosdisk_close (struct grub_disk *disk) { @@ -954,13 +975,7 @@ grub_util_biosdisk_close (struct grub_disk *disk) if (data->fd != -1) { if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY) - { - fsync (data->fd); -#ifdef __linux__ - if (data->is_disk) - ioctl (data->fd, BLKFLSBUF, 0); -#endif - } + grub_util_biosdisk_flush (disk); close (data->fd); } free (data); diff --git a/include/grub/emu/hostdisk.h b/include/grub/emu/hostdisk.h index d8cc02e14..842dff496 100644 --- a/include/grub/emu/hostdisk.h +++ b/include/grub/emu/hostdisk.h @@ -28,5 +28,6 @@ char *grub_util_biosdisk_get_grub_dev (const char *os_dev); const char *grub_util_biosdisk_get_osdev (grub_disk_t disk); int grub_util_biosdisk_is_present (const char *name); int grub_util_biosdisk_is_floppy (grub_disk_t disk); +grub_err_t grub_util_biosdisk_flush (struct grub_disk *disk); #endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */ diff --git a/util/grub-setup.c b/util/grub-setup.c index ed2d63fdd..7d47fa654 100644 --- a/util/grub-setup.c +++ b/util/grub-setup.c @@ -520,9 +520,7 @@ unable_to_embed: core_path_dev = grub_make_system_path_relative_to_its_root (core_path_dev_full); free (core_path_dev_full); - /* It is a Good Thing to sync two times. */ - sync (); - sync (); + grub_util_biosdisk_flush (root_dev->disk); #define MAX_TRIES 5 @@ -583,7 +581,7 @@ unable_to_embed: grub_util_info ("error message = %s", grub_errmsg); grub_errno = GRUB_ERR_NONE; - sync (); + grub_util_biosdisk_flush (root_dev->disk); sleep (1); } @@ -674,8 +672,8 @@ unable_to_embed: grub_util_error ("%s", grub_errmsg); - /* Sync is a Good Thing. */ - sync (); + grub_util_biosdisk_flush (root_dev->disk); + grub_util_biosdisk_flush (dest_dev->disk); free (core_path); free (core_img); From 0624551c2286f9ce94f6c9a24a66da6f60dbe08b Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 20 Apr 2011 01:32:21 +0200 Subject: [PATCH 272/276] * grub-core/lib/efi/datetime.c: Add missing GRUB_MOD_LICENSE. * grub-core/lib/efi/datetime.c: Likewise. --- ChangeLog | 5 +++++ grub-core/lib/efi/datetime.c | 3 +++ grub-core/lib/ieee1275/datetime.c | 3 +++ 3 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1eff73ca3..877186e23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-20 Vladimir Serbinenko + + * grub-core/lib/efi/datetime.c: Add missing GRUB_MOD_LICENSE. + * grub-core/lib/efi/datetime.c: Likewise. + 2011-04-19 Vladimir Serbinenko * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_flush): diff --git a/grub-core/lib/efi/datetime.c b/grub-core/lib/efi/datetime.c index 0a91c345a..0fd1b5fbd 100644 --- a/grub-core/lib/efi/datetime.c +++ b/grub-core/lib/efi/datetime.c @@ -22,6 +22,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); grub_err_t grub_get_datetime (struct grub_datetime *datetime) diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c index 7e6f8d1f1..4105c639b 100644 --- a/grub-core/lib/ieee1275/datetime.c +++ b/grub-core/lib/ieee1275/datetime.c @@ -20,6 +20,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); static char *rtc = 0; From d97e7b5935896a7c5bfe0592385bf19a77f97560 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 20 Apr 2011 01:37:48 +0200 Subject: [PATCH 273/276] * include/grub/dl.h [ASM_FILE]: Adapt for assembly. * grub-core/lib/i386/setjmp.S: Add missing GRUB_MOD_LICENSE. * grub-core/lib/x86_64/setjmp.S: Likewise. * grub-core/lib/mips/setjmp.S: Likewise. * grub-core/lib/powerpc/setjmp.S: Likewise. * grub-core/lib/sparc64/setjmp.S: Likewise. --- ChangeLog | 9 +++++++++ grub-core/lib/i386/setjmp.S | 3 +++ grub-core/lib/mips/setjmp.S | 3 +++ grub-core/lib/powerpc/setjmp.S | 3 +++ grub-core/lib/sparc64/setjmp.S | 3 +++ grub-core/lib/x86_64/setjmp.S | 3 +++ include/grub/dl.h | 31 ++++++++++++++++++++++++++++--- 7 files changed, 52 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 877186e23..c78ae8cab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-04-20 Vladimir Serbinenko + + * include/grub/dl.h [ASM_FILE]: Adapt for assembly. + * grub-core/lib/i386/setjmp.S: Add missing GRUB_MOD_LICENSE. + * grub-core/lib/x86_64/setjmp.S: Likewise. + * grub-core/lib/mips/setjmp.S: Likewise. + * grub-core/lib/powerpc/setjmp.S: Likewise. + * grub-core/lib/sparc64/setjmp.S: Likewise. + 2011-04-20 Vladimir Serbinenko * grub-core/lib/efi/datetime.c: Add missing GRUB_MOD_LICENSE. diff --git a/grub-core/lib/i386/setjmp.S b/grub-core/lib/i386/setjmp.S index a2002ae3d..5b7aa158b 100644 --- a/grub-core/lib/i386/setjmp.S +++ b/grub-core/lib/i386/setjmp.S @@ -17,9 +17,12 @@ */ #include +#include .file "setjmp.S" +GRUB_MOD_LICENSE ("GPLv3+") + .text /* diff --git a/grub-core/lib/mips/setjmp.S b/grub-core/lib/mips/setjmp.S index 8ab6222c4..8259c9d22 100644 --- a/grub-core/lib/mips/setjmp.S +++ b/grub-core/lib/mips/setjmp.S @@ -17,9 +17,12 @@ */ #include +#include .file "setjmp.S" +GRUB_MOD_LICENSE ("GPLv3+") + .text /* diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S index 25cbaa3e9..8c7540e3c 100644 --- a/grub-core/lib/powerpc/setjmp.S +++ b/grub-core/lib/powerpc/setjmp.S @@ -17,9 +17,12 @@ */ #include +#include .file "setjmp.S" +GRUB_MOD_LICENSE ("GPLv3+") + .text /* diff --git a/grub-core/lib/sparc64/setjmp.S b/grub-core/lib/sparc64/setjmp.S index 0e23ecfa1..5c2ec2cf3 100644 --- a/grub-core/lib/sparc64/setjmp.S +++ b/grub-core/lib/sparc64/setjmp.S @@ -17,9 +17,12 @@ */ #include +#include .file "setjmp.S" +GRUB_MOD_LICENSE ("GPLv3+") + .text /* diff --git a/grub-core/lib/x86_64/setjmp.S b/grub-core/lib/x86_64/setjmp.S index 621b09b93..b1f1b22cb 100644 --- a/grub-core/lib/x86_64/setjmp.S +++ b/grub-core/lib/x86_64/setjmp.S @@ -17,9 +17,12 @@ */ #include +#include .file "setjmp.S" +GRUB_MOD_LICENSE ("GPLv3+") + .text /* diff --git a/include/grub/dl.h b/include/grub/dl.h index 71db90c8b..6f23f7d63 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -21,15 +21,18 @@ #define GRUB_DL_H 1 #include +#ifndef ASM_FILE #include #include #include +#endif /* * Macros GRUB_MOD_INIT and GRUB_MOD_FINI are also used by build rules * to collect module names, so we define them only when they are not * defined already. */ +#ifndef ASM_FILE #ifndef GRUB_MOD_INIT #define GRUB_MOD_INIT(name) \ @@ -66,10 +69,20 @@ __asm__ (".section .moddeps\n.asciz \"" #name "\"\n") #endif +#endif + +#ifndef ASM_FILE #ifdef APPLE_CC -#define GRUB_MOD_SECTION(x) "_" x ", _" x "" +#define GRUB_MOD_SECTION(x) "_" #x ", _" #x "" #else -#define GRUB_MOD_SECTION(x) "." x +#define GRUB_MOD_SECTION(x) "." #x +#endif +#else +#ifdef APPLE_CC +#define GRUB_MOD_SECTION(x) _ ## x , _ ##x +#else +#define GRUB_MOD_SECTION(x) . ## x +#endif #endif /* Me, Vladimir Serbinenko, hereby I add this module check as per new @@ -80,8 +93,16 @@ __asm__ (".section .moddeps\n.asciz \"" #name "\"\n") constitutes linking) and GRUB core being licensed under GPLv3+. Be sure to understand your license obligations. */ +#ifndef ASM_FILE #define GRUB_MOD_LICENSE(license) \ - static char grub_module_license[] __attribute__ ((section (GRUB_MOD_SECTION ("module_license")), used)) = "LICENSE=" license; + static char grub_module_license[] __attribute__ ((section (GRUB_MOD_SECTION (module_license)), used)) = "LICENSE=" license; +#else +#define GRUB_MOD_LICENSE(license) \ + .section GRUB_MOD_SECTION(module_license), "a"; \ + .ascii "LICENSE="; \ + .ascii license; \ + .byte 0 +#endif /* Under GPL license obligations you have to distribute your module under GPLv3(+). However, you can also distribute the same code under @@ -89,6 +110,8 @@ __asm__ (".section .moddeps\n.asciz \"" #name "\"\n") */ #define GRUB_MOD_DUAL_LICENSE(x) +#ifndef ASM_FILE + struct grub_dl_segment { struct grub_dl_segment *next; @@ -143,4 +166,6 @@ grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr); void grub_arch_dl_init_linker (void); #endif +#endif + #endif /* ! GRUB_DL_H */ From 9b710a888e80862a18449bc9b5a31e2148da56c6 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 20 Apr 2011 09:23:55 +0200 Subject: [PATCH 274/276] * configure.ac: Bump version to 1.99~rc2. --- ChangeLog | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c78ae8cab..083d22ec5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-04-20 Vladimir Serbinenko + + * configure.ac: Bump version to 1.99~rc2. + 2011-04-20 Vladimir Serbinenko * include/grub/dl.h [ASM_FILE]: Adapt for assembly. diff --git a/configure.ac b/configure.ac index f9e974bca..811bd992d 100644 --- a/configure.ac +++ b/configure.ac @@ -32,7 +32,7 @@ dnl type, so there is no conflict. Variables with the prefix "TARGET_" dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target dnl type. -AC_INIT([GRUB],[1.99~rc1],[bug-grub@gnu.org]) +AC_INIT([GRUB],[1.99~rc2],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) From b13f79a427b6ae6c1405c48b8cf57a1e99de16f9 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 21 Apr 2011 00:07:22 +0100 Subject: [PATCH 275/276] Fix stack pointer handling in 16-bit relocator. * grub-core/lib/i386/relocator16.S (grub_relocator16_start): Move grub_relocator16_sp to %esp rather than %ss, and zero-extend it. Fixes Ubuntu bug #683904. --- ChangeLog | 8 ++++++++ grub-core/lib/i386/relocator16.S | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 083d22ec5..98d3b0ea8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-04-21 Colin Watson + + Fix stack pointer handling in 16-bit relocator. + + * grub-core/lib/i386/relocator16.S (grub_relocator16_start): Move + grub_relocator16_sp to %esp rather than %ss, and zero-extend it. + Fixes Ubuntu bug #683904. + 2011-04-20 Vladimir Serbinenko * configure.ac: Bump version to 1.99~rc2. diff --git a/grub-core/lib/i386/relocator16.S b/grub-core/lib/i386/relocator16.S index c3768f4eb..982415de4 100644 --- a/grub-core/lib/i386/relocator16.S +++ b/grub-core/lib/i386/relocator16.S @@ -130,7 +130,7 @@ VARIABLE(grub_relocator16_ss) .byte 0xb8 VARIABLE(grub_relocator16_sp) .word 0 - movw %ax, %ss + movzwl %ax, %esp /* movw imm32, %edx. */ .byte 0x66, 0xba From 92051871b736cde73d8755b3e29781a677ee362c Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 21 Apr 2011 10:26:29 +0100 Subject: [PATCH 276/276] * grub-core/kern/emu/getroot.c (grub_find_root_device_from_mountinfo): Remove non-virtual-device test that was incorrectly reintroduced in r3214. Reported by: Ian Dall. Fixes Savannah bug #33133. --- ChangeLog | 7 +++++++ grub-core/kern/emu/getroot.c | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98d3b0ea8..1142cf81d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-04-21 Colin Watson + + * grub-core/kern/emu/getroot.c + (grub_find_root_device_from_mountinfo): Remove non-virtual-device + test that was incorrectly reintroduced in r3214. + Reported by: Ian Dall. Fixes Savannah bug #33133. + 2011-04-21 Colin Watson Fix stack pointer handling in 16-bit relocator. diff --git a/grub-core/kern/emu/getroot.c b/grub-core/kern/emu/getroot.c index f836a6625..a274f3c06 100644 --- a/grub-core/kern/emu/getroot.c +++ b/grub-core/kern/emu/getroot.c @@ -216,9 +216,6 @@ grub_find_root_device_from_mountinfo (const char *dir, char **relroot) /* Now scan visible mounts for the ones we're interested in. */ for (i = entry_len - 1; i >= 0; i--) { - if (entries[i].major != 0) - continue; /* not a virtual device */ - if (!*entries[i].device) continue;