2008-02-11 Robert Millan * util/biosdisk.c (grub_util_biosdisk_open, open_device) (grub_util_biosdisk_read, grub_util_biosdisk_write) (grub_util_biosdisk_get_grub_dev): When issuing grub_error() calls, include `strerror (errno)' information in the message string. * util/misc.c (grub_util_error): Invoke grub_print_error() before printing the caller-provided string. diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/biosdisk.c ./util/biosdisk.c --- ../grub2/util/biosdisk.c 2008-02-11 16:48:18.000000000 +0100 +++ ./util/biosdisk.c 2008-02-11 16:49:36.000000000 +0100 @@ -168,7 +168,7 @@ grub_util_biosdisk_open (const char *nam fd = open (map[drive], O_RDONLY); if (fd == -1) - return grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s'", map[drive]); + return grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' (%s)", map[drive], strerror (errno)); if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode)) { @@ -199,7 +199,7 @@ grub_util_biosdisk_open (const char *nam # warning "No special routine to get the size of a block device is implemented for your OS. This is not possibly fatal." #endif if (stat (map[drive], &st) < 0) - return grub_error (GRUB_ERR_BAD_DEVICE, "cannot stat `%s'", map[drive]); + return grub_error (GRUB_ERR_BAD_DEVICE, "cannot stat `%s' (%s)", map[drive], strerror (errno)); disk->total_sectors = st.st_size >> GRUB_DISK_SECTOR_BITS; @@ -307,7 +307,7 @@ open_device (const grub_disk_t disk, gru fd = open (dev, flags); if (fd < 0) { - grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s'", dev); + grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' (%s)", dev, strerror (errno)); return -1; } @@ -321,7 +321,7 @@ open_device (const grub_disk_t disk, gru fd = open (map[disk->id], flags); if (fd < 0) { - grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s'", map[disk->id]); + grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' (%s)", map[disk->id], strerror (errno)); return -1; } #endif /* ! __linux__ */ @@ -339,7 +339,7 @@ open_device (const grub_disk_t disk, gru offset = (loff_t) sector << GRUB_DISK_SECTOR_BITS; if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET)) { - grub_error (GRUB_ERR_BAD_DEVICE, "cannot seek `%s'", map[disk->id]); + grub_error (GRUB_ERR_BAD_DEVICE, "cannot seek `%s' (%s)", map[disk->id], strerror (errno)); close (fd); return -1; } @@ -350,7 +350,7 @@ open_device (const grub_disk_t disk, gru if (lseek (fd, offset, SEEK_SET) != offset) { - grub_error (GRUB_ERR_BAD_DEVICE, "cannot seek `%s'", map[disk->id]); + grub_error (GRUB_ERR_BAD_DEVICE, "cannot seek `%s' (%s)", map[disk->id], strerror (errno)); close (fd); return -1; } @@ -431,7 +431,7 @@ grub_util_biosdisk_read (grub_disk_t dis parts. -jochen */ if (nread (fd, buf, GRUB_DISK_SECTOR_SIZE) != GRUB_DISK_SECTOR_SIZE) { - grub_error (GRUB_ERR_READ_ERROR, "cannot read `%s'", map[disk->id]); + grub_error (GRUB_ERR_READ_ERROR, "cannot read `%s' (%s)", map[disk->id], strerror (errno)); close (fd); return grub_errno; } @@ -443,7 +443,7 @@ grub_util_biosdisk_read (grub_disk_t dis if (nread (fd, buf, size << GRUB_DISK_SECTOR_BITS) != (ssize_t) (size << GRUB_DISK_SECTOR_BITS)) - grub_error (GRUB_ERR_READ_ERROR, "cannot read from `%s'", map[disk->id]); + grub_error (GRUB_ERR_READ_ERROR, "cannot read from `%s' (%s)", map[disk->id], strerror (errno)); close (fd); return grub_errno; @@ -461,7 +461,7 @@ grub_util_biosdisk_write (grub_disk_t di if (nwrite (fd, buf, size << GRUB_DISK_SECTOR_BITS) != (ssize_t) (size << GRUB_DISK_SECTOR_BITS)) - grub_error (GRUB_ERR_WRITE_ERROR, "cannot write to `%s'", map[disk->id]); + grub_error (GRUB_ERR_WRITE_ERROR, "cannot write to `%s' (%s)", map[disk->id], strerror (errno)); close (fd); return grub_errno; @@ -695,7 +695,7 @@ grub_util_biosdisk_get_grub_dev (const c if (stat (os_dev, &st) < 0) { - grub_error (GRUB_ERR_BAD_DEVICE, "cannot stat `%s'", os_dev); + grub_error (GRUB_ERR_BAD_DEVICE, "cannot stat `%s' (%s)", os_dev, strerror (errno)); return 0; } @@ -775,7 +775,7 @@ grub_util_biosdisk_get_grub_dev (const c fd = open (os_dev, O_RDONLY); if (fd == -1) { - grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s'", os_dev); + grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' (%s)", os_dev, strerror (errno)); free (name); return 0; } @@ -783,7 +783,7 @@ grub_util_biosdisk_get_grub_dev (const c if (ioctl (fd, HDIO_GETGEO, &hdg)) { grub_error (GRUB_ERR_BAD_DEVICE, - "cannot get geometry of `%s'", os_dev); + "cannot get geometry of `%s' (%s)", os_dev, strerror (errno)); close (fd); free (name); return 0; diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/misc.c ./util/misc.c --- ../grub2/util/misc.c 2007-10-21 14:29:33.000000000 +0200 +++ ./util/misc.c 2008-02-11 16:49:36.000000000 +0100 @@ -61,6 +61,8 @@ void grub_util_error (const char *fmt, ...) { va_list ap; + + grub_print_error (); fprintf (stderr, "%s: error: ", progname); va_start (ap, fmt);