Skip to content

RFC grub-probe: improve message when disk cannot be opened

Antonio Ospite grub-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2* grub-core/kern/disk.c: don't override grub_errmsg when grub_disk_open failsgrub-core/kern/disk.c+1 -20 replies
2/2* util/getroot.c: improve error message when a disk cannot be openedutil/getroot.c+9 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/2] grub-probe: improve message when disk cannot be opened

Hi,

right now when running grub-probe and the disk cannot be opened the error message can be misleading, it always says "disk not found" but in some case the disk may exist but the user has no permissions to open it, see https://savannah.gnu.org/bugs/?42409

The message can be improved by propagating informations about the cause of the failure from the bottom layers.

Please take a look at the patches in this series, I marked them RFC because I am new to grub code and I am not sure that all the error paths set a meaningful message, but I wanted some code to base the discussion on.

Patch 1/2 aims to prevent overriding the error messages from the disk->open() methods called in grub_disk_open().

Patch 2/2 exposes to the user the —now more informative— message from grub_disk_open().

Before these changes I was getting this output when running grub-probe with insufficient permissions:

  $ LANG=C ./grub-probe /
  ./grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1.
  ./grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1.
  ./grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1.
  ./grub-probe: error: disk `hostdisk//dev/sda1' not found.

After the patches the reason of the failure is clearer:

  $ LANG=C ./grub-probe /
  ./grub-probe: warning: cannot open `/dev/sda': Permission denied, so falling back to partition device /dev/sda1.
  ./grub-probe: warning: cannot open `/dev/sda': Permission denied, so falling back to partition device /dev/sda1.
  ./grub-probe: warning: cannot open `/dev/sda': Permission denied, so falling back to partition device /dev/sda1.
  ./grub-probe: error: cannot open `/dev/sda1': Permission denied.

As I said, this is the final effect I am aiming for but I am not 100% sure my solution is complete.

Thanks,
Antonio

Antonio Ospite (2):
* grub-core/kern/disk.c: don't override grub_errmsg when grub_disk_open fails
* util/getroot.c: improve error message when a disk cannot be opened

 grub-core/kern/disk.c |  3 +--
 util/getroot.c        | 15 +++++++++------
 2 files changed, 10 insertions(+), 8 deletions(-)
Signature · 6 lines
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?