From 27610c3836e79f8c8d8838b8f3121924a9e60500 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 8 Nov 2011 19:34:19 +0100 Subject: [PATCH 01/40] Fix FreeBSD compilation. * grub-core/disk/geli.c (GRUB_MD_SHA256) [GRUB_UTIL]: Redefine in a way to avoid circular dependency. (GRUB_MD_SHA512) [GRUB_UTIL]: Likewise. * util/getroot.c (grub_util_follow_gpart_up): Move from here... * grub-core/kern/emu/hostdisk.c (+grub_util_follow_gpart_up): ... here. --- ChangeLog | 10 +++++++ grub-core/disk/geli.c | 32 +++++++++++++++++++++ grub-core/kern/emu/hostdisk.c | 53 +++++++++++++++++++++++++++++++++++ util/getroot.c | 50 --------------------------------- 4 files changed, 95 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 194bd13fa..925b798bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-11-08 Vladimir Serbinenko + + Fix FreeBSD compilation. + + * grub-core/disk/geli.c (GRUB_MD_SHA256) [GRUB_UTIL]: Redefine in a way + to avoid circular dependency. + (GRUB_MD_SHA512) [GRUB_UTIL]: Likewise. + * util/getroot.c (grub_util_follow_gpart_up): Move from here... + * grub-core/kern/emu/hostdisk.c (+grub_util_follow_gpart_up): ... here. + 2011-11-08 Vladimir Serbinenko Fix ZFS crypto error types. diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c index d2ae5da56..ab94b4131 100644 --- a/grub-core/disk/geli.c +++ b/grub-core/disk/geli.c @@ -58,6 +58,38 @@ GRUB_MOD_LICENSE ("GPLv3+"); +/* Dirty trick to solve circular dependency. */ +#ifdef GRUB_UTIL + +#include + +#undef GRUB_MD_SHA256 +#undef GRUB_MD_SHA512 + +static const gcry_md_spec_t * +grub_md_sha256_real (void) +{ + const gcry_md_spec_t *ret; + ret = grub_crypto_lookup_md_by_name ("sha256"); + if (!ret) + grub_util_error ("Coulnd't load sha256"); + return ret; +} + +static const gcry_md_spec_t * +grub_md_sha512_real (void) +{ + const gcry_md_spec_t *ret; + ret = grub_crypto_lookup_md_by_name ("sha512"); + if (!ret) + grub_util_error ("Coulnd't load sha512"); + return ret; +} + +#define GRUB_MD_SHA256 grub_md_sha256_real() +#define GRUB_MD_SHA512 grub_md_sha512_real() +#endif + struct grub_geli_key { grub_uint8_t iv_key[64]; diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 7074fa8c1..7bfc66fef 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -94,6 +94,8 @@ struct hd_geometry # include /* DIOCGMEDIASIZE */ # include # include +# include +#include # define MAJOR(dev) major(dev) # define FLOPPY_MAJOR 2 #endif @@ -423,8 +425,59 @@ grub_util_device_is_mapped (const char *dev) #endif /* HAVE_DEVICE_MAPPER */ } + #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) +/* FIXME: geom actually gives us the whole container hierarchy. + It can be used more efficiently than this. */ +void +grub_util_follow_gpart_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); + + grub_util_follow_gpart_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) { diff --git a/util/getroot.c b/util/getroot.c index 8fce283bc..41fbdec10 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -790,56 +790,6 @@ grub_util_get_dm_abstraction (const char *os_dev) #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) #include -/* FIXME: geom actually gives us the whole container hierarchy. - It can be used more efficiently than this. */ -void -grub_util_follow_gpart_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); - - grub_util_follow_gpart_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 const char * grub_util_get_geom_abstraction (const char *dev) { From 3ae17eb83c25cd9b82a8e49a3235168661d8cdbe Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 8 Nov 2011 19:44:18 +0100 Subject: [PATCH 02/40] Fix potential problem with calling zfs_to_cpu and cpu_to_be in a row. * grub-core/fs/zfs/zfscrypt.c (grub_zfs_decrypt_real): Use explicit byteswap when needed. --- ChangeLog | 7 +++++++ grub-core/fs/zfs/zfscrypt.c | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 925b798bc..b23f5156d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-11-08 Vladimir Serbinenko + + Fix potential problem with calling zfs_to_cpu and cpu_to_be in a row. + + * grub-core/fs/zfs/zfscrypt.c (grub_zfs_decrypt_real): Use explicit + byteswap when needed. + 2011-11-08 Vladimir Serbinenko Fix FreeBSD compilation. diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c index 14babd29f..13f62b25a 100644 --- a/grub-core/fs/zfs/zfscrypt.c +++ b/grub-core/fs/zfs/zfscrypt.c @@ -277,8 +277,9 @@ grub_zfs_decrypt_real (grub_crypto_cipher_handle_t cipher, grub_err_t err; grub_memcpy (sw, nonce, 16); - for (i = 0; i < 4; i++) - sw[i] = grub_cpu_to_be32 (grub_zfs_to_cpu32 (sw[i], endian)); + if (endian != GRUB_ZFS_BIG_ENDIAN) + for (i = 0; i < 4; i++) + sw[i] = grub_swap_bytes32 (sw[i]); if (!cipher) return grub_error (GRUB_ERR_ACCESS_DENIED, From 49a45021c1430b481ef4c0be95912e065aa9402f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 8 Nov 2011 19:46:41 +0100 Subject: [PATCH 03/40] * grub-core/lib/LzmaEnc.c (LzmaEnc_CodeOneBlock): Remove set but not used variable. * grub-core/kern/ia64/dl_helper.c (grub_ia64_dl_get_tramp_got_size): Likewise. --- ChangeLog | 7 +++++++ grub-core/kern/ia64/dl_helper.c | 3 --- grub-core/lib/LzmaEnc.c | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b23f5156d..b7bd30183 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-11-08 Vladimir Serbinenko + + * grub-core/lib/LzmaEnc.c (LzmaEnc_CodeOneBlock): Remove set but not + used variable. + * grub-core/kern/ia64/dl_helper.c (grub_ia64_dl_get_tramp_got_size): + Likewise. + 2011-11-08 Vladimir Serbinenko Fix potential problem with calling zfs_to_cpu and cpu_to_be in a row. diff --git a/grub-core/kern/ia64/dl_helper.c b/grub-core/kern/ia64/dl_helper.c index 91f28026e..958cdb25e 100644 --- a/grub-core/kern/ia64/dl_helper.c +++ b/grub-core/kern/ia64/dl_helper.c @@ -30,7 +30,6 @@ grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, const Elf64_Ehdr *e = ehdr; grub_size_t cntt = 0, cntg = 0;; const Elf64_Shdr *s; - Elf64_Word entsize; unsigned i; /* Find a symbol table. */ @@ -43,8 +42,6 @@ grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, if (i == grub_le_to_cpu16 (e->e_shnum)) return; - entsize = s->sh_entsize; - for (i = 0, s = (Elf64_Shdr *) ((char *) e + grub_le_to_cpu32 (e->e_shoff)); i < grub_le_to_cpu16 (e->e_shnum); i++, s = (Elf64_Shdr *) ((char *) s + grub_le_to_cpu16 (e->e_shentsize))) diff --git a/grub-core/lib/LzmaEnc.c b/grub-core/lib/LzmaEnc.c index 01ffa91f9..258ed9c91 100644 --- a/grub-core/lib/LzmaEnc.c +++ b/grub-core/lib/LzmaEnc.c @@ -1994,13 +1994,15 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) { UInt32 beforeSize = kNumOpts; +#ifdef COMPRESS_MF_MT Bool btMode; +#endif if (!RangeEnc_Alloc(&p->rc, alloc)) return SZ_ERROR_MEM; +#ifdef COMPRESS_MF_MT btMode = (p->matchFinderBase.btMode != 0); - #ifdef COMPRESS_MF_MT p->mtMode = (p->multiThread && !p->fastMode && btMode); - #endif +#endif { unsigned lclp = p->lc + p->lp; From 438a746a3ff63ed0428818a4f03b181431199747 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 8 Nov 2011 20:03:06 +0100 Subject: [PATCH 04/40] * grub-core/fs/zfs/zfs.c (read_dva): Issue an error if read failed with no error set. --- ChangeLog | 5 +++++ grub-core/fs/zfs/zfs.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b7bd30183..f8f424176 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-08 Vladimir Serbinenko + + * grub-core/fs/zfs/zfs.c (read_dva): Issue an error if read failed + with no error set. + 2011-11-08 Vladimir Serbinenko * grub-core/lib/LzmaEnc.c (LzmaEnc_CodeOneBlock): Remove set but not diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index fb16a009b..f85d56e99 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -1324,7 +1324,7 @@ read_dva (const dva_t *dva, { grub_uint64_t offset; unsigned i; - grub_err_t err; + grub_err_t err = 0; int try = 0; offset = dva_get_offset (dva, endian); @@ -1344,6 +1344,9 @@ read_dva (const dva_t *dva, if (err) return err; } + if (!err) + return grub_error (GRUB_ERR_BAD_FS, "unknown device %d", + (int) DVA_GET_VDEV (dva)); return err; } From 52b656c037a679c74e9c49dd2c92f289a18b2d4c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 9 Nov 2011 11:43:39 +0100 Subject: [PATCH 05/40] Several AFFS fixes. * grub-core/fs/affs.c (grub_affs_bblock): Replace flags with version. (GRUB_AFFS_FLAG_FFS): Removed. (GRUB_AFFS_SYMLINK_SIZE): Likewise. (GRUB_AFFS_FILETYPE_DIR): Make positive and unsigned. (GRUB_AFFS_FILETYPE_DIR), (GRUB_AFFS_FILETYPE_REG): Fix a mix-up. (grub_fshelp_node): Make block 32-bit. Add block_cache and last_block_cache. (grub_affs_read_block): Fill and use block cache. (grub_affs_read_file): Removed. (grub_affs_mount): Zero-fill node. Fix version check. Don't reread boot block. (grub_affs_read_symlink): Fix symlink size. Add a \0 at the end for safety. (grub_affs_iterate_dir): Use more appropriate types. Zero-fill allocated space. (grub_affs_close): Free block cache. (grub_affs_read): Use grub_fshelp_read_file directly. --- ChangeLog | 22 +++++++++ grub-core/fs/affs.c | 111 +++++++++++++++++++++----------------------- 2 files changed, 74 insertions(+), 59 deletions(-) diff --git a/ChangeLog b/ChangeLog index f8f424176..035f18194 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2011-11-09 Vladimir Serbinenko + + Several AFFS fixes. + + * grub-core/fs/affs.c (grub_affs_bblock): Replace flags with version. + (GRUB_AFFS_FLAG_FFS): Removed. + (GRUB_AFFS_SYMLINK_SIZE): Likewise. + (GRUB_AFFS_FILETYPE_DIR): Make positive and unsigned. + (GRUB_AFFS_FILETYPE_DIR), (GRUB_AFFS_FILETYPE_REG): Fix a mix-up. + (grub_fshelp_node): Make block 32-bit. + Add block_cache and last_block_cache. + (grub_affs_read_block): Fill and use block cache. + (grub_affs_read_file): Removed. + (grub_affs_mount): Zero-fill node. Fix version check. Don't reread + boot block. + (grub_affs_read_symlink): Fix symlink size. Add a \0 at the end for + safety. + (grub_affs_iterate_dir): Use more appropriate types. Zero-fill allocated + space. + (grub_affs_close): Free block cache. + (grub_affs_read): Use grub_fshelp_read_file directly. + 2011-11-08 Vladimir Serbinenko * grub-core/fs/zfs/zfs.c (read_dva): Issue an error if read failed diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c index adf2932bd..06f41c4c3 100644 --- a/grub-core/fs/affs.c +++ b/grub-core/fs/affs.c @@ -32,15 +32,11 @@ GRUB_MOD_LICENSE ("GPLv3+"); struct grub_affs_bblock { grub_uint8_t type[3]; - grub_uint8_t flags; + grub_uint8_t version; grub_uint32_t checksum; grub_uint32_t rootblock; } __attribute__ ((packed)); -/* Set if the filesystem is a AFFS filesystem. Otherwise this is an - OFS filesystem. */ -#define GRUB_AFFS_FLAG_FFS 1 - /* The affs rootblock. */ struct grub_affs_rblock { @@ -85,19 +81,19 @@ struct grub_affs_file #define GRUB_AFFS_BLOCKPTR_OFFSET 24 #define GRUB_AFFS_SYMLINK_OFFSET 24 -#define GRUB_AFFS_SYMLINK_SIZE(blocksize) ((blocksize) - 225) - -#define GRUB_AFFS_FILETYPE_DIR -3 -#define GRUB_AFFS_FILETYPE_REG 2 +#define GRUB_AFFS_FILETYPE_REG 0xfffffffd +#define GRUB_AFFS_FILETYPE_DIR 2 #define GRUB_AFFS_FILETYPE_SYMLINK 3 struct grub_fshelp_node { struct grub_affs_data *data; - grub_disk_addr_t block; + grub_uint32_t block; struct grub_fshelp_node *parent; struct grub_affs_file di; + grub_uint32_t *block_cache; + grub_uint32_t last_block_cache; }; /* Information about a "mounted" affs filesystem. */ @@ -120,32 +116,46 @@ static grub_dl_t my_mod; static grub_disk_addr_t grub_affs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) { - int links; + grub_uint32_t target, curblock; grub_uint32_t pos; - int block = node->block; struct grub_affs_file file; struct grub_affs_data *data = node->data; grub_uint64_t mod; + if (!node->block_cache) + { + node->block_cache = grub_malloc ((((grub_be_to_cpu32 (node->di.size) + + 511) >> 9) / data->htsize + 1) + * sizeof (node->block_cache[0])); + if (!node->block_cache) + return -1; + node->last_block_cache = 0; + node->block_cache[0] = node->block; + } + + /* Files are at most 2G on AFFS, so no need for 64-bit division. */ + target = (grub_uint32_t) fileblock / data->htsize; + mod = (grub_uint32_t) fileblock % data->htsize; /* Find the block that points to the fileblock we are looking up by following the chain until the right table is reached. */ - for (links = grub_divmod64 (fileblock, data->htsize, &mod); links; links--) + for (curblock = node->last_block_cache + 1; curblock <= target; curblock++) { - grub_disk_read (data->disk, block + data->blocksize - 1, + grub_disk_read (data->disk, + node->block_cache[curblock - 1] + data->blocksize - 1, data->blocksize * (GRUB_DISK_SECTOR_SIZE - GRUB_AFFS_FILE_LOCATION), sizeof (file), &file); if (grub_errno) return 0; - block = grub_be_to_cpu32 (file.extension); + node->block_cache[curblock] = grub_be_to_cpu32 (file.extension); + node->last_block_cache = curblock; } /* Translate the fileblock to the block within the right table. */ - fileblock = mod; - grub_disk_read (data->disk, block, + grub_disk_read (data->disk, node->block_cache[target], GRUB_AFFS_BLOCKPTR_OFFSET - + (data->htsize - fileblock - 1) * sizeof (pos), + + (data->htsize - mod - 1) * sizeof (pos), sizeof (pos), &pos); if (grub_errno) return 0; @@ -153,21 +163,6 @@ grub_affs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) return grub_be_to_cpu32 (pos); } - -/* Read LEN bytes from the file described by DATA starting with byte - POS. Return the amount of read bytes in READ. */ -static grub_ssize_t -grub_affs_read_file (grub_fshelp_node_t node, - void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector, - unsigned offset, unsigned length), - grub_off_t pos, grub_size_t len, char *buf) -{ - return grub_fshelp_read_file (node->data->disk, node, read_hook, - pos, len, buf, grub_affs_read_block, - grub_be_to_cpu32 (node->di.size), 0); -} - - static struct grub_affs_data * grub_affs_mount (grub_disk_t disk) { @@ -178,7 +173,7 @@ grub_affs_mount (grub_disk_t disk) int checksum = 0; int blocksize = 0; - data = grub_malloc (sizeof (struct grub_affs_data)); + data = grub_zalloc (sizeof (struct grub_affs_data)); if (!data) return 0; @@ -196,18 +191,12 @@ grub_affs_mount (grub_disk_t disk) } /* Test if the filesystem is a OFS filesystem. */ - if (! (data->bblock.flags & GRUB_AFFS_FLAG_FFS)) + if (data->bblock.version < 1) { grub_error (GRUB_ERR_BAD_FS, "OFS not yet supported"); goto fail; } - /* Read the bootblock. */ - grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock), - &data->bblock); - if (grub_errno) - goto fail; - /* No sane person uses more than 8KB for a block. At least I hope for that person because in that case this won't work. */ rootblock = grub_malloc (GRUB_DISK_SECTOR_SIZE * 16); @@ -270,18 +259,21 @@ grub_affs_read_symlink (grub_fshelp_node_t node) { struct grub_affs_data *data = node->data; char *symlink; + const grub_size_t symlink_size = (data->blocksize * GRUB_DISK_SECTOR_SIZE + - 225); - symlink = grub_malloc (GRUB_AFFS_SYMLINK_SIZE (data->blocksize)); + symlink = grub_malloc (symlink_size + 1); if (!symlink) return 0; grub_disk_read (data->disk, node->block, GRUB_AFFS_SYMLINK_OFFSET, - GRUB_AFFS_SYMLINK_SIZE (data->blocksize), symlink); + symlink_size, symlink); if (grub_errno) { grub_free (symlink); return 0; } + symlink[symlink_size] = 1; grub_dprintf ("affs", "Symlink: `%s'\n", symlink); return symlink; } @@ -301,24 +293,24 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir, grub_uint32_t *hashtable; auto int NESTED_FUNC_ATTR grub_affs_create_node (const char *name, - grub_disk_addr_t block, + grub_uint32_t block, const struct grub_affs_file *fil); int NESTED_FUNC_ATTR grub_affs_create_node (const char *name, - grub_disk_addr_t block, + grub_uint32_t block, const struct grub_affs_file *fil) { int type; - node = grub_malloc (sizeof (*node)); + node = grub_zalloc (sizeof (*node)); if (!node) { grub_free (hashtable); return 1; } - if ((int) grub_be_to_cpu32 (fil->type) == GRUB_AFFS_FILETYPE_DIR) + if (grub_be_to_cpu32 (fil->type) == GRUB_AFFS_FILETYPE_REG) type = GRUB_FSHELP_REG; - else if (grub_be_to_cpu32 (fil->type) == GRUB_AFFS_FILETYPE_REG) + else if (grub_be_to_cpu32 (fil->type) == GRUB_AFFS_FILETYPE_DIR) type = GRUB_FSHELP_DIR; else if (grub_be_to_cpu32 (fil->type) == GRUB_AFFS_FILETYPE_SYMLINK) type = GRUB_FSHELP_SYMLINK; @@ -339,7 +331,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir, } /* Create the directory entries for `.' and `..'. */ - node = grub_malloc (sizeof (*node)); + node = grub_zalloc (sizeof (*node)); if (!node) return 1; @@ -348,7 +340,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir, return 1; if (dir->parent) { - node = grub_malloc (sizeof (*node)); + node = grub_zalloc (sizeof (*node)); if (!node) return 1; *node = *dir->parent; @@ -356,7 +348,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir, return 1; } - hashtable = grub_malloc (data->htsize * sizeof (*hashtable)); + hashtable = grub_zalloc (data->htsize * sizeof (*hashtable)); if (!hashtable) return 1; @@ -367,7 +359,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir, for (i = 0; i < data->htsize; i++) { - grub_uint64_t next; + grub_uint32_t next; if (!hashtable[i]) continue; @@ -441,10 +433,13 @@ grub_affs_open (struct grub_file *file, const char *name) return grub_errno; } - static grub_err_t grub_affs_close (grub_file_t file) { + struct grub_affs_data *data = + (struct grub_affs_data *) file->data; + + grub_free (data->diropen.block_cache); grub_free (file->data); grub_dl_unref (my_mod); @@ -452,7 +447,6 @@ grub_affs_close (grub_file_t file) return GRUB_ERR_NONE; } - /* Read LEN bytes data from FILE into BUF. */ static grub_ssize_t grub_affs_read (grub_file_t file, char *buf, grub_size_t len) @@ -460,13 +454,12 @@ grub_affs_read (grub_file_t file, char *buf, grub_size_t len) struct grub_affs_data *data = (struct grub_affs_data *) file->data; - int size = grub_affs_read_file (&data->diropen, file->read_hook, - file->offset, len, buf); - - return size; + return grub_fshelp_read_file (data->diropen.data->disk, &data->diropen, + file->read_hook, + file->offset, len, buf, grub_affs_read_block, + grub_be_to_cpu32 (data->diropen.di.size), 0); } - static grub_err_t grub_affs_dir (grub_device_t device, const char *path, int (*hook) (const char *filename, From 19e81ba7a0b67bb1bd3d427c9c7cc1147a78ec8d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 9 Nov 2011 14:44:21 +0100 Subject: [PATCH 06/40] * configure.ac: Add missing -mXX to TARGET_CPPFLAGS. --- ChangeLog | 4 ++++ configure.ac | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 035f18194..1b7fd4411 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-11-09 Vladimir Serbinenko + + * configure.ac: Add missing -mXX to TARGET_CPPFLAGS. + 2011-11-09 Vladimir Serbinenko Several AFFS fixes. diff --git a/configure.ac b/configure.ac index e707081a7..1b3288c8a 100644 --- a/configure.ac +++ b/configure.ac @@ -464,6 +464,7 @@ if test "x$target_m32" = x1; then # Force 32-bit mode. TARGET_CFLAGS="$TARGET_CFLAGS -m32" TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32" + TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32" TARGET_LDFLAGS="$TARGET_LDFLAGS -m32" TARGET_MODULE_FORMAT="elf32" fi @@ -472,6 +473,7 @@ if test "x$target_m64" = x1; then # Force 64-bit mode. TARGET_CFLAGS="$TARGET_CFLAGS -m64" TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64" + TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64" TARGET_LDFLAGS="$TARGET_LDFLAGS -m64" TARGET_MODULE_FORMAT="elf64" fi From 57b01250046a33900d3e4b7434967aacb343bc7e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 9 Nov 2011 14:47:45 +0100 Subject: [PATCH 07/40] * include/grub/misc.h (grub_strncat): Fix the order of conditionals to avoid accessing beyond the array. --- ChangeLog | 5 +++++ include/grub/misc.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1b7fd4411..352c69c4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-09 Vladimir Serbinenko + + * include/grub/misc.h (grub_strncat): Fix the order of conditionals to + avoid accessing beyond the array. + 2011-11-09 Vladimir Serbinenko * configure.ac: Add missing -mXX to TARGET_CPPFLAGS. diff --git a/include/grub/misc.h b/include/grub/misc.h index 5bc159e7d..4e7d9077c 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -87,7 +87,7 @@ grub_strncat (char *dest, const char *src, int c) while (*p) p++; - while ((*p = *src) != '\0' && c--) + while (c-- && (*p = *src) != '\0') { p++; src++; From 8a5a3a5b5a3f53520f8dd63808e5715558d0d326 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 9 Nov 2011 15:01:58 +0100 Subject: [PATCH 08/40] Fix several memory leaks. * grub-core/fs/btrfs.c (grub_btrfs_dir): Fix memory leak. * grub-core/fs/cpio.c (grub_cpio_find_file): Likewise. (grub_cpio_dir): Likewise. * grub-core/fs/fat.c (grub_fat_label): Likewise. * grub-core/fs/jfs.c (grub_jfs_label): Likewise. * grub-core/fs/romfs.c (grub_romfs_close): Likewise. (grub_romfs_label): Likewise. * grub-core/fs/squash4.c (squash_mount): Use zalloc for safety. (squash_unmount): New function. (grub_squash_dir): Fix memory leak. (grub_squash_open): Likewise. (grub_squash_read): Likewise. (grub_squash_mtime): Likewise. * grub-core/fs/xfs.c (grub_xfs_open): Likewise. * grub-core/fs/zfs/zfs.c (check_pool_label): Likewise. * util/grub-fstest.c (fstest): Likewise. --- ChangeLog | 21 +++++++++++++++++++++ grub-core/fs/btrfs.c | 29 +++++++++++++++++++---------- grub-core/fs/cpio.c | 3 +++ grub-core/fs/fat.c | 6 +++++- grub-core/fs/jfs.c | 2 ++ grub-core/fs/romfs.c | 6 +++++- grub-core/fs/squash4.c | 22 +++++++++++++++++----- grub-core/fs/xfs.c | 11 +++++++---- grub-core/fs/zfs/zfs.c | 2 ++ util/grub-fstest.c | 4 +++- 10 files changed, 84 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 352c69c4f..c367bb134 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2011-11-09 Vladimir Serbinenko + + Fix several memory leaks. + + * grub-core/fs/btrfs.c (grub_btrfs_dir): Fix memory leak. + * grub-core/fs/cpio.c (grub_cpio_find_file): Likewise. + (grub_cpio_dir): Likewise. + * grub-core/fs/fat.c (grub_fat_label): Likewise. + * grub-core/fs/jfs.c (grub_jfs_label): Likewise. + * grub-core/fs/romfs.c (grub_romfs_close): Likewise. + (grub_romfs_label): Likewise. + * grub-core/fs/squash4.c (squash_mount): Use zalloc for safety. + (squash_unmount): New function. + (grub_squash_dir): Fix memory leak. + (grub_squash_open): Likewise. + (grub_squash_read): Likewise. + (grub_squash_mtime): Likewise. + * grub-core/fs/xfs.c (grub_xfs_open): Likewise. + * grub-core/fs/zfs/zfs.c (check_pool_label): Likewise. + * util/grub-fstest.c (fstest): Likewise. + 2011-11-09 Vladimir Serbinenko * include/grub/misc.h (grub_strncat): Fix the order of conditionals to diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 3dc680034..e5aa3084c 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -1415,22 +1415,28 @@ grub_btrfs_dir (grub_device_t device, const char *path, err = find_path (data, path, &key_in, &tree, &type); if (err) - return err; + { + grub_btrfs_unmount (data); + return err; + } if (type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); + { + grub_btrfs_unmount (data); + return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); + } err = lower_bound (data, &key_in, &key_out, tree, &elemaddr, &elemsize, &desc); if (err) - return err; + { + grub_btrfs_unmount (data); + return err; + } if (key_out.type != GRUB_BTRFS_ITEM_TYPE_DIR_ITEM || key_out.object_id != key_in.object_id) { r = next (data, &desc, &elemaddr, &elemsize, &key_out); if (r <= 0) - { - free_iterator (&desc); - return -r; - } + goto out; } do { @@ -1448,14 +1454,17 @@ grub_btrfs_dir (grub_device_t device, const char *path, direl = grub_malloc (allocated + 1); if (!direl) { - free_iterator (&desc); - return grub_errno; + r = -grub_errno; + break; } } err = grub_btrfs_read_logical (data, elemaddr, direl, elemsize); if (err) - return err; + { + r = -err; + break; + } for (cdirel = direl; (grub_uint8_t *) cdirel - (grub_uint8_t *) direl diff --git a/grub-core/fs/cpio.c b/grub-core/fs/cpio.c index b43e54ec9..39b35b335 100644 --- a/grub-core/fs/cpio.c +++ b/grub-core/fs/cpio.c @@ -147,6 +147,7 @@ grub_cpio_find_file (struct grub_cpio_data *data, char **name, && grub_memcmp(*name, "TRAILER!!!", 11) == 0) { *ofs = 0; + grub_free (*name); return GRUB_ERR_NONE; } @@ -481,6 +482,8 @@ grub_cpio_dir (grub_device_t device, const char *path_in, } } } + else + grub_free (name); data->hofs = ofs; } diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index fb1113814..0d32e229d 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -1048,7 +1048,10 @@ grub_fat_label (grub_device_t device, char **label) grub_size_t chc; *label = grub_malloc (11 * 4 + 1); if (!*label) - return grub_errno; + { + grub_free (data); + return grub_errno; + } chc = dir.type_specific.volume_label.character_count; if (chc > ARRAY_SIZE (dir.type_specific.volume_label.str)) chc = ARRAY_SIZE (dir.type_specific.volume_label.str); @@ -1057,6 +1060,7 @@ grub_fat_label (grub_device_t device, char **label) } } + grub_free (data); return grub_errno; } diff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c index cf7520bb3..91497f143 100644 --- a/grub-core/fs/jfs.c +++ b/grub-core/fs/jfs.c @@ -891,6 +891,8 @@ grub_jfs_label (grub_device_t device, char **label) else *label = 0; + grub_free (data); + return grub_errno; } diff --git a/grub-core/fs/romfs.c b/grub-core/fs/romfs.c index 713e8293f..202ca102e 100644 --- a/grub-core/fs/romfs.c +++ b/grub-core/fs/romfs.c @@ -397,7 +397,10 @@ grub_romfs_read (grub_file_t file, char *buf, grub_size_t len) static grub_err_t grub_romfs_close (grub_file_t file) { - grub_free (file->data); + struct grub_fshelp_node *data = file->data; + + grub_free (data->data); + grub_free (data); return GRUB_ERR_NONE; } @@ -432,6 +435,7 @@ grub_romfs_label (grub_device_t device, char **label) return err; } (*label)[data->first_file - sizeof (struct grub_romfs_superblock)] = 0; + grub_free (data); return GRUB_ERR_NONE; } diff --git a/grub-core/fs/squash4.c b/grub-core/fs/squash4.c index a3832b6be..0728287b7 100644 --- a/grub-core/fs/squash4.c +++ b/grub-core/fs/squash4.c @@ -287,7 +287,7 @@ squash_mount (grub_disk_t disk) if (err) return NULL; - data = grub_malloc (sizeof (*data)); + data = grub_zalloc (sizeof (*data)); if (!data) return NULL; data->sb = sb; @@ -418,6 +418,15 @@ make_root_node (struct grub_squash_data *data, struct grub_fshelp_node *root) grub_cpu_to_le16 (data->sb.root_ino_offset)); } +static void +squash_unmount (struct grub_squash_data *data) +{ + grub_free (data->ino.cumulated_block_sizes); + grub_free (data->ino.block_sizes); + grub_free (data); +} + + static grub_err_t grub_squash_dir (grub_device_t device, const char *path, int (*hook) (const char *filename, @@ -436,6 +445,7 @@ grub_squash_dir (grub_device_t device, const char *path, info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR); info.mtimeset = 1; info.mtime = grub_le_to_cpu32 (node->ino.mtime); + grub_free (node); return hook (filename, &info); } @@ -457,7 +467,7 @@ grub_squash_dir (grub_device_t device, const char *path, if (!grub_errno) grub_squash_iterate_dir (fdiro, iterate); - grub_free (data); + squash_unmount (data); return grub_errno; } @@ -482,7 +492,7 @@ grub_squash_open (struct grub_file *file, const char *name) grub_squash_read_symlink, GRUB_FSHELP_REG); if (grub_errno) { - grub_free (data); + squash_unmount (data); return grub_errno; } @@ -499,6 +509,8 @@ grub_squash_open (struct grub_file *file, const char *name) else file->size = grub_le_to_cpu32 (fdiro->ino.file.size); + grub_free (fdiro); + return GRUB_ERR_NONE; } @@ -664,7 +676,7 @@ grub_squash_read (grub_file_t file, char *buf, grub_size_t len) static grub_err_t grub_squash_close (grub_file_t file) { - grub_free (file->data); + squash_unmount (file->data); return GRUB_ERR_NONE; } @@ -677,7 +689,7 @@ grub_squash_mtime (grub_device_t dev, grub_int32_t *tm) if (! data) return grub_errno; *tm = grub_le_to_cpu32 (data->sb.creation_time); - grub_free (data); + squash_unmount (data); return GRUB_ERR_NONE; } diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 3dc5e0af0..c4d47a099 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -771,10 +771,13 @@ grub_xfs_open (struct grub_file *file, const char *name) } if (fdiro != &data->diropen) - grub_memcpy (&data->diropen, fdiro, - sizeof (struct grub_fshelp_node) - - sizeof (struct grub_xfs_inode) - + (1 << data->sblock.log2_inode)); + { + grub_memcpy (&data->diropen, fdiro, + sizeof (struct grub_fshelp_node) + - sizeof (struct grub_xfs_inode) + + (1 << data->sblock.log2_inode)); + grub_free (fdiro); + } file->size = grub_be_to_cpu64 (data->diropen.inode.size); file->data = data; diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index f85d56e99..7ceb16db2 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -781,9 +781,11 @@ check_pool_label (struct grub_zfs_data *data, err = fill_vdev_info (data, nv, diskdesc); if (err) { + grub_free (nv); grub_free (nvlist); return err; } + grub_free (nv); } grub_dprintf ("zfs", "check 10 passed\n"); diff --git a/util/grub-fstest.c b/util/grub-fstest.c index f90755e86..47b536771 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -401,7 +401,9 @@ fstest (int n, char **args) if (!uuid) grub_util_error ("couldn't retrieve UUID"); argv[1] = uuid; - execute_command ("xnu_uuid", 2, argv); + execute_command ("xnu_uuid", 2, argv); + grub_free (uuid); + grub_device_close (dev); } } From 28840fdaae146999e51d5741a6434b4f3ffaf54c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 10 Nov 2011 08:07:51 +0100 Subject: [PATCH 09/40] * include/grub/i386/netbsd_bootinfo.h (grub_netbsd_btinfo_bootwedge): Fix declaration. --- ChangeLog | 5 +++++ include/grub/i386/netbsd_bootinfo.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c367bb134..7cd370c1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-10 Vladimir Serbinenko + + * include/grub/i386/netbsd_bootinfo.h (grub_netbsd_btinfo_bootwedge): + Fix declaration. + 2011-11-09 Vladimir Serbinenko Fix several memory leaks. diff --git a/include/grub/i386/netbsd_bootinfo.h b/include/grub/i386/netbsd_bootinfo.h index 228f26aaa..24e145b01 100644 --- a/include/grub/i386/netbsd_bootinfo.h +++ b/include/grub/i386/netbsd_bootinfo.h @@ -92,7 +92,7 @@ struct grub_netbsd_btinfo_bootwedge { grub_disk_addr_t matchblk; grub_uint64_t matchnblks; grub_uint8_t matchhash[16]; /* MD5 hash */ -} __packed; +} __attribute__ ((packed)); struct grub_netbsd_btinfo_symtab { From 6b68db81fc42ed6a4b9aa7f15f5578136c383980 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 10 Nov 2011 08:09:33 +0100 Subject: [PATCH 10/40] * grub-core/fs/btrfs.c (grub_btrfs_read_logical): Fix RAID10 logic for >= 6 drives. --- ChangeLog | 5 +++++ grub-core/fs/btrfs.c | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7cd370c1b..506036d5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-10 Vladimir Serbinenko + + * grub-core/fs/btrfs.c (grub_btrfs_read_logical): Fix RAID10 logic for + >= 6 drives. + 2011-11-10 Vladimir Serbinenko * include/grub/i386/netbsd_bootinfo.h (grub_netbsd_btinfo_bootwedge): diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index e5aa3084c..fae9199a4 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -734,12 +734,11 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, &low); high = grub_divmod64 (middle, - grub_le_to_cpu16 (chunk->nsubstripes), + grub_le_to_cpu16 (chunk->nstripes) + / grub_le_to_cpu16 (chunk->nsubstripes), &stripen); - stripen *= grub_le_to_cpu16 (chunk->nstripes) - / grub_le_to_cpu16 (chunk->nsubstripes); - redundancy = grub_le_to_cpu16 (chunk->nstripes) - / grub_le_to_cpu16 (chunk->nsubstripes); + stripen *= grub_le_to_cpu16 (chunk->nsubstripes); + redundancy = grub_le_to_cpu16 (chunk->nsubstripes); stripe_offset = low + grub_le_to_cpu64 (chunk->stripe_length) * high; csize = grub_le_to_cpu64 (chunk->stripe_length) - low; From ad9a2f44b4cbf8e22a65f9f019b7914f1a60d169 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 10 Nov 2011 08:16:27 +0100 Subject: [PATCH 11/40] * grub-core/fs/iso9660.c (grub_iso9660_iterate_dir): Fix grub_strncat argument (access out of bounds). --- ChangeLog | 5 +++++ grub-core/fs/iso9660.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 506036d5a..ef82df3af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-10 Vladimir Serbinenko + + * grub-core/fs/iso9660.c (grub_iso9660_iterate_dir): Fix grub_strncat + argument (access out of bounds). + 2011-11-10 Vladimir Serbinenko * grub-core/fs/btrfs.c (grub_btrfs_read_logical): Fix RAID10 logic for diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c index d4c52bed4..5e2f7824a 100644 --- a/grub-core/fs/iso9660.c +++ b/grub-core/fs/iso9660.c @@ -559,9 +559,9 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, filename = ".."; else if (entry->len >= 5) { - int size = 1; + grub_size_t size = 1, csize = 1; char *old; - size = entry->len - 5; + csize = size = entry->len - 5; old = filename; if (filename_alloc) { @@ -580,7 +580,7 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, return grub_errno; } filename_alloc = 1; - grub_strncat (filename, (char *) &entry->data[1], size); + grub_strncat (filename, (char *) &entry->data[1], csize); filename[size] = '\0'; } } From 45bd824d2eed877eef2c55c96063eefbc4a3c5d5 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 10 Nov 2011 08:38:06 +0100 Subject: [PATCH 12/40] Fix ZFS memory and resource leaks. * grub-core/fs/zfs/zfs.c (fill_vdev_info_real): New paramter inserted. All users updated. Free type on exit. (fill_vdev_info): New parameter inserted. All users updated. (check_pool_label): Likewise. (scan_disk): Likewise. (scan_devices): Close non-inserted disks. (fzap_iterate): Free l. (unmount_device): Free children descripto memory. --- ChangeLog | 14 +++++++ grub-core/fs/zfs/zfs.c | 84 +++++++++++++++++++++++++++++++----------- 2 files changed, 77 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index ef82df3af..24a2b783b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-11-10 Vladimir Serbinenko + + Fix ZFS memory and resource leaks. + + * grub-core/fs/zfs/zfs.c (fill_vdev_info_real): New paramter inserted. + All users updated. + Free type on exit. + (fill_vdev_info): New parameter inserted. All users updated. + (check_pool_label): Likewise. + (scan_disk): Likewise. + (scan_devices): Close non-inserted disks. + (fzap_iterate): Free l. + (unmount_device): Free children descripto memory. + 2011-11-10 Vladimir Serbinenko * grub-core/fs/iso9660.c (grub_iso9660_iterate_dir): Fix grub_strncat diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 7ceb16db2..760668940 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -535,7 +535,8 @@ static grub_err_t fill_vdev_info_real (struct grub_zfs_data *data, const char *nvlist, struct grub_zfs_device_desc *fill, - struct grub_zfs_device_desc *insert) + struct grub_zfs_device_desc *insert, + int *inserted) { char *type; @@ -545,10 +546,16 @@ fill_vdev_info_real (struct grub_zfs_data *data, return grub_errno; if (!grub_zfs_nvlist_lookup_uint64 (nvlist, "id", &(fill->id))) - return grub_error (GRUB_ERR_BAD_FS, "couldn't find vdev id"); + { + grub_free (type); + return grub_error (GRUB_ERR_BAD_FS, "couldn't find vdev id"); + } if (!grub_zfs_nvlist_lookup_uint64 (nvlist, "guid", &(fill->guid))) - return grub_error (GRUB_ERR_BAD_FS, "couldn't find vdev id"); + { + grub_free (type); + return grub_error (GRUB_ERR_BAD_FS, "couldn't find vdev id"); + } if (grub_strcmp (type, VDEV_TYPE_DISK) == 0 || grub_strcmp (type, VDEV_TYPE_FILE) == 0) @@ -563,8 +570,11 @@ fill_vdev_info_real (struct grub_zfs_data *data, fill->original = insert->original; if (!data->device_original) data->device_original = fill; + *inserted = 1; } + grub_free (type); + return GRUB_ERR_NONE; } @@ -580,17 +590,27 @@ fill_vdev_info_real (struct grub_zfs_data *data, grub_uint64_t par; fill->type = DEVICE_RAIDZ; if (!grub_zfs_nvlist_lookup_uint64 (nvlist, "nparity", &par)) - return grub_error (GRUB_ERR_BAD_FS, "couldn't find raidz parity"); + { + grub_free (type); + return grub_error (GRUB_ERR_BAD_FS, "couldn't find raidz parity"); + } fill->nparity = par; if (!grub_zfs_nvlist_lookup_uint64 (nvlist, "ashift", &par)) - return grub_error (GRUB_ERR_BAD_FS, "couldn't find raidz ashift"); + { + grub_free (type); + return grub_error (GRUB_ERR_BAD_FS, "couldn't find raidz ashift"); + } fill->ashift = par; } - nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm (nvlist, ZPOOL_CONFIG_CHILDREN); + nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm (nvlist, + ZPOOL_CONFIG_CHILDREN); if (nelm <= 0) - return grub_error (GRUB_ERR_BAD_FS, "incorrect mirror VDEV"); + { + grub_free (type); + return grub_error (GRUB_ERR_BAD_FS, "incorrect mirror VDEV"); + } if (!fill->children) { @@ -608,34 +628,43 @@ fill_vdev_info_real (struct grub_zfs_data *data, child = grub_zfs_nvlist_lookup_nvlist_array (nvlist, ZPOOL_CONFIG_CHILDREN, i); - err = fill_vdev_info_real (data, child, &fill->children[i], insert); + err = fill_vdev_info_real (data, child, &fill->children[i], insert, + inserted); grub_free (child); if (err) - return err; + { + grub_free (type); + return err; + } } + grub_free (type); return GRUB_ERR_NONE; } - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "vdev %s isn't supported", - type); + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "vdev %s isn't supported", type); + grub_free (type); + return grub_errno; } static grub_err_t fill_vdev_info (struct grub_zfs_data *data, - char *nvlist, struct grub_zfs_device_desc *diskdesc) + char *nvlist, struct grub_zfs_device_desc *diskdesc, + int *inserted) { grub_uint64_t id; unsigned i; + *inserted = 0; + if (!grub_zfs_nvlist_lookup_uint64 (nvlist, "id", &id)) return grub_error (GRUB_ERR_BAD_FS, "couldn't find vdev id"); for (i = 0; i < data->n_devices_attached; i++) if (data->devices_attached[i].id == id) return fill_vdev_info_real (data, nvlist, &data->devices_attached[i], - diskdesc); + diskdesc, inserted); data->n_devices_attached++; if (data->n_devices_attached > data->n_devices_allocated) @@ -658,7 +687,7 @@ fill_vdev_info (struct grub_zfs_data *data, return fill_vdev_info_real (data, nvlist, &data->devices_attached[data->n_devices_attached - 1], - diskdesc); + diskdesc, inserted); } /* @@ -667,7 +696,8 @@ fill_vdev_info (struct grub_zfs_data *data, */ static grub_err_t check_pool_label (struct grub_zfs_data *data, - struct grub_zfs_device_desc *diskdesc) + struct grub_zfs_device_desc *diskdesc, + int *inserted) { grub_uint64_t pool_state, txg = 0; char *nvlist; @@ -679,6 +709,8 @@ check_pool_label (struct grub_zfs_data *data, int found; grub_err_t err; + *inserted = 0; + err = zfs_fetch_nvlist (diskdesc, &nvlist); if (err) return err; @@ -778,7 +810,7 @@ check_pool_label (struct grub_zfs_data *data, grub_free (nvlist); return grub_error (GRUB_ERR_BAD_FS, "couldn't find vdev tree"); } - err = fill_vdev_info (data, nv, diskdesc); + err = fill_vdev_info (data, nv, diskdesc, inserted); if (err) { grub_free (nv); @@ -796,7 +828,7 @@ check_pool_label (struct grub_zfs_data *data, static grub_err_t scan_disk (grub_device_t dev, struct grub_zfs_data *data, - int original) + int original, int *inserted) { int label = 0; uberblock_phys_t *ub_array, *ubbest = NULL; @@ -858,7 +890,7 @@ scan_disk (grub_device_t dev, struct grub_zfs_data *data, grub_memmove (&(data->current_uberblock), &ubbest->ubp_uberblock, sizeof (uberblock_t)); - err = check_pool_label (data, &desc); + err = check_pool_label (data, &desc, inserted); if (err) { grub_errno = GRUB_ERR_NONE; @@ -889,6 +921,7 @@ scan_devices (struct grub_zfs_data *data) { grub_device_t dev; grub_err_t err; + int inserted; dev = grub_device_open (name); if (!dev) return 0; @@ -897,7 +930,7 @@ scan_devices (struct grub_zfs_data *data) grub_device_close (dev); return 0; } - err = scan_disk (dev, data, 0); + err = scan_disk (dev, data, 0, &inserted); if (err == GRUB_ERR_BAD_FS) { grub_device_close (dev); @@ -910,6 +943,9 @@ scan_devices (struct grub_zfs_data *data) grub_print_error (); return 0; } + + if (!inserted) + grub_device_close (dev); return 0; } @@ -2042,10 +2078,14 @@ fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap, if (hook (buf, le->le_name_length, val, le->le_value_length, le->le_int_size)) - return 1; + { + grub_free (l); + return 1; + } grub_free (buf); grub_free (val); } + grub_free (l); } return 0; } @@ -3156,6 +3196,7 @@ unmount_device (struct grub_zfs_device_desc *desc) case DEVICE_MIRROR: for (i = 0; i < desc->n_children; i++) unmount_device (&desc->children[i]); + grub_free (desc->children); return; } } @@ -3190,6 +3231,7 @@ zfs_mount (grub_device_t dev) grub_size_t ospsize; grub_zfs_endian_t ub_endian = GRUB_ZFS_UNKNOWN_ENDIAN; uberblock_t *ub; + int inserted; if (! dev->disk) { @@ -3210,7 +3252,7 @@ zfs_mount (grub_device_t dev) data->devices_attached = grub_malloc (sizeof (data->devices_attached[0]) * data->n_devices_allocated); data->n_devices_attached = 0; - err = scan_disk (dev, data, 1); + err = scan_disk (dev, data, 1, &inserted); if (err) { zfs_unmount (data); From cb544caa2ecd10367cd05d5ebbcdc019fdab255a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 10 Nov 2011 08:43:08 +0100 Subject: [PATCH 13/40] * grub-core/fs/zfs/zfs.c (zfs_mount): Fix spurious warning. --- ChangeLog | 4 ++++ grub-core/fs/zfs/zfs.c | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24a2b783b..2687b65be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-11-10 Vladimir Serbinenko + + * grub-core/fs/zfs/zfs.c (zfs_mount): Fix spurious warning. + 2011-11-10 Vladimir Serbinenko Fix ZFS memory and resource leaks. diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 760668940..20cba3509 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -3227,7 +3227,7 @@ zfs_mount (grub_device_t dev) { struct grub_zfs_data *data = 0; grub_err_t err; - objset_phys_t *osp = 0; + void *osp = 0; grub_size_t ospsize; grub_zfs_endian_t ub_endian = GRUB_ZFS_UNKNOWN_ENDIAN; uberblock_t *ub; @@ -3265,7 +3265,7 @@ zfs_mount (grub_device_t dev) ? GRUB_ZFS_LITTLE_ENDIAN : GRUB_ZFS_BIG_ENDIAN); err = zio_read (&ub->ub_rootbp, ub_endian, - (void **) &osp, &ospsize, data); + &osp, &ospsize, data); if (err) { zfs_unmount (data); @@ -3281,7 +3281,8 @@ zfs_mount (grub_device_t dev) } /* 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 (ub->ub_rootbp.blk_prop, ub_endian) >> 63) & 1; grub_free (osp); From c3591189b82421a8eaeebc97c118d81bba1931cd Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 10 Nov 2011 08:46:09 +0100 Subject: [PATCH 14/40] Remove local keyword. * util/grub-mkconfig_lib.in (version_test_numeric): Remove local. (version_test_gt): Likewise. (version_find_latest): Likewise. (gettext_printf): Likewise. * util/grub.d/10_windows.in (get_os_name_from_boot_ini): Likewise. --- ChangeLog | 10 ++++++++ util/grub-mkconfig_lib.in | 48 +++++++++++++++++++-------------------- util/grub.d/10_windows.in | 10 ++++---- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2687b65be..e60b4da9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-11-10 Vladimir Serbinenko + + Remove local keyword. + + * util/grub-mkconfig_lib.in (version_test_numeric): Remove local. + (version_test_gt): Likewise. + (version_find_latest): Likewise. + (gettext_printf): Likewise. + * util/grub.d/10_windows.in (get_os_name_from_boot_ini): Likewise. + 2011-11-10 Vladimir Serbinenko * grub-core/fs/zfs/zfs.c (zfs_mount): Fix spurious warning. diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index a453a6bb5..5a9bf90c0 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -167,21 +167,21 @@ grub_file_is_not_garbage () version_test_numeric () { - local a="$1" - local cmp="$2" - local b="$3" - if [ "$a" = "$b" ] ; then - case "$cmp" in + version_test_numeric_a="$1" + version_test_numeric_cmp="$2" + version_test_numeric_b="$3" + if [ "$version_test_numeric_a" = "$version_test_numeric_b" ] ; then + case "$version_test_numeric_cmp" in ge|eq|le) return 0 ;; gt|lt) return 1 ;; esac fi - if [ "$cmp" = "lt" ] ; then - c="$a" - a="$b" - b="$c" + if [ "$version_test_numeric_cmp" = "lt" ] ; then + version_test_numeric_c="$version_test_numeric_a" + version_test_numeric_a="$version_test_numeric_b" + version_test_numeric_b="$version_test_numeric_c" fi - if (echo "$a" ; echo "$b") | sort -n | head -n 1 | grep -qx "$b" ; then + if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | sort -n | head -n 1 | grep -qx "$version_test_numeric_b" ; then return 0 else return 1 @@ -190,30 +190,30 @@ version_test_numeric () version_test_gt () { - local a="`echo "$1" | sed -e "s/[^-]*-//"`" - local b="`echo "$2" | sed -e "s/[^-]*-//"`" - local cmp=gt - if [ "x$b" = "x" ] ; then + version_test_gt_a="`echo "$1" | sed -e "s/[^-]*-//"`" + version_test_gt_b="`echo "$2" | sed -e "s/[^-]*-//"`" + version_test_gt_cmp=gt + if [ "x$version_test_gt_b" = "x" ] ; then return 0 fi - case "$a:$b" in + case "$version_test_gt_a:$version_test_gt_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:*) version_test_gt_a="`echo -n "$version_test_gt_a" | sed -e 's/\.old$//'`" ; cmp=gt ;; + *:*.old) version_test_gt_b="`echo -n "$version_test_gt_b" | sed -e 's/\.old$//'`" ; cmp=ge ;; esac - version_test_numeric "$a" "$cmp" "$b" + version_test_numeric "$version_test_gt_a" "$version_test_gt_cmp" "$version_test_gt_b" return "$?" } version_find_latest () { - local a="" + version_find_latest_a="" for i in "$@" ; do - if version_test_gt "$i" "$a" ; then - a="$i" + if version_test_gt "$i" "$version_find_latest_a" ; then + version_find_latest_a="$i" fi done - echo "$a" + echo "$version_find_latest_a" } # One layer of quotation is eaten by "", the second by sed, and the third by @@ -227,9 +227,9 @@ gettext_quoted () { # remaining arguments to printf. This is a useful abbreviation and tends to # be easier to type. gettext_printf () { - local format="$1" + gettext_printf_format="$1" shift - printf "$(gettext_quoted "$format")" "$@" + printf "$(gettext_quoted "$gettext_printf_format")" "$@" } uses_abstraction () { diff --git a/util/grub.d/10_windows.in b/util/grub.d/10_windows.in index 0a848880d..20fd4e044 100644 --- a/util/grub.d/10_windows.in +++ b/util/grub.d/10_windows.in @@ -42,14 +42,14 @@ get_os_name_from_boot_ini () sort | uniq | wc -l`" = 1 || return 1 # Search 'default=PARTITION' - local part=`sed -n 's,^default=,,p' "$1" | sed 's,\\\\,/,g;s,[ \t\r]*$,,;1q'` - test -n "$part" || return 1 + get_os_name_from_boot_ini_part=`sed -n 's,^default=,,p' "$1" | sed 's,\\\\,/,g;s,[ \t\r]*$,,;1q'` + test -n "$get_os_name_from_boot_ini_part" || return 1 # Search 'PARTITION="NAME" ...' - local name=`sed -n 's,\\\\,/,g;s,^'"$part"'="\([^"]*\)".*$,\1,p' "$1" | sed 1q` - test -n "$name" || return 1 + get_os_name_from_boot_ini_name=`sed -n 's,\\\\,/,g;s,^'"$get_os_name_from_boot_ini_part"'="\([^"]*\)".*$,\1,p' "$1" | sed 1q` + test -n "$get_os_name_from_boot_ini_name" || return 1 - echo "$name" + echo "$get_os_name_from_boot_ini_name" } From f627652531ee17d729e024858d529c9b05657593 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 10 Nov 2011 09:31:06 +0100 Subject: [PATCH 15/40] Put symlink at the end of the node and fix a potential memory corruption. * grub-core/fs/iso9660.c (grub_fshelp_node): New field have_symlink. Make symlink into an array. (set_rockridge): Set have_symlink and alloc_dirents. (grub_iso9660_read_symlink): Use new layout. (grub_iso9660_iterate_dir): Fix memory corruption. Use new layout. (grub_iso9660_dir): Set have_symlink. (grub_iso9660_open): Likewise. --- ChangeLog | 14 +++++++++++ grub-core/fs/iso9660.c | 55 +++++++++++++++++++++++++++++++++--------- 2 files changed, 58 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index e60b4da9c..f293e0773 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-11-10 Vladimir Serbinenko + + Put symlink at the end of the node and fix a potential + memory corruption. + + * grub-core/fs/iso9660.c (grub_fshelp_node): New field have_symlink. + Make symlink into an array. + (set_rockridge): Set have_symlink and alloc_dirents. + (grub_iso9660_read_symlink): Use new layout. + (grub_iso9660_iterate_dir): Fix memory corruption. + Use new layout. + (grub_iso9660_dir): Set have_symlink. + (grub_iso9660_open): Likewise. + 2011-11-10 Vladimir Serbinenko Remove local keyword. diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c index 5e2f7824a..7b1e32f7c 100644 --- a/grub-core/fs/iso9660.c +++ b/grub-core/fs/iso9660.c @@ -159,8 +159,9 @@ struct grub_fshelp_node { struct grub_iso9660_data *data; grub_size_t have_dirents, alloc_dirents; - char *symlink; + int have_symlink; struct grub_iso9660_dir dirents[8]; + char symlink[0]; }; enum @@ -408,9 +409,9 @@ set_rockridge (struct grub_iso9660_data *data) struct grub_fshelp_node rootnode; rootnode.data = data; - rootnode.alloc_dirents = 0; + rootnode.alloc_dirents = ARRAY_SIZE (rootnode.dirents); rootnode.have_dirents = 1; - rootnode.symlink = 0; + rootnode.have_symlink = 0; rootnode.dirents[0] = data->voldesc.rootdir; /* The 2nd data byte stored how many bytes are skipped every time @@ -500,7 +501,10 @@ grub_iso9660_mount (grub_disk_t disk) static char * grub_iso9660_read_symlink (grub_fshelp_node_t node) { - return node->symlink ? grub_strdup (node->symlink) : grub_strdup (""); + return node->have_symlink + ? grub_strdup (node->symlink + + (node->have_dirents) * sizeof (node->dirents[0]) + - sizeof (node->dirents)) : grub_strdup (""); } static grub_off_t @@ -703,7 +707,7 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, /* Setup a new node. */ node->data = dir->data; - node->symlink = symlink; + node->have_symlink = 0; /* If the filetype was not stored using rockridge, use whatever is stored in the iso9660 filesystem. */ @@ -767,10 +771,11 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, { struct grub_fshelp_node *new_node; node->alloc_dirents *= 2; - new_node = grub_malloc (sizeof (struct grub_fshelp_node) - + ((node->alloc_dirents - - ARRAY_SIZE (node->dirents)) - * sizeof (node->dirents[0]))); + new_node = grub_realloc (node, + sizeof (struct grub_fshelp_node) + + ((node->alloc_dirents + - ARRAY_SIZE (node->dirents)) + * sizeof (node->dirents[0]))); if (!new_node) { if (filename_alloc) @@ -778,9 +783,37 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, grub_free (node); return 0; } + node = new_node; } node->dirents[node->have_dirents++] = dirent; } + if (symlink) + { + if ((node->alloc_dirents - node->have_dirents) + * sizeof (node->dirents[0]) < grub_strlen (symlink) + 1) + { + struct grub_fshelp_node *new_node; + new_node = grub_realloc (node, + sizeof (struct grub_fshelp_node) + + ((node->alloc_dirents + - ARRAY_SIZE (node->dirents)) + * sizeof (node->dirents[0])) + + grub_strlen (symlink) + 1); + if (!new_node) + { + if (filename_alloc) + grub_free (filename); + grub_free (node); + return 0; + } + node = new_node; + } + node->have_symlink = 1; + grub_strcpy (node->symlink + + node->have_dirents * sizeof (node->dirents[0]) + - sizeof (node->dirents), symlink); + grub_free (symlink); + } if (hook (filename, type, node)) { if (filename_alloc) @@ -832,7 +865,7 @@ grub_iso9660_dir (grub_device_t device, const char *path, rootnode.data = data; rootnode.alloc_dirents = 0; rootnode.have_dirents = 1; - rootnode.symlink = 0; + rootnode.have_symlink = 0; rootnode.dirents[0] = data->voldesc.rootdir; /* Use the fshelp function to traverse the path. */ @@ -875,7 +908,7 @@ grub_iso9660_open (struct grub_file *file, const char *name) rootnode.data = data; rootnode.alloc_dirents = 0; rootnode.have_dirents = 1; - rootnode.symlink = 0; + rootnode.have_symlink = 0; rootnode.dirents[0] = data->voldesc.rootdir; /* Use the fshelp function to traverse the path. */ From 33f784e88175d449eab915d74020cb6cd581b333 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Thu, 10 Nov 2011 09:41:07 +0100 Subject: [PATCH 16/40] Allow all modules to perform serial IO * grub-core/term-serial.c (grub_serial_find): Remove static qualifier * include/grub/serial.h (grub_serial_port_configure): New inline function. (grub_serial_port_fetch): Likewise. (grub_serial_port_put): Likewise. (grub_serial_port_fini): Likewise. (grub_serial_find): New proto. --- ChangeLog | 12 ++++++++++++ grub-core/term/serial.c | 2 +- include/grub/serial.h | 27 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f293e0773..6c7304387 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-11-10 Shea Levy + + Allow all modules to perform serial IO + + * grub-core/term-serial.c (grub_serial_find): Remove static qualifier + * include/grub/serial.h (grub_serial_port_configure): New inline + function. + (grub_serial_port_fetch): Likewise. + (grub_serial_port_put): Likewise. + (grub_serial_port_fini): Likewise. + (grub_serial_find): New proto. + 2011-11-10 Vladimir Serbinenko Put symlink at the end of the node and fix a potential diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c index 306694192..86935626c 100644 --- a/grub-core/term/serial.c +++ b/grub-core/term/serial.c @@ -125,7 +125,7 @@ static struct grub_term_output grub_serial_term_output = -static struct grub_serial_port * +struct grub_serial_port * grub_serial_find (char *name) { struct grub_serial_port *port; diff --git a/include/grub/serial.h b/include/grub/serial.h index 41b720891..49ac0623a 100644 --- a/include/grub/serial.h +++ b/include/grub/serial.h @@ -96,6 +96,32 @@ grub_err_t EXPORT_FUNC(grub_serial_register) (struct grub_serial_port *port); void EXPORT_FUNC(grub_serial_unregister) (struct grub_serial_port *port); + /* Convenience functions to perform primitive operations on a port. */ +static inline grub_err_t +grub_serial_port_configure (struct grub_serial_port *port, + struct grub_serial_config *config) +{ + return port->driver->configure (port, config); +} + +static inline int +grub_serial_port_fetch (struct grub_serial_port *port) +{ + return port->driver->fetch (port); +} + +static inline void +grub_serial_port_put (struct grub_serial_port *port, const int c) +{ + port->driver->put (port, c); +} + +static inline void +grub_serial_port_fini (struct grub_serial_port *port) +{ + port->driver->fini (port); +} + /* Set default settings. */ static inline grub_err_t grub_serial_config_defaults (struct grub_serial_port *port) @@ -117,6 +143,7 @@ grub_serial_config_defaults (struct grub_serial_port *port) void grub_ns8250_init (void); char *grub_serial_ns8250_add_port (grub_port_t port); +struct grub_serial_port *grub_serial_find (char *name); extern struct grub_serial_driver grub_ns8250_driver; void EXPORT_FUNC(grub_serial_unregister_driver) (struct grub_serial_driver *driver); From 11a775a3ad55e6de651edcd71d344ea41e64d2eb Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 17:08:29 +0100 Subject: [PATCH 17/40] * grub-core/commands/probe.c (grub_cmd_probe): Fix error message. --- ChangeLog | 4 ++++ grub-core/commands/probe.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6c7304387..4e2d18c11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/commands/probe.c (grub_cmd_probe): Fix error message. + 2011-11-10 Shea Levy Allow all modules to perform serial IO diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c index ce1e9aac0..a1d68cdeb 100644 --- a/grub-core/commands/probe.c +++ b/grub-core/commands/probe.c @@ -136,7 +136,7 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args) return err; if (! label) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "uuid for this FS isn't supported yet"); + "label for this FS isn't supported yet"); if (state[0].set) grub_env_set (state[0].arg, label); From f768836950b038dbc67dabafb2a6086148edab82 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 17:10:50 +0100 Subject: [PATCH 18/40] * grub-core/efiemu/main.c (grub_efiemu_register_configuration_table): A stylistic fix. --- ChangeLog | 5 +++++ grub-core/efiemu/main.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4e2d18c11..fcbfe0c9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/efiemu/main.c (grub_efiemu_register_configuration_table): + A stylistic fix. + 2011-11-11 Vladimir Serbinenko * grub-core/commands/probe.c (grub_cmd_probe): Fix error message. diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c index 7ad3abb0d..126ecf9e7 100644 --- a/grub-core/efiemu/main.c +++ b/grub-core/efiemu/main.c @@ -149,7 +149,8 @@ grub_efiemu_register_configuration_table (grub_efi_guid_t guid, if (! get_table && ! data) return grub_error (GRUB_ERR_BAD_ARGUMENT, "you must set at least get_table or data"); - if ((err = grub_efiemu_unregister_configuration_table (guid))) + err = grub_efiemu_unregister_configuration_table (guid); + if (err) return err; tbl = (struct grub_efiemu_configuration_table *) grub_malloc (sizeof (*tbl)); From 6c1892942da03b61e5bfe74f670d3b5c33053152 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 17:13:23 +0100 Subject: [PATCH 19/40] * grub-core/fs/btrfs.c (grub_btrfs_embed): Spelling fix. --- ChangeLog | 4 ++++ grub-core/fs/btrfs.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fcbfe0c9d..e37326afa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/fs/btrfs.c (grub_btrfs_embed): Spelling fix. + 2011-11-11 Vladimir Serbinenko * grub-core/efiemu/main.c (grub_efiemu_register_configuration_table): diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index fae9199a4..db251ffd7 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -1615,7 +1615,7 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), if (embed_type != GRUB_EMBED_PCBIOS) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "BtrFS curently supports only PC-BIOS embedding"); + "BtrFS currently supports only PC-BIOS embedding"); if (64 * 2 - 1 < *nsectors) return grub_error (GRUB_ERR_OUT_OF_RANGE, From 53dc85906500ef6a23a37562c5619bf25ca6d7a2 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 17:18:34 +0100 Subject: [PATCH 20/40] * grub-core/fs/ntfs.c (grub_ntfs_read_symlink): Stylistic fix. Remove leftover debug printf. --- ChangeLog | 5 +++++ grub-core/fs/ntfs.c | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e37326afa..2b2920b79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/fs/ntfs.c (grub_ntfs_read_symlink): Stylistic fix. Remove + leftover debug printf. + 2011-11-11 Vladimir Serbinenko * grub-core/fs/btrfs.c (grub_btrfs_embed): Spelling fix. diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c index 13de52cd8..ac695a29f 100644 --- a/grub-core/fs/ntfs.c +++ b/grub-core/fs/ntfs.c @@ -705,17 +705,18 @@ grub_ntfs_read_symlink (grub_fshelp_node_t node) switch (grub_cpu_to_le32 (symdesc.type)) { case 0xa000000c: - off = sizeof (struct symlink_descriptor) + 4 + grub_cpu_to_le32 (symdesc.off1); + off = (sizeof (struct symlink_descriptor) + 4 + + grub_cpu_to_le32 (symdesc.off1)); len = grub_cpu_to_le32 (symdesc.len1); break; case 0xa0000003: - off = sizeof (struct symlink_descriptor) + grub_cpu_to_le32 (symdesc.off1); + off = (sizeof (struct symlink_descriptor) + + grub_cpu_to_le32 (symdesc.off1)); len = grub_cpu_to_le32 (symdesc.len1); break; default: grub_error (GRUB_ERR_BAD_FS, "symlink type invalid (%x)", grub_cpu_to_le32 (symdesc.type)); - grub_printf ("%d\n", __LINE__); return NULL; } From e2d22baf41ecd6252d9c7ca718d4906f37338cd9 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 17:21:33 +0100 Subject: [PATCH 21/40] * grub-core/fs/zfs/zfscrypt.c (GRUB_MOD_INIT), (GRUB_MOD_FINI): Fix module name. --- ChangeLog | 5 +++++ grub-core/fs/zfs/zfscrypt.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b2920b79..0864781d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/fs/zfs/zfscrypt.c (GRUB_MOD_INIT), (GRUB_MOD_FINI): + Fix module name. + 2011-11-11 Vladimir Serbinenko * grub-core/fs/ntfs.c (grub_ntfs_read_symlink): Stylistic fix. Remove diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c index 13f62b25a..619878243 100644 --- a/grub-core/fs/zfs/zfscrypt.c +++ b/grub-core/fs/zfs/zfscrypt.c @@ -455,7 +455,7 @@ grub_cmd_zfs_key (grub_extcmd_context_t ctxt, int argc, char **args) static grub_extcmd_t cmd_key; -GRUB_MOD_INIT(zfscrypto) +GRUB_MOD_INIT(zfscrypt) { grub_zfs_decrypt = grub_zfs_decrypt_real; grub_zfs_load_key = grub_zfs_load_key_real; @@ -465,7 +465,7 @@ GRUB_MOD_INIT(zfscrypto) options); } -GRUB_MOD_FINI(zfscrypto) +GRUB_MOD_FINI(zfscrypt) { grub_zfs_decrypt = 0; grub_zfs_load_key = 0; From 4c458569a7f1a7ac71c0d4f91820d45a227b3326 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 17:34:38 +0100 Subject: [PATCH 22/40] * grub-core/kern/ieee1275/ieee1275.c (grub_ieee1275_set_property): Make buf a const. --- ChangeLog | 5 +++++ grub-core/kern/ieee1275/ieee1275.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0864781d7..f011fdef5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/kern/ieee1275/ieee1275.c (grub_ieee1275_set_property): + Make buf a const. + 2011-11-11 Vladimir Serbinenko * grub-core/fs/zfs/zfscrypt.c (GRUB_MOD_INIT), (GRUB_MOD_FINI): diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c index 9e2919172..b32fd2d8b 100644 --- a/grub-core/kern/ieee1275/ieee1275.c +++ b/grub-core/kern/ieee1275/ieee1275.c @@ -532,7 +532,7 @@ grub_ieee1275_release (grub_addr_t addr, grub_size_t size) int grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle, - const char *propname, void *buf, + const char *propname, const void *buf, grub_size_t size, grub_ssize_t *actual) { struct set_property_args From 63a9e6f6a07bc07ae1df3c6917428cccfbf1fb71 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 17:44:47 +0100 Subject: [PATCH 23/40] * grub-core/kern/ieee1275/openfw.c (grub_ieee1275_parse_args): Issue error rather than printf on unknown arguments. --- ChangeLog | 5 +++++ grub-core/kern/ieee1275/openfw.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f011fdef5..7c2b55e3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/kern/ieee1275/openfw.c (grub_ieee1275_parse_args): + Issue error rather than printf on unknown arguments. + 2011-11-11 Vladimir Serbinenko * grub-core/kern/ieee1275/ieee1275.c (grub_ieee1275_set_property): diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c index 57252d96b..3568ffe64 100644 --- a/grub-core/kern/ieee1275/openfw.c +++ b/grub-core/kern/ieee1275/openfw.c @@ -403,7 +403,8 @@ grub_ieee1275_parse_args (const char *path, enum grub_ieee1275_parse_type ptype) break; default: unknown: - grub_printf ("Unsupported type %s for device %s\n", type, device); + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "unsupported type %s for device %s", type, device); } fail: From 9bb182f3716cc9f850f5e64edb61a6da09748d7e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 18:05:16 +0100 Subject: [PATCH 24/40] * grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Issue an error and not a fatal on unrecognised relocation types. --- ChangeLog | 5 +++++ grub-core/kern/x86_64/dl.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7c2b55e3b..b0a790c10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Issue + an error and not a fatal on unrecognised relocation types. + 2011-11-11 Vladimir Serbinenko * grub-core/kern/ieee1275/openfw.c (grub_ieee1275_parse_args): diff --git a/grub-core/kern/x86_64/dl.c b/grub-core/kern/x86_64/dl.c index 090ad78b8..9b63b30f8 100644 --- a/grub-core/kern/x86_64/dl.c +++ b/grub-core/kern/x86_64/dl.c @@ -109,7 +109,9 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) break; default: - grub_fatal ("Unrecognized relocation: %d\n", ELF_R_TYPE (rel->r_info)); + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "this relocation (%d) is not implemented yet", + ELF_R_TYPE (rel->r_info)); } } } From f7ce5bafb56ebeb2121c2d35eb98293f3e98acd0 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 18:30:34 +0100 Subject: [PATCH 25/40] Fix mips compilation. * grub-core/lib/xzembed/xz_dec_stream.c (xz_dec): Restrict hash_id to normal decoder. (hashes): Use in embed decoder as well (for sizes). (dec_stream_header): Fix embed decompressor logic. (dec_stream_footer): Likewise. --- ChangeLog | 10 ++++++++++ grub-core/lib/xzembed/xz_dec_stream.c | 19 ++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index b0a790c10..ca07d5cab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-11-11 Vladimir Serbinenko + + Fix mips compilation. + + * grub-core/lib/xzembed/xz_dec_stream.c (xz_dec): Restrict hash_id to + normal decoder. + (hashes): Use in embed decoder as well (for sizes). + (dec_stream_header): Fix embed decompressor logic. + (dec_stream_footer): Likewise. + 2011-11-11 Vladimir Serbinenko * grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Issue diff --git a/grub-core/lib/xzembed/xz_dec_stream.c b/grub-core/lib/xzembed/xz_dec_stream.c index 383c29a2f..09e5e513a 100644 --- a/grub-core/lib/xzembed/xz_dec_stream.c +++ b/grub-core/lib/xzembed/xz_dec_stream.c @@ -78,9 +78,9 @@ struct xz_dec { #ifndef GRUB_EMBED_DECOMPRESSOR const gcry_md_spec_t *hash; const gcry_md_spec_t *crc32; + grub_uint8_t hash_id; #endif grub_size_t hash_size; - grub_uint8_t hash_id; /* True if we are operating in single-call mode. */ bool single_call; @@ -428,8 +428,7 @@ static enum xz_ret hash_validate(struct xz_dec *s, struct xz_buf *b, return XZ_STREAM_END; } -#ifndef GRUB_EMBED_DECOMPRESSOR -static struct +static const struct { const char *name; grub_size_t size; @@ -438,7 +437,6 @@ static struct [0x04] = { "CRC64", 8}, [0x0A] = { "SHA256", 32}, }; -#endif /* Decode the Stream Header field (the first 12 bytes of the .xz Stream). */ static enum xz_ret dec_stream_header(struct xz_dec *s) @@ -470,9 +468,9 @@ static enum xz_ret dec_stream_header(struct xz_dec *s) } #endif +#ifndef GRUB_EMBED_DECOMPRESSOR /* - * Decode the Stream Flags field. Of integrity checks, we support - * only none (Check ID = 0) and CRC32 (Check ID = 1). + * Decode the Stream Flags field. */ if (s->temp.buf[HEADER_MAGIC_SIZE] != 0 || s->temp.buf[HEADER_MAGIC_SIZE + 1] >= ARRAY_SIZE (hashes) @@ -482,7 +480,6 @@ static enum xz_ret dec_stream_header(struct xz_dec *s) s->hash_id = s->temp.buf[HEADER_MAGIC_SIZE + 1]; -#ifndef GRUB_EMBED_DECOMPRESSOR if (s->crc32) { s->crc32_context = kmalloc(s->crc32->contextsize, GFP_KERNEL); @@ -530,17 +527,15 @@ static enum xz_ret dec_stream_header(struct xz_dec *s) s->hash->init(s->index.hash.hash_context); s->hash->init(s->block.hash.hash_context); } -#else - s->hash = 0; -#endif -#if 1 if (!s->hash) return XZ_OPTIONS_ERROR; #endif } else { +#ifndef GRUB_EMBED_DECOMPRESSOR s->hash = 0; +#endif s->hash_size = 0; } @@ -589,8 +584,10 @@ static enum xz_ret dec_stream_footer(struct xz_dec *s) if ((s->index.size >> 2) != get_le32(s->temp.buf + 4)) return XZ_DATA_ERROR; +#ifndef GRUB_EMBED_DECOMPRESSOR if (s->temp.buf[8] != 0 || s->temp.buf[9] != s->hash_id) return XZ_DATA_ERROR; +#endif /* * Use XZ_STREAM_END instead of XZ_OK to be more convenient From a8bd9d39d6fa19ee6672db9732a6f9f1a6d2502e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 18:32:06 +0100 Subject: [PATCH 26/40] * include/grub/ieee1275/ieee1275.h (grub_ieee1275_set_property): Fix prototype. --- ChangeLog | 5 +++++ include/grub/ieee1275/ieee1275.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ca07d5cab..4838d9566 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Vladimir Serbinenko + + * include/grub/ieee1275/ieee1275.h (grub_ieee1275_set_property): + Fix prototype. + 2011-11-11 Vladimir Serbinenko Fix mips compilation. diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index 81590ee4b..be3835a42 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -173,7 +173,8 @@ int EXPORT_FUNC(grub_ieee1275_claim) (grub_addr_t addr, grub_size_t size, unsigned int align, grub_addr_t *result); int EXPORT_FUNC(grub_ieee1275_release) (grub_addr_t addr, grub_size_t size); int EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle, - const char *propname, void *buf, + const char *propname, + const void *buf, grub_size_t size, grub_ssize_t *actual); int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle, From 067fdf005573500c6998402affe1723cd51efaf9 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 20:02:51 +0100 Subject: [PATCH 27/40] * grub-core/kern/misc.c (grub_strstr): Moved from here ... * include/grub/misc.h (grub_strstr): ... here. Make static and inline. --- ChangeLog | 5 +++++ grub-core/kern/misc.c | 46 ----------------------------------------- include/grub/misc.h | 48 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4838d9566..6d740545a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/kern/misc.c (grub_strstr): Moved from here ... + * include/grub/misc.h (grub_strstr): ... here. Make static and inline. + 2011-11-11 Vladimir Serbinenko * include/grub/ieee1275/ieee1275.h (grub_ieee1275_set_property): diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index ebf80f100..34c9b3b0c 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -312,52 +312,6 @@ grub_strrchr (const char *s, int c) return p; } -/* Copied from gnulib. - Written by Bruno Haible , 2005. */ -char * -grub_strstr (const char *haystack, const char *needle) -{ - /* Be careful not to look at the entire extent of haystack or needle - until needed. This is useful because of these two cases: - - haystack may be very long, and a match of needle found early, - - needle may be very long, and not even a short initial segment of - needle may be found in haystack. */ - if (*needle != '\0') - { - /* Speed up the following searches of needle by caching its first - character. */ - char b = *needle++; - - for (;; haystack++) - { - if (*haystack == '\0') - /* No match. */ - return NULL; - if (*haystack == b) - /* The first character matches. */ - { - const char *rhaystack = haystack + 1; - const char *rneedle = needle; - - for (;; rhaystack++, rneedle++) - { - if (*rneedle == '\0') - /* Found a match. */ - return (char *) haystack; - if (*rhaystack == '\0') - /* No match. */ - return NULL; - if (*rhaystack != *rneedle) - /* Nothing in this round. */ - break; - } - } - } - } - else - return (char *) haystack; -} - int grub_strword (const char *haystack, const char *needle) { diff --git a/include/grub/misc.h b/include/grub/misc.h index 4e7d9077c..358f73258 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -113,7 +113,53 @@ int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n); char *EXPORT_FUNC(grub_strchr) (const char *s, int c); char *EXPORT_FUNC(grub_strrchr) (const char *s, int c); int EXPORT_FUNC(grub_strword) (const char *s, const char *w); -char *EXPORT_FUNC(grub_strstr) (const char *haystack, const char *needle); + +/* Copied from gnulib. + Written by Bruno Haible , 2005. */ +static inline char * +grub_strstr (const char *haystack, const char *needle) +{ + /* Be careful not to look at the entire extent of haystack or needle + until needed. This is useful because of these two cases: + - haystack may be very long, and a match of needle found early, + - needle may be very long, and not even a short initial segment of + needle may be found in haystack. */ + if (*needle != '\0') + { + /* Speed up the following searches of needle by caching its first + character. */ + char b = *needle++; + + for (;; haystack++) + { + if (*haystack == '\0') + /* No match. */ + return 0; + if (*haystack == b) + /* The first character matches. */ + { + const char *rhaystack = haystack + 1; + const char *rneedle = needle; + + for (;; rhaystack++, rneedle++) + { + if (*rneedle == '\0') + /* Found a match. */ + return (char *) haystack; + if (*rhaystack == '\0') + /* No match. */ + return 0; + if (*rhaystack != *rneedle) + /* Nothing in this round. */ + break; + } + } + } + } + else + return (char *) haystack; +} + int EXPORT_FUNC(grub_isspace) (int c); int EXPORT_FUNC(grub_isprint) (int c); From 9aed8a7178adb8c959fde3c3c3318478c8eab9ec Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 20:09:14 +0100 Subject: [PATCH 28/40] * grub-core/normal/main.c (grub_normal_execute): Remove leftover call. --- ChangeLog | 4 ++++ grub-core/normal/main.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6d740545a..abf4dce28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/normal/main.c (grub_normal_execute): Remove leftover call. + 2011-11-11 Vladimir Serbinenko * grub-core/kern/misc.c (grub_strstr): Moved from here ... diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index f372b6798..281b1f4bc 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -274,7 +274,6 @@ grub_normal_execute (const char *config, int nested, int batch) prefix = grub_env_get ("prefix"); read_lists (prefix); grub_register_variable_hook ("prefix", NULL, read_lists_hook); - grub_command_execute ("parser.grub", 0, 0); } if (config) From d35d0d3753cef291ed141d891f6c5e98dee929f7 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 20:34:37 +0100 Subject: [PATCH 29/40] Add const keyword to grub_env_get and gettextize week days. * grub-core/hook/datehook.c (grub_datetime_names): Make const. (grub_read_hook_datetime): Return const char *. * grub-core/kern/env.c (grub_env_get): Return const char *. All users updated. * grub-core/normal/datetime.c (grub_weekday_names): Make const. Mark for gettext. (grub_get_weekday_name): Return const char *. Call gettext. * grub-core/script/argv.c (grub_script_argv_append): Receive const char * and len as the argument. All users updated. (grub_script_argv_split_append): Receive const char *. * include/grub/datetime.h (grub_get_weekday_name): Update proto. * include/grub/env.h (grub_env_get): Likewise. (grub_env_read_hook_t): Return const char *. * include/grub/script_sh.h (grub_script_argv_append): Update proto. (grub_script_argv_split_append): Likewise. --- ChangeLog | 20 ++++++++++++++ grub-core/commands/i386/pc/drivemap.c | 2 +- grub-core/commands/legacycfg.c | 2 +- grub-core/commands/loadenv.c | 4 +-- grub-core/commands/wildcard.c | 2 +- grub-core/gettext/gettext.c | 2 +- grub-core/hook/datehook.c | 4 +-- grub-core/kern/dl.c | 2 +- grub-core/kern/env.c | 2 +- grub-core/kern/parser.c | 2 +- grub-core/lib/i386/pc/biosnum.c | 2 +- grub-core/loader/i386/linux.c | 7 ++--- grub-core/loader/i386/xnu.c | 2 +- grub-core/normal/datetime.c | 21 ++++++++------- grub-core/normal/menu.c | 4 +-- grub-core/script/argv.c | 25 ++++++++--------- grub-core/script/execute.c | 39 ++++++++++++++++----------- include/grub/datetime.h | 2 +- include/grub/env.h | 6 ++--- include/grub/script_sh.h | 5 ++-- 20 files changed, 91 insertions(+), 64 deletions(-) diff --git a/ChangeLog b/ChangeLog index abf4dce28..f98fd8e75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2011-11-11 Vladimir Serbinenko + + Add const keyword to grub_env_get and gettextize week days. + + * grub-core/hook/datehook.c (grub_datetime_names): Make const. + (grub_read_hook_datetime): Return const char *. + * grub-core/kern/env.c (grub_env_get): Return const char *. All users + updated. + * grub-core/normal/datetime.c (grub_weekday_names): Make const. + Mark for gettext. + (grub_get_weekday_name): Return const char *. Call gettext. + * grub-core/script/argv.c (grub_script_argv_append): Receive const + char * and len as the argument. All users updated. + (grub_script_argv_split_append): Receive const char *. + * include/grub/datetime.h (grub_get_weekday_name): Update proto. + * include/grub/env.h (grub_env_get): Likewise. + (grub_env_read_hook_t): Return const char *. + * include/grub/script_sh.h (grub_script_argv_append): Update proto. + (grub_script_argv_split_append): Likewise. + 2011-11-11 Vladimir Serbinenko * grub-core/normal/main.c (grub_normal_execute): Remove leftover call. diff --git a/grub-core/commands/i386/pc/drivemap.c b/grub-core/commands/i386/pc/drivemap.c index c9c8881b4..9a89f968c 100644 --- a/grub-core/commands/i386/pc/drivemap.c +++ b/grub-core/commands/i386/pc/drivemap.c @@ -363,7 +363,7 @@ uninstall_int13_handler (void) static int grub_get_root_biosnumber_drivemap (void) { - char *biosnum; + const char *biosnum; int ret = -1; grub_device_t dev; diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index e68b3315a..4e87adafc 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -344,7 +344,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), int bsd_part = -1; { grub_device_t dev; - char *hdbiasstr; + const char *hdbiasstr; int hdbias = 0; hdbiasstr = grub_env_get ("legacy_hdbias"); if (hdbiasstr) diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c index 5d53a8e66..1073712d5 100644 --- a/grub-core/commands/loadenv.c +++ b/grub-core/commands/loadenv.c @@ -43,7 +43,7 @@ open_envblk_file (char *filename) if (! filename) { - char *prefix; + const char *prefix; prefix = grub_env_get ("prefix"); if (prefix) @@ -346,7 +346,7 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args) while (argc) { - char *value; + const char *value; value = grub_env_get (args[0]); if (value) diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c index 256c07e51..d991b2010 100644 --- a/grub-core/commands/wildcard.c +++ b/grub-core/commands/wildcard.c @@ -436,7 +436,7 @@ wildcard_expand (const char *s, char ***strs) else if (*start == '/') /* no device part */ { - char *root; + const char *root; char *prefix; root = grub_env_get ("root"); diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c index 8581b1ff3..682754421 100644 --- a/grub-core/gettext/gettext.c +++ b/grub-core/gettext/gettext.c @@ -294,7 +294,7 @@ grub_mofile_open_lang (const char *locale_dir, const char *locale) static void grub_gettext_init_ext (const char *locale) { - char *locale_dir; + const char *locale_dir; if (!locale) return; diff --git a/grub-core/hook/datehook.c b/grub-core/hook/datehook.c index f64fac074..d7ceb85c8 100644 --- a/grub-core/hook/datehook.c +++ b/grub-core/hook/datehook.c @@ -26,7 +26,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); -static char *grub_datetime_names[] = +static const char *grub_datetime_names[] = { "YEAR", "MONTH", @@ -37,7 +37,7 @@ static char *grub_datetime_names[] = "WEEKDAY", }; -static char * +static const char * grub_read_hook_datetime (struct grub_env_var *var, const char *val __attribute__ ((unused))) { diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index b6fb537e8..26cf0d21d 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -697,7 +697,7 @@ grub_dl_load (const char *name) { char *filename; grub_dl_t mod; - char *grub_dl_dir = grub_env_get ("prefix"); + const char *grub_dl_dir = grub_env_get ("prefix"); mod = grub_dl_get (name); if (mod) diff --git a/grub-core/kern/env.c b/grub-core/kern/env.c index 8f843a872..96b730d35 100644 --- a/grub-core/kern/env.c +++ b/grub-core/kern/env.c @@ -132,7 +132,7 @@ grub_env_set (const char *name, const char *val) return grub_errno; } -char * +const char * grub_env_get (const char *name) { struct grub_env_var *var; diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c index 6370a7b3a..5b449586c 100644 --- a/grub-core/kern/parser.c +++ b/grub-core/kern/parser.c @@ -123,7 +123,7 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline, void add_var (grub_parser_state_t newstate) { - char *val; + const char *val; /* Check if a variable was being read in and the end of the name was reached. */ diff --git a/grub-core/lib/i386/pc/biosnum.c b/grub-core/lib/i386/pc/biosnum.c index 12771085a..0f0e743c4 100644 --- a/grub-core/lib/i386/pc/biosnum.c +++ b/grub-core/lib/i386/pc/biosnum.c @@ -24,7 +24,7 @@ static int grub_get_root_biosnumber_default (void) { - char *biosnum; + const char *biosnum; int ret = -1; grub_device_t dev; diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index fded7bb0a..a6eb95028 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -320,7 +320,7 @@ grub_linux_setup_video (struct linux_kernel_params *params) void *framebuffer; grub_err_t err; grub_video_driver_id_t driver_id; - char *gfxlfbvar = grub_env_get ("gfxpayloadforcelfb"); + const char *gfxlfbvar = grub_env_get ("gfxpayloadforcelfb"); driver_id = grub_video_get_driver_id (); @@ -418,14 +418,15 @@ grub_linux_boot (void) struct linux_kernel_params *params; int e820_num; grub_err_t err = 0; - char *modevar, *tmp; + const char *modevar; + char *tmp; struct grub_relocator32_state state; params = real_mode_mem; #ifdef GRUB_MACHINE_IEEE1275 { - char *bootpath; + const char *bootpath; grub_ssize_t len; bootpath = grub_env_get ("root"); diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index 6128ec384..fa7af514b 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -700,7 +700,7 @@ grub_cpu_xnu_fill_devicetree (void) return grub_errno; /* First see if user supplies the value. */ - char *fsbvar = grub_env_get ("fsb"); + const char *fsbvar = grub_env_get ("fsb"); if (! fsbvar) *((grub_uint64_t *) curval->data) = 0; else diff --git a/grub-core/normal/datetime.c b/grub-core/normal/datetime.c index 44791e18c..8183601ba 100644 --- a/grub-core/normal/datetime.c +++ b/grub-core/normal/datetime.c @@ -18,16 +18,17 @@ */ #include +#include -static char *grub_weekday_names[] = +static const char *grub_weekday_names[] = { - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", + N_("Sunday"), + N_("Monday"), + N_("Tuesday"), + N_("Wednesday"), + N_("Thursday"), + N_("Friday"), + N_("Saturday"), }; int @@ -42,10 +43,10 @@ grub_get_weekday (struct grub_datetime *datetime) return (datetime->day + y + y / 4 - y / 100 + y / 400 + (31 * m / 12)) % 7; } -char * +const char * grub_get_weekday_name (struct grub_datetime *datetime) { - return grub_weekday_names[grub_get_weekday (datetime)]; + return _ (grub_weekday_names[grub_get_weekday (datetime)]); } #define SECPERMIN 60 diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index 2c127794b..b75e9f523 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -79,7 +79,7 @@ grub_menu_get_entry (grub_menu_t menu, int no) int grub_menu_get_timeout (void) { - char *val; + const char *val; int timeout; val = grub_env_get ("timeout"); @@ -124,7 +124,7 @@ grub_menu_set_timeout (int timeout) static int get_and_remove_first_entry_number (const char *name) { - char *val; + const char *val; char *tail; int entry; diff --git a/grub-core/script/argv.c b/grub-core/script/argv.c index 856828d7b..b58d3e658 100644 --- a/grub-core/script/argv.c +++ b/grub-core/script/argv.c @@ -66,7 +66,8 @@ grub_script_argv_make (struct grub_script_argv *argv, int argc, char **args) struct grub_script_argv r = { 0, 0, 0 }; for (i = 0; i < argc; i++) - if (grub_script_argv_next (&r) || grub_script_argv_append (&r, args[i])) + if (grub_script_argv_next (&r) + || grub_script_argv_append (&r, args[i], grub_strlen (args[i]))) { grub_script_argv_free (&r); return 1; @@ -99,23 +100,23 @@ grub_script_argv_next (struct grub_script_argv *argv) /* Append `s' to the last argument. */ int -grub_script_argv_append (struct grub_script_argv *argv, const char *s) +grub_script_argv_append (struct grub_script_argv *argv, const char *s, + grub_size_t slen) { - int a; - int b; + grub_size_t a; char *p = argv->args[argv->argc - 1]; if (! s) return 0; a = p ? grub_strlen (p) : 0; - b = grub_strlen (s); - p = grub_realloc (p, round_up_exp ((a + b + 1) * sizeof (char))); + p = grub_realloc (p, round_up_exp ((a + slen + 1) * sizeof (char))); if (! p) return 1; - grub_strcpy (p + a, s); + grub_memcpy (p + a, s, slen); + p[a+slen] = 0; argv->args[argv->argc - 1] = p; return 0; @@ -123,10 +124,9 @@ grub_script_argv_append (struct grub_script_argv *argv, const char *s) /* Split `s' and append words as multiple arguments. */ int -grub_script_argv_split_append (struct grub_script_argv *argv, char *s) +grub_script_argv_split_append (struct grub_script_argv *argv, const char *s) { - char ch; - char *p; + const char *p; int errors = 0; if (! s) @@ -138,10 +138,7 @@ grub_script_argv_split_append (struct grub_script_argv *argv, char *s) while (*s && ! grub_isspace (*s)) s++; - ch = *s; - *s = '\0'; - errors += grub_script_argv_append (argv, p); - *s = ch; + errors += grub_script_argv_append (argv, p, s - p); while (*s && grub_isspace (*s)) s++; diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c index 72d199760..1fb5de6a3 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -193,7 +193,7 @@ grub_script_env_get (const char *name, grub_script_arg_type_t type) if (! grub_env_special (name)) { - char *v = grub_env_get (name); + const char *v = grub_env_get (name); if (v && v[0]) { if (type == GRUB_SCRIPT_ARG_TYPE_VAR) @@ -202,20 +202,20 @@ grub_script_env_get (const char *name, grub_script_arg_type_t type) goto fail; } else - if (grub_script_argv_append (&result, v)) + if (grub_script_argv_append (&result, v, grub_strlen (v))) goto fail; } } else if (! scope) { - if (grub_script_argv_append (&result, 0)) + if (grub_script_argv_append (&result, 0, 0)) goto fail; } else if (grub_strcmp (name, "#") == 0) { char buffer[ERRNO_DIGITS_MAX + 1]; grub_snprintf (buffer, sizeof (buffer), "%u", scope->argv.argc); - if (grub_script_argv_append (&result, buffer)) + if (grub_script_argv_append (&result, buffer, grub_strlen (buffer))) goto fail; } else if (grub_strcmp (name, "*") == 0) @@ -231,10 +231,11 @@ grub_script_env_get (const char *name, grub_script_arg_type_t type) } else { - if (i != 0 && grub_script_argv_append (&result, " ")) + if (i != 0 && grub_script_argv_append (&result, " ", 1)) goto fail; - if (grub_script_argv_append (&result, scope->argv.args[i])) + if (grub_script_argv_append (&result, scope->argv.args[i], + grub_strlen (scope->argv.args[i]))) goto fail; } } @@ -251,7 +252,8 @@ grub_script_env_get (const char *name, grub_script_arg_type_t type) goto fail; } else - if (grub_script_argv_append (&result, scope->argv.args[i])) + if (grub_script_argv_append (&result, scope->argv.args[i], + grub_strlen (scope->argv.args[i]))) goto fail; } } @@ -270,7 +272,9 @@ grub_script_env_get (const char *name, grub_script_arg_type_t type) goto fail; } else - if (grub_script_argv_append (&result, scope->argv.args[num - 1])) + if (grub_script_argv_append (&result, scope->argv.args[num - 1], + grub_strlen (scope->argv.args[num - 1]) + )) goto fail; } } @@ -309,7 +313,7 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist, char *p = 0; if (! grub_wildcard_translator || escape_type == 0) - return grub_script_argv_append (&result, s); + return grub_script_argv_append (&result, s, grub_strlen (s)); if (escape_type > 0) p = grub_wildcard_translator->escape (s); @@ -319,7 +323,7 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist, if (! p) return 1; - r = grub_script_argv_append (&result, p); + r = grub_script_argv_append (&result, p, grub_strlen (p)); grub_free (p); return r; } @@ -344,7 +348,8 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist, if (arg->type == GRUB_SCRIPT_ARG_TYPE_VAR) { - if (grub_script_argv_append (&result, values[i])) + if (grub_script_argv_append (&result, values[i], + grub_strlen (values[i]))) goto fail; } else @@ -359,16 +364,18 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist, break; case GRUB_SCRIPT_ARG_TYPE_BLOCK: - if (grub_script_argv_append (&result, "{") || - grub_script_argv_append (&result, arg->str) || - grub_script_argv_append (&result, "}")) + if (grub_script_argv_append (&result, "{", 1) + || grub_script_argv_append (&result, arg->str, + grub_strlen (arg->str)) + || grub_script_argv_append (&result, "}", 1)) goto fail; result.script = arg->script; break; case GRUB_SCRIPT_ARG_TYPE_TEXT: if (grub_strlen (arg->str) && - grub_script_argv_append (&result, arg->str)) + grub_script_argv_append (&result, arg->str, + grub_strlen (arg->str))) goto fail; break; @@ -680,7 +687,7 @@ grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd) { int ret; - char *result; + const char *result; struct grub_script_cmdif *cmdif = (struct grub_script_cmdif *) cmd; /* Check if the commands results in a true or a false. The value is diff --git a/include/grub/datetime.h b/include/grub/datetime.h index 049dbc227..a7154fa1a 100644 --- a/include/grub/datetime.h +++ b/include/grub/datetime.h @@ -46,7 +46,7 @@ grub_err_t grub_set_datetime (struct grub_datetime *datetime); #endif int grub_get_weekday (struct grub_datetime *datetime); -char *grub_get_weekday_name (struct grub_datetime *datetime); +const char *grub_get_weekday_name (struct grub_datetime *datetime); void grub_unixtime2datetime (grub_int32_t nix, struct grub_datetime *datetime); diff --git a/include/grub/env.h b/include/grub/env.h index c0107f16a..1ef11ecad 100644 --- a/include/grub/env.h +++ b/include/grub/env.h @@ -26,8 +26,8 @@ struct grub_env_var; -typedef char *(*grub_env_read_hook_t) (struct grub_env_var *var, - const char *val); +typedef const char *(*grub_env_read_hook_t) (struct grub_env_var *var, + const char *val); typedef char *(*grub_env_write_hook_t) (struct grub_env_var *var, const char *val); @@ -43,7 +43,7 @@ struct grub_env_var }; grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val); -char *EXPORT_FUNC(grub_env_get) (const char *name); +const char *EXPORT_FUNC(grub_env_get) (const char *name); void EXPORT_FUNC(grub_env_unset) (const char *name); void EXPORT_FUNC(grub_env_iterate) (int (*func) (struct grub_env_var *var)); struct grub_env_var *EXPORT_FUNC(grub_env_find) (const char *name); diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h index 6d31fca5a..fdccaca8d 100644 --- a/include/grub/script_sh.h +++ b/include/grub/script_sh.h @@ -245,8 +245,9 @@ void grub_script_mem_free (struct grub_script_mem *mem); void grub_script_argv_free (struct grub_script_argv *argv); int grub_script_argv_make (struct grub_script_argv *argv, int argc, char **args); int grub_script_argv_next (struct grub_script_argv *argv); -int grub_script_argv_append (struct grub_script_argv *argv, const char *s); -int grub_script_argv_split_append (struct grub_script_argv *argv, char *s); +int grub_script_argv_append (struct grub_script_argv *argv, const char *s, + grub_size_t slen); +int grub_script_argv_split_append (struct grub_script_argv *argv, const char *s); struct grub_script_arglist * grub_script_create_arglist (struct grub_parser_param *state); From c1860f878be376b2778dc0590a94f8f8494a7c87 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 20:45:31 +0100 Subject: [PATCH 30/40] * grub-core/kern/misc.c (grub_vprintf): Add missing va_end. (grub_xvasprintf): Likewise. --- ChangeLog | 5 +++++ grub-core/kern/misc.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index f98fd8e75..bdab31591 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/kern/misc.c (grub_vprintf): Add missing va_end. + (grub_xvasprintf): Likewise. + 2011-11-11 Vladimir Serbinenko Add const keyword to grub_env_get and gettextize week days. diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 34c9b3b0c..8dd7f453f 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -216,6 +216,8 @@ grub_vprintf (const char *fmt, va_list args) s = grub_vsnprintf_real (curbuf, s, fmt, ap2); } + va_end (ap2); + grub_xputs (curbuf); if (curbuf != buf) @@ -911,6 +913,9 @@ grub_xvasprintf (const char *fmt, va_list ap) return NULL; s = grub_vsnprintf_real (ret, as, fmt, ap2); + + va_end (ap2); + if (s <= as) return ret; From 5b289bc5f6b48bdfb12a9a78779b4fef66d91d6e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 20:52:41 +0100 Subject: [PATCH 31/40] * util/grub-macho2img.c: Add comment concerning gettext. * grub-core/lib/legacy_parse.c: Likewise. --- ChangeLog | 5 +++++ grub-core/lib/legacy_parse.c | 3 +++ util/grub-macho2img.c | 2 ++ 3 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index bdab31591..aaec2066b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Vladimir Serbinenko + + * util/grub-macho2img.c: Add comment concerning gettext. + * grub-core/lib/legacy_parse.c: Likewise. + 2011-11-11 Vladimir Serbinenko * grub-core/kern/misc.c (grub_vprintf): Add missing va_end. diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c index 659fa7061..43fca51dc 100644 --- a/grub-core/lib/legacy_parse.c +++ b/grub-core/lib/legacy_parse.c @@ -58,6 +58,9 @@ struct legacy_command const char *longdesc; }; +/* Help texts are kept here mostly for reference. They are never shown. So + no need to gettextize. + */ static struct legacy_command legacy_commands[] = { {"blocklist", "blocklist '%s'\n", NULL, 0, 1, {TYPE_FILE}, 0, "FILE", diff --git a/util/grub-macho2img.c b/util/grub-macho2img.c index bce0a06d1..6dfb5fcbe 100644 --- a/util/grub-macho2img.c +++ b/util/grub-macho2img.c @@ -25,6 +25,8 @@ #include #include +/* Please don't internationalise this file. It's pointless. */ + /* XXX: this file assumes particular Mach-O layout and does no checks. */ /* However as build system ensures correct usage of this tool this shouldn't be a problem. */ From df067ad13af3c5722a0d7370d429415342d446a0 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 20:59:25 +0100 Subject: [PATCH 32/40] * grub-core/efiemu/mm.c (grub_efiemu_mmap_fill): Change printf into dprintf. * grub-core/font/font.c (grub_font_load): Likewise. --- ChangeLog | 6 ++++++ grub-core/efiemu/mm.c | 3 ++- grub-core/font/font.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index aaec2066b..e645709ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/efiemu/mm.c (grub_efiemu_mmap_fill): Change printf into + dprintf. + * grub-core/font/font.c (grub_font_load): Likewise. + 2011-11-11 Vladimir Serbinenko * util/grub-macho2img.c: Add comment concerning gettext. diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c index 3c1dc2946..7bb7cc080 100644 --- a/grub-core/efiemu/mm.c +++ b/grub-core/efiemu/mm.c @@ -404,7 +404,8 @@ grub_efiemu_mmap_fill (void) GRUB_EFI_ACPI_MEMORY_NVS); default: - grub_printf ("Unknown memory type %d. Assuming unusable\n", type); + grub_dprintf ("efiemu", + "Unknown memory type %d. Assuming unusable\n", type); case GRUB_MEMORY_RESERVED: return grub_efiemu_add_to_mmap (addr, size, GRUB_EFI_UNUSABLE_MEMORY); diff --git a/grub-core/font/font.c b/grub-core/font/font.c index 26eac4c05..3737480cf 100644 --- a/grub-core/font/font.c +++ b/grub-core/font/font.c @@ -608,7 +608,7 @@ grub_font_load (const char *filename) if (!font->name) { - grub_printf ("Note: Font has no name.\n"); + grub_dprintf ("font", "Font has no name.\n"); font->name = grub_strdup ("Unknown"); } From c76b54176213bb705badc31a434ec0229a45751e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 21:03:49 +0100 Subject: [PATCH 33/40] * grub-core/hook/datehook.c (grub_read_hook_datetime): Small stylistic fix. --- ChangeLog | 5 +++++ grub-core/hook/datehook.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e645709ef..be33b7660 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/hook/datehook.c (grub_read_hook_datetime): Small stylistic + fix. + 2011-11-11 Vladimir Serbinenko * grub-core/efiemu/mm.c (grub_efiemu_mmap_fill): Change printf into diff --git a/grub-core/hook/datehook.c b/grub-core/hook/datehook.c index d7ceb85c8..ac75908ef 100644 --- a/grub-core/hook/datehook.c +++ b/grub-core/hook/datehook.c @@ -50,7 +50,7 @@ grub_read_hook_datetime (struct grub_env_var *var, int i; for (i = 0; i < 7; i++) - if (! grub_strcmp (var->name, grub_datetime_names[i])) + if (grub_strcmp (var->name, grub_datetime_names[i]) == 0) { int n; From 12d4f965cddb0625d2c6ada654463adefdef8bce Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 21:14:41 +0100 Subject: [PATCH 34/40] Support %1$d syntax. * tests/printf_unit_test.c: New file. * Makefile.util.def (printf_test): New test. * grub-core/kern/misc.c (grub_vsnprintf_real): Support %1$d syntax. --- Makefile.util.def | 15 ++ grub-core/kern/misc.c | 484 ++++++++++++++++++++++++++------------- tests/printf_unit_test.c | 43 ++++ 3 files changed, 378 insertions(+), 164 deletions(-) create mode 100644 tests/printf_unit_test.c diff --git a/Makefile.util.def b/Makefile.util.def index 8742d1583..89e614468 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -660,6 +660,21 @@ program = { ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; +program = { + testcase; + name = printf_test; + common = tests/printf_unit_test.c; + common = tests/lib/unit_test.c; + common = grub-core/kern/list.c; + common = grub-core/kern/misc.c; + common = grub-core/tests/lib/test.c; + ldadd = libgrubmods.a; + ldadd = libgrubgcry.a; + ldadd = libgrubkern.a; + ldadd = grub-core/gnulib/libgnu.a; + ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; +}; + program = { name = grub-menulst2cfg; mansection = 1; diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 8dd7f453f..128139dc8 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -637,10 +637,13 @@ grub_lltoa (char *str, int c, unsigned long long n) } static int -grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt, va_list args) +grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, va_list args_in) { char c; + grub_size_t n = 0; grub_size_t count = 0; + grub_size_t count_args = 0; + const char *fmt; auto void write_char (unsigned char ch); auto void write_str (const char *s); auto void write_fill (const char ch, int n); @@ -659,209 +662,362 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt, va_list ar write_char (*s++); } - void write_fill (const char ch, int n) + void write_fill (const char ch, int count_fill) { int i; - for (i = 0; i < n; i++) + for (i = 0; i < count_fill; i++) write_char (ch); } + fmt = fmt0; while ((c = *fmt++) != 0) { if (c != '%') - write_char (c); - else + continue; + + if (*fmt && *fmt =='-') + fmt++; + + while (*fmt && grub_isdigit (*fmt)) + fmt++; + + if (*fmt && *fmt == '$') + fmt++; + + if (*fmt && *fmt =='-') + fmt++; + + while (*fmt && grub_isdigit (*fmt)) + fmt++; + + if (*fmt && *fmt =='.') + fmt++; + + while (*fmt && grub_isdigit (*fmt)) + fmt++; + + c = *fmt++; + if (c == 'l') { - char tmp[32]; - char *p; - unsigned int format1 = 0; - unsigned int format2 = ~ 0U; - char zerofill = ' '; - int rightfill = 0; - int n; - int longfmt = 0; - int longlongfmt = 0; - int unsig = 0; + c = *fmt++; + if (c == 'l') + c = *fmt++; + } + switch (c) + { + case 'p': + case 'x': + case 'u': + case 'd': + case 'c': + case 'C': + case 's': + count_args++; + break; + } + } - if (*fmt && *fmt =='-') + enum { INT, WCHAR, LONG, LONGLONG, POINTER } types[count_args]; + union + { + int i; + grub_uint32_t w; + long l; + long long ll; + void *p; + } args[count_args]; + + grub_memset (types, 0, sizeof (types)); + + fmt = fmt0; + n = 0; + while ((c = *fmt++) != 0) + { + int longfmt = 0; + int longlongfmt = 0; + grub_size_t curn; + const char *p; + + if (c != '%') + continue; + + curn = n++; + + if (*fmt && *fmt =='-') + fmt++; + + while (*fmt && grub_isdigit (*fmt)) + fmt++; + + p = fmt; + + if (*fmt && *fmt == '$') + { + curn = grub_strtoull (p, 0, 10) - 1; + fmt++; + } + + while (*fmt && grub_isdigit (*fmt)) + fmt++; + + c = *fmt++; + if (c == 'l') + { + c = *fmt++; + longfmt = 1; + if (c == 'l') { - rightfill = 1; - fmt++; + c = *fmt++; + longlongfmt = 1; } + } + if (curn >= count_args) + continue; + switch (c) + { + case 'x': + case 'u': + case 'd': + if (longlongfmt) + types[curn] = LONGLONG; + else if (longfmt) + types[curn] = LONG; + else + types[curn] = INT; + break; + case 'p': + case 's': + types[curn] = POINTER; + break; + case 'c': + types[curn] = INT; + break; + case 'C': + types[curn] = WCHAR; + break; + } + } - p = (char *) fmt; - /* Read formatting parameters. */ + for (n = 0; n < count_args; n++) + switch (types[n]) + { + case WCHAR: + args[n].w = va_arg (args_in, grub_uint32_t); + break; + case POINTER: + args[n].p = va_arg (args_in, void *); + break; + case INT: + args[n].i = va_arg (args_in, int); + break; + case LONG: + args[n].l = va_arg (args_in, long); + break; + case LONGLONG: + args[n].ll = va_arg (args_in, long long); + break; + } + + fmt = fmt0; + + n = 0; + while ((c = *fmt++) != 0) + { + char tmp[32]; + char *p; + unsigned int format1 = 0; + unsigned int format2 = ~ 0U; + char zerofill = ' '; + int rightfill = 0; + int longfmt = 0; + int longlongfmt = 0; + int unsig = 0; + grub_size_t curn; + + if (c != '%') + { + write_char (c); + continue; + } + + curn = n++; + + rescan:; + + if (*fmt && *fmt =='-') + { + rightfill = 1; + fmt++; + } + + p = (char *) fmt; + /* Read formatting parameters. */ + while (*p && grub_isdigit (*p)) + p++; + + if (p > fmt) + { + char s[p - fmt + 1]; + grub_strncpy (s, fmt, p - fmt); + s[p - fmt] = 0; + if (s[0] == '0') + zerofill = '0'; + format1 = grub_strtoul (s, 0, 10); + fmt = p; + } + + if (*p && *p == '.') + { + p++; + fmt++; while (*p && grub_isdigit (*p)) p++; if (p > fmt) { - char s[p - fmt + 1]; - grub_strncpy (s, fmt, p - fmt); - s[p - fmt] = 0; - if (s[0] == '0') - zerofill = '0'; - format1 = grub_strtoul (s, 0, 10); + char fstr[p - fmt + 1]; + grub_strncpy (fstr, fmt, p - fmt); + fstr[p - fmt] = 0; + format2 = grub_strtoul (fstr, 0, 10); fmt = p; } + } + if (*fmt == '$') + { + curn = format1 - 1; + fmt++; + format1 = 0; + format2 = ~ 0U; + zerofill = ' '; + rightfill = 0; - if (*p && *p == '.') - { - p++; - fmt++; - while (*p && grub_isdigit (*p)) - p++; - - if (p > fmt) - { - char fstr[p - fmt + 1]; - grub_strncpy (fstr, fmt, p - fmt); - fstr[p - fmt] = 0; - format2 = grub_strtoul (fstr, 0, 10); - fmt = p; - } - } + goto rescan; + } + c = *fmt++; + if (c == 'l') + { + longfmt = 1; c = *fmt++; if (c == 'l') { - longfmt = 1; + longlongfmt = 1; c = *fmt++; - if (c == 'l') - { - longlongfmt = 1; - c = *fmt++; - } } + } - switch (c) - { - case 'p': - write_str ("0x"); - c = 'x'; - longlongfmt |= (sizeof (void *) == sizeof (long long)); - /* Fall through. */ - case 'x': - case 'u': - unsig = 1; - /* Fall through. */ - case 'd': - if (longlongfmt) - { - long long ll; + if (curn >= count_args) + continue; - ll = va_arg (args, long long); - grub_lltoa (tmp, c, ll); - } - else if (longfmt && unsig) - { - unsigned long l = va_arg (args, unsigned long); - grub_lltoa (tmp, c, l); - } - else if (longfmt) - { - long l = va_arg (args, long); - grub_lltoa (tmp, c, l); - } - else if (unsig) - { - unsigned u = va_arg (args, unsigned); - grub_lltoa (tmp, c, u); - } - else - { - n = va_arg (args, int); - grub_lltoa (tmp, c, n); - } - if (! rightfill && grub_strlen (tmp) < format1) - write_fill (zerofill, format1 - grub_strlen (tmp)); - write_str (tmp); - if (rightfill && grub_strlen (tmp) < format1) - write_fill (zerofill, format1 - grub_strlen (tmp)); - break; + switch (c) + { + case 'p': + write_str ("0x"); + c = 'x'; + longlongfmt |= (sizeof (void *) == sizeof (long long)); + /* Fall through. */ + case 'x': + case 'u': + unsig = 1; + /* Fall through. */ + case 'd': + if (longlongfmt) + grub_lltoa (tmp, c, args[curn].ll); + else if (longfmt && unsig) + grub_lltoa (tmp, c, (unsigned long) args[curn].l); + else if (longfmt) + grub_lltoa (tmp, c, args[curn].l); + else if (unsig) + grub_lltoa (tmp, c, (unsigned) args[curn].i); + else + grub_lltoa (tmp, c, args[curn].i); + if (! rightfill && grub_strlen (tmp) < format1) + write_fill (zerofill, format1 - grub_strlen (tmp)); + write_str (tmp); + if (rightfill && grub_strlen (tmp) < format1) + write_fill (zerofill, format1 - grub_strlen (tmp)); + break; - case 'c': - n = va_arg (args, int); - write_char (n & 0xff); - break; + case 'c': + write_char (args[curn].i & 0xff); + break; - case 'C': + case 'C': + { + grub_uint32_t code = args[curn].w; + int shift; + unsigned mask; + + if (code <= 0x7f) { - grub_uint32_t code = va_arg (args, grub_uint32_t); - int shift; - unsigned mask; - - if (code <= 0x7f) - { - shift = 0; - mask = 0; - } - else if (code <= 0x7ff) - { - shift = 6; - mask = 0xc0; - } - else if (code <= 0xffff) - { - shift = 12; - mask = 0xe0; - } - else if (code <= 0x1fffff) - { - shift = 18; - mask = 0xf0; - } - else if (code <= 0x3ffffff) - { - shift = 24; - mask = 0xf8; - } - else if (code <= 0x7fffffff) - { - shift = 30; - mask = 0xfc; - } - else - { - code = '?'; - shift = 0; - mask = 0; - } - - write_char (mask | (code >> shift)); - - for (shift -= 6; shift >= 0; shift -= 6) - write_char (0x80 | (0x3f & (code >> shift))); + shift = 0; + mask = 0; + } + else if (code <= 0x7ff) + { + shift = 6; + mask = 0xc0; + } + else if (code <= 0xffff) + { + shift = 12; + mask = 0xe0; + } + else if (code <= 0x1fffff) + { + shift = 18; + mask = 0xf0; + } + else if (code <= 0x3ffffff) + { + shift = 24; + mask = 0xf8; + } + else if (code <= 0x7fffffff) + { + shift = 30; + mask = 0xfc; + } + else + { + code = '?'; + shift = 0; + mask = 0; } - break; - case 's': - p = va_arg (args, char *); - if (p) - { - grub_size_t len = 0; - while (len < format2 && p[len]) - len++; + write_char (mask | (code >> shift)); - if (!rightfill && len < format1) - write_fill (zerofill, format1 - len); + for (shift -= 6; shift >= 0; shift -= 6) + write_char (0x80 | (0x3f & (code >> shift))); + } + break; - grub_size_t i; - for (i = 0; i < len; i++) - write_char (*p++); + case 's': + p = args[curn].p; + if (p) + { + grub_size_t len = 0; + while (len < format2 && p[len]) + len++; - if (rightfill && len < format1) - write_fill (zerofill, format1 - len); - } - else - write_str ("(null)"); + if (!rightfill && len < format1) + write_fill (zerofill, format1 - len); - break; + grub_size_t i; + for (i = 0; i < len; i++) + write_char (*p++); - default: - write_char (c); - break; + if (rightfill && len < format1) + write_fill (zerofill, format1 - len); } + else + write_str ("(null)"); + + break; + + default: + write_char (c); + break; } } diff --git a/tests/printf_unit_test.c b/tests/printf_unit_test.c new file mode 100644 index 000000000..6e601b401 --- /dev/null +++ b/tests/printf_unit_test.c @@ -0,0 +1,43 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2011 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include + +static void +printf_test (void) +{ + char real[512]; + char expected[512]; + grub_snprintf (real, sizeof (real), "%d %d %d", 1, 2, 3); + snprintf (expected, sizeof (expected), "%d %d %d", 1, 2, 3); + grub_test_assert (strcmp (real, expected) == 0); + grub_snprintf (real, sizeof (real), "%3$d %2$d %1$d", 1, 2, 3); + snprintf (expected, sizeof (expected), "%3$d %2$d %1$d", 1, 2, 3); + grub_test_assert (strcmp (real, expected) == 0); + grub_snprintf (real, sizeof (real), "%d %lld %d", 1, 2LL, 3); + snprintf (expected, sizeof (expected), "%d %lld %d", 1, 2LL, 3); + grub_test_assert (strcmp (real, expected) == 0); + grub_snprintf (real, sizeof (real), "%3$d %2$lld %1$d", 1, 2LL, 3); + snprintf (expected, sizeof (expected), "%3$d %2$lld %1$d", 1, 2LL, 3); + grub_test_assert (strcmp (real, expected) == 0); +} + +GRUB_UNIT_TEST ("printf_unit_test", printf_test); From 073aa7a9bf07d988b6337850f48599901089b9d7 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 21:22:02 +0100 Subject: [PATCH 35/40] Forgotten ChangeLog entry --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index be33b7660..725415cd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-11-11 Vladimir Serbinenko + + Support %1$d syntax. + + * tests/printf_unit_test.c: New file. + * Makefile.util.def (printf_test): New test. + * grub-core/kern/misc.c (grub_vsnprintf_real): Support %1$d syntax. + 2011-11-11 Vladimir Serbinenko * grub-core/hook/datehook.c (grub_read_hook_datetime): Small stylistic From 6e0632e28cd692faae2b026bb987e69906d6326a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 21:44:56 +0100 Subject: [PATCH 36/40] * grub-core/commands/acpihalt.c: Gettextized. * grub-core/commands/cacheinfo.c: Likewise. * grub-core/commands/cmp.c: Likewise. * grub-core/commands/efi/loadbios.c: Likewise. * grub-core/commands/gptsync.c: Likewise. * grub-core/commands/ieee1275/suspend.c: Likewise. * grub-core/commands/legacycfg.c: Likewise. * grub-core/commands/memrw.c: Likewise. * grub-core/commands/minicmd.c: Likewise. * grub-core/commands/parttool.c: Likewise. * grub-core/commands/time.c: Likewise. * grub-core/commands/videoinfo.c: Likewise. * grub-core/disk/geli.c: Likewise. * grub-core/disk/i386/pc/biosdisk.c: Likewise. * grub-core/disk/luks.c: Likewise. * grub-core/disk/lvm.c: Likewise. * grub-core/font/font_cmd.c: Likewise. * grub-core/fs/zfs/zfscrypt.c: Likewise. * grub-core/fs/zfs/zfsinfo.c: Likewise. * grub-core/gfxmenu/view.c: Likewise. * grub-core/kern/emu/hostdisk.c: Likewise. * grub-core/kern/emu/main.c: Likewise. * grub-core/kern/emu/misc.c: Likewise. * grub-core/kern/emu/mm.c: Likewise. * grub-core/kern/mips/arc/init.c: Likewise. * grub-core/kern/mips/loongson/init.c: Likewise. * grub-core/kern/partition.c: Likewise. * grub-core/lib/i386/halt.c: Likewise. * grub-core/lib/mips/arc/reboot.c: Likewise. * grub-core/lib/mips/loongson/reboot.c: Likewise. * grub-core/loader/i386/pc/chainloader.c: Likewise. * grub-core/loader/i386/xnu.c: Likewise. * grub-core/loader/multiboot.c: Likewise. * grub-core/net/bootp.c: Likewise. * grub-core/net/net.c: Likewise. * grub-core/normal/term.c: Likewise. * grub-core/partmap/bsdlabel.c: Likewise. * grub-core/parttool/msdospart.c: Likewise. * grub-core/term/gfxterm.c: Likewise. * grub-core/term/terminfo.c: Likewise. * grub-core/video/i386/pc/vbe.c: Likewise. * util/grub-menulst2cfg.c: Likewise. * util/grub-mkdevicemap.c: Likewise. * util/grub-mklayout.c: Likewise. * util/grub-mkrelpath.c: Likewise. * util/grub-script-check.c: Likewise. * util/ieee1275/grub-ofpathname.c: Likewise. * util/resolve.c: Likewise. --- ChangeLog | 51 ++++++++++++++++ grub-core/commands/acpihalt.c | 3 +- grub-core/commands/cacheinfo.c | 4 +- grub-core/commands/cmp.c | 19 +++--- grub-core/commands/efi/loadbios.c | 6 +- grub-core/commands/gptsync.c | 2 +- grub-core/commands/ieee1275/suspend.c | 2 +- grub-core/commands/legacycfg.c | 2 +- grub-core/commands/memrw.c | 2 +- grub-core/commands/minicmd.c | 2 +- grub-core/commands/parttool.c | 14 ++--- grub-core/commands/time.c | 4 +- grub-core/commands/videoinfo.c | 65 ++++++++++---------- grub-core/disk/geli.c | 14 ++--- grub-core/disk/i386/pc/biosdisk.c | 3 +- grub-core/disk/luks.c | 6 +- grub-core/disk/lvm.c | 3 +- grub-core/font/font_cmd.c | 2 +- grub-core/fs/zfs/zfscrypt.c | 6 +- grub-core/fs/zfs/zfsinfo.c | 83 +++++++++++++------------- grub-core/gfxmenu/view.c | 3 +- grub-core/kern/emu/hostdisk.c | 20 +++---- grub-core/kern/emu/main.c | 10 ++-- grub-core/kern/emu/misc.c | 6 +- grub-core/kern/emu/mm.c | 2 +- grub-core/kern/mips/arc/init.c | 5 +- grub-core/kern/mips/loongson/init.c | 3 +- grub-core/kern/partition.c | 3 +- grub-core/lib/i386/halt.c | 3 +- grub-core/lib/mips/arc/reboot.c | 3 +- grub-core/lib/mips/loongson/reboot.c | 3 +- grub-core/loader/i386/pc/chainloader.c | 2 +- grub-core/loader/i386/xnu.c | 2 +- grub-core/loader/multiboot.c | 2 +- grub-core/net/bootp.c | 4 +- grub-core/net/net.c | 8 +-- grub-core/normal/term.c | 5 +- grub-core/partmap/bsdlabel.c | 3 +- grub-core/parttool/msdospart.c | 13 ++-- grub-core/term/gfxterm.c | 5 +- grub-core/term/terminfo.c | 2 +- grub-core/video/i386/pc/vbe.c | 17 +++--- util/grub-menulst2cfg.c | 7 ++- util/grub-mkdevicemap.c | 8 +-- util/grub-mklayout.c | 16 ++--- util/grub-mkrelpath.c | 10 ++-- util/grub-script-check.c | 10 ++-- util/ieee1275/grub-ofpathname.c | 2 +- util/resolve.c | 5 +- 49 files changed, 275 insertions(+), 200 deletions(-) diff --git a/ChangeLog b/ChangeLog index 725415cd0..c3c0cfe61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,54 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/commands/acpihalt.c: Gettextized. + * grub-core/commands/cacheinfo.c: Likewise. + * grub-core/commands/cmp.c: Likewise. + * grub-core/commands/efi/loadbios.c: Likewise. + * grub-core/commands/gptsync.c: Likewise. + * grub-core/commands/ieee1275/suspend.c: Likewise. + * grub-core/commands/legacycfg.c: Likewise. + * grub-core/commands/memrw.c: Likewise. + * grub-core/commands/minicmd.c: Likewise. + * grub-core/commands/parttool.c: Likewise. + * grub-core/commands/time.c: Likewise. + * grub-core/commands/videoinfo.c: Likewise. + * grub-core/disk/geli.c: Likewise. + * grub-core/disk/i386/pc/biosdisk.c: Likewise. + * grub-core/disk/luks.c: Likewise. + * grub-core/disk/lvm.c: Likewise. + * grub-core/font/font_cmd.c: Likewise. + * grub-core/fs/zfs/zfscrypt.c: Likewise. + * grub-core/fs/zfs/zfsinfo.c: Likewise. + * grub-core/gfxmenu/view.c: Likewise. + * grub-core/kern/emu/hostdisk.c: Likewise. + * grub-core/kern/emu/main.c: Likewise. + * grub-core/kern/emu/misc.c: Likewise. + * grub-core/kern/emu/mm.c: Likewise. + * grub-core/kern/mips/arc/init.c: Likewise. + * grub-core/kern/mips/loongson/init.c: Likewise. + * grub-core/kern/partition.c: Likewise. + * grub-core/lib/i386/halt.c: Likewise. + * grub-core/lib/mips/arc/reboot.c: Likewise. + * grub-core/lib/mips/loongson/reboot.c: Likewise. + * grub-core/loader/i386/pc/chainloader.c: Likewise. + * grub-core/loader/i386/xnu.c: Likewise. + * grub-core/loader/multiboot.c: Likewise. + * grub-core/net/bootp.c: Likewise. + * grub-core/net/net.c: Likewise. + * grub-core/normal/term.c: Likewise. + * grub-core/partmap/bsdlabel.c: Likewise. + * grub-core/parttool/msdospart.c: Likewise. + * grub-core/term/gfxterm.c: Likewise. + * grub-core/term/terminfo.c: Likewise. + * grub-core/video/i386/pc/vbe.c: Likewise. + * util/grub-menulst2cfg.c: Likewise. + * util/grub-mkdevicemap.c: Likewise. + * util/grub-mklayout.c: Likewise. + * util/grub-mkrelpath.c: Likewise. + * util/grub-script-check.c: Likewise. + * util/ieee1275/grub-ofpathname.c: Likewise. + * util/resolve.c: Likewise. + 2011-11-11 Vladimir Serbinenko Support %1$d syntax. diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c index 9a4cda521..177ec15f0 100644 --- a/grub-core/commands/acpihalt.c +++ b/grub-core/commands/acpihalt.c @@ -33,6 +33,7 @@ typedef uint8_t grub_uint8_t; #endif #include +#include #ifndef GRUB_DSDT_TEST #include @@ -327,6 +328,6 @@ grub_acpi_halt (void) grub_millisleep (1500); - grub_printf ("ACPI shutdown failed\n"); + grub_puts_ (N_("ACPI shutdown failed")); } #endif diff --git a/grub-core/commands/cacheinfo.c b/grub-core/commands/cacheinfo.c index 771763c9c..92aaa218d 100644 --- a/grub-core/commands/cacheinfo.c +++ b/grub-core/commands/cacheinfo.c @@ -31,14 +31,14 @@ grub_rescue_cmd_info (struct grub_command *cmd __attribute__ ((unused)), unsigned long hits, misses; grub_disk_cache_get_performance (&hits, &misses); - grub_printf ("Disk cache: hits = %lu, misses = %lu ", hits, misses); + grub_printf_ (N_("Disk cache: hits = %lu, misses = %lu "), hits, misses); if (hits + misses) { unsigned long ratio = hits * 10000 / (hits + misses); grub_printf ("(%lu.%lu%%)\n", ratio / 100, ratio % 100); } else - grub_printf ("(N/A)\n"); + grub_puts_ (N_("(N/A)")); return 0; } diff --git a/grub-core/commands/cmp.c b/grub-core/commands/cmp.c index 526459311..5d5925dd5 100644 --- a/grub-core/commands/cmp.c +++ b/grub-core/commands/cmp.c @@ -42,8 +42,8 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)), if (argc != 2) return grub_error (GRUB_ERR_BAD_ARGUMENT, "two arguments required"); - grub_printf ("Compare file `%s' with `%s':\n", args[0], - args[1]); + grub_printf_ (N_("Compare file `%s' with `%s':\n"), args[0], + args[1]); file1 = grub_file_open (args[0]); file2 = grub_file_open (args[1]); @@ -51,9 +51,9 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)), goto cleanup; if (grub_file_size (file1) != grub_file_size (file2)) - grub_printf ("Files differ in size: %llu [%s], %llu [%s]\n", - (unsigned long long) grub_file_size (file1), args[0], - (unsigned long long) grub_file_size (file2), args[1]); + grub_printf_ (N_("Files differ in size: %llu [%s], %llu [%s]\n"), + (unsigned long long) grub_file_size (file1), args[0], + (unsigned long long) grub_file_size (file2), args[1]); else { pos = 0; @@ -78,9 +78,9 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)), { if (buf1[i] != buf2[i]) { - grub_printf ("Files differ at the offset %llu: 0x%x [%s], 0x%x [%s]\n", - (unsigned long long) (i + pos), buf1[i], args[0], - buf2[i], args[1]); + grub_printf_ (N_("Files differ at the offset %llu: 0x%x [%s], 0x%x [%s]\n"), + (unsigned long long) (i + pos), buf1[i], + args[0], buf2[i], args[1]); goto cleanup; } } @@ -89,7 +89,8 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)), } while (rd2); - grub_printf ("The files are identical.\n"); + /* TRANSLATORS: it's always exactly 2 files. */ + grub_printf_ (N_("The files are identical.\n")); } cleanup: diff --git a/grub-core/commands/efi/loadbios.c b/grub-core/commands/efi/loadbios.c index 138311222..5eb490fd4 100644 --- a/grub-core/commands/efi/loadbios.c +++ b/grub-core/commands/efi/loadbios.c @@ -49,7 +49,7 @@ enable_rom_area (void) rom_ptr = (grub_uint32_t *) VBIOS_ADDR; if (*rom_ptr != BLANK_MEM) { - grub_printf ("ROM image is present.\n"); + grub_puts_ (N_("ROM image is present.")); return 0; } @@ -67,7 +67,7 @@ enable_rom_area (void) *rom_ptr = 0; if (*rom_ptr != 0) { - grub_printf ("Can\'t enable ROM area.\n"); + grub_puts_ (N_("Can\'t enable ROM area.")); return 0; } @@ -209,7 +209,7 @@ GRUB_MOD_INIT(loadbios) 0, N_("Fake BIOS.")); cmd_loadbios = grub_register_command ("loadbios", grub_cmd_loadbios, - "BIOS_DUMP [INT10_DUMP]", + N_("BIOS_DUMP [INT10_DUMP]"), N_("Load BIOS dump.")); } diff --git a/grub-core/commands/gptsync.c b/grub-core/commands/gptsync.c index e92dc20ec..88d4b6296 100644 --- a/grub-core/commands/gptsync.c +++ b/grub-core/commands/gptsync.c @@ -231,7 +231,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)), return grub_errno; } - grub_printf ("New MBR is written to '%s'\n", args[0]); + grub_printf_ (N_("New MBR is written to '%s'\n"), args[0]); return GRUB_ERR_NONE; } diff --git a/grub-core/commands/ieee1275/suspend.c b/grub-core/commands/ieee1275/suspend.c index de068951d..844485077 100644 --- a/grub-core/commands/ieee1275/suspend.c +++ b/grub-core/commands/ieee1275/suspend.c @@ -31,7 +31,7 @@ grub_cmd_suspend (grub_command_t cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), char **args __attribute__ ((unused))) { - grub_printf ("Run 'go' to resume GRUB.\n"); + grub_puts_ (N_("Run 'go' to resume GRUB.")); grub_ieee1275_enter (); grub_cls (); return 0; diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index 4e87adafc..4de2d84d5 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -723,7 +723,7 @@ grub_cmd_legacy_check_password (struct grub_command *mycmd __attribute__ ((unuse if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, "arguments expected"); - grub_printf ("Enter password:"); + grub_puts_ (N_("Enter password: ")); if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN)) return GRUB_ACCESS_DENIED; diff --git a/grub-core/commands/memrw.c b/grub-core/commands/memrw.c index 3b51189d6..5984288ce 100644 --- a/grub-core/commands/memrw.c +++ b/grub-core/commands/memrw.c @@ -31,7 +31,7 @@ static grub_command_t cmd_write_byte, cmd_write_word, cmd_write_dword; static const struct grub_arg_option options[] = { {0, 'v', 0, N_("Save read value into variable VARNAME."), - "VARNAME", ARG_TYPE_STRING}, + N_("VARNAME"), ARG_TYPE_STRING}, {0, 0, 0, 0, 0, 0} }; diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c index b9cbd06c1..1bb0147df 100644 --- a/grub-core/commands/minicmd.c +++ b/grub-core/commands/minicmd.c @@ -145,7 +145,7 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)), { grub_dl_t mod; - grub_printf ("Name\tRef Count\tDependencies\n"); + grub_printf_ (N_("Name\tRef Count\tDependencies\n")); FOR_DL_MODULES (mod) { grub_dl_dep_t dep; diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c index a54286161..ab5ab5ea4 100644 --- a/grub-core/commands/parttool.c +++ b/grub-core/commands/parttool.c @@ -37,9 +37,9 @@ static struct grub_parttool *parts = 0; static int curhandle = 0; static grub_dl_t mymod; static char helpmsg[] = - "Perform COMMANDS on partition.\n" - "Use \"parttool PARTITION help\" for the list " - "of available commands."; + N_("Perform COMMANDS on partition.\n" + "Use \"parttool PARTITION help\" for the list " + "of available commands."); int grub_parttool_register(const char *part_name, @@ -128,7 +128,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), break; case GRUB_PARTTOOL_ARG_VAL: - grub_printf ("=VAL"); + grub_xputs (_("=VAL")); spacing -= 4; break; @@ -137,18 +137,18 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), } while (spacing-- > 0) grub_printf (" "); - grub_printf ("%s\n", curarg->desc); + grub_puts_ (curarg->desc); } } if (! found) - grub_printf ("Sorry no parttool is available for %s\n", + grub_printf_ (N_("Sorry no parttool is available for %s\n"), dev->disk->partition->partmap->name); return GRUB_ERR_NONE; } if (argc < 1) { - grub_printf ("%s\n", helpmsg); + grub_puts_ (helpmsg); return grub_error (GRUB_ERR_BAD_ARGUMENT, "too few arguments"); } diff --git a/grub-core/commands/time.c b/grub-core/commands/time.c index 687495964..224f92b3f 100644 --- a/grub-core/commands/time.c +++ b/grub-core/commands/time.c @@ -47,8 +47,8 @@ grub_cmd_time (grub_command_t ctxt __attribute__ ((unused)), (cmd->func) (cmd, argc - 1, &args[1]); end = grub_get_time_ms (); - grub_printf ("Elapsed time: %d.%03d seconds \n", (end - start) / 1000, - (end - start) % 1000); + grub_printf_ (N_("Elapsed time: %d.%03d seconds \n"), (end - start) / 1000, + (end - start) % 1000); return grub_errno; } diff --git a/grub-core/commands/videoinfo.c b/grub-core/commands/videoinfo.c index 7ff172fd7..9e12ff55e 100644 --- a/grub-core/commands/videoinfo.c +++ b/grub-core/commands/videoinfo.c @@ -52,36 +52,36 @@ hook (const struct grub_video_mode_info *info) grub_printf ("%4d x %4d x %2d ", info->width, info->height, info->bpp); if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PURE_TEXT) - grub_printf ("Text-only "); + grub_xputs (_("Text-only ")); /* Show mask and position details for direct color modes. */ if (info->mode_type & GRUB_VIDEO_MODE_TYPE_RGB) - grub_printf ("Direct, mask: %d/%d/%d/%d pos: %d/%d/%d/%d", - info->red_mask_size, - info->green_mask_size, - info->blue_mask_size, - info->reserved_mask_size, - info->red_field_pos, - info->green_field_pos, - info->blue_field_pos, - info->reserved_field_pos); + grub_printf_ (N_("Direct, mask: %d/%d/%d/%d pos: %d/%d/%d/%d"), + info->red_mask_size, + info->green_mask_size, + info->blue_mask_size, + info->reserved_mask_size, + info->red_field_pos, + info->green_field_pos, + info->blue_field_pos, + info->reserved_field_pos); if (info->mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) - grub_printf ("Packed "); + grub_xputs (_("Packed ")); if (info->mode_type & GRUB_VIDEO_MODE_TYPE_YUV) - grub_printf ("YUV "); + grub_xputs (_("YUV ")); if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PLANAR) - grub_printf ("Planar "); + grub_xputs (_("Planar ")); if (info->mode_type & GRUB_VIDEO_MODE_TYPE_HERCULES) - grub_printf ("Hercules "); + grub_xputs (_("Hercules ")); if (info->mode_type & GRUB_VIDEO_MODE_TYPE_CGA) - grub_printf ("CGA "); + grub_xputs (_("CGA ")); if (info->mode_type & GRUB_VIDEO_MODE_TYPE_NONCHAIN4) - grub_printf ("Non-chain 4 "); + grub_xputs (_("Non-chain 4 ")); if (info->mode_type & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) - grub_printf ("Monochrome "); + grub_xputs (_("Monochrome ")); if (info->mode_type & GRUB_VIDEO_MODE_TYPE_UNKNOWN) - grub_printf ("Unknown "); + grub_xputs (_("Unknown ")); - grub_printf ("\n"); + grub_xputs ("\n"); return 0; } @@ -93,19 +93,19 @@ print_edid (struct grub_video_edid_info *edid_info) if (grub_video_edid_checksum (edid_info)) { - grub_printf (" EDID checksum invalid\n"); + grub_puts_ (N_(" EDID checksum invalid")); grub_errno = GRUB_ERR_NONE; return; } - grub_printf (" EDID version: %u.%u\n", - edid_info->version, edid_info->revision); + grub_printf_ (N_(" EDID version: %u.%u\n"), + edid_info->version, edid_info->revision); if (grub_video_edid_preferred_mode (edid_info, &edid_width, &edid_height) == GRUB_ERR_NONE) - grub_printf (" Preferred mode: %ux%u\n", edid_width, edid_height); + grub_printf_ (N_(" Preferred mode: %ux%u\n"), edid_width, edid_height); else { - grub_printf (" No preferred mode available\n"); + grub_printf_ (N_(" No preferred mode available\n")); grub_errno = GRUB_ERR_NONE; } } @@ -147,20 +147,20 @@ grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)), id = grub_video_get_driver_id (); - grub_printf ("List of supported video modes:\n"); - grub_printf ("Legend: P=Packed pixel, D=Direct color, " - "mask/pos=R/G/B/reserved\n"); + grub_puts_ (N_("List of supported video modes:")); + grub_puts_ (N_("Legend: P=Packed pixel, D=Direct color, " + "mask/pos=R/G/B/reserved")); FOR_VIDEO_ADAPTERS (adapter) { struct grub_video_mode_info info; struct grub_video_edid_info edid_info; - grub_printf ("Adapter '%s':\n", adapter->name); + grub_printf_ (N_("Adapter '%s':\n"), adapter->name); if (!adapter->iterate) { - grub_printf (" No info available\n"); + grub_puts_ (N_(" No info available")); continue; } @@ -178,7 +178,7 @@ grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)), { if (adapter->init ()) { - grub_printf (" Failed\n"); + grub_puts_ (N_(" Failed")); grub_errno = GRUB_ERR_NONE; continue; } @@ -215,12 +215,13 @@ static grub_command_t cmd_vbe; GRUB_MOD_INIT(videoinfo) { - cmd = grub_register_command ("videoinfo", grub_cmd_videoinfo, "[WxH[xD]]", + cmd = grub_register_command ("videoinfo", grub_cmd_videoinfo, N_("[WxH[xD]]"), N_("List available video modes. If " "resolution is given show only modes" " matching it.")); #ifdef GRUB_MACHINE_PCBIOS - cmd_vbe = grub_register_command ("vbeinfo", grub_cmd_videoinfo, "[WxH[xD]]", + cmd_vbe = grub_register_command ("vbeinfo", grub_cmd_videoinfo, + N_("[WxH[xD]]"), N_("List available video modes. If " "resolution is given show only modes" " matching it.")); diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c index ab94b4131..d3137bc16 100644 --- a/grub-core/disk/geli.c +++ b/grub-core/disk/geli.c @@ -226,7 +226,7 @@ grub_util_get_geli_uuid (const char *dev) uuid = xmalloc (GRUB_MD_SHA256->mdlen * 2 + 1); if (grub_util_fd_read (fd, (void *) &hdr, 512) < 0) - grub_util_error ("couldn't read ELI metadata"); + grub_util_error (_("couldn't read ELI metadata")); COMPILE_TIME_ASSERT (sizeof (header) <= 512); header = (void *) &hdr; @@ -235,7 +235,7 @@ grub_util_get_geli_uuid (const char *dev) if (grub_memcmp (header->magic, GELI_MAGIC, sizeof (GELI_MAGIC)) || grub_le_to_cpu32 (header->version) > 5 || grub_le_to_cpu32 (header->version) < 1) - grub_util_error ("wrong ELI magic or version"); + grub_util_error (_("wrong ELI magic or version")); err = make_uuid ((void *) &hdr, uuid); if (err) @@ -418,15 +418,15 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev) keysize = grub_le_to_cpu16 (header.keylen) / 8; grub_memset (zero, 0, sizeof (zero)); - grub_printf ("Attempting to decrypt master key...\n"); + grub_puts_ (N_("Attempting to decrypt master key...")); /* Get the passphrase from the user. */ tmp = NULL; if (source->partition) tmp = grub_partition_get_name (source->partition); - grub_printf ("Enter passphrase for %s%s%s (%s): ", source->name, - source->partition ? "," : "", tmp ? : "", - dev->uuid); + grub_printf_ (N_("Enter passphrase for %s%s%s (%s): "), source->name, + source->partition ? "," : "", tmp ? : "", + dev->uuid); grub_free (tmp); if (!grub_password_get (passphrase, MAX_PASSPHRASE)) return grub_error (GRUB_ERR_BAD_ARGUMENT, "Passphrase not supplied"); @@ -513,7 +513,7 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev) if (grub_memcmp (candidate_key.hmac, key_hmac, dev->hash->mdlen) != 0) continue; - grub_printf ("Slot %d opened\n", i); + grub_printf_ (N_("Slot %d opened\n"), i); /* Set the master key. */ if (!dev->rekey) diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c index e152b9d89..25f683fd1 100644 --- a/grub-core/disk/i386/pc/biosdisk.c +++ b/grub-core/disk/i386/pc/biosdisk.c @@ -27,6 +27,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -625,7 +626,7 @@ GRUB_MOD_INIT(biosdisk) if (grub_disk_firmware_is_tainted) { - grub_printf ("Firmware is marked as tainted, refusing to initialize.\n"); + grub_puts_ (N_("Firmware is marked as tainted, refusing to initialize.")); return; } grub_disk_firmware_fini = grub_disk_biosdisk_fini; diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c index 0ec95fccd..a5c0d3418 100644 --- a/grub-core/disk/luks.c +++ b/grub-core/disk/luks.c @@ -316,7 +316,7 @@ luks_recover_key (grub_disk_t source, if (err) return err; - grub_printf ("Attempting to decrypt master key...\n"); + grub_puts_ (N_("Attempting to decrypt master key...")); keysize = grub_be_to_cpu32 (header.keyBytes); for (i = 0; i < ARRAY_SIZE (header.keyblock); i++) @@ -332,7 +332,7 @@ luks_recover_key (grub_disk_t source, tmp = NULL; if (source->partition) tmp = grub_partition_get_name (source->partition); - grub_printf ("Enter passphrase for %s%s%s (%s): ", source->name, + grub_printf_ (N_("Enter passphrase for %s%s%s (%s): "), source->name, source->partition ? "," : "", tmp ? : "", dev->uuid); grub_free (tmp); @@ -434,7 +434,7 @@ luks_recover_key (grub_disk_t source, continue; } - grub_printf ("Slot %d opened\n", i); + grub_printf_ (N_("Slot %d opened\n"), i); /* Set the master key. */ gcry_err = grub_cryptodisk_setkey (dev, candidate_key, keysize); diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 4020fc427..388c7f173 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef GRUB_UTIL #include @@ -775,7 +776,7 @@ grub_lvm_memberlist (grub_disk_t disk) for (pv = lv->vg->pvs; pv; pv = pv->next) { if (!pv->disk) - grub_util_error ("Couldn't find PV %s. Check your device.map", + grub_util_error (_("Couldn't find PV %s. Check your device.map"), pv->name); tmp = grub_malloc (sizeof (*tmp)); tmp->disk = pv->disk; diff --git a/grub-core/font/font_cmd.c b/grub-core/font/font_cmd.c index 98f0b88d6..b38eccd6d 100644 --- a/grub-core/font/font_cmd.c +++ b/grub-core/font/font_cmd.c @@ -49,7 +49,7 @@ lsfonts_command (grub_command_t cmd __attribute__ ((unused)), { struct grub_font_node *node; - grub_printf ("Loaded fonts:\n"); + grub_puts_ (N_("Loaded fonts:")); for (node = grub_font_list; node; node = node->next) { grub_font_t font = node->value; diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c index 619878243..63380f66a 100644 --- a/grub-core/fs/zfs/zfscrypt.c +++ b/grub-core/fs/zfs/zfscrypt.c @@ -421,7 +421,7 @@ grub_cmd_zfs_key (grub_extcmd_context_t ctxt, int argc, char **args) } else { - grub_printf ("Enter ZFS password: "); + grub_xputs (_("Enter ZFS password: ")); if (!grub_password_get ((char *) buf, 1023)) return grub_errno; real_size = grub_strlen ((char *) buf); @@ -460,8 +460,8 @@ GRUB_MOD_INIT(zfscrypt) grub_zfs_decrypt = grub_zfs_decrypt_real; grub_zfs_load_key = grub_zfs_load_key_real; cmd_key = grub_register_extcmd ("zfskey", grub_cmd_zfs_key, 0, - "zfskey [-h|-p|-r] [FILE]", - "Import ZFS wrapping key stored in FILE.", + N_("[-h|-p|-r] [FILE]"), + N_("Import ZFS wrapping key stored in FILE."), options); } diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c index 8c073fab5..94f2a1ac8 100644 --- a/grub-core/fs/zfs/zfsinfo.c +++ b/grub-core/fs/zfs/zfsinfo.c @@ -25,6 +25,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -44,32 +45,32 @@ print_state (char *nvlist, int tab) int isok = 1; print_tabs (tab); - grub_printf ("State: "); + grub_xputs (_("State: ")); if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_REMOVED, &ival)) { - grub_printf ("removed "); + grub_xputs (_("removed ")); isok = 0; } if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival)) { - grub_printf ("faulted "); + grub_xputs (_("faulted ")); isok = 0; } if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_OFFLINE, &ival)) { - grub_printf ("offline "); + grub_xputs (_("offline ")); isok = 0; } if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival)) - grub_printf ("degraded "); + grub_xputs (_("degraded ")); if (isok) - grub_printf ("online"); - grub_printf ("\n"); + grub_xputs (_("online")); + grub_xputs ("\n"); return GRUB_ERR_NONE; } @@ -84,7 +85,7 @@ print_vdev_info (char *nvlist, int tab) if (!type) { print_tabs (tab); - grub_printf ("Incorrect VDEV: no type available\n"); + grub_puts_ (N_("Incorrect VDEV: no type available")); return grub_errno; } @@ -95,7 +96,7 @@ print_vdev_info (char *nvlist, int tab) char *devid = 0; print_tabs (tab); - grub_printf ("Leaf VDEV\n"); + grub_puts_ (N_("Leaf VDEV")); print_state (nvlist, tab); @@ -103,23 +104,23 @@ print_vdev_info (char *nvlist, int tab) grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_PHYS_PATH); print_tabs (tab); if (!bootpath) - grub_printf ("Bootpath: unavailable\n"); + grub_puts_ (N_("Bootpath: unavailable\n")); else - grub_printf ("Bootpath: %s\n", bootpath); + grub_printf_ (N_("Bootpath: %s\n"), bootpath); path = grub_zfs_nvlist_lookup_string (nvlist, "path"); print_tabs (tab); if (!path) - grub_printf ("Path: unavailable\n"); + grub_puts_ (N_("Path: unavailable")); else - grub_printf ("Path: %s\n", path); + grub_printf_ (N_("Path: %s\n"), path); devid = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_DEVID); print_tabs (tab); if (!devid) - grub_printf ("Devid: unavailable\n"); + grub_puts_ (N_("Devid: unavailable")); else - grub_printf ("Devid: %s\n", devid); + grub_printf_ (N_("Devid: %s\n"), devid); grub_free (bootpath); grub_free (devid); grub_free (path); @@ -136,10 +137,10 @@ print_vdev_info (char *nvlist, int tab) print_tabs (tab); if (nelm <= 0) { - grub_printf ("Incorrect mirror VDEV\n"); + grub_puts_ (N_("Incorrect mirror VDEV")); return GRUB_ERR_NONE; } - grub_printf ("Mirror VDEV with %d children\n", nelm); + grub_printf_ (N_("Mirror VDEV with %d children\n"), nelm); print_state (nvlist, tab); for (i = 0; i < nelm; i++) { @@ -151,11 +152,11 @@ print_vdev_info (char *nvlist, int tab) print_tabs (tab); if (!child) { - grub_printf ("Mirror VDEV element %d isn't correct\n", i); + grub_printf_ (N_("Mirror VDEV element %d isn't correct\n"), i); continue; } - grub_printf ("Mirror VDEV element %d:\n", i); + grub_printf_ (N_("Mirror VDEV element %d:\n"), i); print_vdev_info (child, tab + 1); grub_free (child); @@ -164,7 +165,7 @@ print_vdev_info (char *nvlist, int tab) } print_tabs (tab); - grub_printf ("Unknown VDEV type: %s\n", type); + grub_printf_ (N_("Unknown VDEV type: %s\n"), type); return GRUB_ERR_NONE; } @@ -221,15 +222,15 @@ get_bootpath (char *nvlist, char **bootpath, char **devid) 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 const char *poolstates[] = { + [POOL_STATE_ACTIVE] = N_("Pool state: active"), + [POOL_STATE_EXPORTED] = N_("Pool state: exported"), + [POOL_STATE_DESTROYED] = N_("Pool state: destroyed"), + [POOL_STATE_SPARE] = N_("Pool state: reserved for hot spare"), + [POOL_STATE_L2CACHE] = N_("Pool state: level 2 ARC device"), + [POOL_STATE_UNINITIALIZED] = N_("Pool state: uninitialized"), + [POOL_STATE_UNAVAIL] = N_("Pool state: unavailable"), + [POOL_STATE_POTENTIALLY_ACTIVE] = N_("Pool state: potentially active") }; static grub_err_t @@ -274,30 +275,30 @@ grub_cmd_zfsinfo (grub_command_t cmd __attribute__ ((unused)), int argc, poolname = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME); if (!poolname) - grub_printf ("Pool name: unavailable\n"); + grub_puts_ (N_("Pool name: unavailable")); else - grub_printf ("Pool name: %s\n", poolname); + grub_printf_ (N_("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"); + grub_puts_ (N_("Pool GUID: unavailable")); else - grub_printf ("Pool GUID: %016llx\n", (long long unsigned) guid); + grub_printf_ (N_("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"); + grub_puts_ (N_("Unable to retrieve pool state")); else if (pool_state >= ARRAY_SIZE (poolstates)) - grub_printf ("Unrecognized pool state\n"); + grub_puts_ (N_("Unrecognized pool state")); else - grub_printf ("Pool state: %s\n", poolstates[pool_state]); + grub_puts_ (poolstates[pool_state]); nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE); if (!nv) - grub_printf ("No vdev tree available\n"); + grub_puts_ (N_("No vdev tree available")); else print_vdev_info (nv, 1); @@ -395,11 +396,11 @@ 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."); + N_("DEVICE"), + N_("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"); + N_("FILESYSTEM [VARIABLE]"), + N_("Print ZFS-BOOTFSOBJ or set it to VARIABLE")); } GRUB_MOD_FINI (zfsinfo) diff --git a/grub-core/gfxmenu/view.c b/grub-core/gfxmenu/view.c index 836a9884d..9023fd3c4 100644 --- a/grub-core/gfxmenu/view.c +++ b/grub-core/gfxmenu/view.c @@ -36,6 +36,7 @@ #include #include #include +#include static void init_terminal (grub_gfxmenu_view_t view); @@ -77,7 +78,7 @@ grub_gfxmenu_view_new (const char *theme_path, view->desktop_image = 0; view->desktop_color = default_bg_color; view->terminal_box = grub_gfxmenu_create_box (0, 0); - view->title_text = grub_strdup ("GRUB Boot Menu"); + view->title_text = grub_strdup (_("GRUB Boot Menu")); view->progress_message_text = 0; view->theme_path = 0; diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 7bfc66fef..f537b2759 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -269,7 +269,7 @@ grub_util_get_fd_sectors (int fd, unsigned *log_secsize) struct stat st; if (fstat (fd, &st) < 0) - grub_util_error ("fstat failed"); + grub_util_error (_("fstat failed")); #if defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \ defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__) \ @@ -324,7 +324,7 @@ grub_util_get_fd_sectors (int fd, unsigned *log_secsize) return minfo.dki_capacity; # else if (nr & ((1 << log_sector_size) - 1)) - grub_util_error ("unaligned device size"); + grub_util_error (_("unaligned device size")); return (nr >> log_sector_size); # endif @@ -373,7 +373,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) size = grub_util_get_disk_size (map[drive].device); if (size % 512) - grub_util_error ("unaligned device size"); + grub_util_error (_("unaligned device size")); disk->total_sectors = size >> 9; @@ -442,13 +442,13 @@ grub_util_follow_gpart_up (const char *name, grub_disk_addr_t *off_out, char **n error = geom_gettree (&mesh); if (error != 0) - grub_util_error ("couldn't open geom"); + 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"); + grub_util_error (_("couldn't open geom part")); LIST_FOREACH (geom, &class->lg_geom, lg_geom) { @@ -1144,18 +1144,18 @@ read_device_map (const char *dev_map) continue; if (*p != '(') - show_error ("No open parenthesis found"); + show_error (_("No open parenthesis found")); p++; /* Find a free slot. */ drive = find_free_slot (); if (drive < 0) - show_error ("Map table size exceeded"); + show_error (_("Map table size exceeded")); e = p; p = strchr (p, ')'); if (! p) - show_error ("No close parenthesis found"); + show_error (_("No close parenthesis found")); map[drive].drive = xmalloc (p - e + sizeof ('\0')); strncpy (map[drive].drive, e, p - e + sizeof ('\0')); @@ -1167,7 +1167,7 @@ read_device_map (const char *dev_map) p++; if (*p == '\0') - show_error ("No filename found"); + show_error (_("No filename found")); /* NUL-terminate the filename. */ e = p; @@ -1196,7 +1196,7 @@ read_device_map (const char *dev_map) { map[drive].device = xmalloc (PATH_MAX); if (! realpath (p, map[drive].device)) - grub_util_error ("cannot get the real path of `%s'", p); + grub_util_error (_("cannot get the real path of `%s'"), p); } else #endif diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c index 8d15f17c5..725d1ac7f 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -98,10 +98,10 @@ usage (int status) { if (status) fprintf (stderr, - "Try `%s --help' for more information.\n", program_name); + _("Try `%s --help' for more information.\n"), program_name); else printf ( - "Usage: %s [OPTION]...\n" + _("Usage: %s [OPTION]...\n" "\n" "GRUB emulator.\n" "\n" @@ -113,7 +113,7 @@ usage (int status) " -h, --help display this message and exit\n" " -V, --version print version information and exit\n" "\n" - "Report bugs to <%s>.\n", program_name, DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); + "Report bugs to <%s>.\n"), program_name, DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT); return status; } @@ -166,13 +166,13 @@ main (int argc, char *argv[]) if (optind < argc) { - fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind]); + fprintf (stderr, _("Unknown extra argument `%s'.\n"), argv[optind]); return usage (1); } /* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */ if (hold && verbosity > 0) - printf ("Run \"gdb %s %d\", and set ARGS.HOLD to zero.\n", + printf (_("Run \"gdb %s %d\", and set ARGS.HOLD to zero.\n"), program_name, (int) getpid ()); while (hold) { diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c index 6f5ea9fb9..21f314d55 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -117,7 +117,7 @@ xmalloc (grub_size_t size) p = malloc (size); if (! p) - grub_util_error ("out of memory"); + grub_util_error (_("out of memory")); return p; } @@ -127,7 +127,7 @@ xrealloc (void *ptr, grub_size_t size) { ptr = realloc (ptr, size); if (! ptr) - grub_util_error ("out of memory"); + grub_util_error (_("out of memory")); return ptr; } @@ -185,7 +185,7 @@ xasprintf (const char *fmt, ...) if (vasprintf (&result, fmt, ap) < 0) { if (errno == ENOMEM) - grub_util_error ("out of memory"); + grub_util_error (_("out of memory")); return NULL; } diff --git a/grub-core/kern/emu/mm.c b/grub-core/kern/emu/mm.c index 6a70efb4c..b58ccc794 100644 --- a/grub-core/kern/emu/mm.c +++ b/grub-core/kern/emu/mm.c @@ -77,7 +77,7 @@ grub_memalign (grub_size_t align, grub_size_t size) #else (void) align; (void) size; - grub_util_error ("grub_memalign is not supported"); + grub_util_error (_("grub_memalign is not supported")); #endif if (!p) diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c index ec0fa521a..41545b11f 100644 --- a/grub-core/kern/mips/arc/init.c +++ b/grub-core/kern/mips/arc/init.c @@ -33,6 +33,7 @@ #include #include #include +#include const char *type_names[] = { #ifdef GRUB_CPU_WORDS_BIGENDIAN @@ -178,7 +179,7 @@ grub_halt (void) grub_millisleep (1500); - grub_printf ("Shutdown failed\n"); + grub_puts_ (N_("Shutdown failed")); grub_refresh (); while (1); } @@ -190,7 +191,7 @@ grub_exit (void) grub_millisleep (1500); - grub_printf ("Exit failed\n"); + grub_puts_ (N_("Exit failed")); grub_refresh (); while (1); } diff --git a/grub-core/kern/mips/loongson/init.c b/grub-core/kern/mips/loongson/init.c index 6ddf151f2..3b282e1e0 100644 --- a/grub-core/kern/mips/loongson/init.c +++ b/grub-core/kern/mips/loongson/init.c @@ -31,6 +31,7 @@ #include #include #include +#include extern void grub_video_sm712_init (void); extern void grub_video_sis315pro_init (void); @@ -254,7 +255,7 @@ grub_halt (void) break; } - grub_printf ("Shutdown failed\n"); + grub_puts_ (N_("Shutdown failed")); grub_refresh (); while (1); } diff --git a/grub-core/kern/partition.c b/grub-core/kern/partition.c index a2f5dd722..cd9e8ae0f 100644 --- a/grub-core/kern/partition.c +++ b/grub-core/kern/partition.c @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef GRUB_UTIL #include @@ -47,7 +48,7 @@ grub_partition_check_containment (const grub_disk_t disk, grub_dprintf ("partition", "sub-partition %s%d of (%s,%s) ends after parent.\n", part->partmap->name, part->number + 1, disk->name, partname); #ifdef GRUB_UTIL - grub_util_warn ("Discarding improperly nested partition (%s,%s,%s%d)", + grub_util_warn (_("Discarding improperly nested partition (%s,%s,%s%d)"), disk->name, partname, part->partmap->name, part->number + 1); #endif grub_free (partname); diff --git a/grub-core/lib/i386/halt.c b/grub-core/lib/i386/halt.c index 15c4ba0d6..bd878c9bf 100644 --- a/grub-core/lib/i386/halt.c +++ b/grub-core/lib/i386/halt.c @@ -19,6 +19,7 @@ #include #include #include +#include const char bochs_shutdown[] = "Shutdown"; @@ -52,7 +53,7 @@ grub_halt (void) for (i = 0; i < sizeof (bochs_shutdown) - 1; i++) grub_outb (bochs_shutdown[i], 0x8900); - grub_printf ("GRUB doesn't know how to halt this machine yet!\n"); + grub_puts_ (N_("GRUB doesn't know how to halt this machine yet!")); /* In order to return we'd have to check what the previous status of IF flag was. But user most likely doesn't want to return anyway ... */ diff --git a/grub-core/lib/mips/arc/reboot.c b/grub-core/lib/mips/arc/reboot.c index f0d085765..ecf12a7ed 100644 --- a/grub-core/lib/mips/arc/reboot.c +++ b/grub-core/lib/mips/arc/reboot.c @@ -20,6 +20,7 @@ #include #include #include +#include void grub_reboot (void) @@ -28,7 +29,7 @@ grub_reboot (void) grub_millisleep (1500); - grub_printf ("Reboot failed\n"); + grub_puts_ (N_("Reboot failed")); grub_refresh (); while (1); } diff --git a/grub-core/lib/mips/loongson/reboot.c b/grub-core/lib/mips/loongson/reboot.c index f099ba250..1b510784b 100644 --- a/grub-core/lib/mips/loongson/reboot.c +++ b/grub-core/lib/mips/loongson/reboot.c @@ -24,6 +24,7 @@ #include #include #include +#include void grub_reboot (void) @@ -51,7 +52,7 @@ grub_reboot (void) } grub_millisleep (1500); - grub_printf ("Reboot failed\n"); + grub_puts_ (N_("Reboot failed")); grub_refresh (); while (1); } diff --git a/grub-core/loader/i386/pc/chainloader.c b/grub-core/loader/i386/pc/chainloader.c index 8d6ec8f20..42fbdeb32 100644 --- a/grub-core/loader/i386/pc/chainloader.c +++ b/grub-core/loader/i386/pc/chainloader.c @@ -247,7 +247,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(chainloader) { cmd = grub_register_command ("chainloader", grub_cmd_chainloader, - "[--force|--bpb] FILE", + N_("[--force|--bpb] FILE"), N_("Load another boot loader.")); my_mod = mod; } diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index fa7af514b..36893ae62 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -1018,7 +1018,7 @@ grub_xnu_boot (void) { grub_print_error (); grub_errno = GRUB_ERR_NONE; - grub_printf ("Booting in blind mode\n"); + grub_puts_ (N_("Booting in blind mode")); bootparams->lfb_mode = 0; bootparams->lfb_width = 0; diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index d9e74b3c7..2de8e0909 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -182,7 +182,7 @@ grub_multiboot_set_console (int console_type, int accepted_consoles, if (console_required) return grub_error (GRUB_ERR_BAD_OS, "OS requires a console but none is available"); - grub_printf ("WARNING: no console will be available to OS"); + grub_puts_ (N_("WARNING: no console will be available to OS")); accepts_video = 0; accepts_ega_text = 0; return GRUB_ERR_NONE; diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 84bdc04d7..ba6a29020 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -520,10 +520,10 @@ void grub_bootp_init (void) { cmd_bootp = grub_register_command ("net_bootp", grub_cmd_bootp, - "[CARD]", + N_("[CARD]"), N_("perform a bootp autoconfiguration")); cmd_dhcp = grub_register_command ("net_dhcp", grub_cmd_bootp, - "[CARD]", + N_("[CARD]"), N_("perform a bootp autoconfiguration")); cmd_getdhcp = grub_register_command ("net_get_dhcp_option", grub_cmd_dhcpopt, N_("VAR INTERFACE NUMBER DESCRIPTION"), diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 0f8a60413..09acea900 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -946,16 +946,16 @@ static grub_command_t cmd_lsaddr; GRUB_MOD_INIT(net) { cmd_addaddr = grub_register_command ("net_add_addr", grub_cmd_addaddr, - "SHORTNAME CARD ADDRESS [HWADDRESS]", + N_("SHORTNAME CARD ADDRESS [HWADDRESS]"), N_("Add a network address.")); cmd_deladdr = grub_register_command ("net_del_addr", grub_cmd_deladdr, - "SHORTNAME", + N_("SHORTNAME"), N_("Delete a network address.")); cmd_addroute = grub_register_command ("net_add_route", grub_cmd_addroute, - "SHORTNAME NET [INTERFACE| gw GATEWAY]", + N_("SHORTNAME NET [INTERFACE| gw GATEWAY]"), N_("Add a network route.")); cmd_delroute = grub_register_command ("net_del_route", grub_cmd_delroute, - "SHORTNAME", + N_("SHORTNAME"), N_("Delete a network route.")); cmd_lsroutes = grub_register_command ("net_ls_routes", grub_cmd_listroutes, "", N_("list network routes")); diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c index a8b9e6683..922f8518f 100644 --- a/grub-core/normal/term.c +++ b/grub-core/normal/term.c @@ -24,6 +24,7 @@ #include #include #include +#include struct term_state { @@ -63,7 +64,9 @@ print_more (void) pos = grub_term_save_pos (); - grub_utf8_to_ucs4_alloc ("--MORE--", &unicode_str, + /* TRANSLATORS: This has to fit on one line. It's ok to include few + words but don't write poems. */ + grub_utf8_to_ucs4_alloc (_("--MORE--"), &unicode_str, &unicode_last_position); if (!unicode_str) diff --git a/grub-core/partmap/bsdlabel.c b/grub-core/partmap/bsdlabel.c index 888100aa2..490fbdd7b 100644 --- a/grub-core/partmap/bsdlabel.c +++ b/grub-core/partmap/bsdlabel.c @@ -24,6 +24,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -105,7 +106,7 @@ iterate_real (grub_disk_t disk, grub_disk_addr_t sector, int freebsd, /* disk->partition != NULL as 0 < delta */ partname = disk->partition ? grub_partition_get_name (disk->partition) : ""; - grub_util_warn ("Discarding improperly nested partition (%s,%s,%s%d)", + grub_util_warn (_("Discarding improperly nested partition (%s,%s,%s%d)"), disk->name, partname, p.partmap->name, p.number + 1); grub_free (partname); #endif diff --git a/grub-core/parttool/msdospart.c b/grub-core/parttool/msdospart.c index ecaca140a..3377a2ccc 100644 --- a/grub-core/parttool/msdospart.c +++ b/grub-core/parttool/msdospart.c @@ -27,6 +27,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv2+"); @@ -35,7 +36,7 @@ static int type_table_handle = -1; static struct grub_parttool_argdesc grub_pcpart_bootargs[] = { - {"boot", "Make partition active", GRUB_PARTTOOL_ARG_BOOL}, + {"boot", N_("Make partition active"), GRUB_PARTTOOL_ARG_BOOL}, {0, 0, 0} }; @@ -65,12 +66,12 @@ static grub_err_t grub_pcpart_boot (const grub_device_t dev, for (i = 0; i < 4; i++) mbr.entries[i].flag = 0x0; mbr.entries[index].flag = 0x80; - grub_printf ("Partition %d is active now. \n", index); + grub_printf_ (N_("Partition %d is active now. \n"), index); } else { mbr.entries[index].flag = 0x0; - grub_printf ("Cleared active flag on %d. \n", index); + grub_printf (N_("Cleared active flag on %d. \n"), index); } /* Write the MBR. */ @@ -83,8 +84,8 @@ static grub_err_t grub_pcpart_boot (const grub_device_t dev, static struct grub_parttool_argdesc grub_pcpart_typeargs[] = { - {"type", "Change partition type", GRUB_PARTTOOL_ARG_VAL}, - {"hidden", "Make partition hidden", GRUB_PARTTOOL_ARG_BOOL}, + {"type", N_("Change partition type"), GRUB_PARTTOOL_ARG_VAL}, + {"hidden", N_("Make partition hidden"), GRUB_PARTTOOL_ARG_BOOL}, {0, 0, 0} }; @@ -129,7 +130,7 @@ static grub_err_t grub_pcpart_type (const grub_device_t dev, } mbr.entries[index].type = type; - grub_printf ("Setting partition type to 0x%x\n", type); + grub_printf_ (N_("Setting partition type to 0x%x\n"), type); /* Write the parttable. */ grub_disk_write (dev->disk, part->offset, 0, diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c index 2f8deac18..a10af5930 100644 --- a/grub-core/term/gfxterm.c +++ b/grub-core/term/gfxterm.c @@ -1111,7 +1111,10 @@ grub_gfxterm_set_repaint_callback (grub_gfxterm_repaint_callback_t func) static const struct grub_arg_option background_image_cmd_options[] = { - {"mode", 'm', 0, "Background image mode.", "stretch|normal", + /* TRANSLATORS: note that GRUB will accept only original keywords stretch + and normal, not the translated ones. So please put both in translation + e.g. stretch=(%STRETCH%)|normal(=%NORMAL). */ + {"mode", 'm', 0, N_("Background image mode."), N_("stretch|normal"), ARG_TYPE_STRING}, {0, 0, 0, 0, 0, 0} }; diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c index 3419a5117..f8b29ec2e 100644 --- a/grub-core/term/terminfo.c +++ b/grub-core/term/terminfo.c @@ -606,7 +606,7 @@ print_terminfo (void) }; struct grub_term_output *cur; - grub_printf ("Current terminfo types: \n"); + grub_puts_ (N_("Current terminfo types:")); for (cur = terminfo_outputs; cur; cur = ((struct grub_terminfo_output_state *) cur->data)->next) grub_printf ("%s: %s\t%s\n", cur->name, diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c index 438ac92b2..92dd7ec07 100644 --- a/grub-core/video/i386/pc/vbe.c +++ b/grub-core/video/i386/pc/vbe.c @@ -28,6 +28,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -993,15 +994,15 @@ grub_video_vbe_get_info_and_fini (struct grub_video_mode_info *mode_info, static void grub_video_vbe_print_adapter_specific_info (void) { - grub_printf (" VBE info: version: %d.%d OEM software rev: %d.%d\n", - controller_info.version >> 8, - controller_info.version & 0xFF, - controller_info.oem_software_rev >> 8, - controller_info.oem_software_rev & 0xFF); - + grub_printf_ (N_(" VBE info: version: %d.%d OEM software rev: %d.%d\n"), + controller_info.version >> 8, + controller_info.version & 0xFF, + controller_info.oem_software_rev >> 8, + controller_info.oem_software_rev & 0xFF); + /* The total_memory field is in 64 KiB units. */ - grub_printf (" total memory: %d KiB\n", - (controller_info.total_memory << 16) / 1024); + grub_printf_ (N_(" total memory: %d KiB\n"), + (controller_info.total_memory << 16) / 1024); } static struct grub_video_adapter grub_video_vbe_adapter = diff --git a/util/grub-menulst2cfg.c b/util/grub-menulst2cfg.c index 513af47c1..aeabad976 100644 --- a/util/grub-menulst2cfg.c +++ b/util/grub-menulst2cfg.c @@ -24,6 +24,7 @@ #include #include #include +#include int main (int argc, char **argv) @@ -37,7 +38,7 @@ main (int argc, char **argv) if (argc >= 2 && argv[1][0] == '-') { - fprintf (stdout, "Usage: %s [INFILE [OUTFILE]]\n", argv[0]); + fprintf (stdout, _("Usage: %s [INFILE [OUTFILE]]\n"), argv[0]); return 0; } @@ -46,7 +47,7 @@ main (int argc, char **argv) in = fopen (argv[1], "r"); if (!in) { - fprintf (stderr, "Couldn't open %s for reading: %s\n", + fprintf (stderr, _("Couldn't open %s for reading: %s\n"), argv[1], strerror (errno)); return 1; } @@ -61,7 +62,7 @@ main (int argc, char **argv) { if (in != stdin) fclose (in); - fprintf (stderr, "Couldn't open %s for writing: %s\n", + fprintf (stderr, _("Couldn't open %s for writing: %s\n"), argv[2], strerror (errno)); return 1; } diff --git a/util/grub-mkdevicemap.c b/util/grub-mkdevicemap.c index bdecae4a3..bdf8ef1c6 100644 --- a/util/grub-mkdevicemap.c +++ b/util/grub-mkdevicemap.c @@ -62,7 +62,7 @@ make_device_map (const char *device_map, int floppy_disks) fp = fopen (device_map, "w"); if (! fp) - grub_util_error ("cannot open %s", device_map); + grub_util_error (_("cannot open %s"), device_map); grub_util_iterate_devices (process_device, floppy_disks); @@ -86,9 +86,9 @@ usage (int status) { if (status) fprintf (stderr, - "Try `%s --help' for more information.\n", program_name); + _("Try `%s --help' for more information.\n"), program_name); else - printf ("\ + printf (_("\ Usage: %s [OPTION]...\n\ \n\ Generate a device map file automatically.\n\ @@ -101,7 +101,7 @@ Generate a device map file automatically.\n\ -v, --verbose print verbose messages\n\ \n\ Report bugs to <%s>.\n\ -", program_name, +"), program_name, DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT); exit (status); diff --git a/util/grub-mklayout.c b/util/grub-mklayout.c index 04501cb40..8de07747d 100644 --- a/util/grub-mklayout.c +++ b/util/grub-mklayout.c @@ -260,9 +260,9 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try `%s --help' for more information.\n", program_name); + fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); else - printf ("\ + printf (_("\ Usage: %s [OPTIONS]\n\ -i, --input set input filename. Default is STDIN\n\ -o, --output set output filename. Default is STDOUT\n\ @@ -270,7 +270,7 @@ Usage: %s [OPTIONS]\n\ -V, --version print version information and exit.\n\ -v, --verbose print verbose messages.\n\ \n\ -Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT); +Report bugs to <%s>.\n"), program_name, PACKAGE_BUGREPORT); exit (status); } @@ -300,7 +300,7 @@ lookup (char *code, int shift) if (strcmp (code, console_grub_equivalences_common[i].layout) == 0) return console_grub_equivalences_common[i].grub; - fprintf (stderr, "Unknown key %s\n", code); + fprintf (stderr, _("Unknown key %s\n"), code); return '\0'; } @@ -396,7 +396,7 @@ write_keymaps (FILE *in, FILE *out) if (keycode_usb == 0 || keycode_usb >= GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE) { - fprintf (stderr, "Unknown keycode 0x%02x\n", keycode_linux); + fprintf (stderr, _("Unknown keycode 0x%02x\n"), keycode_linux); continue; } if (keycode_usb < GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE) @@ -414,7 +414,7 @@ write_keymaps (FILE *in, FILE *out) if (ok == 0) { - fprintf (stderr, "ERROR: no keycodes found. Check output of %s.\n", + fprintf (stderr, _("ERROR: no keycodes found. Check output of %s.\n"), CKBCOMP); exit (1); } @@ -479,7 +479,7 @@ main (int argc, char *argv[]) in = stdin; if (!in) - grub_util_error ("Couldn't open input file: %s\n", strerror (errno)); + grub_util_error (_("Couldn't open input file: %s\n"), strerror (errno)); if (outfile_name) out = fopen (outfile_name, "wb"); @@ -490,7 +490,7 @@ main (int argc, char *argv[]) { if (in != stdin) fclose (in); - grub_util_error ("Couldn't open output file: %s\n", strerror (errno)); + grub_util_error (_("Couldn't open output file: %s\n"), strerror (errno)); } write_keymaps (in, out); diff --git a/util/grub-mkrelpath.c b/util/grub-mkrelpath.c index 3fe3fe698..788db38a2 100644 --- a/util/grub-mkrelpath.c +++ b/util/grub-mkrelpath.c @@ -38,9 +38,9 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try `%s --help' for more information.\n", program_name); + fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); else - printf ("\ + printf (_("\ Usage: %s [OPTIONS] PATH\n\ \n\ Make a system path relative to its root.\n\ @@ -49,7 +49,7 @@ Options:\n\ -h, --help display this message and exit\n\ -V, --version print version information and exit\n\ \n\ -Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT); +Report bugs to <%s>.\n"), program_name, PACKAGE_BUGREPORT); exit (status); } @@ -89,13 +89,13 @@ main (int argc, char *argv[]) if (optind >= argc) { - fprintf (stderr, "No path is specified.\n"); + fprintf (stderr, _("No path is specified.\n")); usage (1); } if (optind + 1 != argc) { - fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]); + fprintf (stderr, _("Unknown extra argument `%s'.\n"), argv[optind + 1]); usage (1); } diff --git a/util/grub-script-check.c b/util/grub-script-check.c index 2d1b31c9a..25358a553 100644 --- a/util/grub-script-check.c +++ b/util/grub-script-check.c @@ -51,9 +51,9 @@ usage (int status) { if (status) fprintf (stderr, - "Try ``%s --help'' for more information.\n", program_name); + _("Try ``%s --help'' for more information.\n"), program_name); else - printf ("\ + printf (_("\ Usage: %s [PATH]\n\ \n\ Checks GRUB script configuration file for syntax errors.\n\ @@ -63,7 +63,7 @@ Checks GRUB script configuration file for syntax errors.\n\ -v, --verbose print the script as it is being processed\n\ \n\ Report bugs to <%s>.\n\ -", program_name, +"), program_name, PACKAGE_BUGREPORT); exit (status); } @@ -157,7 +157,7 @@ main (int argc, char *argv[]) } else if (optind + 1 != argc) { - fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]); + fprintf (stderr, _("Unknown extra argument `%s'.\n"), argv[optind + 1]); usage (1); } else @@ -193,7 +193,7 @@ main (int argc, char *argv[]) if (found_input && script == 0) { - fprintf (stderr, "error: line no: %u\n", lineno); + fprintf (stderr, _("error: line no: %u\n"), lineno); return 1; } diff --git a/util/ieee1275/grub-ofpathname.c b/util/ieee1275/grub-ofpathname.c index ee81457b3..03d47bc99 100644 --- a/util/ieee1275/grub-ofpathname.c +++ b/util/ieee1275/grub-ofpathname.c @@ -36,7 +36,7 @@ int main(int argc, char **argv) if (argc != 2 || strcmp (argv[1], "--help") == 0) { - printf("Usage: %s DEVICE\n", program_name); + printf(_("Usage: %s DEVICE\n"), program_name); return 1; } if (strcmp (argv[1], "--version") == 0) diff --git a/util/resolve.c b/util/resolve.c index 63bd7ccb2..3eb8bfb14 100644 --- a/util/resolve.c +++ b/util/resolve.c @@ -26,6 +26,7 @@ #include #include #include +#include /* Module. */ struct mod_list @@ -87,7 +88,7 @@ read_dep_list (FILE *fp) /* Get the target name. */ p = strchr (buf, ':'); if (! p) - grub_util_error ("invalid line format: %s", buf); + grub_util_error (_("invalid line format: %s"), buf); *p++ = '\0'; @@ -240,7 +241,7 @@ grub_util_resolve_dependencies (const char *prefix, path = grub_util_get_path (prefix, dep_list_file); fp = fopen (path, "r"); if (! fp) - grub_util_error ("cannot open %s", path); + grub_util_error (_("cannot open %s"), path); free (path); dep_list = read_dep_list (fp); From 119d11c8857ce2d354fbbada64cc27f783b57ecb Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 22:35:09 +0100 Subject: [PATCH 37/40] Replace grub_fatal with normal errors in i386 linux loader. * grub-core/loader/i386/linux.c (find_efi_mmap_size): Return 0 on error. (allocate_pages): Check find_efi_mmap_size return value. (grub_e820_add_region): Return error. (grub_linux_boot): Check mmap return value. --- ChangeLog | 9 +++++++++ grub-core/loader/i386/linux.c | 38 ++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3c0cfe61..490bc693b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-11-11 Vladimir Serbinenko + + Replace grub_fatal with normal errors in i386 linux loader. + + * grub-core/loader/i386/linux.c (find_efi_mmap_size): Return 0 on error. + (allocate_pages): Check find_efi_mmap_size return value. + (grub_e820_add_region): Return error. + (grub_linux_boot): Check mmap return value. + 2011-11-11 Vladimir Serbinenko * grub-core/commands/acpihalt.c: Gettextized. diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index a6eb95028..c63c6c3ef 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -130,7 +130,10 @@ find_efi_mmap_size (void) grub_free (mmap); if (ret < 0) - grub_fatal ("cannot get memory map"); + { + grub_error (GRUB_ERR_IO, "cannot get memory map"); + return 0; + } else if (ret > 0) break; @@ -198,6 +201,8 @@ allocate_pages (grub_size_t prot_size) #ifdef GRUB_MACHINE_EFI efi_mmap_size = find_efi_mmap_size (); + if (efi_mmap_size == 0) + return grub_errno; #endif grub_dprintf ("linux", "real_size = %x, prot_size = %x, mmap_size = %x\n", @@ -291,7 +296,7 @@ allocate_pages (grub_size_t prot_size) return err; } -static void +static grub_err_t grub_e820_add_region (struct grub_e820_mmap *e820_map, int *e820_num, grub_uint64_t start, grub_uint64_t size, grub_uint32_t type) @@ -299,7 +304,10 @@ grub_e820_add_region (struct grub_e820_mmap *e820_map, int *e820_num, int n = *e820_num; if (n >= GRUB_E820_MAX_ENTRY) - grub_fatal ("Too many e820 memory map entries"); + { + return grub_error (GRUB_ERR_OUT_OF_RANGE, + "Too many e820 memory map entries"); + } if ((n > 0) && (e820_map[n - 1].addr + e820_map[n - 1].size == start) && (e820_map[n - 1].type == type)) @@ -311,6 +319,7 @@ grub_e820_add_region (struct grub_e820_mmap *e820_map, int *e820_num, e820_map[n].type = type; (*e820_num)++; } + return GRUB_ERR_NONE; } static grub_err_t @@ -446,37 +455,38 @@ grub_linux_boot (void) int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type) { + grub_uint32_t e820_type; switch (type) { case GRUB_MEMORY_AVAILABLE: - grub_e820_add_region (params->e820_map, &e820_num, - addr, size, GRUB_E820_RAM); + e820_type = GRUB_E820_RAM; break; case GRUB_MEMORY_ACPI: - grub_e820_add_region (params->e820_map, &e820_num, - addr, size, GRUB_E820_ACPI); + e820_type = GRUB_E820_ACPI; break; case GRUB_MEMORY_NVS: - grub_e820_add_region (params->e820_map, &e820_num, - addr, size, GRUB_E820_NVS); + e820_type = GRUB_E820_NVS; break; case GRUB_MEMORY_BADRAM: - grub_e820_add_region (params->e820_map, &e820_num, - addr, size, GRUB_E820_BADRAM); + e820_type = GRUB_E820_BADRAM; break; default: - grub_e820_add_region (params->e820_map, &e820_num, - addr, size, GRUB_E820_RESERVED); + e820_type = GRUB_E820_RESERVED; } + if (grub_e820_add_region (params->e820_map, &e820_num, + addr, size, e820_type)) + return 1; + return 0; } e820_num = 0; - grub_mmap_iterate (hook); + if (grub_mmap_iterate (hook)) + return grub_errno; params->mmap_size = e820_num; modevar = grub_env_get ("gfxpayload"); From 566f779bd8a7245f5c867ab276d62a0b54d3c222 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 11 Nov 2011 22:58:18 +0100 Subject: [PATCH 38/40] 2011-11-11 Robert Millan * util/getroot.c (grub_util_get_geom_abstraction): Remove __attribute__((unused)) from `os_dev', which *is* being used. --- ChangeLog | 5 +++++ util/getroot.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 490bc693b..6b726987a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-11 Robert Millan + + * util/getroot.c (grub_util_get_geom_abstraction): Remove + __attribute__((unused)) from `os_dev', which *is* being used. + 2011-11-11 Vladimir Serbinenko Replace grub_fatal with normal errors in i386 linux loader. diff --git a/util/getroot.c b/util/getroot.c index 41fbdec10..750773c90 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -826,7 +826,7 @@ grub_util_get_geom_abstraction (const char *dev) #endif int -grub_util_get_dev_abstraction (const char *os_dev __attribute__((unused))) +grub_util_get_dev_abstraction (const char *os_dev) { #if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) /* User explicitly claims that this drive is visible by BIOS. */ From b50787de091db9e94dc48fe68e3d79d5126d065d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 12 Nov 2011 00:26:04 +0100 Subject: [PATCH 39/40] * include/grub/dl.h (GRUB_ARCH_DL_TRAMP_SIZE) [__ia64__]: Add back forgotten define. (GRUB_ARCH_DL_GOT_ALIGN) [__ia64__]: Redefine in terms of GRUB_IA64_DL_GOT_ALIGN. (GRUB_ARCH_DL_TRAMP_ALIGN) [__ia64__]: Redefine in terms of GRUB_IA64_DL_TRAMP_ALIGN. --- ChangeLog | 9 +++++++++ include/grub/dl.h | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b726987a..3970ec293 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,15 @@ * util/getroot.c (grub_util_get_geom_abstraction): Remove __attribute__((unused)) from `os_dev', which *is* being used. +2011-11-11 Vladimir Serbinenko + + * include/grub/dl.h (GRUB_ARCH_DL_TRAMP_SIZE) [__ia64__]: Add back + forgotten define. + (GRUB_ARCH_DL_GOT_ALIGN) [__ia64__]: Redefine in terms of + GRUB_IA64_DL_GOT_ALIGN. + (GRUB_ARCH_DL_TRAMP_ALIGN) [__ia64__]: Redefine in terms of + GRUB_IA64_DL_TRAMP_ALIGN. + 2011-11-11 Vladimir Serbinenko Replace grub_fatal with normal errors in i386 linux loader. diff --git a/include/grub/dl.h b/include/grub/dl.h index 886e966cc..d5f009829 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -178,8 +178,9 @@ grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, grub_size_t *got); #if defined (__ia64__) -#define GRUB_ARCH_DL_TRAMP_ALIGN 16 -#define GRUB_ARCH_DL_GOT_ALIGN 16 +#define GRUB_ARCH_DL_TRAMP_ALIGN GRUB_IA64_DL_TRAMP_ALIGN +#define GRUB_ARCH_DL_GOT_ALIGN GRUB_IA64_DL_GOT_ALIGN +#define GRUB_ARCH_DL_TRAMP_SIZE GRUB_IA64_DL_TRAMP_SIZE #define grub_arch_dl_get_tramp_got_size grub_ia64_dl_get_tramp_got_size #else void From 10f0117bf93a31cdf952a6379ab33a03e4920993 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 12 Nov 2011 00:34:14 +0100 Subject: [PATCH 40/40] * grub-core/commands/efi/fixvideo.c: Gettextize. * grub-core/commands/hashsum.c: Likewise. * grub-core/commands/i386/cmostest.c: Likewise. * grub-core/commands/i386/pc/drivemap.c: Likewise. * grub-core/commands/i386/pc/lsapm.c: Likewise. * grub-core/commands/i386/pc/sendkey.c: Likewise. * grub-core/commands/lsmmap.c: Likewise. * grub-core/commands/menuentry.c: Likewise. * grub-core/commands/mips/loongson/lsspd.c: Likewise. * grub-core/commands/setpci.c: Likewise. * grub-core/loader/i386/bsd.c: Likewise. * grub-core/loader/i386/linux.c: Likewise. * util/getroot.c: Likewise. * util/grub-editenv.c: Likewise. * util/grub-fstest.c: Likewise. * util/grub-mkfont.c: Likewise. * util/grub-mkimage.c: Likewise. * util/grub-mkpasswd-pbkdf2.c: Likewise. * util/grub-pe2elf.c: Likewise. * util/grub-probe.c: Likewise. * util/grub-setup.c: Likewise. * util/ieee1275/ofpath.c: Likewise. * util/misc.c: Likewise. * util/raid.c: Likewise. --- ChangeLog | 27 +++++++++++ grub-core/commands/efi/fixvideo.c | 10 ++-- grub-core/commands/hashsum.c | 10 ++-- grub-core/commands/i386/cmostest.c | 9 ++-- grub-core/commands/i386/pc/drivemap.c | 4 +- grub-core/commands/i386/pc/lsapm.c | 32 ++++++------- grub-core/commands/i386/pc/sendkey.c | 39 ++++++++-------- grub-core/commands/lsmmap.c | 22 ++++----- grub-core/commands/menuentry.c | 8 ++-- grub-core/commands/mips/loongson/lsspd.c | 24 +++++----- grub-core/commands/setpci.c | 14 +++--- grub-core/loader/i386/bsd.c | 10 ++-- grub-core/loader/i386/linux.c | 28 ++++++------ util/getroot.c | 58 ++++++++++++------------ util/grub-editenv.c | 28 ++++++------ util/grub-fstest.c | 10 ++-- util/grub-mkfont.c | 57 +++++++++++------------ util/grub-mkimage.c | 22 ++++----- util/grub-mkpasswd-pbkdf2.c | 35 +++++++------- util/grub-pe2elf.c | 2 + util/grub-probe.c | 29 ++++++------ util/grub-setup.c | 29 ++++++------ util/ieee1275/ofpath.c | 20 ++++---- util/misc.c | 22 ++++----- util/raid.c | 13 +++--- 25 files changed, 302 insertions(+), 260 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3970ec293..23679917c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2011-11-11 Vladimir Serbinenko + + * grub-core/commands/efi/fixvideo.c: Gettextize. + * grub-core/commands/hashsum.c: Likewise. + * grub-core/commands/i386/cmostest.c: Likewise. + * grub-core/commands/i386/pc/drivemap.c: Likewise. + * grub-core/commands/i386/pc/lsapm.c: Likewise. + * grub-core/commands/i386/pc/sendkey.c: Likewise. + * grub-core/commands/lsmmap.c: Likewise. + * grub-core/commands/menuentry.c: Likewise. + * grub-core/commands/mips/loongson/lsspd.c: Likewise. + * grub-core/commands/setpci.c: Likewise. + * grub-core/loader/i386/bsd.c: Likewise. + * grub-core/loader/i386/linux.c: Likewise. + * util/getroot.c: Likewise. + * util/grub-editenv.c: Likewise. + * util/grub-fstest.c: Likewise. + * util/grub-mkfont.c: Likewise. + * util/grub-mkimage.c: Likewise. + * util/grub-mkpasswd-pbkdf2.c: Likewise. + * util/grub-pe2elf.c: Likewise. + * util/grub-probe.c: Likewise. + * util/grub-setup.c: Likewise. + * util/ieee1275/ofpath.c: Likewise. + * util/misc.c: Likewise. + * util/raid.c: Likewise. + 2011-11-11 Robert Millan * util/getroot.c (grub_util_get_geom_abstraction): Remove diff --git a/grub-core/commands/efi/fixvideo.c b/grub-core/commands/efi/fixvideo.c index c53e47d8a..a58c27916 100644 --- a/grub-core/commands/efi/fixvideo.c +++ b/grub-core/commands/efi/fixvideo.c @@ -56,24 +56,24 @@ scan_card (grub_pci_device_t dev, grub_pci_id_t pciid) { grub_target_addr_t base; - grub_printf ("Found graphic card: %s\n", p->name); + grub_dprintf ("fixvideo", "Found graphic card: %s\n", p->name); addr += 8 + p->mmio_bar * 4; base = grub_pci_read (addr); if ((! base) || (base & GRUB_PCI_ADDR_SPACE_IO) || (base & GRUB_PCI_ADDR_MEM_PREFETCH)) - grub_printf ("Invalid MMIO bar %d\n", p->mmio_bar); + grub_dprintf ("fixvideo", "Invalid MMIO bar %d\n", p->mmio_bar); else { base &= GRUB_PCI_ADDR_MEM_MASK; base += p->mmio_reg; if (*((volatile grub_uint32_t *) base) != p->mmio_old) - grub_printf ("Old value don't match\n"); + grub_dprintf ("fixvideo", "Old value doesn't match\n"); else { *((volatile grub_uint32_t *) base) = 0; if (*((volatile grub_uint32_t *) base)) - grub_printf ("Set MMIO fails\n"); + grub_dprintf ("fixvideo", "Setting MMIO fails\n"); } } @@ -82,7 +82,7 @@ scan_card (grub_pci_device_t dev, grub_pci_id_t pciid) p++; } - grub_printf ("Unknown graphic card: %x\n", pciid); + grub_dprintf ("fixvideo", "Unknown graphic card: %x\n", pciid); } return 0; diff --git a/grub-core/commands/hashsum.c b/grub-core/commands/hashsum.c index 6825d4811..fb737c2f8 100644 --- a/grub-core/commands/hashsum.c +++ b/grub-core/commands/hashsum.c @@ -141,7 +141,7 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename, grub_file_close (file); if (err) { - grub_printf ("%s: READ ERROR\n", p); + grub_printf_ (N_("%s: READ ERROR\n"), p); if (!keep) { grub_file_close (hashlist); @@ -155,7 +155,7 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename, } if (grub_crypto_memcmp (expected, actual, hash->mdlen) != 0) { - grub_printf ("%s: HASH MISMATCH\n", p); + grub_printf_ (N_("%s: HASH MISMATCH\n"), p); if (!keep) { grub_file_close (hashlist); @@ -166,7 +166,7 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename, mismatch++; continue; } - grub_printf ("%s: OK\n", p); + grub_printf_ (N_("%s: OK\n"), p); } if (mismatch || unread) return grub_error (GRUB_ERR_TEST_FAILURE, @@ -257,8 +257,8 @@ static grub_extcmd_t cmd, cmd_md5, cmd_sha1, cmd_sha256, cmd_sha512, cmd_crc; GRUB_MOD_INIT(hashsum) { cmd = grub_register_extcmd ("hashsum", grub_cmd_hashsum, 0, - "hashsum -h HASH [-c FILE [-p PREFIX]] " - "[FILE1 [FILE2 ...]]", + N_("-h HASH [-c FILE [-p PREFIX]] " + "[FILE1 [FILE2 ...]]"), N_("Compute or check hash checksum."), options); cmd_md5 = grub_register_extcmd ("md5sum", grub_cmd_hashsum, 0, diff --git a/grub-core/commands/i386/cmostest.c b/grub-core/commands/i386/cmostest.c index 6439159bd..6a4290155 100644 --- a/grub-core/commands/i386/cmostest.c +++ b/grub-core/commands/i386/cmostest.c @@ -20,6 +20,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -86,11 +87,11 @@ static grub_command_t cmd, cmd_clean; GRUB_MOD_INIT(cmostest) { cmd = grub_register_command ("cmostest", grub_cmd_cmostest, - "cmostest BYTE:BIT", - "Test bit at BYTE:BIT in CMOS."); + N_("BYTE:BIT"), + N_("Test bit at BYTE:BIT in CMOS.")); cmd_clean = grub_register_command ("cmosclean", grub_cmd_cmosclean, - "cmosclean BYTE:BIT", - "Clean bit at BYTE:BIT in CMOS."); + N_("BYTE:BIT"), + N_("Clean bit at BYTE:BIT in CMOS.")); } GRUB_MOD_FINI(cmostest) diff --git a/grub-core/commands/i386/pc/drivemap.c b/grub-core/commands/i386/pc/drivemap.c index 9a89f968c..4f752bed5 100644 --- a/grub-core/commands/i386/pc/drivemap.c +++ b/grub-core/commands/i386/pc/drivemap.c @@ -178,11 +178,11 @@ list_mappings (void) /* Show: list mappings. */ if (! map_head) { - grub_printf ("No drives have been remapped\n"); + grub_puts_ (N_("No drives have been remapped")); return GRUB_ERR_NONE; } - grub_printf ("OS disk #num ------> GRUB/BIOS device\n"); + grub_puts_ (N_("OS disk #num ------> GRUB/BIOS device")); drivemap_node_t *curnode = map_head; while (curnode) { diff --git a/grub-core/commands/i386/pc/lsapm.c b/grub-core/commands/i386/pc/lsapm.c index 17bcfd6eb..45b43b242 100644 --- a/grub-core/commands/i386/pc/lsapm.c +++ b/grub-core/commands/i386/pc/lsapm.c @@ -74,27 +74,27 @@ grub_cmd_lsapm (grub_command_t cmd __attribute__ ((unused)), if (!grub_apm_get_info (&info)) return grub_error (GRUB_ERR_IO, "no APM found"); - grub_printf ("Vesion %u.%u\n" - "32-bit CS = 0x%x, len = 0x%x, offset = 0x%x\n" - "16-bit CS = 0x%x, len = 0x%x\n" - "DS = 0x%x, len = 0x%x\n", - info.version >> 8, info.version & 0xff, - info.cseg, info.cseg_len, info.offset, - info.cseg_16, info.cseg_16_len, - info.dseg, info.dseg_len); + grub_printf_ (N_("Vesion %u.%u\n" + "32-bit CS = 0x%x, len = 0x%x, offset = 0x%x\n" + "16-bit CS = 0x%x, len = 0x%x\n" + "DS = 0x%x, len = 0x%x\n"), + info.version >> 8, info.version & 0xff, + info.cseg, info.cseg_len, info.offset, + info.cseg_16, info.cseg_16_len, + info.dseg, info.dseg_len); grub_xputs (info.flags & GRUB_APM_FLAGS_16BITPROTECTED_SUPPORTED - ? "16-bit protected interface supported\n" - : "16-bit protected interface unsupported\n"); + ? _("16-bit protected interface supported\n") + : _("16-bit protected interface unsupported\n")); grub_xputs (info.flags & GRUB_APM_FLAGS_32BITPROTECTED_SUPPORTED - ? "32-bit protected interface supported\n" - : "32-bit protected interface unsupported\n"); + ? _("32-bit protected interface supported\n") + : _("32-bit protected interface unsupported\n")); grub_xputs (info.flags & GRUB_APM_FLAGS_CPUIDLE_SLOWS_DOWN - ? "CPU Idle slows down processor\n" - : "CPU Idle doesn't slow down processor\n"); + ? _("CPU Idle slows down processor\n") + : _("CPU Idle doesn't slow down processor\n")); grub_xputs (info.flags & GRUB_APM_FLAGS_DISABLED - ? "APM disabled\n" : "APM enabled\n"); + ? _("APM disabled\n") : _("APM enabled\n")); grub_xputs (info.flags & GRUB_APM_FLAGS_DISENGAGED - ? "APM disengaged\n" : "APM engaged\n"); + ? _("APM disengaged\n") : _("APM engaged\n")); return GRUB_ERR_NONE; } diff --git a/grub-core/commands/i386/pc/sendkey.c b/grub-core/commands/i386/pc/sendkey.c index a55d17bd0..83400c347 100644 --- a/grub-core/commands/i386/pc/sendkey.c +++ b/grub-core/commands/i386/pc/sendkey.c @@ -26,6 +26,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv2+"); @@ -35,23 +36,23 @@ static int keylen = 0; static int noled = 0; static const struct grub_arg_option options[] = { - {"num", 'n', 0, "set numlock mode", "[on|off]", ARG_TYPE_STRING}, - {"caps", 'c', 0, "set capslock mode", "[on|off]", ARG_TYPE_STRING}, - {"scroll", 's', 0, "set scrolllock mode", "[on|off]", ARG_TYPE_STRING}, - {"insert", 0, 0, "set insert mode", "[on|off]", ARG_TYPE_STRING}, - {"pause", 0, 0, "set pause mode", "[on|off]", ARG_TYPE_STRING}, - {"left-shift", 0, 0, "press left shift", "[on|off]", ARG_TYPE_STRING}, - {"right-shift", 0, 0, "press right shift", "[on|off]", ARG_TYPE_STRING}, - {"sysrq", 0, 0, "press SysRq", "[on|off]", ARG_TYPE_STRING}, - {"numkey", 0, 0, "press NumLock key", "[on|off]", ARG_TYPE_STRING}, - {"capskey", 0, 0, "press CapsLock key", "[on|off]", ARG_TYPE_STRING}, - {"scrollkey", 0, 0, "press ScrollLock key", "[on|off]", ARG_TYPE_STRING}, - {"insertkey", 0, 0, "press Insert key", "[on|off]", ARG_TYPE_STRING}, - {"left-alt", 0, 0, "press left alt", "[on|off]", ARG_TYPE_STRING}, - {"right-alt", 0, 0, "press right alt", "[on|off]", ARG_TYPE_STRING}, - {"left-ctrl", 0, 0, "press left ctrl", "[on|off]", ARG_TYPE_STRING}, - {"right-ctrl", 0, 0, "press right ctrl", "[on|off]", ARG_TYPE_STRING}, - {"no-led", 0, 0, "don't update LED state", 0, 0}, + {"num", 'n', 0, N_("set numlock mode"), "[on|off]", ARG_TYPE_STRING}, + {"caps", 'c', 0, N_("set capslock mode"), "[on|off]", ARG_TYPE_STRING}, + {"scroll", 's', 0, N_("set scrolllock mode"), "[on|off]", ARG_TYPE_STRING}, + {"insert", 0, 0, N_("set insert mode"), "[on|off]", ARG_TYPE_STRING}, + {"pause", 0, 0, N_("set pause mode"), "[on|off]", ARG_TYPE_STRING}, + {"left-shift", 0, 0, N_("press left shift"), "[on|off]", ARG_TYPE_STRING}, + {"right-shift", 0, 0, N_("press right shift"), "[on|off]", ARG_TYPE_STRING}, + {"sysrq", 0, 0, N_("press SysRq"), "[on|off]", ARG_TYPE_STRING}, + {"numkey", 0, 0, N_("press NumLock key"), "[on|off]", ARG_TYPE_STRING}, + {"capskey", 0, 0, N_("press CapsLock key"), "[on|off]", ARG_TYPE_STRING}, + {"scrollkey", 0, 0, N_("press ScrollLock key"), "[on|off]", ARG_TYPE_STRING}, + {"insertkey", 0, 0, N_("press Insert key"), "[on|off]", ARG_TYPE_STRING}, + {"left-alt", 0, 0, N_("press left alt"), "[on|off]", ARG_TYPE_STRING}, + {"right-alt", 0, 0, N_("press right alt"), "[on|off]", ARG_TYPE_STRING}, + {"left-ctrl", 0, 0, N_("press left ctrl"), "[on|off]", ARG_TYPE_STRING}, + {"right-ctrl", 0, 0, N_("press right ctrl"), "[on|off]", ARG_TYPE_STRING}, + {"no-led", 0, 0, N_("don't update LED state"), 0, 0}, {0, 0, 0, 0, 0, 0} }; static int simple_flag_offsets[] @@ -369,8 +370,8 @@ static void *preboot_hook; GRUB_MOD_INIT (sendkey) { cmd = grub_register_extcmd ("sendkey", grub_cmd_sendkey, 0, - "sendkey [KEYSTROKE1] [KEYSTROKE2] ...", - "Emulate a keystroke", options); + N_("[KEYSTROKE1] [KEYSTROKE2] ..."), + N_("Emulate a keystroke"), options); preboot_hook = grub_loader_register_preboot_hook (grub_sendkey_preboot, diff --git a/grub-core/commands/lsmmap.c b/grub-core/commands/lsmmap.c index 44598f0df..4815fd174 100644 --- a/grub-core/commands/lsmmap.c +++ b/grub-core/commands/lsmmap.c @@ -26,13 +26,13 @@ GRUB_MOD_LICENSE ("GPLv3+"); static const char *names[] = { - [GRUB_MEMORY_AVAILABLE] = "available", - [GRUB_MEMORY_RESERVED] = "reserved", - [GRUB_MEMORY_ACPI] = "ACPI reclamaible", - [GRUB_MEMORY_NVS] = "NVS", - [GRUB_MEMORY_BADRAM] = "BadRAM", - [GRUB_MEMORY_CODE] = "firmware code", - [GRUB_MEMORY_HOLE] = "hole" + [GRUB_MEMORY_AVAILABLE] = N_("available"), + [GRUB_MEMORY_RESERVED] = N_("reserved"), + [GRUB_MEMORY_ACPI] = N_("ACPI reclamaible"), + [GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage"), + [GRUB_MEMORY_BADRAM] = N_("BadRAM"), + [GRUB_MEMORY_CODE] = N_("firmware code"), + [GRUB_MEMORY_HOLE] = N_("hole") }; static grub_err_t @@ -46,11 +46,11 @@ grub_cmd_lsmmap (grub_command_t cmd __attribute__ ((unused)), grub_memory_type_t type) { if (type < ARRAY_SIZE (names) && names[type]) - grub_printf ("base_addr = 0x%llx, length = 0x%llx, %s\n", - (long long) addr, (long long) size, names[type]); + grub_printf_ (N_("base_addr = 0x%llx, length = 0x%llx, %s\n"), + (long long) addr, (long long) size, _(names[type])); else - grub_printf ("base_addr = 0x%llx, length = 0x%llx, type = 0x%x\n", - (long long) addr, (long long) size, type); + grub_printf_ (N_("base_addr = 0x%llx, length = 0x%llx, type = 0x%x\n"), + (long long) addr, (long long) size, type); return 0; } #ifndef GRUB_MACHINE_EMU diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c index 4849f8bb8..f5ec60bff 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -28,13 +28,13 @@ static const struct grub_arg_option options[] = { {"class", 1, GRUB_ARG_OPTION_REPEATABLE, - N_("Menu entry type."), "STRING", ARG_TYPE_STRING}, + N_("Menu entry type."), N_("STRING"), ARG_TYPE_STRING}, {"users", 2, 0, - N_("Users allowed to boot this entry."), "USERNAME", ARG_TYPE_STRING}, + N_("Users allowed to boot this entry."), N_("USERNAME"), ARG_TYPE_STRING}, {"hotkey", 3, 0, - N_("Keyboard key for this entry."), "KEY", ARG_TYPE_STRING}, + N_("Keyboard key for this entry."), N_("KEY"), ARG_TYPE_STRING}, {"source", 4, 0, - N_("Menu entry definition as a string."), "STRING", ARG_TYPE_STRING}, + N_("Menu entry definition as a string."), N_("STRING"), ARG_TYPE_STRING}, {0, 0, 0, 0, 0, 0} }; diff --git a/grub-core/commands/mips/loongson/lsspd.c b/grub-core/commands/mips/loongson/lsspd.c index c1c5e2ef7..76999368f 100644 --- a/grub-core/commands/mips/loongson/lsspd.c +++ b/grub-core/commands/mips/loongson/lsspd.c @@ -23,6 +23,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -38,43 +39,44 @@ grub_cmd_lsspd (grub_command_t cmd __attribute__ ((unused)), if (!grub_cs5536_find (&dev)) { - grub_printf ("No CS5536 found\n"); + grub_puts_ (N_("No CS5536 found")); return GRUB_ERR_NONE; } - grub_printf ("CS5536 at %d:%d.%d\n", grub_pci_get_bus (dev), - grub_pci_get_device (dev), grub_pci_get_function (dev)); + grub_printf_ (N_("CS5536 at %d:%d.%d\n"), grub_pci_get_bus (dev), + grub_pci_get_device (dev), grub_pci_get_function (dev)); err = grub_cs5536_init_smbus (dev, 0x7fff, &smbbase); if (err) return err; - grub_printf ("SMB base = 0x%x\n", smbbase); + grub_printf_ (N_("SMB base = 0x%x\n"), smbbase); for (i = GRUB_SMB_RAM_START_ADDR; i < GRUB_SMB_RAM_START_ADDR + GRUB_SMB_RAM_NUM_MAX; i++) { struct grub_smbus_spd spd; grub_memset (&spd, 0, sizeof (spd)); - grub_printf ("Device %d\n", i); + grub_printf_ (N_("Device %d\n"), i); err = grub_cs5536_read_spd (smbbase, i, &spd); if (err) { grub_print_error (); continue; } - grub_printf ("Written SPD bytes: %d B.\n", spd.written_size); - grub_printf ("Total flash size: %d B.\n", 1 << spd.log_total_flash_size); + grub_printf_ (N_("Written SPD bytes: %d B.\n"), spd.written_size); + grub_printf_ (N_("Total flash size: %d B.\n"), + 1 << spd.log_total_flash_size); if (spd.memory_type == GRUB_SMBUS_SPD_MEMORY_TYPE_DDR2) { char str[sizeof (spd.ddr2.part_number) + 1]; - grub_printf ("Memory type: DDR2.\n"); + grub_puts_ (N_("Memory type: DDR2.")); grub_memcpy (str, spd.ddr2.part_number, sizeof (spd.ddr2.part_number)); str[sizeof (spd.ddr2.part_number)] = 0; - grub_printf ("Part no: %s.\n", str); + grub_printf_ (N_("Part no: %s.\n"), str); } else - grub_printf ("Memory type: Unknown.\n"); + grub_puts_ (N_("Memory type: Unknown.")); } return GRUB_ERR_NONE; @@ -85,7 +87,7 @@ static grub_command_t cmd; GRUB_MOD_INIT(lsspd) { cmd = grub_register_command ("lsspd", grub_cmd_lsspd, 0, - "Print Memory information."); + N_("Print Memory information.")); } GRUB_MOD_FINI(lsspd) diff --git a/grub-core/commands/setpci.c b/grub-core/commands/setpci.c index 70f5bcdad..81e7f726d 100644 --- a/grub-core/commands/setpci.c +++ b/grub-core/commands/setpci.c @@ -66,12 +66,12 @@ static struct pci_register pci_registers[] = static const struct grub_arg_option options[] = { - {0, 'd', 0, "Select device by vendor and device IDs.", - "[vendor]:[device]", ARG_TYPE_STRING}, - {0, 's', 0, "Select device by its position on the bus.", - "[bus]:[slot][.func]", ARG_TYPE_STRING}, - {0, 'v', 0, "Save read value into variable VARNAME.", - "VARNAME", ARG_TYPE_STRING}, + {0, 'd', 0, N_("Select device by vendor and device IDs."), + N_("[vendor]:[device]"), ARG_TYPE_STRING}, + {0, 's', 0, N_("Select device by its position on the bus."), + N_("[bus]:[slot][.func]"), ARG_TYPE_STRING}, + {0, 'v', 0, N_("Save read value into variable VARNAME."), + N_("VARNAME"), ARG_TYPE_STRING}, {0, 0, 0, 0, 0, 0} }; @@ -128,7 +128,7 @@ grub_setpci_iter (grub_pci_device_t dev, grub_pci_id_t pciid) if (!write_mask) { - grub_printf ("Register %x of %d:%d.%d is %x\n", regaddr, + grub_printf (N_("Register %x of %d:%d.%d is %x\n"), regaddr, grub_pci_get_bus (dev), grub_pci_get_device (dev), grub_pci_get_function (dev), diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index f2d0845f8..6746b3853 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -450,7 +450,8 @@ grub_freebsd_list_modules (void) { struct bsd_tag *tag; - grub_printf (" %-18s %-18s%14s%14s\n", "name", "type", "addr", "size"); + grub_printf (" %-18s %-18s%14s%14s\n", _("name"), _("type"), _("addr"), + _("size")); for (tag = tags; tag; tag = tag->next) { @@ -515,7 +516,8 @@ grub_netbsd_list_modules (void) { struct netbsd_module *mod; - grub_printf (" %-18s%14s%14s%14s\n", "name", "type", "addr", "size"); + grub_printf (" %-18s%14s%14s%14s\n", _("name"), _("type"), _("addr"), + _("size")); for (mod = netbsd_mods; mod; mod = mod->next) grub_printf (" %-18s 0x%08x 0x%08x 0x%08x", mod->mod.name, @@ -1050,7 +1052,7 @@ grub_netbsd_boot (void) if (err) { grub_print_error (); - grub_printf ("Booting however\n"); + grub_puts_ (N_("Booting in blind mode")); grub_errno = GRUB_ERR_NONE; } @@ -2061,7 +2063,7 @@ GRUB_MOD_INIT (bsd) cmd_openbsd_ramdisk = grub_register_command ("kopenbsd_ramdisk", grub_cmd_openbsd_ramdisk, 0, - "Load kOpenBSD ramdisk. "); + N_("Load kOpenBSD ramdisk.")); my_mod = mod; } diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index c63c6c3ef..80ad542e3 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -517,7 +517,7 @@ grub_linux_boot (void) if (err) { grub_print_error (); - grub_printf ("Booting however\n"); + grub_puts_ (N_("Booting in blind mode")); grub_errno = GRUB_ERR_NONE; } @@ -793,7 +793,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), vid_mode = GRUB_LINUX_VID_MODE_EXTENDED; else if (grub_strcmp (val, "ask") == 0) { - grub_printf ("Legacy `ask' parameter no longer supported.\n"); + grub_puts_ (N_("Legacy `ask' parameter no longer supported.")); /* We usually would never do this in a loader, but "vga=ask" means user requested interaction, so it can't hurt to request keyboard input. */ @@ -809,9 +809,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), case 0: case GRUB_LINUX_VID_MODE_NORMAL: grub_env_set ("gfxpayload", "text"); - grub_printf ("%s is deprecated. " - "Use set gfxpayload=text before " - "linux command instead.\n", + grub_printf_ (N_("%s is deprecated. " + "Use set gfxpayload=text before " + "linux command instead.\n"), argv[i]); break; @@ -819,9 +819,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), case GRUB_LINUX_VID_MODE_EXTENDED: /* FIXME: support 80x50 text. */ grub_env_set ("gfxpayload", "text"); - grub_printf ("%s is deprecated. " - "Use set gfxpayload=text before " - "linux command instead.\n", + grub_printf_ (N_("%s is deprecated. " + "Use set gfxpayload=text before " + "linux command instead.\n"), argv[i]); break; default: @@ -830,9 +830,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), vid_mode > GRUB_VESA_MODE_TABLE_END) { grub_env_set ("gfxpayload", "text"); - grub_printf ("%s is deprecated. Mode %d isn't recognized. " - "Use set gfxpayload=WIDTHxHEIGHT[xDEPTH] before " - "linux command instead.\n", + grub_printf_ (N_("%s is deprecated. Mode %d isn't recognized. " + "Use set gfxpayload=WIDTHxHEIGHT[xDEPTH] " + "before linux command instead.\n"), argv[i], vid_mode); break; } @@ -847,9 +847,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (! buf) goto fail; - grub_printf ("%s is deprecated. " - "Use set gfxpayload=%s before " - "linux command instead.\n", + grub_printf_ (N_("%s is deprecated. " + "Use set gfxpayload=%s before " + "linux command instead.\n"), argv[i], buf); err = grub_env_set ("gfxpayload", buf); grub_free (buf); diff --git a/util/getroot.c b/util/getroot.c index 750773c90..f5d6d3f62 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -35,6 +35,7 @@ #include #include #include +#include #ifdef HAVE_DEVICE_MAPPER # include @@ -454,7 +455,7 @@ grub_find_device (const char *dir, dev_t dev) continue; if (chdir (saved_cwd) < 0) - grub_util_error ("cannot restore the original directory"); + grub_util_error (_("cannot restore the original directory")); free (saved_cwd); closedir (dp); @@ -463,7 +464,7 @@ grub_find_device (const char *dir, dev_t dev) } if (chdir (saved_cwd) < 0) - grub_util_error ("cannot restore the original directory"); + grub_util_error (_("cannot restore the original directory")); free (saved_cwd); closedir (dp); @@ -581,17 +582,17 @@ grub_guess_root_device (const char *dir) &data, &data_len); if (num_ints < 1) - grub_util_error ("Storage info for `%s' does not include type", dir); + grub_util_error (_("Storage info for `%s' does not include type"), dir); if (ints[0] != STORAGE_DEVICE) - grub_util_error ("Filesystem of `%s' is not stored on local disk", dir); + grub_util_error (_("Filesystem of `%s' is not stored on local disk"), dir); if (num_ints < 5) - grub_util_error ("Storage info for `%s' does not include name", dir); + grub_util_error (_("Storage info for `%s' does not include name"), dir); name_len = ints[4]; if (name_len < data_len) - grub_util_error ("Bogus name length for storage info for `%s'", dir); + grub_util_error (_("Bogus name length for storage info for `%s'"), dir); if (data[name_len - 1] != '\0') - grub_util_error ("Storage name for `%s' not NUL-terminated", dir); + grub_util_error (_("Storage name for `%s' not NUL-terminated"), dir); os_dev = xmalloc (strlen ("/dev/") + data_len); memcpy (os_dev, "/dev/", strlen ("/dev/")); @@ -653,7 +654,7 @@ grub_guess_root_device (const char *dir) } if (stat (dir, &st) < 0) - grub_util_error ("cannot stat `%s'", dir); + grub_util_error (_("cannot stat `%s'"), dir); dev = st.st_dev; @@ -692,7 +693,7 @@ grub_util_open_dm (const char *os_dev, struct dm_tree **tree, *tree = dm_tree_create (); if (! *tree) { - grub_printf ("Failed to create tree\n"); + grub_puts_ (N_("Failed to create tree")); grub_dprintf ("hostdisk", "dm_tree_create failed\n"); return 0; } @@ -808,7 +809,7 @@ grub_util_get_geom_abstraction (const char *dev) error = geom_gettree (&mesh); if (error != 0) - grub_util_error ("couldn't open geom"); + grub_util_error (_("couldn't open geom")); LIST_FOREACH (class, &mesh.lg_class, lg_class) { @@ -874,13 +875,14 @@ get_mdadm_uuid (const char *os_dev) if (pipe (mdadm_pipe) < 0) { - grub_util_warn ("Unable to create pipe for mdadm: %s", strerror (errno)); + grub_util_warn (_("Unable to create pipe for mdadm: %s"), + strerror (errno)); return NULL; } mdadm_pid = fork (); if (mdadm_pid < 0) - grub_util_warn ("Unable to fork mdadm: %s", strerror (errno)); + grub_util_warn (_("Unable to fork mdadm: %s"), strerror (errno)); else if (mdadm_pid == 0) { /* Child. */ @@ -911,7 +913,7 @@ get_mdadm_uuid (const char *os_dev) mdadm = fdopen (mdadm_pipe[0], "r"); if (! mdadm) { - grub_util_warn ("Unable to open stream from mdadm: %s", + grub_util_warn (_("Unable to open stream from mdadm: %s"), strerror (errno)); goto out; } @@ -971,7 +973,7 @@ grub_util_pull_device (const char *os_dev) error = geom_gettree (&mesh); if (error != 0) - grub_util_error ("couldn't open geom"); + grub_util_error (_("couldn't open geom")); LIST_FOREACH (class, &mesh.lg_class, lg_class) { @@ -989,7 +991,7 @@ grub_util_pull_device (const char *os_dev) LIST_FOREACH (consumer, &geom->lg_consumer, lg_consumer) break; if (!consumer) - grub_util_error ("couldn't find geli consumer"); + grub_util_error (_("couldn't find geli consumer")); fname = xasprintf ("/dev/%s", consumer->lg_provider->lg_name); grub_util_info ("consumer %s", consumer->lg_provider->lg_name); lastsubdev = consumer->lg_provider->lg_name; @@ -1009,7 +1011,7 @@ grub_util_pull_device (const char *os_dev) grub_err_t err; err = grub_cryptodisk_cheat_mount (grdev, os_dev); if (err) - grub_util_error ("Can't mount crypto: %s", grub_errmsg); + grub_util_error (_("Can't mount crypto: %s"), _(grub_errmsg)); } grub_free (grdev); @@ -1053,7 +1055,7 @@ grub_util_pull_device (const char *os_dev) grub_err_t err; err = grub_cryptodisk_cheat_mount (grdev, os_dev); if (err) - grub_util_error ("Can't mount crypto: %s", grub_errmsg); + grub_util_error (_("Can't mount crypto: %s"), _(grub_errmsg)); } grub_free (grdev); } @@ -1141,7 +1143,7 @@ grub_util_get_grub_dev (const char *os_dev) error = geom_gettree (&mesh); if (error != 0) - grub_util_error ("couldn't open geom"); + grub_util_error (_("couldn't open geom")); LIST_FOREACH (class, &mesh.lg_class, lg_class) { @@ -1159,11 +1161,11 @@ grub_util_get_grub_dev (const char *os_dev) LIST_FOREACH (consumer, &geom->lg_consumer, lg_consumer) break; if (!consumer) - grub_util_error ("couldn't find geli consumer"); + grub_util_error (_("couldn't find geli consumer")); fname = xasprintf ("/dev/%s", consumer->lg_provider->lg_name); uuid = grub_util_get_geli_uuid (fname); if (!uuid) - grub_util_error ("couldn't retrieve geli UUID"); + grub_util_error (_("couldn't retrieve geli UUID")); grub_dev = xasprintf ("cryptouuid/%s", uuid); free (fname); free (uuid); @@ -1248,7 +1250,7 @@ grub_util_get_grub_dev (const char *os_dev) free (p); } else - grub_util_error ("unknown kind of RAID device `%s'", os_dev); + grub_util_error (_("unknown kind of RAID device `%s'"), os_dev); { char *mdadm_name = get_mdadm_uuid (os_dev); @@ -1290,7 +1292,7 @@ grub_util_check_block_device (const char *blk_dev) struct stat st; if (stat (blk_dev, &st) < 0) - grub_util_error ("cannot stat `%s'", blk_dev); + grub_util_error (_("cannot stat `%s'"), blk_dev); if (S_ISBLK (st.st_mode)) return (blk_dev); @@ -1304,7 +1306,7 @@ grub_util_check_char_device (const char *blk_dev) struct stat st; if (stat (blk_dev, &st) < 0) - grub_util_error ("cannot stat `%s'", blk_dev); + grub_util_error (_("cannot stat `%s'"), blk_dev); if (S_ISCHR (st.st_mode)) return (blk_dev); @@ -1320,7 +1322,7 @@ get_win32_path (const char *path) { char winpath[PATH_MAX]; if (cygwin_conv_path (CCP_POSIX_TO_WIN_A, path, winpath, sizeof(winpath))) - grub_util_error ("cygwin_conv_path() failed"); + grub_util_error (_("cygwin_conv_path() failed")); int len = strlen (winpath); int offs = (len > 2 && winpath[1] == ':' ? 2 : 0); @@ -1438,7 +1440,7 @@ grub_make_system_path_relative_to_its_root (const char *path) /* canonicalize. */ p = canonicalize_file_name (path); if (p == NULL) - grub_util_error ("failed to get canonical path of %s", path); + grub_util_error (_("failed to get canonical path of %s"), path); #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) /* For ZFS sub-pool filesystems, could be extended to others (btrfs?). */ @@ -1453,7 +1455,7 @@ grub_make_system_path_relative_to_its_root (const char *path) free (p); if (stat (buf, &st) < 0) - grub_util_error ("cannot stat %s: %s", buf, strerror (errno)); + grub_util_error (_("cannot stat %s: %s"), buf, strerror (errno)); buf2 = xstrdup (buf); num = st.st_dev; @@ -1465,14 +1467,14 @@ grub_make_system_path_relative_to_its_root (const char *path) p = strrchr (buf, '/'); if (p == NULL) /* This should never happen. */ - grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)"); + grub_util_error (_("FIXME: no / in buf. (make_system_path_relative_to_its_root)")); if (p != buf) *p = 0; else *++p = 0; if (stat (buf, &st) < 0) - grub_util_error ("cannot stat %s: %s", buf, strerror (errno)); + grub_util_error (_("cannot stat %s: %s"), buf, strerror (errno)); /* buf is another filesystem; we found it. */ if (st.st_dev != num) diff --git a/util/grub-editenv.c b/util/grub-editenv.c index 519945411..2bff80612 100644 --- a/util/grub-editenv.c +++ b/util/grub-editenv.c @@ -115,26 +115,26 @@ create_envblk_file (const char *name) buf = malloc (DEFAULT_ENVBLK_SIZE); if (! buf) - grub_util_error ("out of memory"); + grub_util_error (_("out of memory")); namenew = xasprintf ("%s.new", name); fp = fopen (namenew, "wb"); if (! fp) - grub_util_error ("cannot open the file %s", namenew); + grub_util_error (_("cannot open the file %s"), namenew); memcpy (buf, GRUB_ENVBLK_SIGNATURE, sizeof (GRUB_ENVBLK_SIGNATURE) - 1); memset (buf + sizeof (GRUB_ENVBLK_SIGNATURE) - 1, '#', DEFAULT_ENVBLK_SIZE - sizeof (GRUB_ENVBLK_SIGNATURE) + 1); if (fwrite (buf, 1, DEFAULT_ENVBLK_SIZE, fp) != DEFAULT_ENVBLK_SIZE) - grub_util_error ("cannot write to the file %s", namenew); + grub_util_error (_("cannot write to the file %s"), namenew); fsync (fileno (fp)); free (buf); fclose (fp); if (rename (namenew, name) < 0) - grub_util_error ("cannot rename the file %s to %s", namenew, name); + grub_util_error (_("cannot rename the file %s to %s"), namenew, name); free (namenew); } @@ -153,29 +153,29 @@ open_envblk_file (const char *name) create_envblk_file (name); fp = fopen (name, "rb"); if (! fp) - grub_util_error ("cannot open the file %s", name); + grub_util_error (_("cannot open the file %s"), name); } if (fseek (fp, 0, SEEK_END) < 0) - grub_util_error ("cannot seek the file %s", name); + grub_util_error (_("cannot seek the file %s"), name); size = (size_t) ftell (fp); if (fseek (fp, 0, SEEK_SET) < 0) - grub_util_error ("cannot seek the file %s", name); + grub_util_error (_("cannot seek the file %s"), name); buf = malloc (size); if (! buf) - grub_util_error ("out of memory"); + grub_util_error (_("out of memory")); if (fread (buf, 1, size, fp) != size) - grub_util_error ("cannot read the file %s", name); + grub_util_error (_("cannot read the file %s"), name); fclose (fp); envblk = grub_envblk_open (buf, size); if (! envblk) - grub_util_error ("invalid environment block"); + grub_util_error (_("invalid environment block")); return envblk; } @@ -204,11 +204,11 @@ write_envblk (const char *name, grub_envblk_t envblk) fp = fopen (name, "wb"); if (! fp) - grub_util_error ("cannot open the file %s", name); + grub_util_error (_("cannot open the file %s"), name); if (fwrite (grub_envblk_buffer (envblk), 1, grub_envblk_size (envblk), fp) != grub_envblk_size (envblk)) - grub_util_error ("cannot write to the file %s", name); + grub_util_error (_("cannot write to the file %s"), name); fsync (fileno (fp)); fclose (fp); @@ -226,12 +226,12 @@ set_variables (const char *name, int argc, char *argv[]) p = strchr (argv[0], '='); if (! p) - grub_util_error ("invalid parameter %s", argv[0]); + grub_util_error (_("invalid parameter %s"), argv[0]); *(p++) = 0; if (! grub_envblk_set (envblk, argv[0], p)) - grub_util_error ("environment block too small"); + grub_util_error (_("environment block too small")); argc--; argv++; diff --git a/util/grub-fstest.c b/util/grub-fstest.c index 47b536771..c9f24ff08 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -395,11 +395,11 @@ fstest (int n, char **args) if (!fs) grub_util_error (grub_errmsg); if (!fs->uuid) - grub_util_error ("couldn't retrieve UUID"); + grub_util_error (_("couldn't retrieve UUID")); if (fs->uuid (dev, &uuid)) grub_util_error (grub_errmsg); if (!uuid) - grub_util_error ("couldn't retrieve UUID"); + grub_util_error (_("couldn't retrieve UUID")); argv[1] = uuid; execute_command ("xnu_uuid", 2, argv); grub_free (uuid); @@ -470,7 +470,7 @@ argp_parser (int key, char *arg, struct argp_state *state) if (strcmp (arg, "prompt") == 0) { char buf[1024]; - grub_printf ("Enter ZFS password: "); + grub_puts_ (N_("Enter ZFS password: ")); if (grub_password_get (buf, 1023)) { grub_zfs_add_key ((grub_uint8_t *) buf, grub_strlen (buf), 1); @@ -484,13 +484,13 @@ argp_parser (int key, char *arg, struct argp_state *state) f = fopen (arg, "rb"); if (!f) { - printf ("Error loading file %s: %s\n", arg, strerror (errno)); + printf (_("Error loading file %s: %s\n"), arg, strerror (errno)); return 0; } real_size = fread (buf, 1, 1024, f); if (real_size < 0) { - printf ("Error loading file %s: %s\n", arg, strerror (errno)); + printf (_("Error loading file %s: %s\n"), arg, strerror (errno)); fclose (f); return 0; } diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index 3108d4694..1fad15660 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -121,9 +121,10 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try `%s --help' for more information.\n", program_name); + fprintf (stderr, _("Try `%s --help' for more information.\n"), + program_name); else - printf ("\ + printf (_("\ Usage: %s [OPTIONS] FONT_FILES\n\ \nOptions:\n\ -o, --output=FILE_NAME set output file name\n\ @@ -143,7 +144,7 @@ Usage: %s [OPTIONS] FONT_FILES\n\ -V, --version print version information and exit\n\ -v, --verbose print verbose messages\n\ \n\ -Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT); +Report bugs to <%s>.\n"), program_name, PACKAGE_BUGREPORT); exit (status); } @@ -188,12 +189,12 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, err = FT_Load_Glyph (face, glyph_idx, flag); if (err) { - printf ("Freetype Error %d loading glyph 0x%x for U+0x%x%s", + printf (_("Freetype Error %d loading glyph 0x%x for U+0x%x%s"), err, glyph_idx, char_code & GRUB_FONT_CODE_CHAR_MASK, char_code & GRUB_FONT_CODE_RIGHT_JOINED - ? ((char_code & GRUB_FONT_CODE_LEFT_JOINED) ? " (medial)": - " (leftmost)") - : ((char_code & GRUB_FONT_CODE_LEFT_JOINED) ? " (rightmost)": + ? ((char_code & GRUB_FONT_CODE_LEFT_JOINED) ? _(" (medial)"): + _(" (leftmost)")) + : ((char_code & GRUB_FONT_CODE_LEFT_JOINED) ? _(" (rightmost)"): "")); if (err > 0 && err < (signed) ARRAY_SIZE (ft_errmsgs)) @@ -519,7 +520,7 @@ process_cursive (struct gsub_feature *feature, if (substtype == GSUB_SUBSTITUTION_DELTA) add_subst (glyph, glyph + grub_be_to_cpu16 (sub->delta), target); else if (i >= grub_be_to_cpu16 (sub->count)) - printf ("Out of range substitution (%d, %d)\n", i, + printf (_("Out of range substitution (%d, %d)\n"), i, grub_be_to_cpu16 (sub->count)); else add_subst (glyph, grub_be_to_cpu16 (sub->repl[i++]), target); @@ -531,7 +532,7 @@ process_cursive (struct gsub_feature *feature, struct gsub_lookup *lookup; if (lookup_index >= grub_be_to_cpu16 (lookups->count)) { - printf ("Out of range lookup: %d\n", lookup_index); + printf (_("Out of range lookup: %d\n"), lookup_index); continue; } lookup = (struct gsub_lookup *) @@ -539,13 +540,13 @@ process_cursive (struct gsub_feature *feature, + grub_be_to_cpu16 (lookups->offsets[lookup_index])); if (grub_be_to_cpu16 (lookup->type) != GSUB_SINGLE_SUBSTITUTION) { - printf ("Unsupported substitution type: %d\n", + printf (_("Unsupported substitution type: %d\n"), grub_be_to_cpu16 (lookup->type)); continue; } if (grub_be_to_cpu16 (lookup->flag) & ~GSUB_RTL_CHAR) { - printf ("Unsupported substitution flag: 0x%x\n", + printf (_("Unsupported substitution flag: 0x%x\n"), grub_be_to_cpu16 (lookup->flag)); } switch (feattag) @@ -575,7 +576,7 @@ process_cursive (struct gsub_feature *feature, if (substtype != GSUB_SUBSTITUTION_MAP && substtype != GSUB_SUBSTITUTION_DELTA) { - printf ("Unsupported substitution specification: %d\n", + printf (_("Unsupported substitution specification: %d\n"), substtype); continue; } @@ -601,7 +602,7 @@ process_cursive (struct gsub_feature *feature, subst (m); } else - printf ("Unsupported coverage specification: %d\n", covertype); + printf (_("Unsupported coverage specification: %d\n"), covertype); } } } @@ -640,7 +641,7 @@ add_font (struct grub_font_info *font_info, FT_Face face, int nocut) grub_uint32_t feattag = grub_be_to_cpu32 (features->features[i].feature_tag); if (feature->params) - printf ("WARNING: unsupported feature parameters: %x\n", + printf (_("WARNING: unsupported feature parameters: %x\n"), grub_be_to_cpu16 (feature->params)); switch (feattag) { @@ -670,7 +671,7 @@ add_font (struct grub_font_info *font_info, FT_Face face, int nocut) for (j = 0; j < 4; j++) if (!grub_isgraph (str[j])) str[j] = '?'; - printf ("Unknown gsub feature 0x%x (%s)\n", feattag, str); + printf (_("Unknown gsub feature 0x%x (%s)\n"), feattag, str); } } } @@ -739,8 +740,8 @@ print_glyphs (struct grub_font_info *font_info) int x, y, xmax, xmin, ymax, ymin; grub_uint8_t *bitmap, mask; - printf ("\nGlyph #%d, U+%04x\n", num, glyph->char_code); - printf ("Width %d, Height %d, X offset %d, Y offset %d, Device width %d\n", + printf (_("\nGlyph #%d, U+%04x\n"), num, glyph->char_code); + printf (_("Width %d, Height %d, X offset %d, Y offset %d, Device width %d\n"), glyph->width, glyph->height, glyph->x_ofs, glyph->y_ofs, glyph->device_width); @@ -807,7 +808,7 @@ write_font_ascii_bitmap (struct grub_font_info *font_info, char *output_file) file = fopen (output_file, "wb"); if (! file) - grub_util_error ("Can\'t write to file %s.", output_file); + grub_util_error (_("Can\'t write to file %s."), output_file); int correct_size; for (glyph = font_info->glyphs_sorted, num = 0; num < font_info->num_glyphs; @@ -843,7 +844,7 @@ write_font_width_spec (struct grub_font_info *font_info, char *output_file) file = fopen (output_file, "wb"); if (! file) - grub_util_error ("Can\'t write to file %s.", output_file); + grub_util_error (_("Can\'t write to file %s."), output_file); for (glyph = font_info->glyphs_sorted; glyph < font_info->glyphs_sorted + font_info->num_glyphs; glyph++) @@ -866,7 +867,7 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file) file = fopen (output_file, "wb"); if (! file) - grub_util_error ("can\'t write to file %s.", output_file); + grub_util_error (_("Can\'t write to file %s."), output_file); offset = 0; @@ -1063,7 +1064,7 @@ main (int argc, char *argv[]) a = strtoul (p, &p, 0); if (*p != '-') - grub_util_error ("invalid font range"); + grub_util_error (_("invalid font range")); b = strtoul (p + 1, &p, 0); if ((font_info.num_range & (GRUB_FONT_RANGE_BLOCK - 1)) == 0) font_info.ranges = xrealloc (font_info.ranges, @@ -1078,7 +1079,7 @@ main (int argc, char *argv[]) if (*p) { if (*p != ',') - grub_util_error ("invalid font range"); + grub_util_error (_("invalid font range")); else p++; } @@ -1124,7 +1125,7 @@ main (int argc, char *argv[]) if (file_format == ASCII_BITMAPS && font_info.num_range > 0) { - grub_util_error ("Option --ascii-bitmaps doesn't accept ranges (use ASCII)."); + grub_util_error (_("Option --ascii-bitmaps doesn't accept ranges (use ASCII).")); return 1; } @@ -1140,10 +1141,10 @@ main (int argc, char *argv[]) } if (! output_file) - grub_util_error ("no output file is specified"); + grub_util_error (_("no output file is specified")); if (FT_Init_FreeType (&ft_lib)) - grub_util_error ("FT_Init_FreeType fails"); + grub_util_error (_("FT_Init_FreeType fails")); for (; optind < argc; optind++) { @@ -1154,8 +1155,8 @@ main (int argc, char *argv[]) err = FT_New_Face (ft_lib, argv[optind], font_index, &ft_face); if (err) { - grub_printf ("can't open file %s, index %d: error %d", argv[optind], - font_index, err); + 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 @@ -1181,7 +1182,7 @@ main (int argc, char *argv[]) font_info.size = size; if (FT_Set_Pixel_Sizes (ft_face, size, size)) - grub_util_error ("can't set %dx%d font size", 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); } diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index fb1c5babe..9369fba3d 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -703,7 +703,7 @@ compress_kernel (struct image_target_desc *image_target, char *kernel_img, if (image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS && (comp != COMPRESSION_NONE)) - grub_util_error ("unknown compression %d\n", comp); + grub_util_error (_("unknown compression %d\n"), comp); *core_img = xmalloc (kernel_size); memcpy (*core_img, kernel_img, kernel_size); @@ -945,7 +945,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], name = "none_decompress.img"; break; default: - grub_util_error ("unknown compression %d\n", comp); + grub_util_error (_("unknown compression %d\n"), comp); } decompress_path = grub_util_get_path (dir, name); @@ -1301,7 +1301,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], boot_path = grub_util_get_path (dir, "diskboot.img"); boot_size = grub_util_get_image_size (boot_path); if (boot_size != GRUB_DISK_SECTOR_SIZE) - grub_util_error ("diskboot.img is not one sector size"); + grub_util_error (_("diskboot.img is not one sector size")); boot_img = grub_util_read_image (boot_path); @@ -1366,11 +1366,11 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], 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"); + grub_util_warn (_("fwstart.img doesn't match the known good version. " + "proceed at your own risk")); if (core_size + boot_size > 512 * 1024) - grub_util_error ("firmware image is too big"); + grub_util_error (_("firmware image is too big")); rom_size = 512 * 1024; rom_img = xmalloc (rom_size); @@ -1394,7 +1394,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], size_t rom_size; if (core_size > 512 * 1024) - grub_util_error ("firmware image is too big"); + grub_util_error (_("firmware image is too big")); rom_size = 512 * 1024; rom_img = xmalloc (rom_size); @@ -1762,7 +1762,7 @@ main (int argc, char *argv[]) image_target = &image_targets[i]; if (!image_target) { - printf ("unknown target format %s\n", optarg); + printf (_("unknown target format %s\n"), optarg); usage (1); } break; @@ -1803,14 +1803,14 @@ main (int argc, char *argv[]) #ifdef HAVE_LIBLZMA comp = COMPRESSION_XZ; #else - grub_util_error ("grub-mkimage is compiled without XZ support", + grub_util_error (_("grub-mkimage is compiled without XZ support"), optarg); #endif } else if (grub_strcmp (optarg, "none") == 0) comp = COMPRESSION_NONE; else - grub_util_error ("Unknown compression format %s", optarg); + grub_util_error (_("Unknown compression format %s"), optarg); break; case 'h': @@ -1840,7 +1840,7 @@ main (int argc, char *argv[]) if (!image_target) { - printf ("Target format not specified (use the -O option).\n"); + printf (_("Target format not specified (use the -O option).\n")); usage (1); } diff --git a/util/grub-mkpasswd-pbkdf2.c b/util/grub-mkpasswd-pbkdf2.c index f75f27611..9c676a100 100644 --- a/util/grub-mkpasswd-pbkdf2.c +++ b/util/grub-mkpasswd-pbkdf2.c @@ -46,16 +46,17 @@ static void usage (int status) { if (status) - fprintf (stderr, "Try `%s --help' for more information.\n", program_name); + fprintf (stderr, _("Try `%s --help' for more information.\n"), + program_name); else - printf ("\ + printf (_("\ Usage: %s [OPTIONS]\n\ \nOptions:\n\ -c number, --iteration-count=number Number of PBKDF2 iterations\n\ -l number, --buflen=number Length of generated hash\n\ -s number, --salt=number Length of salt\n\ \n\ -Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT); +Report bugs to <%s>.\n"), program_name, PACKAGE_BUGREPORT); exit (status); } @@ -135,12 +136,12 @@ main (int argc, char *argv[]) bufhex = malloc (buflen * 2 + 1); if (!bufhex) - grub_util_error ("out of memory"); + grub_util_error (_("out of memory")); buf = malloc (buflen); if (!buf) { free (bufhex); - grub_util_error ("out of memory"); + grub_util_error (_("out of memory")); } salt = malloc (saltlen); @@ -148,7 +149,7 @@ main (int argc, char *argv[]) { free (bufhex); free (buf); - grub_util_error ("out of memory"); + grub_util_error (_("out of memory")); } salthex = malloc (saltlen * 2 + 1); if (!salthex) @@ -156,26 +157,26 @@ main (int argc, char *argv[]) free (salt); free (bufhex); free (buf); - grub_util_error ("out of memory"); + grub_util_error (_("out of memory")); } - printf ("Enter password: "); + printf ("%s", _("Enter password: ")); if (!grub_password_get (pass1, GRUB_AUTH_MAX_PASSLEN)) { free (buf); free (bufhex); free (salthex); free (salt); - grub_util_error ("failure to read password"); + grub_util_error (_("failure to read password")); } - printf ("\nReenter password: "); + printf ("\n%s", _("Reenter password: ")); if (!grub_password_get (pass2, GRUB_AUTH_MAX_PASSLEN)) { free (buf); free (bufhex); free (salthex); free (salt); - grub_util_error ("failure to read password"); + grub_util_error (_("failure to read password")); } if (strcmp (pass1, pass2) != 0) @@ -186,12 +187,12 @@ main (int argc, char *argv[]) free (bufhex); free (salthex); free (salt); - grub_util_error ("passwords don't match"); + grub_util_error (_("passwords don't match")); } memset (pass2, 0, sizeof (pass2)); #if ! defined (__linux__) && ! defined (__FreeBSD__) - printf ("WARNING: your random generator isn't known to be secure\n"); + printf ("%s", _("WARNING: your random generator isn't known to be secure\n")); #endif { @@ -206,7 +207,7 @@ main (int argc, char *argv[]) free (salthex); free (salt); fclose (f); - grub_util_error ("couldn't retrieve random data for salt"); + grub_util_error (_("couldn't retrieve random data for salt")); } rd = fread (salt, 1, saltlen, f); if (rd != saltlen) @@ -217,7 +218,7 @@ main (int argc, char *argv[]) free (bufhex); free (salthex); free (salt); - grub_util_error ("couldn't retrieve random data for salt"); + grub_util_error (_("couldn't retrieve random data for salt")); } fclose (f); } @@ -238,13 +239,13 @@ main (int argc, char *argv[]) memset (salthex, 0, 2 * saltlen); free (salt); free (salthex); - grub_util_error ("cryptographic error number %d", gcry_err); + grub_util_error (_("cryptographic error number %d"), gcry_err); } hexify (bufhex, buf, buflen); hexify (salthex, salt, saltlen); - printf ("Your PBKDF2 is grub.pbkdf2.sha512.%d.%s.%s\n", + printf (_("Your PBKDF2 is grub.pbkdf2.sha512.%d.%s.%s\n"), count, salthex, bufhex); memset (buf, 0, buflen); memset (bufhex, 0, 2 * buflen); diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c index 4b93faa05..51d41c9f0 100644 --- a/util/grub-pe2elf.c +++ b/util/grub-pe2elf.c @@ -31,6 +31,8 @@ #include "progname.h" +/* Please don't internationalise this file. It's pointless. */ + static struct option options[] = { {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, diff --git a/util/grub-probe.c b/util/grub-probe.c index 54b9d03c6..795a9344e 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -173,10 +173,10 @@ probe (const char *path, char *device_name) { #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__sun__) if (! grub_util_check_char_device (device_name)) - grub_util_error ("%s is not a character device", device_name); + grub_util_error (_("%s is not a character device"), device_name); #else if (! grub_util_check_block_device (device_name)) - grub_util_error ("%s is not a block device", device_name); + grub_util_error (_("%s is not a block device"), device_name); #endif } else @@ -186,7 +186,7 @@ probe (const char *path, char *device_name) } if (! device_name) - grub_util_error ("cannot find a device for %s (is /dev mounted?)", path); + grub_util_error (_("cannot find a device for %s (is /dev mounted?)"), path); if (print == PRINT_DEVICE) { @@ -196,7 +196,8 @@ probe (const char *path, char *device_name) drive_name = grub_util_get_grub_dev (device_name); if (! drive_name) - grub_util_error ("cannot find a GRUB drive for %s. Check your device.map", device_name); + grub_util_error (_("cannot find a GRUB drive for %s. Check your device.map"), + device_name); if (print == PRINT_DRIVE) { @@ -207,7 +208,7 @@ probe (const char *path, char *device_name) grub_util_info ("opening %s", drive_name); dev = grub_device_open (drive_name); if (! dev) - grub_util_error ("%s", grub_errmsg); + grub_util_error ("%s", _(grub_errmsg)); if (print == PRINT_ABSTRACTION) { @@ -233,7 +234,7 @@ probe (const char *path, char *device_name) fs = grub_fs_probe (dev); if (! fs) - grub_util_error ("%s", grub_errmsg); + grub_util_error ("%s", _(grub_errmsg)); if (print == PRINT_FS) { @@ -243,7 +244,7 @@ probe (const char *path, char *device_name) { char *uuid; if (! fs->uuid) - grub_util_error ("%s does not support UUIDs", fs->name); + grub_util_error (_("%s does not support UUIDs"), fs->name); if (fs->uuid (dev, &uuid) != GRUB_ERR_NONE) grub_util_error ("%s", grub_errmsg); @@ -254,10 +255,10 @@ probe (const char *path, char *device_name) { char *label; if (! fs->label) - grub_util_error ("%s does not support labels", fs->name); + grub_util_error (_("%s does not support labels"), fs->name); if (fs->label (dev, &label) != GRUB_ERR_NONE) - grub_util_error ("%s", grub_errmsg); + grub_util_error ("%s", _(grub_errmsg)); printf ("%s\n", label); } @@ -287,9 +288,9 @@ usage (int status) { if (status) fprintf (stderr, - "Try `%s --help' for more information.\n", program_name); + _("Try `%s --help' for more information.\n"), program_name); else - printf ("\ + printf (_("\ Usage: %s [OPTION]... [PATH|DEVICE]\n\ \n\ Probe device information for a given path (or device, if the -d option is given).\n\ @@ -303,7 +304,7 @@ Probe device information for a given path (or device, if the -d option is given) -v, --verbose print verbose messages\n\ \n\ Report bugs to <%s>.\n\ -", program_name, +"), program_name, DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT); exit (status); @@ -385,13 +386,13 @@ main (int argc, char *argv[]) /* Obtain ARGUMENT. */ if (optind >= argc) { - fprintf (stderr, "No path or device is specified.\n"); + fprintf (stderr, _("No path or device is specified.\n")); usage (1); } if (optind + 1 != argc) { - fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]); + fprintf (stderr, _("Unknown extra argument `%s'.\n"), argv[optind + 1]); usage (1); } diff --git a/util/grub-setup.c b/util/grub-setup.c index d3f6fe8b8..f185ed747 100644 --- a/util/grub-setup.c +++ b/util/grub-setup.c @@ -125,8 +125,8 @@ write_rootdev (char *core_img, grub_device_t root_dev, if (root_dev->disk->partition->parent) { if (root_dev->disk->partition->parent->parent) - grub_util_error ("Installing on doubly nested partitions is " - "not supported"); + grub_util_error (_("Installing on doubly nested partitions " + "is not supported")); dos_part = root_dev->disk->partition->parent->number; bsd_part = root_dev->disk->partition->number; } @@ -283,22 +283,22 @@ setup (const char *dir, grub_util_info ("Opening root"); root_dev = grub_device_open (root); if (! root_dev) - grub_util_error ("%s", grub_errmsg); + grub_util_error ("%s", _(grub_errmsg)); grub_util_info ("Opening dest"); dest_dev = grub_device_open (dest); if (! dest_dev) - grub_util_error ("%s", grub_errmsg); + grub_util_error ("%s", _(grub_errmsg)); grub_util_info ("setting the root device to `%s'", root); if (grub_env_set ("root", root) != GRUB_ERR_NONE) - grub_util_error ("%s", grub_errmsg); + grub_util_error ("%s", _(grub_errmsg)); #ifdef GRUB_MACHINE_PCBIOS /* Read the original sector from the disk. */ tmp_img = xmalloc (GRUB_DISK_SECTOR_SIZE); if (grub_disk_read (dest_dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, tmp_img)) - grub_util_error ("%s", grub_errmsg); + grub_util_error ("%s", _(grub_errmsg)); #endif #ifdef GRUB_MACHINE_PCBIOS @@ -421,14 +421,14 @@ setup (const char *dir, if (dest_partmap && !dest_partmap->embed) { - grub_util_warn ("Partition style '%s' doesn't support embeding", + grub_util_warn (_("Partition style '%s' doesn't support embeding"), dest_partmap->name); goto unable_to_embed; } if (fs && !fs->embed) { - grub_util_warn ("File system '%s' doesn't support embeding", + grub_util_warn (_("File system '%s' doesn't support embeding"), fs->name); goto unable_to_embed; } @@ -443,13 +443,13 @@ setup (const char *dir, if (!err && nsec < core_sectors) { err = grub_error (GRUB_ERR_OUT_OF_RANGE, - "Your embedding area is unusually small. " - "core.img won't fit in it."); + N_("Your embedding area is unusually small. " + "core.img won't fit in it.")); } if (err) { - grub_util_warn ("%s", grub_errmsg); + grub_util_warn ("%s", _(grub_errmsg)); grub_errno = GRUB_ERR_NONE; goto unable_to_embed; } @@ -466,7 +466,7 @@ setup (const char *dir, block--; if ((char *) block <= core_img) - grub_util_error ("No terminator in the core image"); + grub_util_error (_("No terminator in the core image")); } save_first_sector (sectors[0] + grub_partition_get_start (container), @@ -626,7 +626,7 @@ unable_to_embed: grub_file_filter_disable_compression (); file = grub_file_open (core_path_dev); if (! file) - grub_util_error ("%s", grub_errmsg); + grub_util_error ("%s", _(grub_errmsg)); file->read_hook = save_first_sector; if (grub_file_read (file, tmp_img, GRUB_DISK_SECTOR_SIZE) @@ -687,8 +687,7 @@ unable_to_embed: /* Write the boot image onto the disk. */ if (grub_disk_write (dest_dev->disk, BOOT_SECTOR, 0, GRUB_DISK_SECTOR_SIZE, boot_img)) - grub_util_error ("%s", grub_errmsg); - + grub_util_error ("%s", _(grub_errmsg)); grub_util_biosdisk_flush (root_dev->disk); grub_util_biosdisk_flush (dest_dev->disk); diff --git a/util/ieee1275/ofpath.c b/util/ieee1275/ofpath.c index f72bea8a5..20a571191 100644 --- a/util/ieee1275/ofpath.c +++ b/util/ieee1275/ofpath.c @@ -23,6 +23,7 @@ #include #include #include +#include #endif #include @@ -53,6 +54,7 @@ grub_util_error (const char *fmt, ...) exit (1); } +#define _(x) x #endif static void @@ -106,7 +108,7 @@ find_obppath(char *of_path, const char *sysfs_path_orig) { kill_trailing_dir(sysfs_path); if (!strcmp(sysfs_path, "/sys")) - grub_util_error("'obppath' not found in parent dirs of %s", + grub_util_error(_("'obppath' not found in parent dirs of %s"), sysfs_path_orig); continue; } @@ -131,12 +133,12 @@ block_device_get_sysfs_path_and_link(const char *devicenode, snprintf(sysfs_path, sysfs_path_len, "/sys/block/%s", devicenode); if (!realpath (sysfs_path, rpath)) - grub_util_error ("cannot get the real path of `%s'", sysfs_path); + grub_util_error (_("cannot get the real path of `%s'"), sysfs_path); strcat(rpath, "/device"); if (!realpath (rpath, sysfs_path)) - grub_util_error ("cannot get the real path of `%s'", rpath); + grub_util_error (_("cannot get the real path of `%s'"), rpath); free (rpath); } @@ -247,12 +249,12 @@ vendor_is_ATA(const char *path) snprintf(buf, PATH_MAX, "%s/vendor", path); fd = open(buf, O_RDONLY); if (fd < 0) - grub_util_error ("cannot open 'vendor' node of `%s'", path); + grub_util_error (_("cannot open 'vendor' node of `%s'"), path); memset(buf, 0, PATH_MAX); err = read(fd, buf, PATH_MAX); if (err < 0) - grub_util_error ("cannot read 'vendor' node of `%s'", path); + grub_util_error (_("cannot read 'vendor' node of `%s'"), path); close(fd); @@ -288,7 +290,7 @@ check_sas (char *sysfs_path, int *tgt) fd = open(path, O_RDONLY); if (fd < 0) - grub_util_error("cannot open SAS PHY ID `%s'\n", path); + grub_util_error(_("cannot open SAS PHY ID `%s'\n"), path); memset (phy, 0, sizeof (phy)); read (fd, phy, sizeof (phy)); @@ -376,7 +378,7 @@ grub_util_devname_to_ofpath (const char *devname) name_buf = xmalloc (PATH_MAX); name_buf = realpath (devname, name_buf); if (! name_buf) - grub_util_error ("cannot get the real path of `%s'", devname); + grub_util_error (_("cannot get the real path of `%s'"), devname); device = get_basename (name_buf); devnode = strip_trailing_digits (name_buf); @@ -398,7 +400,7 @@ grub_util_devname_to_ofpath (const char *devname) New models have no floppy at all. */ strcpy (ofpath, "floppy"); else - grub_util_error ("unknown device type %s\n", device); + grub_util_error (_("unknown device type %s\n"), device); free (devnode); free (devicenode); @@ -414,7 +416,7 @@ int main(int argc, char **argv) if (argc != 2) { - printf("Usage: grub-ofpathname DEVICE\n"); + printf(_("Usage: %s DEVICE\n"), argv[0]); return 1; } diff --git a/util/misc.c b/util/misc.c index 72bedde0c..6ebaf30bc 100644 --- a/util/misc.c +++ b/util/misc.c @@ -89,10 +89,10 @@ grub_util_get_fp_size (FILE *fp) struct stat st; if (fflush (fp) == EOF) - grub_util_error ("fflush failed"); + grub_util_error (_("fflush failed")); if (fstat (fileno (fp), &st) == -1) - grub_util_error ("fstat failed"); + grub_util_error (_("fstat failed")); return st.st_size; } @@ -105,7 +105,7 @@ grub_util_get_image_size (const char *path) grub_util_info ("getting the size of %s", path); if (stat (path, &st) == -1) - grub_util_error ("cannot stat %s", path); + grub_util_error (_("cannot stat %s"), path); return st.st_size; } @@ -114,10 +114,10 @@ void grub_util_read_at (void *img, size_t size, off_t offset, FILE *fp) { if (fseeko (fp, offset, SEEK_SET) == -1) - grub_util_error ("seek failed"); + grub_util_error (_("seek failed")); if (fread (img, 1, size, fp) != size) - grub_util_error ("read failed"); + grub_util_error (_("read failed")); } char * @@ -134,7 +134,7 @@ grub_util_read_image (const char *path) fp = fopen (path, "rb"); if (! fp) - grub_util_error ("cannot open %s", path); + grub_util_error (_("cannot open %s"), path); grub_util_read_at (img, size, 0, fp); @@ -155,10 +155,10 @@ grub_util_load_image (const char *path, char *buf) fp = fopen (path, "rb"); if (! fp) - grub_util_error ("cannot open %s", path); + grub_util_error (_("cannot open %s"), path); if (fread (buf, 1, size, fp) != size) - grub_util_error ("cannot read %s", path); + grub_util_error (_("cannot read %s"), path); fclose (fp); } @@ -168,9 +168,9 @@ grub_util_write_image_at (const void *img, size_t size, off_t offset, FILE *out) { grub_util_info ("writing 0x%x bytes at offset 0x%x", size, offset); if (fseeko (out, offset, SEEK_SET) == -1) - grub_util_error ("seek failed"); + grub_util_error (_("seek failed")); if (fwrite (img, 1, size, out) != size) - grub_util_error ("write failed"); + grub_util_error (_("write failed")); } void @@ -178,7 +178,7 @@ grub_util_write_image (const char *img, size_t size, FILE *out) { grub_util_info ("writing 0x%x bytes", size); if (fwrite (img, 1, size, out) != size) - grub_util_error ("write failed"); + grub_util_error (_("write failed")); } char * diff --git a/util/raid.c b/util/raid.c index 1e312491b..8de5fbac0 100644 --- a/util/raid.c +++ b/util/raid.c @@ -33,6 +33,7 @@ #include #include #include +#include char ** grub_util_raid_getmembers (const char *name, int bootable) @@ -46,26 +47,26 @@ grub_util_raid_getmembers (const char *name, int bootable) fd = open (name, O_RDONLY); if (fd == -1) - grub_util_error ("can't open %s: %s", name, strerror (errno)); + grub_util_error (_("can't open %s: %s"), name, strerror (errno)); ret = ioctl (fd, RAID_VERSION, &version); if (ret != 0) - grub_util_error ("ioctl RAID_VERSION error: %s", strerror (errno)); + grub_util_error (_("ioctl RAID_VERSION error: %s"), strerror (errno)); if ((version.major != 0 || version.minor != 90) && (version.major != 1 || version.minor != 0) && (version.major != 1 || version.minor != 1) && (version.major != 1 || version.minor != 2)) - grub_util_error ("unsupported RAID version: %d.%d", + grub_util_error (_("unsupported RAID version: %d.%d"), version.major, version.minor); if (bootable && (version.major != 0 || version.minor != 90)) - grub_util_error ("unsupported RAID version: %d.%d", + grub_util_error (_("unsupported RAID version: %d.%d"), version.major, version.minor); ret = ioctl (fd, GET_ARRAY_INFO, &info); if (ret != 0) - grub_util_error ("ioctl GET_ARRAY_INFO error: %s", strerror (errno)); + grub_util_error (_("ioctl GET_ARRAY_INFO error: %s"), strerror (errno)); devicelist = xmalloc ((info.nr_disks + 1) * sizeof (char *)); @@ -74,7 +75,7 @@ grub_util_raid_getmembers (const char *name, int bootable) disk.number = i; ret = ioctl (fd, GET_DISK_INFO, &disk); if (ret != 0) - grub_util_error ("ioctl GET_DISK_INFO error: %s", strerror (errno)); + grub_util_error (_("ioctl GET_DISK_INFO error: %s"), strerror (errno)); if (disk.state & (1 << MD_DISK_ACTIVE)) {