Received: from list by lists.gnu.org with archive (Exim 4.71) id 1bc8mn-00074O-Ld for mharc-grub-devel@gnu.org; Tue, 23 Aug 2016 06:18:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bc8ml-00073L-Vn for grub-devel@gnu.org; Tue, 23 Aug 2016 06:18:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bc8mg-000514-9s for grub-devel@gnu.org; Tue, 23 Aug 2016 06:18:22 -0400 Received: from smtp209.alice.it ([82.57.200.105]:62159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bc8mf-0004x8-US for grub-devel@gnu.org; Tue, 23 Aug 2016 06:18:18 -0400 Received: from jcn (82.51.74.25) by smtp209.alice.it (8.6.060.28) id 57B41B5E00D7E4BE; Tue, 23 Aug 2016 12:18:11 +0200 Received: from ao2 by jcn with local (Exim 4.87) (envelope-from ) id 1bc8mW-0004te-Gi; Tue, 23 Aug 2016 12:18:08 +0200 From: Antonio Ospite To: grub-devel@gnu.org Cc: 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 Message-Id: <20160823101728.18774-3-ao2@ao2.it> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160823101728.18774-1-ao2@ao2.it> References: <20160823101728.18774-1-ao2@ao2.it> X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 82.57.200.105 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Aug 2016 10:18:25 -0000 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