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

@ -1,3 +1,8 @@
2012-02-08 Vladimir Serbinenko <phcoder@gmail.com>
Improve gettext support. Stylistic fixes and error handling fixes while
on it.
2012-02-07 Vladimir Serbinenko <phcoder@gmail.com> 2012-02-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/i386/relocator16.S: Revert moving A20 code into PM * grub-core/lib/i386/relocator16.S: Revert moving A20 code into PM

View file

@ -36,6 +36,16 @@ grub_memalign_dma32 (grub_size_t align, grub_size_t size)
align = 64; align = 64;
size = ALIGN_UP (size, align); size = ALIGN_UP (size, align);
ret = grub_memalign (align, size); ret = grub_memalign (align, size);
#if GRUB_CPU_SIZEOF_VOID_P == 8
if ((grub_addr_t) ret >> 32)
{
/* Shouldn't happend since the only platform in this case is
x86_64-efi and it skips any regions > 4GiB because
of EFI bugs anyway. */
grub_error (GRUB_ERR_BUG, "allocation outside 32-bit range");
return 0;
}
#endif
if (!ret) if (!ret)
return 0; return 0;
grub_arch_sync_dma_caches (ret, size); grub_arch_sync_dma_caches (ret, size);

View file

@ -294,13 +294,15 @@ grub_ohci_pci_iter (grub_pci_device_t dev,
o->hcca_chunk, o->hcca, o->hcca_addr); o->hcca_chunk, o->hcca, o->hcca_addr);
/* Reserve memory for ctrl EDs. */ /* Reserve memory for ctrl EDs. */
o->ed_ctrl_chunk = grub_memalign_dma32 (16, sizeof(struct grub_ohci_ed)*GRUB_OHCI_CTRL_EDS); o->ed_ctrl_chunk = grub_memalign_dma32 (16, sizeof(struct grub_ohci_ed)
* GRUB_OHCI_CTRL_EDS);
if (! o->ed_ctrl_chunk) if (! o->ed_ctrl_chunk)
goto fail; goto fail;
o->ed_ctrl = grub_dma_get_virt (o->ed_ctrl_chunk); o->ed_ctrl = grub_dma_get_virt (o->ed_ctrl_chunk);
o->ed_ctrl_addr = grub_dma_get_phys (o->ed_ctrl_chunk); o->ed_ctrl_addr = grub_dma_get_phys (o->ed_ctrl_chunk);
/* Preset EDs */ /* Preset EDs */
grub_memset ((void*)o->ed_ctrl, 0, sizeof(struct grub_ohci_ed) * GRUB_OHCI_CTRL_EDS); grub_memset ((void *) o->ed_ctrl, 0, sizeof (struct grub_ohci_ed)
* GRUB_OHCI_CTRL_EDS);
for (j=0; j < GRUB_OHCI_CTRL_EDS; j++) for (j=0; j < GRUB_OHCI_CTRL_EDS; j++)
o->ed_ctrl[j].target = grub_cpu_to_le32 (1 << 14); /* skip */ o->ed_ctrl[j].target = grub_cpu_to_le32 (1 << 14); /* skip */
@ -308,7 +310,8 @@ grub_ohci_pci_iter (grub_pci_device_t dev,
o->ed_ctrl_chunk, o->ed_ctrl, o->ed_ctrl_addr); o->ed_ctrl_chunk, o->ed_ctrl, o->ed_ctrl_addr);
/* Reserve memory for bulk EDs. */ /* Reserve memory for bulk EDs. */
o->ed_bulk_chunk = grub_memalign_dma32 (16, sizeof(struct grub_ohci_ed)*GRUB_OHCI_BULK_EDS); o->ed_bulk_chunk = grub_memalign_dma32 (16, sizeof (struct grub_ohci_ed)
* GRUB_OHCI_BULK_EDS);
if (! o->ed_bulk_chunk) if (! o->ed_bulk_chunk)
goto fail; goto fail;
o->ed_bulk = grub_dma_get_virt (o->ed_bulk_chunk); o->ed_bulk = grub_dma_get_virt (o->ed_bulk_chunk);

View file

