Improve gettext support. Stylistic fixes and error handling fixes while

on it.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-08 19:26:01 +01:00
parent 215c90cb82
commit 9c4b5c13e6
184 changed files with 1175 additions and 959 deletions

View file

@ -25,6 +25,7 @@
#include <grub/misc.h>
#include <grub/env.h>
#include <grub/partition.h>
#include <grub/i18n.h>
grub_net_t (*grub_net_open) (const char *name) = NULL;
@ -39,7 +40,7 @@ grub_device_open (const char *name)
name = grub_env_get ("root");
if (name == NULL || *name == '\0')
{
grub_error (GRUB_ERR_BAD_DEVICE, "no device is set");
grub_error (GRUB_ERR_BAD_DEVICE, N_("variable `%s' isn't set"), "root");
goto fail;
}
}

View file

@ -24,6 +24,7 @@
#include <grub/misc.h>
#include <grub/time.h>
#include <grub/file.h>
#include <grub/i18n.h>
#define GRUB_CACHE_TIMEOUT 2
@ -263,7 +264,8 @@ grub_disk_open (const char *name)
if (! dev)
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such disk");
grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"),
name);
goto fail;
}
if (disk->log_sector_size > GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS
@ -360,7 +362,8 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
if (*sector >= len
|| len - *sector < ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
>> GRUB_DISK_SECTOR_BITS))
return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of partition");
return grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("attempt to read or write outside of partition"));
*sector += start;
}
@ -371,7 +374,8 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
>> GRUB_DISK_SECTOR_BITS) > (disk->total_sectors
<< (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS)) - *sector))
return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk");
return grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("attempt to read or write outside of disk `%s'"), disk->name);
return GRUB_ERR_NONE;
}

View file

@ -31,6 +31,7 @@
#include <grub/file.h>
#include <grub/env.h>
#include <grub/cache.h>
#include <grub/i18n.h>
/* Platforms where modules are in a readonly area of memory. */
#if defined(GRUB_MACHINE_QEMU)
@ -208,20 +209,24 @@ static grub_err_t
grub_dl_check_header (void *ehdr, grub_size_t size)
{
Elf_Ehdr *e = ehdr;
grub_err_t err;
/* Check the header size. */
if (size < sizeof (Elf_Ehdr))
return grub_error (GRUB_ERR_BAD_OS, "ELF header smaller than expected");
/* Check the magic numbers. */
if (grub_arch_dl_check_header (ehdr)
|| e->e_ident[EI_MAG0] != ELFMAG0
if (e->e_ident[EI_MAG0] != ELFMAG0
|| e->e_ident[EI_MAG1] != ELFMAG1
|| e->e_ident[EI_MAG2] != ELFMAG2
|| e->e_ident[EI_MAG3] != ELFMAG3
|| e->e_ident[EI_VERSION] != EV_CURRENT
|| e->e_version != EV_CURRENT)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch independent ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch independent ELF magic"));
err = grub_arch_dl_check_header (ehdr);
if (err)
return err;
return GRUB_ERR_NONE;
}
@ -345,7 +350,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symbol table");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
#ifdef GRUB_MODULES_MACHINE_READONLY
mod->symtab = grub_malloc (s->sh_size);
@ -378,7 +383,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
grub_symbol_t nsym = grub_dl_resolve_symbol (name);
if (! nsym)
return grub_error (GRUB_ERR_BAD_MODULE,
"symbol not found: `%s'", name);
N_("symbol `%s' not found"), name);
sym->st_value = (Elf_Addr) nsym->addr;
if (nsym->isfunc)
sym->st_info = ELF_ST_INFO (bind, STT_FUNC);
@ -596,7 +601,7 @@ grub_dl_load_core (void *addr, grub_size_t size)
if (e->e_type != ET_REL)
{
grub_error (GRUB_ERR_BAD_MODULE, "invalid ELF file type");
grub_error (GRUB_ERR_BAD_MODULE, N_("this ELF file is not of the right type"));
return 0;
}
@ -704,7 +709,7 @@ grub_dl_load (const char *name)
return mod;
if (! grub_dl_dir) {
grub_error (GRUB_ERR_FILE_NOT_FOUND, "\"prefix\" is not set");
grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
return 0;
}

View file

