Improve and unify messages.

* grub-core/kern/emu/hostdisk.c (grub_util_get_fd_sectors): Add argument
	name. All users updated.
	Print filename in error.
	(read_device_map): Print filename in error.
	* util/getroot.c (grub_guess_root_devices): Print filename in error.
	(grub_util_get_os_disk): Likewise.
	(grub_util_biosdisk_get_grub_dev): Likewise.
	(grub_util_check_block_device): Likewise.
	(grub_util_check_char_device): Likewise.
	(grub_make_system_path_relative_to_its_root): Likewise.
	* util/grub-editenv.c (create_envblk_file): Likewise.
	(open_envblk_file): Likewise.
	(write_envblk): Likewise.
	* util/grub-fstest.c (cmd_cp): Likewise.
	(cmd_cat): Likewise.
	(cmd_cmp): Likewise.
	* util/grub-menulst2cfg.c (main): Likewise.
	* util/grub-mkfont.c (write_font_ascii_bitmap): Likewise.
	(write_font_width_spec): Likewise.
	(write_font_pf2): Likewise.
	* util/grub-mkimage.c (generate_image): New argument outname.
	All users updated.
	Remove unreacheable message.
	(options): Unify messages.
	(help_filter): Likewise.
	* util/grub-mklayout.c (usage): Removed (unused).
	(main): Print filename in error.
	* util/grub-mkrescue.in: Fix wrong quoting.
	* util/grub-setup.c (setup): Print filename in error.
	* util/ieee1275/ofpath.c (vendor_is_ATA): Likewise.
	(check_sas): Likewise.
	* util/misc.c (grub_util_get_fp_size): Removed.
	(grub_util_get_image_size): Print filename in error.
	(grub_util_read_at): Removed.
	(grub_util_read_image): Print filename in error.
	(grub_util_load_image): Likewise.
	(grub_util_write_image_at): New argument filename. All users updated.
	Print filename in error.
	(grub_util_write_image): New argument filename. All users updated.
	Print filename in error.
	* util/raid.c (grub_util_raid_getmembers): Print filename in error.
	* util/resolve.c (grub_util_resolve_dependencies): Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-05 11:07:33 +01:00
parent 0a96117de7
commit 0ae70393ba
19 changed files with 222 additions and 166 deletions

View file

@ -83,20 +83,6 @@ grub_util_get_path (const char *dir, const char *file)
return path;
}
size_t
grub_util_get_fp_size (FILE *fp)
{
struct stat st;
if (fflush (fp) == EOF)
grub_util_error (_("fflush failed"));
if (fstat (fileno (fp), &st) == -1)
grub_util_error (_("fstat failed"));
return st.st_size;
}
size_t
grub_util_get_image_size (const char *path)
{
@ -105,21 +91,11 @@ grub_util_get_image_size (const char *path)
grub_util_info ("getting the size of %s", path);
if (stat (path, &st) == -1)
grub_util_error (_("cannot stat %s"), path);
grub_util_error (_("cannot stat `%s': %s"), path, strerror (errno));
return st.st_size;
}
void
grub_util_read_at (void *img, size_t size, off_t offset, FILE *fp)
{
if (fseeko (fp, offset, SEEK_SET) == -1)
grub_util_error (_("seek failed"));
if (fread (img, 1, size, fp) != size)
grub_util_error (_("read failed"));
}
char *
grub_util_read_image (const char *path)
{
@ -134,9 +110,12 @@ grub_util_read_image (const char *path)
fp = fopen (path, "rb");
if (! fp)
grub_util_error (_("cannot open %s"), path);
grub_util_error (_("cannot open `%s': %s"), path,
strerror (errno));
grub_util_read_at (img, size, 0, fp);
if (fread (img, 1, size, fp) != size)
grub_util_error (_("cannot read the file `%s': %s"), path,
strerror (errno));
fclose (fp);
@ -155,30 +134,41 @@ grub_util_load_image (const char *path, char *buf)
fp = fopen (path, "rb");
if (! fp)
grub_util_error (_("cannot open %s"), path);
grub_util_error (_("cannot open `%s': %s"), path,
strerror (errno));
if (fread (buf, 1, size, fp) != size)
grub_util_error (_("cannot read %s"), path);
grub_util_error (_("cannot read the file `%s': %s"), path,
strerror (errno));
fclose (fp);
}
void
grub_util_write_image_at (const void *img, size_t size, off_t offset, FILE *out)
grub_util_write_image_at (const void *img, size_t size, off_t offset, FILE *out,
const char *name)
{
grub_util_info ("writing 0x%x bytes at offset 0x%x", size, offset);
if (fseeko (out, offset, SEEK_SET) == -1)
grub_util_error (_("seek failed"));
grub_util_error (_("cannot seek the file `%s': %s"),
name, strerror (errno));
if (fwrite (img, 1, size, out) != size)
grub_util_error (_("write failed"));
grub_util_error (_("cannot write to the file `%s': %s"),
name, strerror (errno));
}
void
grub_util_write_image (const char *img, size_t size, FILE *out)
grub_util_write_image (const char *img, size_t size, FILE *out,
const char *name)
{
grub_util_info ("writing 0x%x bytes", size);
if (fwrite (img, 1, size, out) != size)
grub_util_error (_("write failed"));
if (!name)
grub_util_error (_("cannot write to the stdout: %s"),
strerror (errno));
else
grub_util_error (_("cannot write to the file `%s': %s"),
name, strerror (errno));
}
char *