@ -41,8 +41,8 @@ static const struct grub_arg_option options[] = {
0, ARG_TYPE_STRING}, 0, ARG_TYPE_STRING},
{"load-only", 'n', 0, {"load-only", 'n', 0,
N_("Load only tables specified by comma-separated list."), 0, ARG_TYPE_STRING}, N_("Load only tables specified by comma-separated list."), 0, ARG_TYPE_STRING},
{"v1", '1', 0, N_("Expose v1 tables."), 0, ARG_TYPE_NONE}, {"v1", '1', 0, N_("Export version 1 tables to the OS."), 0, ARG_TYPE_NONE},
{"v2", '2', 0, N_("Expose v2 and v3 tables."), 0, ARG_TYPE_NONE}, {"v2", '2', 0, N_("Export version 2 and version 3 tables to the OS."), 0, ARG_TYPE_NONE},
{"oemid", 'o', 0, N_("Set OEMID of RSDP, XSDT and RSDT."), 0, ARG_TYPE_STRING}, {"oemid", 'o', 0, N_("Set OEMID of RSDP, XSDT and RSDT."), 0, ARG_TYPE_STRING},
{"oemtable", 't', 0, {"oemtable", 't', 0,
N_("Set OEMTABLE ID of RSDP, XSDT and RSDT."), 0, ARG_TYPE_STRING}, N_("Set OEMTABLE ID of RSDP, XSDT and RSDT."), 0, ARG_TYPE_STRING},
@ -553,8 +553,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
free_tables (); free_tables ();
grub_free (exclude); grub_free (exclude);
grub_free (load_only); grub_free (load_only);
return grub_error (GRUB_ERR_OUT_OF_MEMORY, return grub_errno;
"couldn't allocate table");
} }
grub_memcpy (table_dsdt, dsdt, dsdt->length); grub_memcpy (table_dsdt, dsdt, dsdt->length);
} }
@ -580,8 +579,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
free_tables (); free_tables ();
grub_free (exclude); grub_free (exclude);
grub_free (load_only); grub_free (load_only);
return grub_error (GRUB_ERR_OUT_OF_MEMORY, return grub_errno;
"couldn't allocate table structure");
} }
table->size = curtable->length; table->size = curtable->length;
table->addr = grub_malloc (table->size); table->addr = grub_malloc (table->size);
@ -589,8 +587,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
if (! table->addr) if (! table->addr)
{ {
free_tables (); free_tables ();
return grub_error (GRUB_ERR_OUT_OF_MEMORY, return grub_errno;
"couldn't allocate table");
} }
table->next = acpi_tables; table->next = acpi_tables;
acpi_tables = table; acpi_tables = table;
@ -633,7 +630,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
if (! file) if (! file)
{ {
free_tables (); free_tables ();
return grub_error (GRUB_ERR_BAD_OS, "couldn't open file %s", args[i]); return grub_errno;
} }
size = grub_file_size (file); size = grub_file_size (file);
@ -641,7 +638,8 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
{ {
grub_file_close (file); grub_file_close (file);
free_tables (); free_tables ();
return grub_error (GRUB_ERR_BAD_OS, "file %s is too small", args[i]); return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
args[i]);
} }
buf = (char *) grub_malloc (size); buf = (char *) grub_malloc (size);
@ -678,8 +676,7 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
if (! table) if (! table)
{ {
free_tables (); free_tables ();
return grub_error (GRUB_ERR_OUT_OF_MEMORY, return grub_errno;
"couldn't allocate table structure");
} }
table->size = size; table->size = size;
@ -771,7 +768,7 @@ GRUB_MOD_INIT(acpi)
{ {
cmd = grub_register_extcmd ("acpi", grub_cmd_acpi, 0, cmd = grub_register_extcmd ("acpi", grub_cmd_acpi, 0,
N_("[-1|-2] [--exclude=TABLE1,TABLE2|" N_("[-1|-2] [--exclude=TABLE1,TABLE2|"
"--load-only=table1,table2] FILE1" "--load-only=TABLE1,TABLE2] FILE1"
" [FILE2] [...]"), " [FILE2] [...]"),
N_("Load host ACPI tables and tables " N_("Load host ACPI tables and tables "
"specified by arguments."), "specified by arguments."),

View file

@ -82,7 +82,7 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
} }
if (argc < 1) if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
grub_file_filter_disable_compression (); grub_file_filter_disable_compression ();
file = grub_file_open (args[0]); file = grub_file_open (args[0]);

View file

@ -64,10 +64,7 @@ grub_loader_register_preboot_hook (grub_err_t (*preboot_func) (int noreturn),
new_preboot = (struct grub_preboot *) new_preboot = (struct grub_preboot *)
grub_malloc (sizeof (struct grub_preboot)); grub_malloc (sizeof (struct grub_preboot));
if (! new_preboot) if (! new_preboot)
{
grub_error (GRUB_ERR_OUT_OF_MEMORY, "hook not added");
return 0; return 0;
}
new_preboot->preboot_func = preboot_func; new_preboot->preboot_func = preboot_func;
new_preboot->preboot_rest_func = preboot_rest_func; new_preboot->preboot_rest_func = preboot_rest_func;
@ -146,7 +143,8 @@ grub_loader_boot (void)
struct grub_preboot *cur; struct grub_preboot *cur;
if (! grub_loader_loaded) if (! grub_loader_loaded)
return grub_error (GRUB_ERR_NO_KERNEL, "no loaded kernel"); return grub_error (GRUB_ERR_NO_KERNEL,
N_("you need to load the kernel first"));
if (grub_loader_noreturn) if (grub_loader_noreturn)
grub_machine_fini (); grub_machine_fini ();

View file

@ -31,14 +31,16 @@ grub_rescue_cmd_info (struct grub_command *cmd __attribute__ ((unused)),
unsigned long hits, misses; unsigned long hits, misses;
grub_disk_cache_get_performance (&hits, &misses); grub_disk_cache_get_performance (&hits, &misses);
grub_printf_ (N_("Disk cache: hits = %lu, misses = %lu "), hits, misses);
if (hits + misses) if (hits + misses)
{ {
unsigned long ratio = hits * 10000 / (hits + misses); unsigned long ratio = hits * 10000 / (hits + misses);
grub_printf ("(%lu.%lu%%)\n", ratio / 100, ratio % 100); grub_printf ("(%lu.%lu%%)\n", ratio / 100, ratio % 100);
grub_printf_ (N_("Disk cache statistics: hits = %lu (%lu.%02lu%%),"
" misses = %lu\n"), ratio / 100, ratio % 100,
hits, misses);
} }
else else
grub_puts_ (N_("(N/A)")); grub_printf ("%s\n", _("No disk cache statistics available\n"));
return 0; return 0;
} }

View file

@ -47,7 +47,7 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
dos = 1; dos = 1;
if (argc != 1) if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
file = grub_file_open (args[0]); file = grub_file_open (args[0]);
if (! file) if (! file)

View file

@ -40,7 +40,7 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
char *buf2 = 0; char *buf2 = 0;
if (argc != 2) if (argc != 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "two arguments required"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
grub_printf_ (N_("Compare file `%s' with `%s':\n"), args[0], grub_printf_ (N_("Compare file `%s' with `%s':\n"), args[0],
args[1]); args[1]);

View file

@ -32,7 +32,7 @@ grub_cmd_source (grub_command_t cmd, int argc, char **args)
int new_env, extractor; int new_env, extractor;
if (argc != 1) if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
extractor = (cmd->name[0] == 'e'); extractor = (cmd->name[0] == 'e');
new_env = (cmd->name[extractor ? sizeof ("extract_entries_") - 1 : 0] == 'c'); new_env = (cmd->name[extractor ? sizeof ("extract_entries_") - 1 : 0] == 'c');

View file

@ -165,7 +165,7 @@ grub_cmd_loadbios (grub_command_t cmd __attribute__ ((unused)),
int size; int size;
if (argc == 0) if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no ROM image specified"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
if (argc > 1) if (argc > 1)
{ {
@ -206,7 +206,9 @@ static grub_command_t cmd_fakebios, cmd_loadbios;
GRUB_MOD_INIT(loadbios) GRUB_MOD_INIT(loadbios)
{ {
cmd_fakebios = grub_register_command ("fakebios", grub_cmd_fakebios, cmd_fakebios = grub_register_command ("fakebios", grub_cmd_fakebios,
0, N_("Fake BIOS.")); 0, N_("Create BIOS-like structures for"
" backward compatibility with"
" existing OS."));
cmd_loadbios = grub_register_command ("loadbios", grub_cmd_loadbios, cmd_loadbios = grub_register_command ("loadbios", grub_cmd_loadbios,
N_("BIOS_DUMP [INT10_DUMP]"), N_("BIOS_DUMP [INT10_DUMP]"),

View file

@ -30,7 +30,8 @@ GRUB_MOD_LICENSE ("GPLv3+");
static const struct grub_arg_option options[] = { static const struct grub_arg_option options[] = {
{"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING}, {"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING},
{"check", 'c', 0, N_("Check hash list file."), N_("FILE"), ARG_TYPE_STRING}, {"check", 'c', 0, N_("Check hashes of files with hash list FILE."),
N_("FILE"), ARG_TYPE_STRING},
{"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIR"), {"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIR"),
ARG_TYPE_STRING}, ARG_TYPE_STRING},
{"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0}, {"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0},

View file

@ -47,7 +47,7 @@ static const struct grub_arg_option options[] = {
{"sleep", 'Y', 0, N_("Set drive to sleep mode."), 0, ARG_TYPE_NONE}, {"sleep", 'Y', 0, N_("Set drive to sleep mode."), 0, ARG_TYPE_NONE},
{"identify", 'i', 0, N_("Print drive identity and settings."), {"identify", 'i', 0, N_("Print drive identity and settings."),
0, ARG_TYPE_NONE}, 0, ARG_TYPE_NONE},
{"dumpid", 'I', 0, N_("Dump contents of ATA IDENTIFY sector."), {"dumpid", 'I', 0, N_("Show raw contents of ATA IDENTIFY sector."),
0, ARG_TYPE_NONE}, 0, ARG_TYPE_NONE},
{"smart", -1, 0, N_("Disable/enable SMART (0/1)."), 0, ARG_TYPE_INT}, {"smart", -1, 0, N_("Disable/enable SMART (0/1)."), 0, ARG_TYPE_INT},
{"quiet", 'q', 0, N_("Do not print messages."), 0, ARG_TYPE_NONE}, {"quiet", 'q', 0, N_("Do not print messages."), 0, ARG_TYPE_NONE},

View file

@ -44,7 +44,7 @@ grub_cmd_hexdump (grub_extcmd_context_t ctxt, int argc, char **args)
int namelen; int namelen;
if (argc != 1) if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
namelen = grub_strlen (args[0]); namelen = grub_strlen (args[0]);
skip = (state[0].set) ? grub_strtoull (state[0].arg, 0, 0) : 0; skip = (state[0].set) ? grub_strtoull (state[0].arg, 0, 0) : 0;
@ -123,7 +123,7 @@ GRUB_MOD_INIT (hexdump)
{ {
cmd = grub_register_extcmd ("hexdump", grub_cmd_hexdump, 0, cmd = grub_register_extcmd ("hexdump", grub_cmd_hexdump, 0,
N_("[OPTIONS] FILE_OR_DEVICE"), N_("[OPTIONS] FILE_OR_DEVICE"),
N_("Dump the contents of a file or memory."), N_("Show raw contents of a file or memory."),
options); options);
} }

View file

@ -30,11 +30,11 @@ parse_args (int argc, char *argv[], int *byte, int *bit)
char *rest; char *rest;
if (argc != 1) if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Address required."); return grub_error (GRUB_ERR_BAD_ARGUMENT, "address required");
*byte = grub_strtoul (argv[0], &rest, 0); *byte = grub_strtoul (argv[0], &rest, 0);
if (*rest != ':') if (*rest != ':')
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Address required."); return grub_error (GRUB_ERR_BAD_ARGUMENT, "address required");
*bit = grub_strtoul (rest + 1, 0, 0); *bit = grub_strtoul (rest + 1, 0, 0);

View file

@ -107,8 +107,7 @@ drivemap_set (grub_uint8_t newdrive, grub_uint8_t redirto)
{ {
mapping = grub_malloc (sizeof (drivemap_node_t)); mapping = grub_malloc (sizeof (drivemap_node_t));
if (! mapping) if (! mapping)
return grub_error (GRUB_ERR_OUT_OF_MEMORY, return grub_errno;
"cannot allocate map entry, not enough memory");
mapping->newdrive = newdrive; mapping->newdrive = newdrive;
mapping->redirto = redirto; mapping->redirto = redirto;
mapping->next = map_head; mapping->next = map_head;
@ -230,7 +229,7 @@ grub_cmd_drivemap (struct grub_extcmd_context *ctxt, int argc, char **args)
grub_err_t err; grub_err_t err;
if (argc != 2) if (argc != 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "two arguments required"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
err = tryparse_diskstring (args[0], &mapfrom); err = tryparse_diskstring (args[0], &mapfrom);
if (err != GRUB_ERR_NONE) if (err != GRUB_ERR_NONE)

View file

@ -74,7 +74,7 @@ grub_cmd_lsapm (grub_command_t cmd __attribute__ ((unused)),
if (!grub_apm_get_info (&info)) if (!grub_apm_get_info (&info))
return grub_error (GRUB_ERR_IO, "no APM found"); return grub_error (GRUB_ERR_IO, "no APM found");
grub_printf_ (N_("Vesion %u.%u\n" grub_printf_ (N_("Version %u.%u\n"
"32-bit CS = 0x%x, len = 0x%x, offset = 0x%x\n" "32-bit CS = 0x%x, len = 0x%x, offset = 0x%x\n"
"16-bit CS = 0x%x, len = 0x%x\n" "16-bit CS = 0x%x, len = 0x%x\n"
"DS = 0x%x, len = 0x%x\n"), "DS = 0x%x, len = 0x%x\n"),

View file

@ -192,13 +192,15 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
file = grub_file_open (args[0]); file = grub_file_open (args[0]);
if (! file) if (! file)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", args[0]); return grub_errno;
if (grub_file_read (file, &tempo, sizeof (tempo)) != sizeof (tempo)) if (grub_file_read (file, &tempo, sizeof (tempo)) != sizeof (tempo))
{ {
grub_file_close (file); grub_file_close (file);
return grub_error (GRUB_ERR_FILE_READ_ERROR, if (!grub_errno)
"file doesn't even contains a full tempo record"); grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
args[0]);
return grub_errno;
} }
tempo = grub_le_to_cpu32 (tempo); tempo = grub_le_to_cpu32 (tempo);
@ -227,7 +229,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
if (*end) if (*end)
/* Was not a number either, assume it was supposed to be a file name. */ /* Was not a number either, assume it was supposed to be a file name. */
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", args[0]); return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), args[0]);
grub_dprintf ("play","tempo = %d\n", tempo); grub_dprintf ("play","tempo = %d\n", tempo);

View file

@ -42,7 +42,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(ieee1275_suspend) GRUB_MOD_INIT(ieee1275_suspend)
{ {
cmd = grub_register_command ("suspend", grub_cmd_suspend, cmd = grub_register_command ("suspend", grub_cmd_suspend,
0, N_("Return to Open Firmware prompt.")); 0, N_("Return to IEEE1275 prompt."));
} }
GRUB_MOD_FINI(ieee1275_suspend) GRUB_MOD_FINI(ieee1275_suspend)

View file

@ -44,7 +44,7 @@ grub_cmd_read (grub_extcmd_context_t ctxt, int argc, char **argv)
grub_uint32_t value = 0; grub_uint32_t value = 0;
if (argc != 1) if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
addr = grub_strtoul (argv[0], 0, 0); addr = grub_strtoul (argv[0], 0, 0);
switch (ctxt->extcmd->cmd->name[sizeof ("in") - 1]) switch (ctxt->extcmd->cmd->name[sizeof ("in") - 1])
@ -82,7 +82,7 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv)
grub_uint32_t mask = 0xffffffff; grub_uint32_t mask = 0xffffffff;
if (argc != 2 && argc != 3) if (argc != 2 && argc != 3)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
addr = grub_strtoul (argv[0], 0, 0); addr = grub_strtoul (argv[0], 0, 0);
value = grub_strtoul (argv[1], 0, 0); value = grub_strtoul (argv[1], 0, 0);
@ -120,25 +120,28 @@ GRUB_MOD_INIT(memrw)
{ {
cmd_read_byte = cmd_read_byte =
grub_register_extcmd ("inb", grub_cmd_read, 0, grub_register_extcmd ("inb", grub_cmd_read, 0,
N_("PORT"), N_("Read byte from PORT."), options); N_("PORT"), N_("Read 8-bit value from PORT."),
options);
cmd_read_word = cmd_read_word =
grub_register_extcmd ("inw", grub_cmd_read, 0, grub_register_extcmd ("inw", grub_cmd_read, 0,
N_("PORT"), N_("Read word from PORT."), options); N_("PORT"), N_("Read 16-bit value from PORT."),
options);
cmd_read_dword = cmd_read_dword =
grub_register_extcmd ("inl", grub_cmd_read, 0, grub_register_extcmd ("inl", grub_cmd_read, 0,
N_("PORT"), N_("Read dword from PORT."), options); N_("PORT"), N_("Read 32-bit value from PORT."),
options);
cmd_write_byte = cmd_write_byte =
grub_register_command ("outb", grub_cmd_write, grub_register_command ("outb", grub_cmd_write,
N_("PORT VALUE [MASK]"), N_("PORT VALUE [MASK]"),
N_("Write byte VALUE to PORT.")); N_("Write 8-bit VALUE to PORT."));
cmd_write_word = cmd_write_word =
grub_register_command ("outw", grub_cmd_write, grub_register_command ("outw", grub_cmd_write,
N_("PORT VALUE [MASK]"), N_("PORT VALUE [MASK]"),
N_("Write word VALUE to PORT.")); N_("Write 16-bit VALUE to PORT."));
cmd_write_dword = cmd_write_dword =
grub_register_command ("outl", grub_cmd_write, grub_register_command ("outl", grub_cmd_write,
N_("ADDR VALUE [MASK]"), N_("ADDR VALUE [MASK]"),
N_("Write dword VALUE to PORT.")); N_("Write 32-bit VALUE to PORT."));
} }
GRUB_MOD_FINI(memrw) GRUB_MOD_FINI(memrw)

View file

@ -207,7 +207,7 @@ grub_cmd_keymap (struct grub_command *cmd __attribute__ ((unused)),
{ {
const char *prefix = grub_env_get ("prefix"); const char *prefix = grub_env_get ("prefix");
if (!prefix) if (!prefix)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "No prefix set"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("variable `%s' isn't set"), "prefix");
filename = grub_xasprintf ("%s/layouts/%s.gkb", prefix, argv[0]); filename = grub_xasprintf ("%s/layouts/%s.gkb", prefix, argv[0]);
if (!filename) if (!filename)
return grub_errno; return grub_errno;
@ -222,7 +222,8 @@ grub_cmd_keymap (struct grub_command *cmd __attribute__ ((unused)),
if (grub_file_read (file, magic, sizeof (magic)) != sizeof (magic)) if (grub_file_read (file, magic, sizeof (magic)) != sizeof (magic))
{ {
if (!grub_errno) if (!grub_errno)
grub_error (GRUB_ERR_BAD_ARGUMENT, "file is too short"); grub_error (GRUB_ERR_BAD_ARGUMENT, N_("premature end of file %s"),
filename);
goto fail; goto fail;
} }
@ -236,7 +237,8 @@ grub_cmd_keymap (struct grub_command *cmd __attribute__ ((unused)),
if (grub_file_read (file, &version, sizeof (version)) != sizeof (version)) if (grub_file_read (file, &version, sizeof (version)) != sizeof (version))
{ {
if (!grub_errno) if (!grub_errno)
grub_error (GRUB_ERR_BAD_ARGUMENT, "file is too short"); grub_error (GRUB_ERR_BAD_ARGUMENT, N_("premature end of file %s"),
filename);
goto fail; goto fail;
} }
@ -253,7 +255,8 @@ grub_cmd_keymap (struct grub_command *cmd __attribute__ ((unused)),
if (grub_file_read (file, newmap, sizeof (*newmap)) != sizeof (*newmap)) if (grub_file_read (file, newmap, sizeof (*newmap)) != sizeof (*newmap))
{ {
if (!grub_errno) if (!grub_errno)
grub_error (GRUB_ERR_BAD_ARGUMENT, "file is too short"); grub_error (GRUB_ERR_BAD_ARGUMENT, N_("premature end of file %s"),
filename);
goto fail; goto fail;
} }

View file

@ -194,7 +194,7 @@ grub_cmd_legacy_source (struct grub_command *cmd,
grub_err_t ret; grub_err_t ret;
if (argc != 1) if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
extractor = (cmd->name[0] == 'e'); extractor = (cmd->name[0] == 'e');
new_env = (cmd->name[extractor ? (sizeof ("extract_legacy_entries_") - 1) new_env = (cmd->name[extractor ? (sizeof ("extract_legacy_entries_") - 1)
@ -299,7 +299,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
} }
if (argc < 2) if (argc < 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "filename required"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
cutargs = grub_malloc (sizeof (cutargs[0]) * (argc - 1)); cutargs = grub_malloc (sizeof (cutargs[0]) * (argc - 1));
cutargc = argc - 1; cutargc = argc - 1;
@ -481,7 +481,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd __attribute__ ((unused)),
} }
return grub_error (GRUB_ERR_BAD_ARGUMENT, return grub_error (GRUB_ERR_BAD_ARGUMENT,
"no kernel with module support is loaded in legacy way"); "you need to load the kernel first");
} }
static grub_err_t static grub_err_t
@ -517,7 +517,7 @@ grub_cmd_legacy_initrdnounzip (struct grub_command *mycmd __attribute__ ((unused
} }
return grub_error (GRUB_ERR_BAD_ARGUMENT, return grub_error (GRUB_ERR_BAD_ARGUMENT,
"no kernel with module support is loaded in legacy way"); "you need to load the kernel first");
} }
static grub_err_t static grub_err_t
@ -696,7 +696,7 @@ grub_cmd_legacy_password (struct grub_command *mycmd __attribute__ ((unused)),
struct legacy_md5_password *pw = NULL; struct legacy_md5_password *pw = NULL;
if (argc == 0) if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "arguments expected"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
if (args[0][0] != '-' || args[0][1] != '-') if (args[0][0] != '-' || args[0][1] != '-')
return grub_normal_set_password ("legacy", args[0]); return grub_normal_set_password ("legacy", args[0]);
@ -722,7 +722,7 @@ grub_cmd_legacy_check_password (struct grub_command *mycmd __attribute__ ((unuse
char entered[GRUB_AUTH_MAX_PASSLEN]; char entered[GRUB_AUTH_MAX_PASSLEN];
if (argc == 0) if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "arguments expected"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
grub_puts_ (N_("Enter password: ")); grub_puts_ (N_("Enter password: "));
if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN)) if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN))
return GRUB_ACCESS_DENIED; return GRUB_ACCESS_DENIED;

View file

@ -65,7 +65,7 @@ open_envblk_file (char *filename)
} }
else else
{ {
grub_error (GRUB_ERR_FILE_NOT_FOUND, "prefix is not found"); grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
return 0; return 0;
} }
} }
@ -93,8 +93,6 @@ read_envblk_file (grub_file_t file)
ret = grub_file_read (file, buf + offset, size); ret = grub_file_read (file, buf + offset, size);
if (ret <= 0) if (ret <= 0)
{ {
if (grub_errno == GRUB_ERR_NONE)
grub_error (GRUB_ERR_FILE_READ_ERROR, "cannot read");
grub_free (buf); grub_free (buf);
return 0; return 0;
} }

View file

@ -26,13 +26,13 @@ GRUB_MOD_LICENSE ("GPLv3+");
static const char *names[] = static const char *names[] =
{ {
[GRUB_MEMORY_AVAILABLE] = N_("available"), [GRUB_MEMORY_AVAILABLE] = N_("available RAM"),
[GRUB_MEMORY_RESERVED] = N_("reserved"), [GRUB_MEMORY_RESERVED] = N_("reserved RAM"),
[GRUB_MEMORY_ACPI] = N_("ACPI reclamaible"), [GRUB_MEMORY_ACPI] = N_("ACPI reclaimable RAM"),
[GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage"), [GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage RAM"),
[GRUB_MEMORY_BADRAM] = N_("BadRAM"), [GRUB_MEMORY_BADRAM] = N_("faulty RAM (BadRAM)"),
[GRUB_MEMORY_CODE] = N_("firmware code"), [GRUB_MEMORY_CODE] = N_("RAM holding firmware code"),
[GRUB_MEMORY_HOLE] = N_("hole") [GRUB_MEMORY_HOLE] = N_("Address range not associated with RAM")
}; };
static grub_err_t static grub_err_t

View file

@ -44,7 +44,7 @@ grub_cmd_read (grub_extcmd_context_t ctxt, int argc, char **argv)
char buf[sizeof ("XXXXXXXX")]; char buf[sizeof ("XXXXXXXX")];
if (argc != 1) if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid number of arguments"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
addr = grub_strtoul (argv[0], 0, 0); addr = grub_strtoul (argv[0], 0, 0);
switch (ctxt->extcmd->cmd->name[sizeof ("read_") - 1]) switch (ctxt->extcmd->cmd->name[sizeof ("read_") - 1])
@ -81,7 +81,7 @@ grub_cmd_write (grub_command_t cmd, int argc, char **argv)
grub_uint32_t mask = 0xffffffff; grub_uint32_t mask = 0xffffffff;
if (argc != 2 && argc != 3) if (argc != 2 && argc != 3)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid number of arguments"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
addr = grub_strtoul (argv[0], 0, 0); addr = grub_strtoul (argv[0], 0, 0);
value = grub_strtoul (argv[1], 0, 0); value = grub_strtoul (argv[1], 0, 0);
@ -122,22 +122,28 @@ GRUB_MOD_INIT(memrw)
{ {
cmd_read_byte = cmd_read_byte =
grub_register_extcmd ("read_byte", grub_cmd_read, 0, grub_register_extcmd ("read_byte", grub_cmd_read, 0,
N_("ADDR"), N_("Read byte from ADDR."), options); N_("ADDR"), N_("Read 8-bit value from ADDR."),
options);
cmd_read_word = cmd_read_word =
grub_register_extcmd ("read_word", grub_cmd_read, 0, grub_register_extcmd ("read_word", grub_cmd_read, 0,
N_("ADDR"), N_("Read word from ADDR."), options); N_("ADDR"), N_("Read 16-bit value from ADDR."),
options);
cmd_read_dword = cmd_read_dword =
grub_register_extcmd ("read_dword", grub_cmd_read, 0, grub_register_extcmd ("read_dword", grub_cmd_read, 0,
N_("ADDR"), N_("Read dword from ADDR."), options); N_("ADDR"), N_("Read 32-bit value from ADDR."),
options);
cmd_write_byte = cmd_write_byte =
grub_register_command ("write_byte", grub_cmd_write, grub_register_command ("write_byte", grub_cmd_write,
N_("ADDR VALUE [MASK]"), N_("Write byte VALUE to ADDR.")); N_("ADDR VALUE [MASK]"),
N_("Write 8-bit VALUE to ADDR."));
cmd_write_word = cmd_write_word =
grub_register_command ("write_word", grub_cmd_write, grub_register_command ("write_word", grub_cmd_write,
N_("ADDR VALUE [MASK]"), N_("Write word VALUE to ADDR.")); N_("ADDR VALUE [MASK]"),
N_("Write 16-bit VALUE to ADDR."));
cmd_write_dword = cmd_write_dword =
grub_register_command ("write_dword", grub_cmd_write, grub_register_command ("write_dword", grub_cmd_write,
N_("ADDR VALUE [MASK]"), N_("Write dword VALUE to ADDR.")); N_("ADDR VALUE [MASK]"),
N_("Write 32-bit VALUE to ADDR."));
} }
GRUB_MOD_FINI(memrw) GRUB_MOD_FINI(memrw)

View file

@ -30,11 +30,12 @@ static const struct grub_arg_option options[] =
{"class", 1, GRUB_ARG_OPTION_REPEATABLE, {"class", 1, GRUB_ARG_OPTION_REPEATABLE,
N_("Menu entry type."), N_("STRING"), ARG_TYPE_STRING}, N_("Menu entry type."), N_("STRING"), ARG_TYPE_STRING},
{"users", 2, 0, {"users", 2, 0,
N_("Users allowed to boot this entry."), N_("USERNAME"), ARG_TYPE_STRING}, N_("List of users allowed to boot this entry."), N_("USERNAME[,USERNAME]"),
ARG_TYPE_STRING},
{"hotkey", 3, 0, {"hotkey", 3, 0,
N_("Keyboard key to quickly boot this entry."), N_("KEYBOARD_KEY"), ARG_TYPE_STRING}, N_("Keyboard key to quickly boot this entry."), N_("KEYBOARD_KEY"), ARG_TYPE_STRING},
{"source", 4, 0, {"source", 4, 0,
N_("Menu entry definition as a string."), N_("STRING"), ARG_TYPE_STRING}, N_("Use STRING as menu entry body."), N_("STRING"), ARG_TYPE_STRING},
{0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0}
}; };

View file

@ -41,7 +41,7 @@ grub_mini_cmd_cat (struct grub_command *cmd __attribute__ ((unused)),
grub_ssize_t size; grub_ssize_t size;
if (argc < 1) if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
file = grub_file_open (argv[0]); file = grub_file_open (argv[0]);
if (! file) if (! file)
@ -187,7 +187,7 @@ GRUB_MOD_INIT(minicmd)
0, N_("Show this message.")); 0, N_("Show this message."));
cmd_dump = cmd_dump =
grub_register_command ("dump", grub_mini_cmd_dump, grub_register_command ("dump", grub_mini_cmd_dump,
N_("ADDR [SIZE]"), N_("Dump memory.")); N_("ADDR [SIZE]"), N_("Show memory contents."));
cmd_rmmod = cmd_rmmod =
grub_register_command ("rmmod", grub_mini_cmd_rmmod, grub_register_command ("rmmod", grub_mini_cmd_rmmod,
N_("MODULE"), N_("Remove a module.")); N_("MODULE"), N_("Remove a module."));

View file

@ -49,14 +49,15 @@ grub_cmd_lsspd (grub_command_t cmd __attribute__ ((unused)),
if (err) if (err)
return err; return err;
grub_printf_ (N_("SMB base = 0x%x\n"), smbbase); grub_printf_ (N_("System management bus controller I/O space is at 0x%x\n"),
smbbase);
for (i = GRUB_SMB_RAM_START_ADDR; for (i = GRUB_SMB_RAM_START_ADDR;
i < GRUB_SMB_RAM_START_ADDR + GRUB_SMB_RAM_NUM_MAX; i++) i < GRUB_SMB_RAM_START_ADDR + GRUB_SMB_RAM_NUM_MAX; i++)
{ {
struct grub_smbus_spd spd; struct grub_smbus_spd spd;
grub_memset (&spd, 0, sizeof (spd)); grub_memset (&spd, 0, sizeof (spd));
grub_printf_ (N_("Device %d\n"), i); grub_printf_ (N_("RAM slot number %d\n"), i);
err = grub_cs5536_read_spd (smbbase, i, &spd); err = grub_cs5536_read_spd (smbbase, i, &spd);
if (err) if (err)
{ {

View file

@ -72,7 +72,7 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
int argc, char **args) int argc, char **args)
{ {
if (argc != 2) if (argc != 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "two arguments expected"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
return grub_normal_set_password (args[0], args[1]); return grub_normal_set_password (args[0], args[1]);
} }

View file

@ -90,11 +90,11 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
struct pbkdf2_password *pass; struct pbkdf2_password *pass;
if (argc != 2) if (argc != 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Two arguments expected."); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
if (grub_memcmp (args[1], "grub.pbkdf2.sha512.", if (grub_memcmp (args[1], "grub.pbkdf2.sha512.",
sizeof ("grub.pbkdf2.sha512.") - 1) != 0) sizeof ("grub.pbkdf2.sha512.") - 1) != 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Incorrect PBKDF2 password."); return grub_error (GRUB_ERR_BAD_ARGUMENT, "incorrect PBKDF2 password");
ptr = args[1] + sizeof ("grub.pbkdf2.sha512.") - 1; ptr = args[1] + sizeof ("grub.pbkdf2.sha512.") - 1;
@ -106,7 +106,7 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
if (*ptr != '.') if (*ptr != '.')
{ {
grub_free (pass); grub_free (pass);
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Incorrect PBKDF2 password."); return grub_error (GRUB_ERR_BAD_ARGUMENT, "incorrect PBKDF2 password");
} }
ptr++; ptr++;
@ -114,7 +114,7 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
if (!ptr2 || ((ptr2 - ptr) & 1) || grub_strlen (ptr2 + 1) & 1) if (!ptr2 || ((ptr2 - ptr) & 1) || grub_strlen (ptr2 + 1) & 1)
{ {
grub_free (pass); grub_free (pass);
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Incorrect PBKDF2 password."); return grub_error (GRUB_ERR_BAD_ARGUMENT, "incorrect PBKDF2 password");
} }
pass->saltlen = (ptr2 - ptr) >> 1; pass->saltlen = (ptr2 - ptr) >> 1;
@ -137,7 +137,7 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
grub_free (pass->salt); grub_free (pass->salt);
grub_free (pass); grub_free (pass);
return grub_error (GRUB_ERR_BAD_ARGUMENT, return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Incorrect PBKDF2 password."); "incorrect PBKDF2 password");
} }
*ptro = (hex1 << 4) | hex2; *ptro = (hex1 << 4) | hex2;
@ -166,7 +166,7 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
grub_free (pass->salt); grub_free (pass->salt);
grub_free (pass); grub_free (pass);
return grub_error (GRUB_ERR_BAD_ARGUMENT, return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Incorrect PBKDF2 password."); "incorrect PBKDF2 password");
} }
*ptro = (hex1 << 4) | hex2; *ptro = (hex1 << 4) | hex2;

View file

@ -68,7 +68,7 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
else else
dev = grub_device_open (args[0]); dev = grub_device_open (args[0]);
if (! dev) if (! dev)
return grub_error (GRUB_ERR_BAD_DEVICE, "couldn't open device"); return grub_errno;
if (state[1].set) if (state[1].set)
{ {
@ -96,7 +96,7 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
} }
fs = grub_fs_probe (dev); fs = grub_fs_probe (dev);
if (! fs) if (! fs)
return grub_error (GRUB_ERR_UNKNOWN_FS, "unrecognised fs"); return grub_errno;
if (state[3].set) if (state[3].set)
{ {
if (state[0].set) if (state[0].set)

View file

@ -32,7 +32,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
static const struct grub_arg_option options[] = static const struct grub_arg_option options[] =
{ {
{ "set", 's', GRUB_ARG_OPTION_REPEATABLE, { "set", 's', GRUB_ARG_OPTION_REPEATABLE,
N_("Variable names to update with matches."), N_("Store matched component NUMBER in VARNAME."),
N_("[NUMBER:]VARNAME"), ARG_TYPE_STRING }, N_("[NUMBER:]VARNAME"), ARG_TYPE_STRING },
{ 0, 0, 0, 0, 0, 0 } { 0, 0, 0, 0, 0, 0 }
}; };
@ -42,7 +42,6 @@ set_matches (char **varnames, char *str, grub_size_t nmatches,
regmatch_t *matches) regmatch_t *matches)
{ {
int i; int i;
char ch;
char *p; char *p;
char *q; char *q;
grub_err_t err; grub_err_t err;
@ -51,6 +50,7 @@ set_matches (char **varnames, char *str, grub_size_t nmatches,
auto void setvar (char *v, regmatch_t *m); auto void setvar (char *v, regmatch_t *m);
void setvar (char *v, regmatch_t *m) void setvar (char *v, regmatch_t *m)
{ {
char ch;
ch = str[m->rm_eo]; ch = str[m->rm_eo];
str[m->rm_eo] = '\0'; str[m->rm_eo] = '\0';
err = grub_env_set (v, str + m->rm_so); err = grub_env_set (v, str + m->rm_so);
@ -59,7 +59,8 @@ set_matches (char **varnames, char *str, grub_size_t nmatches,
for (i = 0; varnames && varnames[i]; i++) for (i = 0; varnames && varnames[i]; i++)
{ {
if (! (p = grub_strchr (varnames[i], ':'))) p = grub_strchr (varnames[i], ':');
if (! p)
{ {
/* varname w/o index defaults to 1 */ /* varname w/o index defaults to 1 */
if (nmatches < 2 || matches[1].rm_so == -1) if (nmatches < 2 || matches[1].rm_so == -1)
@ -97,7 +98,7 @@ grub_cmd_regexp (grub_extcmd_context_t ctxt, int argc, char **args)
regmatch_t *matches = 0; regmatch_t *matches = 0;
if (argc != 2) if (argc != 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "2 arguments expected"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
ret = regcomp (&regex, args[0], REG_EXTENDED); ret = regcomp (&regex, args[0], REG_EXTENDED);
if (ret) if (ret)

View file

@ -277,7 +277,7 @@ grub_cmd_do_search (grub_command_t cmd __attribute__ ((unused)), int argc,
char **args) char **args)
{ {
if (argc == 0) if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no argument specified"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
FUNC_NAME (args[0], argc == 1 ? 0 : args[1], 0, (args + 2), FUNC_NAME (args[0], argc == 1 ? 0 : args[1], 0, (args + 2),
argc > 2 ? argc - 2 : 0); argc > 2 ? argc - 2 : 0);

View file

@ -158,7 +158,7 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
break; break;
if (argc == j) if (argc == j)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no argument specified"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
if (state[SEARCH_SET].set) if (state[SEARCH_SET].set)
var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root"; var = state[SEARCH_SET].arg ? state[SEARCH_SET].arg : "root";

View file

@ -179,7 +179,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv)
if (grub_errno) if (grub_errno)
return grub_errno; return grub_errno;
if (*ptr != ':') if (*ptr != ':')
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Colon expected."); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':');
ptr++; ptr++;
pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff) pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff)
<< 16; << 16;
@ -210,7 +210,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv)
if (grub_errno) if (grub_errno)
return grub_errno; return grub_errno;
if (*ptr != ':') if (*ptr != ':')
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Colon expected."); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':');
ptr++; ptr++;
optr = ptr; optr = ptr;
device = grub_strtoul (ptr, (char **) &ptr, 16); device = grub_strtoul (ptr, (char **) &ptr, 16);
@ -238,11 +238,8 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv)
write_mask = 0; write_mask = 0;
if (argc == 0) if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Command expected."); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
if (argc > 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Only one command is supported.");
ptr = argv[0]; ptr = argv[0];
@ -257,7 +254,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv)
regsize = 0; regsize = 0;
regaddr = grub_strtoul (ptr, (char **) &ptr, 16); regaddr = grub_strtoul (ptr, (char **) &ptr, 16);
if (grub_errno) if (grub_errno)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown register"); return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown register");
} }
else else
{ {
@ -298,7 +295,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv)
if (!regsize) if (!regsize)
return grub_error (GRUB_ERR_BAD_ARGUMENT, return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Unknown register size."); "unknown register size");
write_mask = 0; write_mask = 0;
if (*ptr == '=') if (*ptr == '=')
@ -321,7 +318,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv)
if (write_mask && varname) if (write_mask && varname)
return grub_error (GRUB_ERR_BAD_ARGUMENT, return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Option -v isn't valid for writes."); "option -v isn't valid for writes");
grub_pci_iterate (grub_setpci_iter); grub_pci_iterate (grub_setpci_iter);
return GRUB_ERR_NONE; return GRUB_ERR_NONE;

View file

@ -67,7 +67,7 @@ grub_cmd_sleep (grub_extcmd_context_t ctxt, int argc, char **args)
int n; int n;
if (argc != 1) if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing operand"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
n = grub_strtoul (args[0], 0, 10); n = grub_strtoul (args[0], 0, 10);

View file

@ -50,7 +50,7 @@ grub_cmd_testload (struct grub_command *cmd __attribute__ ((unused)),
} }
if (argc < 1) if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
file = grub_file_open (argv[0]); file = grub_file_open (argv[0]);
if (! file) if (! file)

View file

@ -46,9 +46,13 @@ GRUB_MOD_INIT(true)
{ {
cmd_true = cmd_true =
grub_register_command ("true", grub_cmd_true, grub_register_command ("true", grub_cmd_true,
/* TRANSLATORS: it's imperative, not
infinitive. */
0, N_("Do nothing, successfully.")); 0, N_("Do nothing, successfully."));
cmd_false = cmd_false =
grub_register_command ("false", grub_cmd_false, grub_register_command ("false", grub_cmd_false,
/* TRANSLATORS: it's imperative, not
infinitive. */
0, N_("Do nothing, unsuccessfully.")); 0, N_("Do nothing, unsuccessfully."));
} }

View file

@ -178,7 +178,7 @@ grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)),
{ {
if (adapter->init ()) if (adapter->init ())
{ {
grub_puts_ (N_(" Failed")); grub_puts_ (N_(" Failed to initialize video adapter"));
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
continue; continue;
} }

View file

@ -543,10 +543,10 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
(unsigned long long) parms->cmdsize); (unsigned long long) parms->cmdsize);
if (parms->cmdsize != 0 && parms->cmdsize != 12 && parms->cmdsize != 16) if (parms->cmdsize != 0 && parms->cmdsize != 12 && parms->cmdsize != 16)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "incorrect ATAPI command size"); return grub_error (GRUB_ERR_BUG, "incorrect ATAPI command size");
if (parms->size > GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH) if (parms->size > GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "too big data buffer"); return grub_error (GRUB_ERR_BUG, "too big data buffer");
bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1)); bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1));
@ -626,7 +626,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
dev->hba->ports[dev->port].command_issue, dev->hba->ports[dev->port].command_issue,
dev->hba->ports[dev->port].intstatus, dev->hba->ports[dev->port].intstatus,
dev->hba->ports[dev->port].task_file_data); dev->hba->ports[dev->port].task_file_data);
err = grub_error (GRUB_ERR_IO, "AHCI transfer timeouted"); err = grub_error (GRUB_ERR_IO, "AHCI transfer timed out");
break; break;
} }

View file

@ -21,6 +21,7 @@
#include <grub/disk.h> #include <grub/disk.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/arc/arc.h> #include <grub/arc/arc.h>
#include <grub/i18n.h>
static grub_arc_fileno_t last_handle = 0; static grub_arc_fileno_t last_handle = 0;
static char *last_path = NULL; static char *last_path = NULL;
@ -255,7 +256,11 @@ grub_arcdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
{ {
if (GRUB_ARC_FIRMWARE_VECTOR->read (last_handle, buf, if (GRUB_ARC_FIRMWARE_VECTOR->read (last_handle, buf,
totl, &count)) totl, &count))
return grub_error (GRUB_ERR_READ_ERROR, "read failed"); return grub_error (GRUB_ERR_READ_ERROR,
N_("failure reading sector 0x%llx "
" from `%s'"),
(unsigned long long) sector,
disk->name);
totl -= count; totl -= count;
buf += count; buf += count;
} }
@ -288,7 +293,10 @@ grub_arcdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
{ {
if (GRUB_ARC_FIRMWARE_VECTOR->write (last_handle, buf, if (GRUB_ARC_FIRMWARE_VECTOR->write (last_handle, buf,
totl, &count)) totl, &count))
return grub_error (GRUB_ERR_WRITE_ERROR, "write failed"); return grub_error (GRUB_ERR_WRITE_ERROR, N_("failure writing sector 0x%llx "
" from `%s'"),
(unsigned long long) sector,
disk->name);
totl -= count; totl -= count;
buf += count; buf += count;
} }

View file

@ -41,7 +41,7 @@ static const struct grub_arg_option options[] =
{ {
{"uuid", 'u', 0, N_("Mount by UUID."), 0, 0}, {"uuid", 'u', 0, N_("Mount by UUID."), 0, 0},
{"all", 'a', 0, N_("Mount all."), 0, 0}, {"all", 'a', 0, N_("Mount all."), 0, 0},
{"boot", 'b', 0, N_("Mount all volumes marked as boot."), 0, 0}, {"boot", 'b', 0, N_("Mount all volumes with `boot' flag set."), 0, 0},
{0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0}
}; };
@ -501,7 +501,7 @@ grub_cryptodisk_open (const char *name, grub_disk_t disk)
if (dev->cheat_fd == -1) if (dev->cheat_fd == -1)
dev->cheat_fd = open (dev->cheat, O_RDONLY); dev->cheat_fd = open (dev->cheat, O_RDONLY);
if (dev->cheat_fd == -1) if (dev->cheat_fd == -1)
return grub_error (GRUB_ERR_IO, "couldn't open %s: %s", return grub_error (GRUB_ERR_IO, N_("cannot open `%s': %s"),
dev->cheat, strerror (errno)); dev->cheat, strerror (errno));
} }
#endif #endif
@ -560,8 +560,8 @@ grub_cryptodisk_read (grub_disk_t disk, grub_disk_addr_t sector,
return err; return err;
if (grub_util_fd_read (dev->cheat_fd, buf, size << disk->log_sector_size) if (grub_util_fd_read (dev->cheat_fd, buf, size << disk->log_sector_size)
!= (ssize_t) (size << disk->log_sector_size)) != (ssize_t) (size << disk->log_sector_size))
return grub_error (GRUB_ERR_READ_ERROR, "cannot read from `%s'", return grub_error (GRUB_ERR_READ_ERROR, N_("cannot read `%s': %s"),
dev->cheat); dev->cheat, strerror (errno));
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
#endif #endif
@ -604,8 +604,8 @@ grub_cryptodisk_write (grub_disk_t disk, grub_disk_addr_t sector,
return err; return err;
if (grub_util_fd_write (dev->cheat_fd, buf, size << disk->log_sector_size) if (grub_util_fd_write (dev->cheat_fd, buf, size << disk->log_sector_size)
!= (ssize_t) (size << disk->log_sector_size)) != (ssize_t) (size << disk->log_sector_size))
return grub_error (GRUB_ERR_READ_ERROR, "cannot read from `%s'", return grub_error (GRUB_ERR_READ_ERROR, N_("cannot read `%s': %s"),
dev->cheat); dev->cheat, strerror (errno));
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
#endif #endif

View file

@ -249,8 +249,8 @@ grub_diskfilter_memberlist (grub_disk_t disk)
for (pv = lv->vg->pvs; pv; pv = pv->next) for (pv = lv->vg->pvs; pv; pv = pv->next)
{ {
if (!pv->disk) if (!pv->disk)
grub_util_error (_("Couldn't find PV %s. Check your device.map"), grub_util_error (_("Couldn't find physical volume `%s'."
pv->name); " Check your device.map"), pv->name);
tmp = grub_malloc (sizeof (*tmp)); tmp = grub_malloc (sizeof (*tmp));
tmp->disk = pv->disk; tmp->disk = pv->disk;
tmp->next = list; tmp->next = list;

View file

@ -408,7 +408,7 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
sector = grub_disk_get_size (source); sector = grub_disk_get_size (source);
if (sector == GRUB_DISK_SIZE_UNKNOWN || sector == 0) if (sector == GRUB_DISK_SIZE_UNKNOWN || sector == 0)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "not a geli"); return grub_error (GRUB_ERR_BUG, "not a geli");
/* Read the GELI header. */ /* Read the GELI header. */
err = grub_disk_read (source, sector - 1, 0, sizeof (header), &header); err = grub_disk_read (source, sector - 1, 0, sizeof (header), &header);

View file

@ -472,7 +472,10 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
break; break;
if (i == GRUB_BIOSDISK_CDROM_RETRY_COUNT) if (i == GRUB_BIOSDISK_CDROM_RETRY_COUNT)
return grub_error (GRUB_ERR_READ_ERROR, "cdrom read error"); return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
" from `%s'"),
(unsigned long long) sector,
disk->name);
} }
else else
if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap)) if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap))
@ -502,7 +505,9 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
coff = head / data->heads; coff = head / data->heads;
if (coff >= data->cylinders) if (coff >= data->cylinders)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "%s out of disk", disk->name); return grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("attempt to read or write outside of disk `%s'"),
disk->name);
if (grub_biosdisk_rw_standard (cmd + 0x02, data->drive, if (grub_biosdisk_rw_standard (cmd + 0x02, data->drive,
coff, hoff, soff, size, segment)) coff, hoff, soff, size, segment))
@ -510,9 +515,15 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
switch (cmd) switch (cmd)
{ {
case GRUB_BIOSDISK_READ: case GRUB_BIOSDISK_READ:
return grub_error (GRUB_ERR_READ_ERROR, "%s read error", disk->name); return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
" from `%s'"),
(unsigned long long) sector,
disk->name);
case GRUB_BIOSDISK_WRITE: case GRUB_BIOSDISK_WRITE:
return grub_error (GRUB_ERR_WRITE_ERROR, "%s write error", disk->name); return grub_error (GRUB_ERR_WRITE_ERROR, N_("failure writing sector 0x%llx "
" from `%s'"),
(unsigned long long) sector,
disk->name);
} }
} }
} }
@ -627,7 +638,8 @@ GRUB_MOD_INIT(biosdisk)
if (grub_disk_firmware_is_tainted) if (grub_disk_firmware_is_tainted)
{ {
grub_puts_ (N_("Firmware is marked as tainted, refusing to initialize.")); grub_puts_ (N_("Native disk drivers are in use. "
"Refusing to use firmware disk interface."));
return; return;
} }
grub_disk_firmware_fini = grub_disk_biosdisk_fini; grub_disk_firmware_fini = grub_disk_biosdisk_fini;

