grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 2/2] * util/getroot.c: improve error message when a disk cann


From: Antonio Ospite
Subject: [RFC PATCH 2/2] * util/getroot.c: improve error message when a disk cannot be opened
Date: Tue, 23 Aug 2016 12:17:28 +0200

Opening a disk can fail for two reasons:

  1. the device does not exist;
  2. the device exists but cannot be accessed for some reason.

The current error message assumes always 1. and this can misled users
when they look for the actual cause of the failure.

So, reuse the error message from grub_disk_open() instead of always
saying "disk does not exist".

https://savannah.gnu.org/bugs/?42409
---
 util/getroot.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/util/getroot.c b/util/getroot.c
index 92c0d70..066d564 100644
--- a/util/getroot.c
+++ b/util/getroot.c
@@ -391,16 +391,19 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
       {
        /* We already know that the partition exists.  Given that we already
           checked the device map above, we can only get
-          GRUB_ERR_UNKNOWN_DEVICE at this point if the disk does not exist.
-          This can happen on Xen, where disk images in the host can be
-          assigned to devices that have partition-like names in the guest
-          but are really more like disks.  */
+          GRUB_ERR_UNKNOWN_DEVICE at this point if the disk does not exist,
+          or cannot be opened for some reason (e.g. insufficient
+          permissions).
+          The first case (the disk does not exist) can happen on Xen, where
+          disk images in the host can be assigned to devices that have
+          partition-like names in the guest but are really more like disks.
+          */
        if (grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
          {
            char *canon;
            grub_util_warn
-             (_("disk does not exist, so falling back to partition device %s"),
-              os_dev);
+             (_("%s, so falling back to partition device %s"),
+              grub_errmsg, os_dev);
            grub_errno = GRUB_ERR_NONE;
 
            canon = grub_canonicalize_file_name (os_dev);
-- 
2.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]