@ -24,6 +24,7 @@
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/dl.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -39,7 +40,7 @@ grub_elf_check_header (grub_elf_t elf)
|| e->e_ident[EI_MAG3] != ELFMAG3
|| e->e_ident[EI_VERSION] != EV_CURRENT
|| e->e_version != EV_CURRENT)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch independent ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch independent ELF magic"));
return GRUB_ERR_NONE;
}
@ -59,7 +60,7 @@ grub_elf_close (grub_elf_t elf)
}
grub_elf_t
grub_elf_file (grub_file_t file)
grub_elf_file (grub_file_t file, const char *filename)
{
grub_elf_t elf;
@ -75,8 +76,9 @@ grub_elf_file (grub_file_t file)
if (grub_file_read (elf->file, &elf->ehdr, sizeof (elf->ehdr))
!= sizeof (elf->ehdr))
{
grub_error_push ();
grub_error (GRUB_ERR_READ_ERROR, "cannot read ELF header");
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
goto fail;
}
@ -101,7 +103,7 @@ grub_elf_open (const char *name)
if (! file)
return 0;
elf = grub_elf_file (file);
elf = grub_elf_file (file, name);
if (! elf)
grub_file_close (file);
@ -118,7 +120,7 @@ grub_elf_is_elf32 (grub_elf_t elf)
}
static grub_err_t
grub_elf32_load_phdrs (grub_elf_t elf)
grub_elf32_load_phdrs (grub_elf_t elf, const char *filename)
{
grub_ssize_t phdrs_size;
@ -135,8 +137,10 @@ grub_elf32_load_phdrs (grub_elf_t elf)
if ((grub_file_seek (elf->file, elf->ehdr.ehdr32.e_phoff) == (grub_off_t) -1)
|| (grub_file_read (elf->file, elf->phdrs, phdrs_size) != phdrs_size))
{
grub_error_push ();
return grub_error (GRUB_ERR_READ_ERROR, "cannot read program headers");
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
return grub_errno;
}
return GRUB_ERR_NONE;
@ -144,6 +148,7 @@ grub_elf32_load_phdrs (grub_elf_t elf)
grub_err_t
grub_elf32_phdr_iterate (grub_elf_t elf,
const char *filename,
int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf32_Phdr *, void *),
void *hook_arg)
{
@ -151,7 +156,7 @@ grub_elf32_phdr_iterate (grub_elf_t elf,
unsigned int i;
if (! elf->phdrs)
if (grub_elf32_load_phdrs (elf))
if (grub_elf32_load_phdrs (elf, filename))
return grub_errno;
phdrs = elf->phdrs;
@ -174,7 +179,8 @@ grub_elf32_phdr_iterate (grub_elf_t elf,
/* Calculate the amount of memory spanned by the segments. */
grub_size_t
grub_elf32_size (grub_elf_t elf, Elf32_Addr *base, grub_uint32_t *max_align)
grub_elf32_size (grub_elf_t elf, const char *filename,
Elf32_Addr *base, grub_uint32_t *max_align)
{
Elf32_Addr segments_start = (Elf32_Addr) -1;
Elf32_Addr segments_end = 0;
@ -201,7 +207,7 @@ grub_elf32_size (grub_elf_t elf, Elf32_Addr *base, grub_uint32_t *max_align)
return 0;
}
grub_elf32_phdr_iterate (elf, calcsize, 0);
grub_elf32_phdr_iterate (elf, filename, calcsize, 0);
if (base)
*base = 0;
@ -228,7 +234,8 @@ grub_elf32_size (grub_elf_t elf, Elf32_Addr *base, grub_uint32_t *max_align)
/* Load every loadable segment into memory specified by `_load_hook'. */
grub_err_t
grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook,
grub_elf32_load (grub_elf_t _elf, const char *filename,
grub_elf32_load_hook_t _load_hook,
grub_addr_t *base, grub_size_t *size)
{
grub_addr_t load_base = (grub_addr_t) -1ULL;
@ -257,11 +264,7 @@ grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook,
(unsigned long long) phdr->p_memsz);
if (grub_file_seek (elf->file, phdr->p_offset) == (grub_off_t) -1)
{
grub_error_push ();
return grub_error (GRUB_ERR_BAD_OS,
"invalid offset in program header");
}
return grub_errno;
if (phdr->p_filesz)
{
@ -270,11 +273,10 @@ grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook,
if (read != (grub_ssize_t) phdr->p_filesz)
{
/* XXX How can we free memory from `load_hook'? */
grub_error_push ();
return grub_error (GRUB_ERR_BAD_OS,
"couldn't read segment from file: "
"wanted 0x%lx bytes; read 0x%lx bytes",
phdr->p_filesz, read);
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
return grub_errno;
}
}
@ -287,7 +289,8 @@ grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook,
return 0;
}
err = grub_elf32_phdr_iterate (_elf, grub_elf32_load_segment, _load_hook);
err = grub_elf32_phdr_iterate (_elf, filename,
grub_elf32_load_segment, _load_hook);
if (base)
*base = load_base;
@ -307,7 +310,7 @@ grub_elf_is_elf64 (grub_elf_t elf)
}
static grub_err_t
grub_elf64_load_phdrs (grub_elf_t elf)
grub_elf64_load_phdrs (grub_elf_t elf, const char *filename)
{
grub_ssize_t phdrs_size;
@ -324,8 +327,10 @@ grub_elf64_load_phdrs (grub_elf_t elf)
if ((grub_file_seek (elf->file, elf->ehdr.ehdr64.e_phoff) == (grub_off_t) -1)
|| (grub_file_read (elf->file, elf->phdrs, phdrs_size) != phdrs_size))
{
grub_error_push ();
return grub_error (GRUB_ERR_READ_ERROR, "cannot read program headers");
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
return grub_errno;
}
return GRUB_ERR_NONE;
@ -333,6 +338,7 @@ grub_elf64_load_phdrs (grub_elf_t elf)
grub_err_t
grub_elf64_phdr_iterate (grub_elf_t elf,
const char *filename,
int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf64_Phdr *, void *),
void *hook_arg)
{
@ -340,7 +346,7 @@ grub_elf64_phdr_iterate (grub_elf_t elf,
unsigned int i;
if (! elf->phdrs)
if (grub_elf64_load_phdrs (elf))
if (grub_elf64_load_phdrs (elf, filename))
return grub_errno;
phdrs = elf->phdrs;
@ -363,7 +369,8 @@ grub_elf64_phdr_iterate (grub_elf_t elf,
/* Calculate the amount of memory spanned by the segments. */
grub_size_t
grub_elf64_size (grub_elf_t elf, Elf64_Addr *base, grub_uint64_t *max_align)
grub_elf64_size (grub_elf_t elf, const char *filename,
Elf64_Addr *base, grub_uint64_t *max_align)
{
Elf64_Addr segments_start = (Elf64_Addr) -1;
Elf64_Addr segments_end = 0;
@ -390,7 +397,7 @@ grub_elf64_size (grub_elf_t elf, Elf64_Addr *base, grub_uint64_t *max_align)
return 0;
}
grub_elf64_phdr_iterate (elf, calcsize, 0);
grub_elf64_phdr_iterate (elf, filename, calcsize, 0);
if (base)
*base = 0;
@ -417,7 +424,8 @@ grub_elf64_size (grub_elf_t elf, Elf64_Addr *base, grub_uint64_t *max_align)
/* Load every loadable segment into memory specified by `_load_hook'. */
grub_err_t
grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook,
grub_elf64_load (grub_elf_t _elf, const char *filename,
grub_elf64_load_hook_t _load_hook,
grub_addr_t *base, grub_size_t *size)
{
grub_addr_t load_base = (grub_addr_t) -1ULL;
@ -447,11 +455,7 @@ grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook,
(unsigned long long) phdr->p_memsz);
if (grub_file_seek (elf->file, phdr->p_offset) == (grub_off_t) -1)
{
grub_error_push ();
return grub_error (GRUB_ERR_BAD_OS,
"invalid offset in program header");
}
return grub_errno;
if (phdr->p_filesz)
{
@ -460,11 +464,10 @@ grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook,
if (read != (grub_ssize_t) phdr->p_filesz)
{
/* XXX How can we free memory from `load_hook'? */
grub_error_push ();
return grub_error (GRUB_ERR_BAD_OS,
"couldn't read segment from file: "
"wanted 0x%lx bytes; read 0x%lx bytes",
phdr->p_filesz, read);
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
return grub_errno;
}
}
@ -477,7 +480,8 @@ grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook,
return 0;
}
err = grub_elf64_phdr_iterate (_elf, grub_elf64_load_segment, _load_hook);
err = grub_elf64_phdr_iterate (_elf, filename,
grub_elf64_load_segment, _load_hook);
if (base)
*base = load_base;

View file

@ -372,7 +372,8 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
fd = open (map[drive].device, O_RDONLY);
if (fd == -1)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot open `%s' while attempting to get disk size", map[drive].device);
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("cannot open `%s': %s"),
map[drive].device, strerror (errno));
disk->total_sectors = grub_util_get_fd_sectors (fd, map[drive].device,
&disk->log_sector_size);
@ -428,13 +429,19 @@ grub_util_follow_gpart_up (const char *name, grub_disk_addr_t *off_out, char **n
error = geom_gettree (&mesh);
if (error != 0)
/* TRANSLATORS: geom is the name of (k)FreeBSD device framework.
Usually left untranslated.
*/
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"));
/* TRANSLATORS: geom is the name of (k)FreeBSD device framework.
Usually left untranslated.
*/
grub_util_error (_("couldn't find geom `part' class"));
LIST_FOREACH (geom, &class->lg_geom, lg_geom)
{
@ -563,12 +570,8 @@ devmapper_fail:
fd = open (dev, O_RDONLY);
if (fd == -1)
{
grub_error (GRUB_ERR_BAD_DEVICE,
# if !defined(HAVE_DIOCGDINFO)
"cannot open `%s' while attempting to get disk geometry", dev);
# else /* defined(HAVE_DIOCGDINFO) */
"cannot open `%s' while attempting to get disk label", dev);
# endif /* !defined(HAVE_DIOCGDINFO) */
grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot open `%s': %s"),
dev, strerror (errno));
return 0;
}
@ -736,9 +739,8 @@ grub_util_fd_seek (int fd, const char *name, grub_uint64_t off)
offset = (loff_t) off;
if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
{
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot seek `%s'", name);
}
return grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot seek `%s': %s"),
name, strerror (errno));
return GRUB_ERR_NONE;
}
#else
@ -748,7 +750,8 @@ grub_util_fd_seek (int fd, const char *name, grub_uint64_t off)
off_t offset = (off_t) off;
if (lseek (fd, offset, SEEK_SET) != offset)
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot seek `%s'", name);
return grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot seek `%s': %s"),
name, strerror (errno));
return 0;
}
#endif
@ -842,7 +845,8 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
fd = open (dev, flags);
if (fd < 0)
{
grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s'", dev);
grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot open `%s': %s"),
dev, strerror (errno));
return -1;
}
@ -922,7 +926,8 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
if (fd < 0)
{
grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' in open_device()", map[disk->id].device);
grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot open `%s': %s"),
map[disk->id].device, strerror (errno));
return -1;
}
#endif /* ! __linux__ */
@ -1030,7 +1035,8 @@ grub_util_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
if (grub_util_fd_read (fd, buf, (1 << disk->log_sector_size))
!= (1 << disk->log_sector_size))
{
grub_error (GRUB_ERR_READ_ERROR, "cannot read `%s'", map[disk->id].device);
grub_error (GRUB_ERR_READ_ERROR, N_("cannot read `%s': %s"),
map[disk->id].device, strerror (errno));
return grub_errno;
}
@ -1041,7 +1047,8 @@ grub_util_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
if (grub_util_fd_read (fd, buf, size << disk->log_sector_size)
!= (ssize_t) (size << disk->log_sector_size))
grub_error (GRUB_ERR_READ_ERROR, "cannot read from `%s'", map[disk->id].device);
grub_error (GRUB_ERR_READ_ERROR, N_("cannot read `%s': %s"),
map[disk->id].device, strerror (errno));
return grub_errno;
}
@ -1075,7 +1082,8 @@ grub_util_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
if (grub_util_fd_write (fd, buf, size << disk->log_sector_size)
!= (ssize_t) (size << disk->log_sector_size))
grub_error (GRUB_ERR_WRITE_ERROR, "cannot write to `%s'", map[disk->id].device);
grub_error (GRUB_ERR_WRITE_ERROR, N_("cannot write to `%s': %s"),
map[disk->id].device, strerror (errno));
return grub_errno;
}
@ -1172,7 +1180,11 @@ read_device_map (const char *dev_map)
continue;
if (*p != '(')
show_error (_("No open parenthesis found"));
{
char *tmp;
tmp = xasprintf (_("missing `%c' symbol"), '(');
show_error (tmp);
}
p++;
/* Find a free slot. */
@ -1183,7 +1195,11 @@ read_device_map (const char *dev_map)
e = p;
p = strchr (p, ')');
if (! p)
show_error (_("No close parenthesis found"));
{
char *tmp;
tmp = xasprintf (_("missing `%c' symbol"), ')');
show_error (tmp);
}
map[drive].drive = xmalloc (p - e + sizeof ('\0'));
strncpy (map[drive].drive, e, p - e + sizeof ('\0'));
@ -1196,7 +1212,7 @@ read_device_map (const char *dev_map)
p++;
if (*p == '\0')
show_error (_("No filename found"));
show_error (_("filename expected"));
/* NUL-terminate the filename. */
e = p;