View file

@ -22,6 +22,7 @@
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/ieee1275/ieee1275.h> #include <grub/ieee1275/ieee1275.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -177,7 +178,10 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
args.result = 1; args.result = 1;
if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result)) if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
return grub_error (GRUB_ERR_READ_ERROR, "read error"); return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
" from `%s'"),
(unsigned long long) sector,
disk->name);
ofs = 0; ofs = 0;
size -= len; size -= len;

View file

@ -22,6 +22,7 @@
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/ieee1275/ieee1275.h> #include <grub/ieee1275/ieee1275.h>
#include <grub/ieee1275/ofdisk.h> #include <grub/ieee1275/ofdisk.h>
#include <grub/i18n.h>
static char *last_devpath; static char *last_devpath;
static grub_ieee1275_ihandle_t last_ihandle; static grub_ieee1275_ihandle_t last_ihandle;
@ -273,7 +274,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
if (grub_strcmp (prop, "block")) if (grub_strcmp (prop, "block"))
{ {
grub_free (devpath); grub_free (devpath);
return grub_error (GRUB_ERR_BAD_DEVICE, "not a block device"); return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a block device");
} }
/* XXX: There is no property to read the number of blocks. There /* XXX: There is no property to read the number of blocks. There
@ -364,8 +365,10 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_ieee1275_read (last_ihandle, buf, size << GRUB_DISK_SECTOR_BITS, grub_ieee1275_read (last_ihandle, buf, size << GRUB_DISK_SECTOR_BITS,
&actual); &actual);
if (actual != (grub_ssize_t) (size << GRUB_DISK_SECTOR_BITS)) if (actual != (grub_ssize_t) (size << GRUB_DISK_SECTOR_BITS))
return grub_error (GRUB_ERR_READ_ERROR, "read error on block: %llu", return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
(long long) sector); " from `%s'"),
(unsigned long long) sector,
disk->name);
return 0; return 0;
} }
@ -382,8 +385,10 @@ grub_ofdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
grub_ieee1275_write (last_ihandle, buf, size << GRUB_DISK_SECTOR_BITS, grub_ieee1275_write (last_ihandle, buf, size << GRUB_DISK_SECTOR_BITS,
&actual); &actual);
if (actual != (grub_ssize_t) (size << GRUB_DISK_SECTOR_BITS)) if (actual != (grub_ssize_t) (size << GRUB_DISK_SECTOR_BITS))
return grub_error (GRUB_ERR_WRITE_ERROR, "write error on block: %llu", return grub_error (GRUB_ERR_WRITE_ERROR, N_("failure writing sector 0x%llx "
(long long) sector); " from `%s'"),
(unsigned long long) sector,
disk->name);
return 0; return 0;
} }

View file

@ -23,6 +23,7 @@
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/diskfilter.h> #include <grub/diskfilter.h>
#include <grub/gpt_partition.h> #include <grub/gpt_partition.h>
#include <grub/i18n.h>
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
#include <grub/emu/misc.h> #include <grub/emu/misc.h>
@ -919,10 +920,10 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"LDM curently supports only PC-BIOS embedding"); "LDM curently supports only PC-BIOS embedding");
if (disk->partition) if (disk->partition)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "disk isn't LDM"); return grub_error (GRUB_ERR_BUG, "disk isn't LDM");
pv = grub_diskfilter_get_pv_from_disk (disk, &vg); pv = grub_diskfilter_get_pv_from_disk (disk, &vg);
if (!pv) if (!pv)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "disk isn't LDM"); return grub_error (GRUB_ERR_BUG, "disk isn't LDM");
for (lv = vg->lvs; lv; lv = lv->next) for (lv = vg->lvs; lv; lv = lv->next)
{ {
struct grub_diskfilter_lv *comp; struct grub_diskfilter_lv *comp;
@ -961,8 +962,8 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
#endif #endif
if (lv->size < *nsectors) if (lv->size < *nsectors)
return grub_error (GRUB_ERR_OUT_OF_RANGE, return grub_error (GRUB_ERR_OUT_OF_RANGE,
"Your LDM embed Partition is too small;" N_("your LDM embed Partition is too small;"
" embedding won't be possible!"); " embedding won't be possible"));
*nsectors = lv->size; *nsectors = lv->size;
*sectors = grub_malloc (*nsectors * sizeof (**sectors)); *sectors = grub_malloc (*nsectors * sizeof (**sectors));
if (!*sectors) if (!*sectors)
@ -975,8 +976,8 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
} }
return grub_error (GRUB_ERR_FILE_NOT_FOUND, return grub_error (GRUB_ERR_FILE_NOT_FOUND,
"This LDM no Embedding Partition;" N_("this LDM has no Embedding Partition;"
" embedding won't be possible!"); " embedding won't be possible"));
} }
#endif #endif

View file

@ -38,7 +38,7 @@ static struct grub_loopback *loopback_list;
static const struct grub_arg_option options[] = static const struct grub_arg_option options[] =
{ {
{"delete", 'd', 0, N_("Delete the loopback device entry."), 0, 0}, {"delete", 'd', 0, N_("Delete the specified loopback drive."), 0, 0},
{0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0}
}; };
@ -86,7 +86,7 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
return delete_loopback (args[0]); return delete_loopback (args[0]);
if (argc < 2) if (argc < 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
file = grub_file_open (args[1]); file = grub_file_open (args[1]);
if (! file) if (! file)
@ -224,7 +224,7 @@ GRUB_MOD_INIT(loopback)
{ {
cmd = grub_register_extcmd ("loopback", grub_cmd_loopback, 0, cmd = grub_register_extcmd ("loopback", grub_cmd_loopback, 0,
N_("[-d] DEVICENAME FILE."), N_("[-d] DEVICENAME FILE."),
N_("Make a device of a file."), options); N_("Make a virtual drive from a file."), options);
grub_disk_dev_register (&grub_loopback_dev); grub_disk_dev_register (&grub_loopback_dev);
} }

View file

@ -23,6 +23,7 @@
#include <grub/efiemu/efiemu.h> #include <grub/efiemu/efiemu.h>
#include <grub/cpu/efiemu.h> #include <grub/cpu/efiemu.h>
#include <grub/elf.h> #include <grub/elf.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */ /* Check if EHDR is a valid ELF header. */
int int
@ -101,8 +102,9 @@ grub_arch_efiemu_relocate_symbols32 (grub_efiemu_segment_t segs,
return err; return err;
break; break;
default: default:
return grub_error (GRUB_ERR_BAD_OS, return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unrecognised relocation"); N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
} }
} }
} }

View file

@ -23,6 +23,7 @@
#include <grub/efiemu/efiemu.h> #include <grub/efiemu/efiemu.h>
#include <grub/cpu/efiemu.h> #include <grub/cpu/efiemu.h>
#include <grub/elf.h> #include <grub/elf.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */ /* Check if EHDR is a valid ELF header. */
int int
@ -109,8 +110,9 @@ grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
return err; return err;
break; break;
default: default:
return grub_error (GRUB_ERR_BAD_OS, return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unrecognised relocation"); N_("relocation 0x%x is not implemented yet"),
ELF_R_TYPE (rel->r_info));
} }
} }
} }

View file

@ -23,6 +23,7 @@
#include <grub/efiemu/efiemu.h> #include <grub/efiemu/efiemu.h>
#include <grub/cpu/efiemu.h> #include <grub/cpu/efiemu.h>
#include <grub/elf.h> #include <grub/elf.h>
#include <grub/i18n.h>
/* ELF symbols and their values */ /* ELF symbols and their values */
static struct grub_efiemu_elf_sym *grub_efiemu_elfsyms = 0; static struct grub_efiemu_elf_sym *grub_efiemu_elfsyms = 0;
@ -193,7 +194,7 @@ grub_efiemu_count_symbols (const Elf_Ehdr *e)
break; break;
if (i == e->e_shnum) if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_OS, "no symbol table"); return grub_error (GRUB_ERR_BAD_OS, N_("no symbol table"));
grub_efiemu_nelfsyms = (unsigned) s->sh_size / (unsigned) s->sh_entsize; grub_efiemu_nelfsyms = (unsigned) s->sh_size / (unsigned) s->sh_entsize;
grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *) grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *)
@ -230,7 +231,7 @@ grub_efiemu_resolve_symbols (grub_efiemu_segment_t segs, Elf_Ehdr *e)
break; break;
if (i == e->e_shnum) if (i == e->e_shnum)
return grub_error (GRUB_ERR_BAD_OS, "no symbol table"); return grub_error (GRUB_ERR_BAD_OS, N_("no symbol table"));
sym = (Elf_Sym *) ((char *) e + s->sh_offset); sym = (Elf_Sym *) ((char *) e + s->sh_offset);
size = s->sh_size; size = s->sh_size;
@ -328,7 +329,7 @@ SUFFIX (grub_efiemu_loadcore_init) (void *core, grub_size_t core_size,
grub_err_t err; grub_err_t err;
if (e->e_type != ET_REL) if (e->e_type != ET_REL)
return grub_error (GRUB_ERR_BAD_MODULE, "invalid ELF file type"); return grub_error (GRUB_ERR_BAD_MODULE, N_("this ELF file is not of the right type"));
/* Make sure that every section is within the core. */ /* Make sure that every section is within the core. */
if ((grub_size_t) core_size < e->e_shoff + e->e_shentsize * e->e_shnum) if ((grub_size_t) core_size < e->e_shoff + e->e_shentsize * e->e_shnum)

View file

@ -140,8 +140,9 @@ grub_efiemu_loadcore_init (grub_file_t file)
switch (grub_efiemu_mode) switch (grub_efiemu_mode)
{ {
case GRUB_EFIEMU32: case GRUB_EFIEMU32:
if ((err = grub_efiemu_loadcore_init32 (efiemu_core, efiemu_core_size, err = grub_efiemu_loadcore_init32 (efiemu_core, efiemu_core_size,
&efiemu_segments))) &efiemu_segments);
if (err)
{ {
grub_free (efiemu_core); grub_free (efiemu_core);
efiemu_core = 0; efiemu_core = 0;
@ -151,8 +152,9 @@ grub_efiemu_loadcore_init (grub_file_t file)
break; break;
case GRUB_EFIEMU64: case GRUB_EFIEMU64:
if ((err = grub_efiemu_loadcore_init64 (efiemu_core, efiemu_core_size, err = grub_efiemu_loadcore_init64 (efiemu_core, efiemu_core_size,
&efiemu_segments))) &efiemu_segments);
if (err)
{ {
grub_free (efiemu_core); grub_free (efiemu_core);
efiemu_core = 0; efiemu_core = 0;
@ -162,7 +164,7 @@ grub_efiemu_loadcore_init (grub_file_t file)
break; break;
default: default:
return grub_error (GRUB_ERR_BAD_OS, "unknown EFI runtime"); return grub_error (GRUB_ERR_BUG, "unknown EFI runtime");
} }
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
@ -184,6 +186,6 @@ grub_efiemu_loadcore_load (void)
grub_efiemu_loadcore_unload (); grub_efiemu_loadcore_unload ();
return err; return err;
default: default:
return grub_error (GRUB_ERR_BAD_OS, "unknown EFI runtime"); return grub_error (GRUB_ERR_BUG, "unknown EFI runtime");
} }
} }

View file

@ -121,11 +121,9 @@ grub_efiemu_register_prepare_hook (grub_err_t (*hook) (void *data),
void *data) void *data)
{ {
struct grub_efiemu_prepare_hook *nhook; struct grub_efiemu_prepare_hook *nhook;
if (! hook)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "you must supply the hook");
nhook = (struct grub_efiemu_prepare_hook *) grub_malloc (sizeof (*nhook)); nhook = (struct grub_efiemu_prepare_hook *) grub_malloc (sizeof (*nhook));
if (! nhook) if (! nhook)
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't prepare hook"); return grub_errno;
nhook->hook = hook; nhook->hook = hook;
nhook->unload = unload; nhook->unload = unload;
nhook->data = data; nhook->data = data;
@ -146,16 +144,13 @@ grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
struct grub_efiemu_configuration_table *tbl; struct grub_efiemu_configuration_table *tbl;
grub_err_t err; grub_err_t err;
if (! get_table && ! data)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"you must set at least get_table or data");
err = grub_efiemu_unregister_configuration_table (guid); err = grub_efiemu_unregister_configuration_table (guid);
if (err) if (err)
return err; return err;
tbl = (struct grub_efiemu_configuration_table *) grub_malloc (sizeof (*tbl)); tbl = (struct grub_efiemu_configuration_table *) grub_malloc (sizeof (*tbl));
if (! tbl) if (! tbl)
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't register table"); return grub_errno;
tbl->guid = guid; tbl->guid = guid;
tbl->get_table = get_table; tbl->get_table = get_table;
@ -201,7 +196,7 @@ grub_efiemu_load_file (const char *filename)
{ {
grub_file_close (file); grub_file_close (file);
grub_efiemu_unload (); grub_efiemu_unload ();
return grub_error (grub_errno, "couldn't init memory management"); return grub_errno;
} }
grub_dprintf ("efiemu", "mm initialized\n"); grub_dprintf ("efiemu", "mm initialized\n");
@ -237,16 +232,14 @@ grub_efiemu_autocore (void)
if (! prefix) if (! prefix)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, return grub_error (GRUB_ERR_FILE_NOT_FOUND,
"couldn't find efiemu core because prefix " N_("variable `%s' isn't set"), "prefix");
"isn't set");
suffix = grub_efiemu_get_default_core_name (); suffix = grub_efiemu_get_default_core_name ();
filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM "/%s", filename = grub_xasprintf ("%s/" GRUB_TARGET_CPU "-" GRUB_PLATFORM "/%s",
prefix, suffix); prefix, suffix);
if (! filename) if (! filename)
return grub_error (GRUB_ERR_OUT_OF_MEMORY, return grub_errno;
"couldn't allocate temporary space");
err = grub_efiemu_load_file (filename); err = grub_efiemu_load_file (filename);
grub_free (filename); grub_free (filename);
@ -297,7 +290,7 @@ grub_cmd_efiemu_load (grub_command_t cmd __attribute__ ((unused)),
grub_efiemu_unload (); grub_efiemu_unload ();
if (argc != 1) if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "filename required"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
err = grub_efiemu_load_file (args[0]); err = grub_efiemu_load_file (args[0]);
if (err) if (err)

View file

@ -62,12 +62,17 @@ grub_efiemu_add_to_mmap (grub_uint64_t start, grub_uint64_t size,
/* Extend map if necessary*/ /* Extend map if necessary*/
if (mmap_num >= mmap_reserved_size) if (mmap_num >= mmap_reserved_size)
{ {
void *old;
mmap_reserved_size = 2 * (mmap_reserved_size + 1);
old = efiemu_mmap;
efiemu_mmap = (grub_efi_memory_descriptor_t *) efiemu_mmap = (grub_efi_memory_descriptor_t *)
grub_realloc (efiemu_mmap, (++mmap_reserved_size) grub_realloc (efiemu_mmap, mmap_reserved_size
* sizeof (grub_efi_memory_descriptor_t)); * sizeof (grub_efi_memory_descriptor_t));
if (!efiemu_mmap) if (!efiemu_mmap)
return grub_error (GRUB_ERR_OUT_OF_MEMORY, {
"not enough space for memory map"); grub_free (old);
return grub_errno;
}
} }
/* Fill slot*/ /* Fill slot*/
@ -176,8 +181,7 @@ efiemu_alloc_requests (void)
/* Allocate the whole memory in one block */ /* Allocate the whole memory in one block */
resident_memory = grub_memalign (GRUB_EFIEMU_PAGESIZE, total_alloc); resident_memory = grub_memalign (GRUB_EFIEMU_PAGESIZE, total_alloc);
if (!resident_memory) if (!resident_memory)
return grub_error (GRUB_ERR_OUT_OF_MEMORY, return grub_errno;
"couldn't allocate resident memory");
/* Split the memory into blocks by type */ /* Split the memory into blocks by type */
curptr = resident_memory; curptr = resident_memory;
@ -540,8 +544,7 @@ grub_efiemu_mmap_sort_and_uniq (void)
{ {
grub_free (result); grub_free (result);
grub_free (scanline_events); grub_free (scanline_events);
return grub_error (GRUB_ERR_OUT_OF_MEMORY, return grub_errno;
"couldn't allocate space for new memory map");
} }
/* Register scanline events */ /* Register scanline events */
@ -642,12 +645,14 @@ grub_efiemu_mm_do_alloc (void)
if (!efiemu_mmap) if (!efiemu_mmap)
{ {
grub_efiemu_unload (); grub_efiemu_unload ();
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't initialize mmap"); return grub_errno;
} }
if ((err = efiemu_alloc_requests ())) err = efiemu_alloc_requests ();
if (err)
return err; return err;
if ((err = grub_efiemu_mmap_fill ())) err = grub_efiemu_mmap_fill ();
if (err)
return err; return err;
return grub_efiemu_mmap_sort_and_uniq (); return grub_efiemu_mmap_sort_and_uniq ();
} }