View file

@ -21,8 +21,10 @@
#include <grub/file.h>
#include <grub/disk.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/dl.h>
#include <grub/util/misc.h>
#include <grub/i18n.h>
#include <dirent.h>
#include <stdio.h>
@ -54,6 +56,12 @@ is_dir (const char *path, const char *name)
return S_ISDIR (st.st_mode);
}
struct grub_hostfs_data
{
char *filename;
FILE *f;
};
static grub_err_t
grub_hostfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
@ -68,7 +76,8 @@ grub_hostfs_dir (grub_device_t device, const char *path,
dir = opendir (path);
if (! dir)
return grub_error (GRUB_ERR_BAD_FILENAME,
"can't open the hostfs directory `%s'", path);
N_("can't open `%s': %s"), path,
strerror (errno));
while (1)
{
@ -95,12 +104,30 @@ static grub_err_t
grub_hostfs_open (struct grub_file *file, const char *name)
{
FILE *f;
struct grub_hostfs_data *data;
f = fopen (name, "rb");
if (! f)
return grub_error (GRUB_ERR_BAD_FILENAME,
"can't open `%s'", name);
file->data = f;
N_("can't open `%s': %s"), name,
strerror (errno));
data = grub_malloc (sizeof (*data));
if (!data)
{
fclose (f);
return grub_errno;
}
data->filename = grub_strdup (name);
if (!data->filename)
{
grub_free (data);
fclose (f);
return grub_errno;
}
data->f = f;
file->data = data;
#ifdef __MINGW32__
file->size = grub_util_get_disk_size (name);
@ -116,18 +143,20 @@ grub_hostfs_open (struct grub_file *file, const char *name)
static grub_ssize_t
grub_hostfs_read (grub_file_t file, char *buf, grub_size_t len)
{
FILE *f;
struct grub_hostfs_data *data;
f = (FILE *) file->data;
if (fseeko (f, file->offset, SEEK_SET) != 0)
data = file->data;
if (fseeko (data->f, file->offset, SEEK_SET) != 0)
{
grub_error (GRUB_ERR_OUT_OF_RANGE, "fseeko: %s", strerror (errno));
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("cannot seek `%s': %s"),
data->filename, strerror (errno));
return -1;
}
unsigned int s = fread (buf, 1, len, f);
unsigned int s = fread (buf, 1, len, data->f);
if (s != len)
grub_error (GRUB_ERR_FILE_READ_ERROR, "fread: %s", strerror (errno));
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("cannot read `%s': %s"),
data->filename, strerror (errno));
return (signed) s;
}
@ -136,9 +165,12 @@ static grub_err_t
grub_hostfs_close (grub_file_t file)
{
FILE *f;
struct grub_hostfs_data *data;
f = (FILE *) file->data;
fclose (f);
data = file->data;
fclose (data->f);
grub_free (data->filename);
grub_free (data);
return GRUB_ERR_NONE;
}