View file

@ -171,12 +171,6 @@ nvram_set (void * data __attribute__ ((unused)))
(nvramsize - (nvramptr - nvram)) / 2, (nvramsize - (nvramptr - nvram)) / 2,
(grub_uint8_t *) varname, len, NULL); (grub_uint8_t *) varname, len, NULL);
if (len < 0)
{
grub_error (GRUB_ERR_BAD_ARGUMENT, "broken UTF-8 in variable name");
return 1;
}
nvramptr += 2 * len; nvramptr += 2 * len;
*((grub_uint16_t *) nvramptr) = 0; *((grub_uint16_t *) nvramptr) = 0;
nvramptr += 2; nvramptr += 2;

View file

@ -22,6 +22,7 @@
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/efiemu/efiemu.h> #include <grub/efiemu/efiemu.h>
#include <grub/efiemu/runtime.h> #include <grub/efiemu/runtime.h>
#include <grub/i18n.h>
static int ptv_written = 0; static int ptv_written = 0;
static int ptv_alloc = 0; static int ptv_alloc = 0;
@ -69,7 +70,7 @@ grub_efiemu_request_symbols (int num)
return grub_error (GRUB_ERR_BAD_ARGUMENT, return grub_error (GRUB_ERR_BAD_ARGUMENT,
"symbols have already been allocated"); "symbols have already been allocated");
if (num < 0) if (num < 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, return grub_error (GRUB_ERR_BUG,
"can't request negative symbols"); "can't request negative symbols");
ptv_requested += num; ptv_requested += num;
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
@ -88,7 +89,7 @@ grub_efiemu_resolve_symbol (const char *name, int *handle, grub_off_t *off)
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
grub_dprintf ("efiemu", "%s not found\n", name); grub_dprintf ("efiemu", "%s not found\n", name);
return grub_error (GRUB_ERR_BAD_OS, "symbol %s isn't found", name); return grub_error (GRUB_ERR_BAD_OS, N_("symbol `%s' not found"), name);
} }
/* Register symbol named NAME in memory handle HANDLE at offset OFF */ /* Register symbol named NAME in memory handle HANDLE at offset OFF */
@ -99,7 +100,7 @@ grub_efiemu_register_symbol (const char *name, int handle, grub_off_t off)
cur = (struct grub_efiemu_sym *) grub_malloc (sizeof (*cur)); cur = (struct grub_efiemu_sym *) grub_malloc (sizeof (*cur));
grub_dprintf ("efiemu", "registering symbol '%s'\n", name); grub_dprintf ("efiemu", "registering symbol '%s'\n", name);
if (!cur) if (!cur)
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't register symbol"); return grub_errno;
cur->name = grub_strdup (name); cur->name = grub_strdup (name);
cur->next = efiemu_syms; cur->next = efiemu_syms;
cur->handle = handle; cur->handle = handle;
@ -153,7 +154,7 @@ grub_efiemu_write_value (void *addr, grub_uint32_t value, int plus_handle,
= grub_efiemu_mm_obtain_request (ptv_handle); = grub_efiemu_mm_obtain_request (ptv_handle);
if (ptv_needed && ptv_written >= ptv_alloc) if (ptv_needed && ptv_written >= ptv_alloc)
return grub_error (GRUB_ERR_OUT_OF_MEMORY, return grub_error (GRUB_ERR_BUG,
"your module didn't declare efiemu " "your module didn't declare efiemu "
" relocators correctly"); " relocators correctly");
@ -200,7 +201,7 @@ grub_efiemu_write_value (void *addr, grub_uint32_t value, int plus_handle,
*((grub_uint8_t *) addr) = value; *((grub_uint8_t *) addr) = value;
break; break;
default: default:
return grub_error (GRUB_ERR_BAD_ARGUMENT, "wrong symbol size"); return grub_error (GRUB_ERR_BUG, "wrong symbol size");
} }
return GRUB_ERR_NONE; return GRUB_ERR_NONE;

View file

@ -29,7 +29,7 @@ loadfont_command (grub_command_t cmd __attribute__ ((unused)),
char **args) char **args)
{ {
if (argc == 0) if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no font specified"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
while (argc--) while (argc--)
if (grub_font_load (*args++) != 0) if (grub_font_load (*args++) != 0)

View file

@ -28,6 +28,7 @@
#include <grub/disk.h> #include <grub/disk.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/types.h> #include <grub/types.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -529,7 +530,7 @@ find_in_b_tree (grub_disk_t disk,
if (err) if (err)
return err; return err;
if (node.count_keys == 0) if (node.count_keys == 0)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
name); name);
{ {
char key_data[grub_bfs_to_cpu_treehead (node.total_key_len) + 1]; char key_data[grub_bfs_to_cpu_treehead (node.total_key_len) + 1];
@ -600,7 +601,7 @@ find_in_b_tree (grub_disk_t disk,
level--; level--;
continue; continue;
} }
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
name); name);
} }
} }
@ -615,7 +616,7 @@ hop_level (grub_disk_t disk,
grub_uint64_t res; grub_uint64_t res;
if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) != ATTR_DIR)) if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) != ATTR_DIR))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
err = find_in_b_tree (disk, sb, ino, name, &res); err = find_in_b_tree (disk, sb, ino, name, &res);
if (err) if (err)
@ -677,7 +678,7 @@ find_file (const char *path, grub_disk_t disk,
{ {
grub_free (alloc); grub_free (alloc);
return grub_error (GRUB_ERR_SYMLINK_LOOP, return grub_error (GRUB_ERR_SYMLINK_LOOP,
"too deep nesting of symlinks"); N_("too deep nesting of symlinks"));
} }
#ifndef MODE_AFS #ifndef MODE_AFS
@ -829,7 +830,7 @@ grub_bfs_dir (grub_device_t device, const char *path,
if (err) if (err)
return err; return err;
if (((grub_bfs_to_cpu32 (ino.ino.mode) & ATTR_TYPE) != ATTR_DIR)) if (((grub_bfs_to_cpu32 (ino.ino.mode) & ATTR_TYPE) != ATTR_DIR))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
iterate_in_b_tree (device->disk, &sb, &ino.ino, hook); iterate_in_b_tree (device->disk, &sb, &ino.ino, hook);
} }
@ -857,7 +858,7 @@ grub_bfs_open (struct grub_file *file, const char *name)
if (err) if (err)
return err; return err;
if (((grub_bfs_to_cpu32 (ino.ino.mode) & ATTR_TYPE) != ATTR_REG)) if (((grub_bfs_to_cpu32 (ino.ino.mode) & ATTR_TYPE) != ATTR_REG))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a regular file"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
data = grub_zalloc (sizeof (struct grub_bfs_data) data = grub_zalloc (sizeof (struct grub_bfs_data)
+ grub_bfs_to_cpu32 (sb.bsize)); + grub_bfs_to_cpu32 (sb.bsize));

View file

@ -27,6 +27,7 @@
#include <grub/lib/crc.h> #include <grub/lib/crc.h>
#include <grub/deflate.h> #include <grub/deflate.h>
#include <minilzo.h> #include <minilzo.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -1204,7 +1205,7 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath); grub_free (origpath);
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
} }
key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM; key->type = GRUB_BTRFS_ITEM_TYPE_DIR_ITEM;
@ -1223,7 +1224,7 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath); err = grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
grub_free (origpath); grub_free (origpath);
return err; return err;
} }
@ -1267,7 +1268,7 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath); err = grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
grub_free (origpath); grub_free (origpath);
return err; return err;
} }
@ -1285,7 +1286,7 @@ find_path (struct grub_btrfs_data *data,
grub_free (path_alloc); grub_free (path_alloc);
grub_free (origpath); grub_free (origpath);
return grub_error (GRUB_ERR_SYMLINK_LOOP, return grub_error (GRUB_ERR_SYMLINK_LOOP,
"too deep nesting of symlinks"); N_("too deep nesting of symlinks"));
} }
err = grub_btrfs_read_inode (data, &inode, err = grub_btrfs_read_inode (data, &inode,
@ -1355,7 +1356,7 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath); err = grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
grub_free (origpath); grub_free (origpath);
return err; return err;
} }
@ -1378,7 +1379,7 @@ find_path (struct grub_btrfs_data *data,
{ {
grub_free (direl); grub_free (direl);
grub_free (path_alloc); grub_free (path_alloc);
err = grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath); err = grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
grub_free (origpath); grub_free (origpath);
return err; return err;
} }
@ -1430,7 +1431,7 @@ grub_btrfs_dir (grub_device_t device, const char *path,
if (type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY) if (type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
{ {
grub_btrfs_unmount (data); grub_btrfs_unmount (data);
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
} }
err = lower_bound (data, &key_in, &key_out, tree, &elemaddr, &elemsize, &desc); err = lower_bound (data, &key_in, &key_out, tree, &elemaddr, &elemsize, &desc);
@ -1535,7 +1536,7 @@ grub_btrfs_open (struct grub_file *file, const char *name)
if (type != GRUB_BTRFS_DIR_ITEM_TYPE_REGULAR) if (type != GRUB_BTRFS_DIR_ITEM_TYPE_REGULAR)
{ {
grub_btrfs_unmount (data); grub_btrfs_unmount (data);
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a regular file"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
} }
data->inode = key_in.object_id; data->inode = key_in.object_id;
@ -1628,8 +1629,8 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)),
if (64 * 2 - 1 < *nsectors) if (64 * 2 - 1 < *nsectors)
return grub_error (GRUB_ERR_OUT_OF_RANGE, return grub_error (GRUB_ERR_OUT_OF_RANGE,
"Your core.img is unusually large. " N_("your core.img is unusually large. "
"It won't fit in the embedding area."); "It won't fit in the embedding area"));
*nsectors = 64 * 2 - 1; *nsectors = 64 * 2 - 1;
*sectors = grub_malloc (*nsectors * sizeof (**sectors)); *sectors = grub_malloc (*nsectors * sizeof (**sectors));

View file

@ -22,6 +22,7 @@
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/disk.h> #include <grub/disk.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -564,7 +565,7 @@ grub_cpio_dir (grub_device_t device, const char *path_in,
if (++symlinknest == 8) if (++symlinknest == 8)
{ {
grub_error (GRUB_ERR_SYMLINK_LOOP, grub_error (GRUB_ERR_SYMLINK_LOOP,
"too deep nesting of symlinks"); N_("too deep nesting of symlinks"));
goto fail; goto fail;
} }
ofs = 0; ofs = 0;
@ -622,7 +623,7 @@ grub_cpio_open (grub_file_t file, const char *name_in)
if (!ofs) if (!ofs)
{ {
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), name_in);
break; break;
} }
@ -638,7 +639,7 @@ grub_cpio_open (grub_file_t file, const char *name_in)
if (++symlinknest == 8) if (++symlinknest == 8)
{ {
grub_error (GRUB_ERR_SYMLINK_LOOP, grub_error (GRUB_ERR_SYMLINK_LOOP,
"too deep nesting of symlinks"); N_("too deep nesting of symlinks"));
goto fail; goto fail;
} }
goto no_match; goto no_match;

View file

@ -27,6 +27,7 @@
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/charset.h> #include <grub/charset.h>
#include <grub/fat.h> #include <grub/fat.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -687,7 +688,7 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
grub_ssize_t offset = -sizeof(dir); grub_ssize_t offset = -sizeof(dir);
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
/* Allocate space enough to hold a long name. */ /* Allocate space enough to hold a long name. */
filename = grub_malloc (0x40 * 13 * GRUB_MAX_UTF8_PER_UTF16 + 1); filename = grub_malloc (0x40 * 13 * GRUB_MAX_UTF8_PER_UTF16 + 1);
@ -864,7 +865,7 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
{ {
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0; return 0;
} }
@ -896,7 +897,7 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
grub_fat_iterate_dir (disk, data, iter_hook); grub_fat_iterate_dir (disk, data, iter_hook);
if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook) if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook)
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath); grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
fail: fail:
grub_free (dirname); grub_free (dirname);
@ -972,7 +973,7 @@ grub_fat_open (grub_file_t file, const char *name)
if (data->attr & GRUB_FAT_ATTR_DIRECTORY) if (data->attr & GRUB_FAT_ATTR_DIRECTORY)
{ {
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a file"); grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
goto fail; goto fail;
} }
@ -1086,7 +1087,7 @@ grub_fat_label (grub_device_t device, char **label)
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
{ {
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0; return 0;
} }

View file

@ -23,6 +23,7 @@
#include <grub/disk.h> #include <grub/disk.h>
#include <grub/fshelp.h> #include <grub/fshelp.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -128,7 +129,7 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
if (type != GRUB_FSHELP_DIR) if (type != GRUB_FSHELP_DIR)
{ {
free_node (currnode); free_node (currnode);
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
} }
/* Iterate over the directory. */ /* Iterate over the directory. */
@ -152,7 +153,7 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
free_node (currnode); free_node (currnode);
free_node (oldnode); free_node (oldnode);
return grub_error (GRUB_ERR_SYMLINK_LOOP, return grub_error (GRUB_ERR_SYMLINK_LOOP,
"too deep nesting of symlinks"); N_("too deep nesting of symlinks"));
} }
symlink = read_symlink (currnode); symlink = read_symlink (currnode);
@ -196,12 +197,12 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
name = next; name = next;
} }
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path); return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
} }
if (!path || path[0] != '/') if (!path || path[0] != '/')
{ {
grub_error (GRUB_ERR_BAD_FILENAME, "bad filename"); grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
return grub_errno; return grub_errno;
} }
@ -211,9 +212,9 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
/* Check if the node that was found was of the expected type. */ /* Check if the node that was found was of the expected type. */
if (expecttype == GRUB_FSHELP_REG && foundtype != expecttype) if (expecttype == GRUB_FSHELP_REG && foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a regular file"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
else if (expecttype == GRUB_FSHELP_DIR && foundtype != expecttype) else if (expecttype == GRUB_FSHELP_DIR && foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0; return 0;
} }

View file

@ -28,6 +28,7 @@
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/types.h> #include <grub/types.h>
#include <grub/hfs.h> #include <grub/hfs.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -1079,7 +1080,7 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
if (path[0] != '/') if (path[0] != '/')
{ {
grub_error (GRUB_ERR_BAD_FILENAME, "bad filename"); grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
return 0; return 0;
} }
@ -1096,7 +1097,7 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
grub_ssize_t slen; grub_ssize_t slen;
if (fdrec.frec.type != GRUB_HFS_FILETYPE_DIR) if (fdrec.frec.type != GRUB_HFS_FILETYPE_DIR)
{ {
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
goto fail; goto fail;
} }
@ -1114,7 +1115,7 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
slen = utf8_to_macroman (key.str, path); slen = utf8_to_macroman (key.str, path);
if (slen < 0) if (slen < 0)
{ {
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path); grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
goto fail; goto fail;
} }
key.strlen = slen; key.strlen = slen;
@ -1123,7 +1124,7 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
if (! grub_hfs_find_node (data, (char *) &key, data->cat_root, if (! grub_hfs_find_node (data, (char *) &key, data->cat_root,
0, (char *) &fdrec.frec, sizeof (fdrec.frec))) 0, (char *) &fdrec.frec, sizeof (fdrec.frec)))
{ {
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", origpath); grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
goto fail; goto fail;
} }
@ -1207,7 +1208,7 @@ grub_hfs_dir (grub_device_t device, const char *path,
if (frec.type != GRUB_HFS_FILETYPE_DIR) if (frec.type != GRUB_HFS_FILETYPE_DIR)
{ {
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
goto fail; goto fail;
} }
@ -1243,7 +1244,7 @@ grub_hfs_open (struct grub_file *file, const char *name)
if (frec.type != GRUB_HFS_FILETYPE_FILE) if (frec.type != GRUB_HFS_FILETYPE_FILE)
{ {
grub_free (data); grub_free (data);
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a file"); grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
grub_dl_unref (my_mod); grub_dl_unref (my_mod);
return grub_errno; return grub_errno;
} }

View file

@ -25,6 +25,7 @@
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/types.h> #include <grub/types.h>
#include <grub/charset.h> #include <grub/charset.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -403,7 +404,7 @@ grub_jfs_opendir (struct grub_jfs_data *data, struct grub_jfs_inode *inode)
if (!((grub_le_to_cpu32 (inode->mode) if (!((grub_le_to_cpu32 (inode->mode)
& GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_DIR)) & GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_DIR))
{ {
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0; return 0;
} }
@ -704,7 +705,7 @@ grub_jfs_find_file (struct grub_jfs_data *data, const char *path,
} }
grub_jfs_closedir (diro); grub_jfs_closedir (diro);
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path); grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
return grub_errno; return grub_errno;
} }
@ -716,7 +717,7 @@ grub_jfs_lookup_symlink (struct grub_jfs_data *data, grub_uint32_t ino)
char symlink[size + 1]; char symlink[size + 1];
if (++data->linknest > GRUB_JFS_MAX_SYMLNK_CNT) if (++data->linknest > GRUB_JFS_MAX_SYMLNK_CNT)
return grub_error (GRUB_ERR_SYMLINK_LOOP, "too deep nesting of symlinks"); return grub_error (GRUB_ERR_SYMLINK_LOOP, N_("too deep nesting of symlinks"));
if (size <= sizeof (data->currinode.symlink.path)) if (size <= sizeof (data->currinode.symlink.path))
grub_strncpy (symlink, (char *) (data->currinode.symlink.path), size); grub_strncpy (symlink, (char *) (data->currinode.symlink.path), size);
@ -730,8 +731,6 @@ grub_jfs_lookup_symlink (struct grub_jfs_data *data, grub_uint32_t ino)
ino = 2; ino = 2;
grub_jfs_find_file (data, symlink, ino); grub_jfs_find_file (data, symlink, ino);
if (grub_errno)
grub_error (grub_errno, "cannot follow symlink `%s'", symlink);
return grub_errno; return grub_errno;
} }
@ -810,7 +809,7 @@ grub_jfs_open (struct grub_file *file, const char *name)
if (! ((grub_le_to_cpu32 (data->currinode.mode) if (! ((grub_le_to_cpu32 (data->currinode.mode)
& GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_REG)) & GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_REG))
{ {
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a regular file"); grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
goto fail; goto fail;
} }

View file

@ -24,6 +24,7 @@
#include <grub/disk.h> #include <grub/disk.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/types.h> #include <grub/types.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -332,7 +333,7 @@ grub_minix_lookup_symlink (struct grub_minix_data *data, int ino)
char symlink[GRUB_MINIX_INODE_SIZE (data) + 1]; char symlink[GRUB_MINIX_INODE_SIZE (data) + 1];
if (++data->linknest > GRUB_MINIX_MAX_SYMLNK_CNT) if (++data->linknest > GRUB_MINIX_MAX_SYMLNK_CNT)
return grub_error (GRUB_ERR_SYMLINK_LOOP, "too deep nesting of symlinks"); return grub_error (GRUB_ERR_SYMLINK_LOOP, N_("too deep nesting of symlinks"));
if (grub_minix_read_file (data, 0, 0, if (grub_minix_read_file (data, 0, 0,
GRUB_MINIX_INODE_SIZE (data), symlink) < 0) GRUB_MINIX_INODE_SIZE (data), symlink) < 0)
@ -349,8 +350,6 @@ grub_minix_lookup_symlink (struct grub_minix_data *data, int ino)
return grub_errno; return grub_errno;
grub_minix_find_file (data, symlink); grub_minix_find_file (data, symlink);
if (grub_errno)
grub_error (grub_errno, "cannot follow symlink `%s'", symlink);
return grub_errno; return grub_errno;
} }
@ -433,7 +432,7 @@ grub_minix_find_file (struct grub_minix_data *data, const char *path)
if ((GRUB_MINIX_INODE_MODE (data) if ((GRUB_MINIX_INODE_MODE (data)
& GRUB_MINIX_IFDIR) != GRUB_MINIX_IFDIR) & GRUB_MINIX_IFDIR) != GRUB_MINIX_IFDIR)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
continue; continue;
} }
@ -441,7 +440,7 @@ grub_minix_find_file (struct grub_minix_data *data, const char *path)
pos += sizeof (ino) + data->filename_size; pos += sizeof (ino) + data->filename_size;
} while (pos < GRUB_MINIX_INODE_SIZE (data)); } while (pos < GRUB_MINIX_INODE_SIZE (data));
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path); grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
return grub_errno; return grub_errno;
} }
@ -532,7 +531,7 @@ grub_minix_dir (grub_device_t device, const char *path,
if ((GRUB_MINIX_INODE_MODE (data) & GRUB_MINIX_IFDIR) != GRUB_MINIX_IFDIR) if ((GRUB_MINIX_INODE_MODE (data) & GRUB_MINIX_IFDIR) != GRUB_MINIX_IFDIR)
{ {
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
goto fail; goto fail;
} }
@ -600,7 +599,7 @@ grub_minix_open (struct grub_file *file, const char *name)
if (!name || name[0] != '/') if (!name || name[0] != '/')
{ {
grub_error (GRUB_ERR_BAD_FILENAME, "bad filename"); grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), name);
return grub_errno; return grub_errno;
} }

View file

@ -38,6 +38,7 @@
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/types.h> #include <grub/types.h>
#include <grub/fshelp.h> #include <grub/fshelp.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -477,6 +478,7 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data,
grub_uint16_t previous_level = ~0; grub_uint16_t previous_level = ~0;
struct grub_reiserfs_item_header *item_headers = 0; struct grub_reiserfs_item_header *item_headers = 0;
#if 0
if (! data) if (! data)
{ {
grub_error (GRUB_ERR_BAD_FS, "data is NULL"); grub_error (GRUB_ERR_BAD_FS, "data is NULL");
@ -494,6 +496,7 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data,
grub_error (GRUB_ERR_BAD_FS, "item is NULL"); grub_error (GRUB_ERR_BAD_FS, "item is NULL");
goto fail; goto fail;
} }
#endif
block_size = grub_le_to_cpu16 (data->superblock.block_size); block_size = grub_le_to_cpu16 (data->superblock.block_size);
block_number = grub_le_to_cpu32 (data->superblock.root_block); block_number = grub_le_to_cpu32 (data->superblock.root_block);
@ -725,8 +728,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
if (item->type != GRUB_REISERFS_DIRECTORY) if (item->type != GRUB_REISERFS_DIRECTORY)
{ {
grub_error (GRUB_ERR_BAD_FILE_TYPE, grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
"grub_reiserfs_iterate_dir called on a non-directory item");
goto fail; goto fail;
} }
block_size = grub_le_to_cpu16 (data->superblock.block_size); block_size = grub_le_to_cpu16 (data->superblock.block_size);
@ -754,7 +756,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
#if 0 #if 0
if (grub_le_to_cpu16 (block_header->level) != 1) if (grub_le_to_cpu16 (block_header->level) != 1)
{ {
grub_error (GRUB_ERR_TEST_FAILURE, grub_error (GRUB_ERR_BAD_FS,
"reiserfs: block %d is not a leaf block", "reiserfs: block %d is not a leaf block",
block_number); block_number);
goto fail; goto fail;

View file

@ -24,6 +24,7 @@
#include <grub/disk.h> #include <grub/disk.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/types.h> #include <grub/types.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -398,7 +399,7 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino)
char symlink[INODE_SIZE (data) + 1]; char symlink[INODE_SIZE (data) + 1];
if (++data->linknest > GRUB_UFS_MAX_SYMLNK_CNT) if (++data->linknest > GRUB_UFS_MAX_SYMLNK_CNT)
return grub_error (GRUB_ERR_SYMLINK_LOOP, "too deep nesting of symlinks"); return grub_error (GRUB_ERR_SYMLINK_LOOP, N_("too deep nesting of symlinks"));
if (INODE_SIZE (data) <= sizeof (data->inode.symlink)) if (INODE_SIZE (data) <= sizeof (data->inode.symlink))
grub_strcpy (symlink, (char *) INODE (data, symlink)); grub_strcpy (symlink, (char *) INODE (data, symlink));
@ -415,8 +416,6 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino)
return grub_errno; return grub_errno;
grub_ufs_find_file (data, symlink); grub_ufs_find_file (data, symlink);
if (grub_errno)
grub_error (grub_errno, "cannot follow symlink `%s'", symlink);
return grub_errno; return grub_errno;
} }
@ -504,7 +503,7 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
} }
if ((INODE_MODE(data) & GRUB_UFS_ATTR_TYPE) != GRUB_UFS_ATTR_DIR) if ((INODE_MODE(data) & GRUB_UFS_ATTR_TYPE) != GRUB_UFS_ATTR_DIR)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
continue; continue;
} }
@ -513,7 +512,7 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
pos += grub_le_to_cpu16 (dirent.direntlen); pos += grub_le_to_cpu16 (dirent.direntlen);
} while (pos < INODE_SIZE (data)); } while (pos < INODE_SIZE (data));
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file `%s' not found", path); grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
return grub_errno; return grub_errno;
} }
@ -589,7 +588,7 @@ grub_ufs_dir (grub_device_t device, const char *path,
if (!path || path[0] != '/') if (!path || path[0] != '/')
{ {
grub_error (GRUB_ERR_BAD_FILENAME, "bad filename"); grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
return grub_errno; return grub_errno;
} }
@ -599,7 +598,7 @@ grub_ufs_dir (grub_device_t device, const char *path,
if ((INODE_MODE (data) & GRUB_UFS_ATTR_TYPE) != GRUB_UFS_ATTR_DIR) if ((INODE_MODE (data) & GRUB_UFS_ATTR_TYPE) != GRUB_UFS_ATTR_DIR)
{ {
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
goto fail; goto fail;
} }
@ -669,7 +668,7 @@ grub_ufs_open (struct grub_file *file, const char *name)
if (!name || name[0] != '/') if (!name || name[0] != '/')
{ {
grub_error (GRUB_ERR_BAD_FILENAME, "bad filename"); grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), name);
return grub_errno; return grub_errno;
} }

View file

@ -53,6 +53,7 @@
#include <grub/zfs/dsl_dataset.h> #include <grub/zfs/dsl_dataset.h>
#include <grub/deflate.h> #include <grub/deflate.h>
#include <grub/crypto.h> #include <grub/crypto.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -1766,7 +1767,7 @@ mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian,
} }
} }
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "couldn't find %s", name); return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), name);
} }
static int static int
@ -1971,7 +1972,7 @@ zap_leaf_lookup (zap_leaf_phys_t * l, grub_zfs_endian_t endian,
} }
} }
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "couldn't find %s", name); return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), name);
} }
@ -2487,7 +2488,7 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
if (dnode_path->dn.dn.dn_type != DMU_OT_DIRECTORY_CONTENTS) if (dnode_path->dn.dn.dn_type != DMU_OT_DIRECTORY_CONTENTS)
{ {
grub_free (path_buf); grub_free (path_buf);
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
} }
err = zap_lookup (&(dnode_path->dn), cname, &objnum, err = zap_lookup (&(dnode_path->dn), cname, &objnum,
data, subvol->case_insensitive); data, subvol->case_insensitive);
@ -3483,14 +3484,14 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename)
if (isfs) if (isfs)
{ {
zfs_unmount (data); zfs_unmount (data);
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "Missing @ or / separator"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("missing `%c' symbol"), '@');
} }
/* We found the dnode for this file. Verify if it is a plain file. */ /* We found the dnode for this file. Verify if it is a plain file. */
if (data->dnode.dn.dn_type != DMU_OT_PLAIN_FILE_CONTENTS) if (data->dnode.dn.dn_type != DMU_OT_PLAIN_FILE_CONTENTS)
{ {
zfs_unmount (data); zfs_unmount (data);
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a file"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
} }
/* get the file size and set the file position to 0 */ /* get the file size and set the file position to 0 */
@ -3882,7 +3883,7 @@ grub_zfs_dir (grub_device_t device, const char *path,
if (data->dnode.dn.dn_type != DMU_OT_DIRECTORY_CONTENTS) if (data->dnode.dn.dn_type != DMU_OT_DIRECTORY_CONTENTS)
{ {
zfs_unmount (data); zfs_unmount (data);
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
} }
zap_iterate_u64 (&(data->dnode), iterate_zap, data); zap_iterate_u64 (&(data->dnode), iterate_zap, data);
} }
@ -3905,8 +3906,8 @@ grub_zfs_embed (grub_device_t device __attribute__ ((unused)),
if ((VDEV_BOOT_SIZE >> GRUB_DISK_SECTOR_BITS) < *nsectors) if ((VDEV_BOOT_SIZE >> GRUB_DISK_SECTOR_BITS) < *nsectors)
return grub_error (GRUB_ERR_OUT_OF_RANGE, return grub_error (GRUB_ERR_OUT_OF_RANGE,
"Your core.img is unusually large. " N_("your core.img is unusually large. "
"It won't fit in the embedding area."); "It won't fit in the embedding area"));
*nsectors = (VDEV_BOOT_SIZE >> GRUB_DISK_SECTOR_BITS); *nsectors = (VDEV_BOOT_SIZE >> GRUB_DISK_SECTOR_BITS);
*sectors = grub_malloc (*nsectors * sizeof (**sectors)); *sectors = grub_malloc (*nsectors * sizeof (**sectors));

View file

@ -45,31 +45,32 @@ print_state (char *nvlist, int tab)
int isok = 1; int isok = 1;
print_tabs (tab); print_tabs (tab);
grub_xputs (_("State: "));
if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_REMOVED, &ival)) if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_REMOVED, &ival))
{ {
grub_xputs (_("removed ")); grub_puts_ (N_("Virtual device is removed"));
isok = 0; isok = 0;
} }
if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival)) if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival))
{ {
grub_xputs (_("faulted ")); grub_puts_ (N_("Virtual device is faulted"));
isok = 0; isok = 0;
} }
if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_OFFLINE, &ival)) if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_OFFLINE, &ival))
{ {
grub_xputs (_("offline ")); grub_puts_ (N_("Virtual device is offline"));
isok = 0; isok = 0;
} }
if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival)) if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival))
grub_xputs (_("degraded ")); /* TRANSLATORS: degraded doesn't mean broken but that some of
component are missing but virtual device as whole is still usable. */
grub_puts_ (N_("Virtual device is degraded"));
if (isok) if (isok)
grub_xputs (_("online")); grub_puts_ (N_("Virtual device is online"));
grub_xputs ("\n"); grub_xputs ("\n");
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
@ -85,7 +86,7 @@ print_vdev_info (char *nvlist, int tab)
if (!type) if (!type)
{ {
print_tabs (tab); print_tabs (tab);
grub_puts_ (N_("Incorrect VDEV: no type available")); grub_puts_ (N_("Incorrect virtual device: no type available"));
return grub_errno; return grub_errno;
} }
@ -96,7 +97,7 @@ print_vdev_info (char *nvlist, int tab)
char *devid = 0; char *devid = 0;
print_tabs (tab); print_tabs (tab);
grub_puts_ (N_("Leaf VDEV")); grub_puts_ (N_("Leaf virtual device (file or disk)"));
print_state (nvlist, tab); print_state (nvlist, tab);
@ -137,10 +138,10 @@ print_vdev_info (char *nvlist, int tab)
print_tabs (tab); print_tabs (tab);
if (nelm <= 0) if (nelm <= 0)
{ {
grub_puts_ (N_("Incorrect mirror VDEV")); grub_puts_ (N_("Incorrect mirror"));
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
grub_printf_ (N_("Mirror VDEV with %d children\n"), nelm); grub_printf_ (N_("Mirror with %d children\n"), nelm);
print_state (nvlist, tab); print_state (nvlist, tab);
for (i = 0; i < nelm; i++) for (i = 0; i < nelm; i++)
{ {
@ -152,11 +153,11 @@ print_vdev_info (char *nvlist, int tab)
print_tabs (tab); print_tabs (tab);
if (!child) if (!child)
{ {
grub_printf_ (N_("Mirror VDEV element %d isn't correct\n"), i); grub_printf_ (N_("Mirror element %d isn't correct\n"), i);
continue; continue;
} }
grub_printf_ (N_("Mirror VDEV element %d:\n"), i); grub_printf_ (N_("Mirror element %d:\n"), i);
print_vdev_info (child, tab + 1); print_vdev_info (child, tab + 1);
grub_free (child); grub_free (child);
@ -165,7 +166,7 @@ print_vdev_info (char *nvlist, int tab)
} }
print_tabs (tab); print_tabs (tab);
grub_printf_ (N_("Unknown VDEV type: %s\n"), type); grub_printf_ (N_("Unknown virtual device type: %s\n"), type);
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
@ -298,7 +299,7 @@ grub_cmd_zfsinfo (grub_command_t cmd __attribute__ ((unused)), int argc,
nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE); nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE);
if (!nv) if (!nv)
grub_puts_ (N_("No vdev tree available")); grub_puts_ (N_("No virtual device tree available"));
else else
print_vdev_info (nv, 1); print_vdev_info (nv, 1);

View file

@ -36,6 +36,7 @@
#include <grub/gfxmenu_model.h> #include <grub/gfxmenu_model.h>
#include <grub/gfxmenu_view.h> #include <grub/gfxmenu_view.h>
#include <grub/time.h> #include <grub/time.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -58,7 +59,8 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
theme_path = grub_env_get ("theme"); theme_path = grub_env_get ("theme");
if (! theme_path) if (! theme_path)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "no theme specified"); return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"),
"theme");
instance = grub_zalloc (sizeof (*instance)); instance = grub_zalloc (sizeof (*instance));
if (!instance) if (!instance)