View file

@ -23,6 +23,7 @@
#include <grub/mm.h>
#include <stdlib.h>
#include <string.h>
#include <grub/i18n.h>
void *
grub_malloc (grub_size_t size)
@ -30,7 +31,7 @@ grub_malloc (grub_size_t size)
void *ret;
ret = malloc (size);
if (!ret)
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
return ret;
}
@ -58,7 +59,7 @@ grub_realloc (void *ptr, grub_size_t size)
void *ret;
ret = realloc (ptr, size);
if (!ret)
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
return ret;
}
@ -77,11 +78,11 @@ 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 on your system"));
#endif
if (!p)
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
return p;
}

View file

@ -24,6 +24,7 @@
#include <grub/mm.h>
#include <grub/fs.h>
#include <grub/device.h>
#include <grub/i18n.h>
void (*EXPORT_VAR (grub_grubnet_fini)) (void);
@ -41,7 +42,7 @@ grub_file_get_device_name (const char *name)
if (! p)
{
grub_error (GRUB_ERR_BAD_FILENAME, "missing `)'");
grub_error (GRUB_ERR_BAD_FILENAME, N_("missing `%c' symbol"), ')');
return 0;
}
@ -138,7 +139,7 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
if (file->offset > file->size)
{
grub_error (GRUB_ERR_OUT_OF_RANGE,
"attempt to read past the end of file");
N_("attempt to read past the end of file"));
return -1;
}
@ -178,7 +179,7 @@ grub_file_seek (grub_file_t file, grub_off_t offset)
if (offset > file->size)
{
grub_error (GRUB_ERR_OUT_OF_RANGE,
"attempt to seek outside of the file");
N_("attempt to seek outside of the file"));
return -1;
}