View file

@ -151,11 +151,6 @@ rescale_image (grub_gui_image_t self)
height, height,
self->raw_bitmap, self->raw_bitmap,
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST); GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
if (grub_errno != GRUB_ERR_NONE)
{
grub_error_push ();
grub_error (grub_errno, "failed to scale bitmap for image component");
}
return grub_errno; return grub_errno;
} }
@ -224,7 +219,7 @@ image_set_property (void *vself, const char *name, const char *value)
/* Resolve to an absolute path. */ /* Resolve to an absolute path. */
if (! self->theme_dir) if (! self->theme_dir)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unspecified theme_dir"); return grub_error (GRUB_ERR_BUG, "unspecified theme_dir");
absvalue = grub_resolve_relative_path (self->theme_dir, value); absvalue = grub_resolve_relative_path (self->theme_dir, value);
if (! absvalue) if (! absvalue)
return grub_errno; return grub_errno;

View file

@ -169,11 +169,7 @@ try_loading_icon (grub_gfxmenu_icon_manager_t mgr,
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST); GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
grub_video_bitmap_destroy (raw_bitmap); grub_video_bitmap_destroy (raw_bitmap);
if (! scaled_bitmap) if (! scaled_bitmap)
{
grub_error_push ();
grub_error (grub_errno, "failed to scale icon");
return 0; return 0;
}
return scaled_bitmap; return scaled_bitmap;
} }

View file

@ -130,12 +130,6 @@ scale_pixmap (grub_gfxmenu_box_t self, int i, int w, int h)
if (w != 0 && h != 0) if (w != 0 && h != 0)
grub_video_bitmap_create_scaled (scaled, w, h, raw, grub_video_bitmap_create_scaled (scaled, w, h, raw,
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST); GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST);
if (grub_errno != GRUB_ERR_NONE)
{
grub_error_push ();
grub_error (grub_errno,
"failed to scale bitmap for styled box pixmap #%d", i);
}
} }
return grub_errno; return grub_errno;

View file

@ -42,6 +42,7 @@
#include <grub/file.h> #include <grub/file.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/deflate.h> #include <grub/deflate.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@ -193,10 +194,7 @@ test_gzip_header (grub_file_t file)
if (grub_file_read (gzio->file, &hdr, 10) != 10 if (grub_file_read (gzio->file, &hdr, 10) != 10
|| ((hdr.magic != GZIP_MAGIC) || ((hdr.magic != GZIP_MAGIC)
&& (hdr.magic != OLD_GZIP_MAGIC))) && (hdr.magic != OLD_GZIP_MAGIC)))
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no gzip magic found");
return 0; return 0;
}
/* /*
* This does consistency checking on the header data. If a * This does consistency checking on the header data. If a
@ -211,10 +209,7 @@ test_gzip_header (grub_file_t file)
grub_le_to_cpu16 (extra_len)))) grub_le_to_cpu16 (extra_len))))
|| ((hdr.flags & ORIG_NAME) && eat_field (gzio->file, -1)) || ((hdr.flags & ORIG_NAME) && eat_field (gzio->file, -1))
|| ((hdr.flags & COMMENT) && eat_field (gzio->file, -1))) || ((hdr.flags & COMMENT) && eat_field (gzio->file, -1)))
{
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "unsupported gzip format");
return 0; return 0;
}
gzio->data_offset = grub_file_tell (gzio->file); gzio->data_offset = grub_file_tell (gzio->file);
@ -222,10 +217,7 @@ test_gzip_header (grub_file_t file)
{ {
grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4); grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4);
if (grub_file_read (gzio->file, &orig_len, 4) != 4) if (grub_file_read (gzio->file, &orig_len, 4) != 4)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
return 0; return 0;
}
/* FIXME: this does not handle files whose original size is over 4GB. /* FIXME: this does not handle files whose original size is over 4GB.
But how can we know the real original size? */ But how can we know the real original size? */
file->size = grub_le_to_cpu32 (orig_len); file->size = grub_le_to_cpu32 (orig_len);
@ -402,7 +394,7 @@ gzio_seek (grub_gzio_t gzio, grub_off_t off)
{ {
if (off > gzio->mem_input_size) if (off > gzio->mem_input_size)
grub_error (GRUB_ERR_OUT_OF_RANGE, grub_error (GRUB_ERR_OUT_OF_RANGE,
"attempt to seek outside of the file"); N_("attempt to seek outside of the file"));
else else
gzio->mem_input_off = off; gzio->mem_input_off = off;
} }
@ -1158,10 +1150,10 @@ grub_gzio_open (grub_file_t io)
if (! test_gzip_header (file)) if (! test_gzip_header (file))
{ {
grub_errno = GRUB_ERR_NONE;
grub_free (gzio); grub_free (gzio);
grub_free (file); grub_free (file);
grub_file_seek (io, 0); grub_file_seek (io, 0);
grub_errno = GRUB_ERR_NONE;
return io; return io;
} }

View file

@ -299,31 +299,17 @@ test_header (grub_file_t file)
grub_uint8_t *name = NULL; grub_uint8_t *name = NULL;
if (grub_file_read (lzopio->file, &header, sizeof (header)) != sizeof (header)) if (grub_file_read (lzopio->file, &header, sizeof (header)) != sizeof (header))
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no lzop magic found");
return 0; return 0;
}
if (grub_memcmp (header.magic, LZOP_MAGIC, LZOP_MAGIC_SIZE) != 0) if (grub_memcmp (header.magic, LZOP_MAGIC, LZOP_MAGIC_SIZE) != 0)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no lzop magic found");
return 0; return 0;
}
if (grub_be_to_cpu16(header.lib_version) < LZOP_NEW_LIB) if (grub_be_to_cpu16(header.lib_version) < LZOP_NEW_LIB)
{
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"unsupported (too old) LZOP version");
return 0; return 0;
}
/* Too new version, should upgrade minilzo? */ /* Too new version, should upgrade minilzo? */
if (grub_be_to_cpu16 (header.lib_version_ext) > MINILZO_VERSION) if (grub_be_to_cpu16 (header.lib_version_ext) > MINILZO_VERSION)
{
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
"unsupported (too new) LZO version");
return 0; return 0;
}
flags = grub_be_to_cpu32 (header.flags); flags = grub_be_to_cpu32 (header.flags);
@ -417,8 +403,6 @@ test_header (grub_file_t file)
return 1; return 1;
CORRUPTED: CORRUPTED:
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "lzop file corrupted");
grub_free(name); grub_free(name);
return 0; return 0;

View file

@ -98,24 +98,15 @@ test_header (grub_file_t file)
STREAM_HEADER_SIZE); STREAM_HEADER_SIZE);
if (xzio->buf.in_size != STREAM_HEADER_SIZE) if (xzio->buf.in_size != STREAM_HEADER_SIZE)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no xz magic found");
return 0; return 0;
}
ret = xz_dec_run (xzio->dec, &xzio->buf); ret = xz_dec_run (xzio->dec, &xzio->buf);
if (ret == XZ_FORMAT_ERROR) if (ret == XZ_FORMAT_ERROR)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "no xz magic found");
return 0; return 0;
}
if (ret != XZ_OK) if (ret != XZ_OK)
{
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "not supported xz options");
return 0; return 0;
}
return 1; return 1;
} }
@ -174,7 +165,6 @@ test_footer (grub_file_t file)
return 1; return 1;
ERROR: ERROR:
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "bad footer magic");
return 0; return 0;
} }

View file

@ -25,6 +25,7 @@
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/env.h> #include <grub/env.h>
#include <grub/partition.h> #include <grub/partition.h>
#include <grub/i18n.h>
grub_net_t (*grub_net_open) (const char *name) = NULL; 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"); name = grub_env_get ("root");
if (name == NULL || *name == '\0') 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; goto fail;
} }
} }

View file

@ -24,6 +24,7 @@
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/time.h> #include <grub/time.h>
#include <grub/file.h> #include <grub/file.h>
#include <grub/i18n.h>
#define GRUB_CACHE_TIMEOUT 2 #define GRUB_CACHE_TIMEOUT 2
@ -263,7 +264,8 @@ grub_disk_open (const char *name)
if (! dev) 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; goto fail;
} }
if (disk->log_sector_size > GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS 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 if (*sector >= len
|| len - *sector < ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1) || len - *sector < ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
>> GRUB_DISK_SECTOR_BITS)) >> 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; *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 >> GRUB_DISK_SECTOR_BITS) > (disk->total_sectors
<< (disk->log_sector_size << (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS)) - *sector)) - 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; return GRUB_ERR_NONE;
} }

View file

@ -31,6 +31,7 @@
#include <grub/file.h> #include <grub/file.h>
#include <grub/env.h> #include <grub/env.h>
#include <grub/cache.h> #include <grub/cache.h>
#include <grub/i18n.h>
/* Platforms where modules are in a readonly area of memory. */ /* Platforms where modules are in a readonly area of memory. */
#if defined(GRUB_MACHINE_QEMU) #if defined(GRUB_MACHINE_QEMU)
@ -208,20 +209,24 @@ static grub_err_t
grub_dl_check_header (void *ehdr, grub_size_t size) grub_dl_check_header (void *ehdr, grub_size_t size)
{ {
Elf_Ehdr *e = ehdr; Elf_Ehdr *e = ehdr;
grub_err_t err;
/* Check the header size. */ /* Check the header size. */
if (size < sizeof (Elf_Ehdr)) if (size < sizeof (Elf_Ehdr))
return grub_error (GRUB_ERR_BAD_OS, "ELF header smaller than expected"); return grub_error (GRUB_ERR_BAD_OS, "ELF header smaller than expected");
/* Check the magic numbers. */ /* Check the magic numbers. */
if (grub_arch_dl_check_header (ehdr) if (e->e_ident[EI_MAG0] != ELFMAG0
|| e->e_ident[EI_MAG0] != ELFMAG0
|| e->e_ident[EI_MAG1] != ELFMAG1 || e->e_ident[EI_MAG1] != ELFMAG1
|| e->e_ident[EI_MAG2] != ELFMAG2 || e->e_ident[EI_MAG2] != ELFMAG2
|| e->e_ident[EI_MAG3] != ELFMAG3 || e->e_ident[EI_MAG3] != ELFMAG3
|| e->e_ident[EI_VERSION] != EV_CURRENT || e->e_ident[EI_VERSION] != EV_CURRENT
|| e->e_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; return GRUB_ERR_NONE;
} }
@ -345,7 +350,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
break; break;
if (i == e->e_shnum) 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 #ifdef GRUB_MODULES_MACHINE_READONLY
mod->symtab = grub_malloc (s->sh_size); 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); grub_symbol_t nsym = grub_dl_resolve_symbol (name);
if (! nsym) if (! nsym)
return grub_error (GRUB_ERR_BAD_MODULE, 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; sym->st_value = (Elf_Addr) nsym->addr;
if (nsym->isfunc) if (nsym->isfunc)
sym->st_info = ELF_ST_INFO (bind, STT_FUNC); 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) 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; return 0;
} }
@ -704,7 +709,7 @@ grub_dl_load (const char *name)
return mod; return mod;
if (! grub_dl_dir) { 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; return 0;
} }

View file