View file

@ -26,6 +26,7 @@
#include <grub/types.h>
#include <grub/mm.h>
#include <grub/term.h>
#include <grub/i18n.h>
grub_fs_t grub_fs_list = 0;
@ -97,7 +98,7 @@ grub_fs_probe (grub_device_t device)
else if (device->net && device->net->fs)
return device->net->fs;
grub_error (GRUB_ERR_UNKNOWN_FS, "unknown filesystem");
grub_error (GRUB_ERR_UNKNOWN_FS, N_("unknown filesystem"));
return 0;
}
@ -145,7 +146,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
if (grub_errno != GRUB_ERR_NONE || *p != '+')
{
grub_error (GRUB_ERR_BAD_FILENAME,
"invalid file name `%s'", name);
N_("invalid file name `%s'"), name);
goto fail;
}
}
@ -157,7 +158,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
|| (*p && *p != ',' && ! grub_isspace (*p)))
{
grub_error (GRUB_ERR_BAD_FILENAME,
"invalid file name `%s'", name);
N_("invalid file name `%s'"), name);
goto fail;
}

View file

@ -21,6 +21,7 @@
#include <grub/elf.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */
grub_err_t
@ -32,7 +33,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS32
|| e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_386)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
@ -54,7 +55,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -100,6 +101,10 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
*addr += (sym->st_value - (Elf_Word) seg->addr
- rel->r_offset);
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}
}