@ -24,6 +24,7 @@
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); 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_MAG3] != ELFMAG3
|| e->e_ident[EI_VERSION] != EV_CURRENT || e->e_ident[EI_VERSION] != EV_CURRENT
|| e->e_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; return GRUB_ERR_NONE;
} }
@ -59,7 +60,7 @@ grub_elf_close (grub_elf_t elf)
} }
grub_elf_t grub_elf_t
grub_elf_file (grub_file_t file) grub_elf_file (grub_file_t file, const char *filename)
{ {
grub_elf_t elf; 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)) if (grub_file_read (elf->file, &elf->ehdr, sizeof (elf->ehdr))
!= sizeof (elf->ehdr)) != sizeof (elf->ehdr))
{ {
grub_error_push (); if (!grub_errno)
grub_error (GRUB_ERR_READ_ERROR, "cannot read ELF header"); grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
goto fail; goto fail;
} }
@ -101,7 +103,7 @@ grub_elf_open (const char *name)
if (! file) if (! file)
return 0; return 0;
elf = grub_elf_file (file); elf = grub_elf_file (file, name);
if (! elf) if (! elf)
grub_file_close (file); grub_file_close (file);
@ -118,7 +120,7 @@ grub_elf_is_elf32 (grub_elf_t elf)
} }
static grub_err_t 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; 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) 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_file_read (elf->file, elf->phdrs, phdrs_size) != phdrs_size))
{ {
grub_error_push (); if (!grub_errno)
return grub_error (GRUB_ERR_READ_ERROR, "cannot read program headers"); grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
return grub_errno;
} }
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
@ -144,6 +148,7 @@ grub_elf32_load_phdrs (grub_elf_t elf)
grub_err_t grub_err_t
grub_elf32_phdr_iterate (grub_elf_t elf, grub_elf32_phdr_iterate (grub_elf_t elf,
const char *filename,
int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf32_Phdr *, void *), int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf32_Phdr *, void *),
void *hook_arg) void *hook_arg)
{ {
@ -151,7 +156,7 @@ grub_elf32_phdr_iterate (grub_elf_t elf,
unsigned int i; unsigned int i;
if (! elf->phdrs) if (! elf->phdrs)
if (grub_elf32_load_phdrs (elf)) if (grub_elf32_load_phdrs (elf, filename))
return grub_errno; return grub_errno;
phdrs = elf->phdrs; phdrs = elf->phdrs;
@ -174,7 +179,8 @@ grub_elf32_phdr_iterate (grub_elf_t elf,
/* Calculate the amount of memory spanned by the segments. */ /* Calculate the amount of memory spanned by the segments. */
grub_size_t 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_start = (Elf32_Addr) -1;
Elf32_Addr segments_end = 0; 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; return 0;
} }
grub_elf32_phdr_iterate (elf, calcsize, 0); grub_elf32_phdr_iterate (elf, filename, calcsize, 0);
if (base) if (base)
*base = 0; *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'. */ /* Load every loadable segment into memory specified by `_load_hook'. */
grub_err_t 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 *base, grub_size_t *size)
{ {
grub_addr_t load_base = (grub_addr_t) -1ULL; 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); (unsigned long long) phdr->p_memsz);
if (grub_file_seek (elf->file, phdr->p_offset) == (grub_off_t) -1) if (grub_file_seek (elf->file, phdr->p_offset) == (grub_off_t) -1)
{ return grub_errno;
grub_error_push ();
return grub_error (GRUB_ERR_BAD_OS,
"invalid offset in program header");
}
if (phdr->p_filesz) 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) if (read != (grub_ssize_t) phdr->p_filesz)
{ {
/* XXX How can we free memory from `load_hook'? */ /* XXX How can we free memory from `load_hook'? */
grub_error_push (); if (!grub_errno)
return grub_error (GRUB_ERR_BAD_OS, grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
"couldn't read segment from file: " filename);
"wanted 0x%lx bytes; read 0x%lx bytes", return grub_errno;
phdr->p_filesz, read);
} }
} }
@ -287,7 +289,8 @@ grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook,
return 0; 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) if (base)
*base = load_base; *base = load_base;
@ -307,7 +310,7 @@ grub_elf_is_elf64 (grub_elf_t elf)
} }
static grub_err_t 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; 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) 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_file_read (elf->file, elf->phdrs, phdrs_size) != phdrs_size))
{ {
grub_error_push (); if (!grub_errno)
return grub_error (GRUB_ERR_READ_ERROR, "cannot read program headers"); grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
return grub_errno;
} }
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
@ -333,6 +338,7 @@ grub_elf64_load_phdrs (grub_elf_t elf)
grub_err_t grub_err_t
grub_elf64_phdr_iterate (grub_elf_t elf, grub_elf64_phdr_iterate (grub_elf_t elf,
const char *filename,
int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf64_Phdr *, void *), int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf64_Phdr *, void *),
void *hook_arg) void *hook_arg)
{ {
@ -340,7 +346,7 @@ grub_elf64_phdr_iterate (grub_elf_t elf,
unsigned int i; unsigned int i;
if (! elf->phdrs) if (! elf->phdrs)
if (grub_elf64_load_phdrs (elf)) if (grub_elf64_load_phdrs (elf, filename))
return grub_errno; return grub_errno;
phdrs = elf->phdrs; phdrs = elf->phdrs;
@ -363,7 +369,8 @@ grub_elf64_phdr_iterate (grub_elf_t elf,
/* Calculate the amount of memory spanned by the segments. */ /* Calculate the amount of memory spanned by the segments. */
grub_size_t 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_start = (Elf64_Addr) -1;
Elf64_Addr segments_end = 0; 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; return 0;
} }
grub_elf64_phdr_iterate (elf, calcsize, 0); grub_elf64_phdr_iterate (elf, filename, calcsize, 0);
if (base) if (base)
*base = 0; *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'. */ /* Load every loadable segment into memory specified by `_load_hook'. */
grub_err_t 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 *base, grub_size_t *size)
{ {
grub_addr_t load_base = (grub_addr_t) -1ULL; 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); (unsigned long long) phdr->p_memsz);
if (grub_file_seek (elf->file, phdr->p_offset) == (grub_off_t) -1) if (grub_file_seek (elf->file, phdr->p_offset) == (grub_off_t) -1)
{ return grub_errno;
grub_error_push ();
return grub_error (GRUB_ERR_BAD_OS,
"invalid offset in program header");
}
if (phdr->p_filesz) 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) if (read != (grub_ssize_t) phdr->p_filesz)
{ {
/* XXX How can we free memory from `load_hook'? */ /* XXX How can we free memory from `load_hook'? */
grub_error_push (); if (!grub_errno)
return grub_error (GRUB_ERR_BAD_OS, grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
"couldn't read segment from file: " filename);
"wanted 0x%lx bytes; read 0x%lx bytes", return grub_errno;
phdr->p_filesz, read);
} }
} }
@ -477,7 +480,8 @@ grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook,
return 0; 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) if (base)
*base = load_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); fd = open (map[drive].device, O_RDONLY);
if (fd == -1) 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->total_sectors = grub_util_get_fd_sectors (fd, map[drive].device,
&disk->log_sector_size); &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); error = geom_gettree (&mesh);
if (error != 0) if (error != 0)
/* TRANSLATORS: geom is the name of (k)FreeBSD device framework.
Usually left untranslated.
*/
grub_util_error (_("couldn't open geom")); grub_util_error (_("couldn't open geom"));
LIST_FOREACH (class, &mesh.lg_class, lg_class) LIST_FOREACH (class, &mesh.lg_class, lg_class)
if (strcasecmp (class->lg_name, "part") == 0) if (strcasecmp (class->lg_name, "part") == 0)
break; break;
if (!class) 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) LIST_FOREACH (geom, &class->lg_geom, lg_geom)
{ {
@ -563,12 +570,8 @@ devmapper_fail:
fd = open (dev, O_RDONLY); fd = open (dev, O_RDONLY);
if (fd == -1) if (fd == -1)
{ {
grub_error (GRUB_ERR_BAD_DEVICE, grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot open `%s': %s"),
# if !defined(HAVE_DIOCGDINFO) dev, strerror (errno));
"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) */
return 0; return 0;
} }
@ -736,9 +739,8 @@ grub_util_fd_seek (int fd, const char *name, grub_uint64_t off)
offset = (loff_t) off; offset = (loff_t) off;
if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET)) if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
{ return grub_error (GRUB_ERR_BAD_DEVICE, N_("cannot seek `%s': %s"),
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot seek `%s'", name); name, strerror (errno));
}
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
#else #else
@ -748,7 +750,8 @@ grub_util_fd_seek (int fd, const char *name, grub_uint64_t off)
off_t offset = (off_t) off; off_t offset = (off_t) off;
if (lseek (fd, offset, SEEK_SET) != offset) 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; return 0;
} }
#endif #endif
@ -842,7 +845,8 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
fd = open (dev, flags); fd = open (dev, flags);
if (fd < 0) 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; return -1;
} }
@ -922,7 +926,8 @@ open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags)
if (fd < 0) 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; return -1;
} }
#endif /* ! __linux__ */ #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)) if (grub_util_fd_read (fd, buf, (1 << disk->log_sector_size))
!= (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; 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) if (grub_util_fd_read (fd, buf, size << disk->log_sector_size)
!= (ssize_t) (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; 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) if (grub_util_fd_write (fd, buf, size << disk->log_sector_size)
!= (ssize_t) (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; return grub_errno;
} }
@ -1172,7 +1180,11 @@ read_device_map (const char *dev_map)
continue; continue;
if (*p != '(') if (*p != '(')
show_error (_("No open parenthesis found")); {
char *tmp;
tmp = xasprintf (_("missing `%c' symbol"), '(');
show_error (tmp);
}
p++; p++;
/* Find a free slot. */ /* Find a free slot. */
@ -1183,7 +1195,11 @@ read_device_map (const char *dev_map)
e = p; e = p;
p = strchr (p, ')'); p = strchr (p, ')');
if (! 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')); map[drive].drive = xmalloc (p - e + sizeof ('\0'));
strncpy (map[drive].drive, e, 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++; p++;
if (*p == '\0') if (*p == '\0')
show_error (_("No filename found")); show_error (_("filename expected"));
/* NUL-terminate the filename. */ /* NUL-terminate the filename. */
e = p; e = p;

View file

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

View file

@ -23,6 +23,7 @@
#include <grub/mm.h> #include <grub/mm.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <grub/i18n.h>
void * void *
grub_malloc (grub_size_t size) grub_malloc (grub_size_t size)
@ -30,7 +31,7 @@ grub_malloc (grub_size_t size)
void *ret; void *ret;
ret = malloc (size); ret = malloc (size);
if (!ret) 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; return ret;
} }
@ -58,7 +59,7 @@ grub_realloc (void *ptr, grub_size_t size)
void *ret; void *ret;
ret = realloc (ptr, size); ret = realloc (ptr, size);
if (!ret) 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; return ret;
} }
@ -77,11 +78,11 @@ grub_memalign (grub_size_t align, grub_size_t size)
#else #else
(void) align; (void) align;
(void) size; (void) size;
grub_util_error (_("grub_memalign is not supported")); grub_util_error (_("grub_memalign is not supported on your system"));
#endif #endif
if (!p) 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; return p;
} }

View file

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

View file

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

View file

@ -21,6 +21,7 @@
#include <grub/elf.h> #include <grub/elf.h>
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/err.h> #include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */ /* Check if EHDR is a valid ELF header. */
grub_err_t grub_err_t
@ -32,7 +33,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS32 if (e->e_ident[EI_CLASS] != ELFCLASS32
|| e->e_ident[EI_DATA] != ELFDATA2LSB || e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_386) || 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; return GRUB_ERR_NONE;
} }
@ -54,7 +55,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break; break;
if (i == e->e_shnum) 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; 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 *addr += (sym->st_value - (Elf_Word) seg->addr
- rel->r_offset); - rel->r_offset);
break; 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/misc.h>
#include <grub/err.h> #include <grub/err.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */ /* Check if EHDR is a valid ELF header. */
grub_err_t grub_err_t
@ -33,7 +34,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS64 if (e->e_ident[EI_CLASS] != ELFCLASS64
|| e->e_ident[EI_DATA] != ELFDATA2LSB || e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_IA_64) || 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; return GRUB_ERR_NONE;
} }
@ -181,7 +182,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break; break;
if (i == e->e_shnum) 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; entsize = s->sh_entsize;
@ -265,7 +266,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break; break;
default: default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, 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)); ELF_R_TYPE (rel->r_info));
} }
} }

View file

@ -23,6 +23,7 @@
#include <grub/err.h> #include <grub/err.h>
#include <grub/cpu/types.h> #include <grub/cpu/types.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/i18n.h>
/* Dummy __gnu_local_gp. Resolved by linker. */ /* Dummy __gnu_local_gp. Resolved by linker. */
static char __gnu_local_gp_dummy; 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_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_MIPS) || e->e_machine != EM_MIPS)
#endif #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; return GRUB_ERR_NONE;
} }
@ -69,7 +70,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break; break;
if (i == e->e_shnum) 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; entsize = s->sh_entsize;
@ -233,7 +234,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
{ {
grub_free (gp); grub_free (gp);
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, 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)); ELF_R_TYPE (rel->r_info));
} }
break; break;

View file

@ -21,6 +21,7 @@
#include <grub/elf.h> #include <grub/elf.h>
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/err.h> #include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */ /* Check if EHDR is a valid ELF header. */
grub_err_t grub_err_t
@ -32,7 +33,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS32 if (e->e_ident[EI_CLASS] != ELFCLASS32
|| e->e_ident[EI_DATA] != ELFDATA2MSB || e->e_ident[EI_DATA] != ELFDATA2MSB
|| e->e_machine != EM_PPC) || 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; return GRUB_ERR_NONE;
} }
@ -112,7 +113,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break; break;
if (i == e->e_shnum) 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; entsize = s->sh_entsize;
@ -195,7 +196,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
default: default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, 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)); ELF_R_TYPE (rel->r_info));
} }
} }

View file

@ -21,6 +21,7 @@
#include <grub/elf.h> #include <grub/elf.h>
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/err.h> #include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */ /* Check if EHDR is a valid ELF header. */
grub_err_t grub_err_t
@ -32,7 +33,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS64 if (e->e_ident[EI_CLASS] != ELFCLASS64
|| e->e_ident[EI_DATA] != ELFDATA2MSB || e->e_ident[EI_DATA] != ELFDATA2MSB
|| e->e_machine != EM_SPARCV9) || 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; return GRUB_ERR_NONE;
} }
@ -55,7 +56,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break; break;
if (i == e->e_shnum) 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; entsize = s->sh_entsize;
@ -134,7 +135,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break; break;
default: default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, 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)); ELF_R_TYPE (rel->r_info));
} }
} }

View file

@ -21,6 +21,7 @@
#include <grub/elf.h> #include <grub/elf.h>
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/err.h> #include <grub/err.h>
#include <grub/i18n.h>
/* Check if EHDR is a valid ELF header. */ /* Check if EHDR is a valid ELF header. */
grub_err_t grub_err_t
@ -32,7 +33,7 @@ grub_arch_dl_check_header (void *ehdr)
if (e->e_ident[EI_CLASS] != ELFCLASS64 if (e->e_ident[EI_CLASS] != ELFCLASS64
|| e->e_ident[EI_DATA] != ELFDATA2LSB || e->e_ident[EI_DATA] != ELFDATA2LSB
|| e->e_machine != EM_X86_64) || 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; return GRUB_ERR_NONE;
} }
@ -54,7 +55,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
break; break;
if (i == e->e_shnum) 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; entsize = s->sh_entsize;
@ -110,7 +111,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
default: default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, 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)); ELF_R_TYPE (rel->r_info));
} }
} }

View file

@ -277,8 +277,9 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
if (! opt) if (! opt)
{ {
char tmp[3] = { '-', *curshort, 0 };
grub_error (GRUB_ERR_BAD_ARGUMENT, grub_error (GRUB_ERR_BAD_ARGUMENT,
"unknown argument `-%c'", *curshort); N_("unknown argument `%s'"), tmp);
goto fail; goto fail;
} }
@ -344,7 +345,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
if (! opt) if (! opt)
{ {
grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown argument `%s'", arg); grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"), arg);
goto fail; goto fail;
} }
} }
@ -355,7 +356,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
if (! option) if (! option)
{ {
grub_error (GRUB_ERR_BAD_ARGUMENT, grub_error (GRUB_ERR_BAD_ARGUMENT,
"missing mandatory option for `%s'", opt->longarg); N_("missing mandatory option for `%s'"), opt->longarg);
goto fail; goto fail;
} }
@ -377,7 +378,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
if (tail == 0 || tail == option || *tail != '\0' || grub_errno) if (tail == 0 || tail == option || *tail != '\0' || grub_errno)
{ {
grub_error (GRUB_ERR_BAD_ARGUMENT, grub_error (GRUB_ERR_BAD_ARGUMENT,
"the argument `%s' requires an integer", N_("the argument `%s' requires an integer"),
arg); arg);
goto fail; goto fail;
@ -400,8 +401,8 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
if (option) if (option)
{ {
grub_error (GRUB_ERR_BAD_ARGUMENT, grub_error (GRUB_ERR_BAD_ARGUMENT,
"a value was assigned to the argument `%s' while it " N_("a value was assigned to the argument `%s' while it "
"doesn't require an argument", arg); "doesn't require an argument"), arg);
goto fail; goto fail;
} }

View file

@ -22,6 +22,7 @@
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/term.h> #include <grub/term.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/i18n.h>
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
#include <termios.h> #include <termios.h>

View file

@ -25,7 +25,7 @@
#include <grub/i386/relocator.h> #include <grub/i386/relocator.h>
#include <grub/relocator_private.h> #include <grub/relocator_private.h>
#include <grub/cpu/relocator_private.h> #include <grub/i386/relocator_private.h>
extern grub_uint8_t grub_relocator_forward_start; extern grub_uint8_t grub_relocator_forward_start;
extern grub_uint8_t grub_relocator_forward_end; extern grub_uint8_t grub_relocator_forward_end;

View file

@ -26,7 +26,7 @@
#define PSEUDO_REAL_DSEG 0x20 #define PSEUDO_REAL_DSEG 0x20
#include <grub/cpu/relocator_private.h> #include <grub/i386/relocator_private.h>
#include "relocator_common.S" #include "relocator_common.S"

View file

@ -801,7 +801,7 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
len = grub_strlen (corig); len = grub_strlen (corig);
if (!slash) if (!slash)
{ {
grub_error (GRUB_ERR_BAD_ARGUMENT, "bad color specification %s", grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid color specification `%s'",
args[0]); args[0]);
return NULL; return NULL;
} }

View file

@ -1209,14 +1209,14 @@ grub_relocator_alloc_chunk_addr (struct grub_relocator *rel,
grub_phys_addr_t min_addr = 0, max_addr; grub_phys_addr_t min_addr = 0, max_addr;
if (target > ~size) if (target > ~size)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "address is out of range"); return grub_error (GRUB_ERR_BUG, "address is out of range");
adjust_limits (rel, &min_addr, &max_addr, target, target); adjust_limits (rel, &min_addr, &max_addr, target, target);
for (chunk = rel->chunks; chunk; chunk = chunk->next) for (chunk = rel->chunks; chunk; chunk = chunk->next)
if ((chunk->target <= target && target < chunk->target + chunk->size) if ((chunk->target <= target && target < chunk->target + chunk->size)
|| (target <= chunk->target && chunk->target < target + size)) || (target <= chunk->target && chunk->target < target + size))
return grub_error (GRUB_ERR_BAD_ARGUMENT, "overlap detected"); return grub_error (GRUB_ERR_BUG, "overlap detected");
chunk = grub_malloc (sizeof (struct grub_relocator_chunk)); chunk = grub_malloc (sizeof (struct grub_relocator_chunk));
if (!chunk) if (!chunk)
@ -1256,7 +1256,7 @@ grub_relocator_alloc_chunk_addr (struct grub_relocator *rel,
grub_dprintf ("relocator", "not allocated\n"); grub_dprintf ("relocator", "not allocated\n");
grub_free (chunk); grub_free (chunk);
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory"); return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
} }
while (0); while (0);
@ -1486,7 +1486,7 @@ grub_relocator_prepare_relocs (struct grub_relocator *rel, grub_addr_t addr,
if (!malloc_in_range (rel, 0, ~(grub_addr_t)0 - rel->relocators_size + 1, if (!malloc_in_range (rel, 0, ~(grub_addr_t)0 - rel->relocators_size + 1,
grub_relocator_align, grub_relocator_align,
rel->relocators_size, &movers_chunk, 1, 1)) rel->relocators_size, &movers_chunk, 1, 1))
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory"); return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
movers_chunk.srcv = rels = rels0 movers_chunk.srcv = rels = rels0
= grub_map_memory (movers_chunk.src, movers_chunk.size); = grub_map_memory (movers_chunk.src, movers_chunk.size);

View file

@ -220,7 +220,7 @@ static grub_command_t cmd;
GRUB_MOD_INIT(appleloader) GRUB_MOD_INIT(appleloader)
{ {
cmd = grub_register_command ("appleloader", grub_cmd_appleloader, cmd = grub_register_command ("appleloader", grub_cmd_appleloader,
N_("[OPTS]"), N_("Boot legacy system.")); N_("[OPTS]"), N_("Boot BIOS-based system."));
my_mod = mod; my_mod = mod;
} }

View file

@ -88,10 +88,10 @@ grub_chainloader_boot (void)
grub_error (GRUB_ERR_BAD_OS, buf); grub_error (GRUB_ERR_BAD_OS, buf);
grub_free (buf); grub_free (buf);
} }
}
else else
grub_error (GRUB_ERR_BAD_OS, "unknown error"); grub_error (GRUB_ERR_BAD_OS, "unknown error");
} }
}
if (exit_data) if (exit_data)
efi_call_1 (b->free_pool, exit_data); efi_call_1 (b->free_pool, exit_data);
@ -197,7 +197,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
char *filename; char *filename;
if (argc == 0) if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified"); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
filename = argv[0]; filename = argv[0];
grub_dl_ref (my_mod); grub_dl_ref (my_mod);
@ -258,7 +258,8 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
if (grub_file_read (file, (void *) ((grub_addr_t) address), size) != size) if (grub_file_read (file, (void *) ((grub_addr_t) address), size) != size)
{ {
if (grub_errno == GRUB_ERR_NONE) if (grub_errno == GRUB_ERR_NONE)
grub_error (GRUB_ERR_BAD_OS, "too small"); grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
filename);
goto fail; goto fail;
} }

Some files were not shown because too many files have changed in this diff Show more