View file

@ -22,6 +22,7 @@
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/mm.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */
grub_err_t
@ -33,7 +34,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS64
|| e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_IA_64)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
@ -181,7 +182,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -265,7 +266,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"this relocation (0x%x) is not implemented yet",
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}

View file

@ -23,6 +23,7 @@
#include <grub/err.h>
#include <grub/cpu/types.h>
#include <grub/mm.h>
#include <grub/i18n.h>
/* Dummy __gnu_local_gp. Resolved by linker. */
static char __gnu_local_gp_dummy;
@ -43,7 +44,7 @@ grub_arch_dl_check_header (void *ehdr)
|| e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_MIPS)
#endif
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
@ -69,7 +70,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -233,7 +234,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
{
grub_free (gp);
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unknown relocation type %d\n",
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
break;

View file

@ -21,6 +21,7 @@
#include <grub/elf.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */
grub_err_t
@ -32,7 +33,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS32
|| e->e_ident[EI_DATA] != ELFDATA2MSB
|| e->e_machine != EM_PPC)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
@ -112,7 +113,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -195,7 +196,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"this relocation (%d) is not implemented yet",
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}

View file

@ -21,6 +21,7 @@
#include <grub/elf.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */
grub_err_t
@ -32,7 +33,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS64
|| e->e_ident[EI_DATA] != ELFDATA2MSB
|| e->e_machine != EM_SPARCV9)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
@ -55,7 +56,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -134,7 +135,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"this relocation (%d) is not implemented yet",
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}

View file

@ -21,6 +21,7 @@
#include <grub/elf.h>
#include <grub/misc.h>
#include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */
grub_err_t
@ -32,7 +33,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS64
|| e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_X86_64)
return grub_error (GRUB_ERR_BAD_OS, "invalid arch specific ELF magic");
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch dependent ELF magic"));
return GRUB_ERR_NONE;
}
@ -54,7 +55,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break;
if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
entsize = s->sh_entsize;
@ -108,9 +109,9 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
*addr32 += rel->r_addend + sym->st_value;
break;
default:
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"this relocation (%d) is not implemented yet",
N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
}
}