Check for device type (block/character) in grub-setup?
Hi,
I'm wondering why there is no check for device type (block/character) in grub-setup.c whereas the function probe() in grub-probe.c exits with error if the device is not of the expected type. Shouldn't there be a similar check in grub-setup?
Currently, on NetBSD (with in-progress patches), grub-setup fails with an `out of disk error' on a block device as the detected disk size is 0, whereas grub-probe exits gracefully with an error message telling that the input device is not a character device. I guess that a similar behavior could be observed on FreeBSD, but I can't actually test this.
Thanks,
Grégoire
Quoted 6 lines · Grégoire Sutre
Hi,
I'm wondering why there is no check for device type (block/character) in
grub-setup.cwhereas the functionprobe()ingrub-probe.cexits with error if the device is not of the expected type. Shouldn't there be a similar check in grub-setup?
Yes.
Quoted 2 lines
I guess that a similar
behavior could be observed on FreeBSD, but I can't actually test this.
Please make the code generic if possible (i.e. accept both character and block devices).
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi
Quoted 11 lines · Robert Millan
Quoted 3 lines · Grégoire Sutre
Hi,
I'm wondering why there is no check for device type (block/character) in
grub-setup.cwhereas the functionprobe()ingrub-probe.cexits with error if the device is not of the expected type. Shouldn't there be a similar check in grub-setup?Yes.
Quoted 1 line
I guess that a similar behavior could be observed on FreeBSD, but I can't actually test this.
Please make the code generic if possible (i.e. accept both character and block devices).
I don't understand what you mean here. I assumed that it's better to use character devices when accessing disks in GRUB utils, isn't it so? Moreover, at least on NetBSD, when a block device is mounted, it cannot be opened (device busy), and this would be a problem with grub-probe.
However, from a user view-point, it could be nice on NetBSD to accept stripped device names (e.g. only wd0d' or even wd0') and automatically get the associated device file (with opendisk(3)). This is what system tools do, e.g. disklabel wd0' or fdisk wd0' actually opens `/dev/rwd0d' (on i386).
Grégoire
Quoted 14 lines · Grégoire Sutre
Quoted 13 lines · Robert Millan
Quoted 6 lines · Grégoire Sutre
Hi,
I'm wondering why there is no check for device type (block/character) in
grub-setup.cwhereas the functionprobe()ingrub-probe.cexits with error if the device is not of the expected type. Shouldn't there be a similar check in grub-setup?Yes.
Quoted 2 lines
I guess that a similar behavior could be observed on FreeBSD, but I can't actually test this.
Quoted 7 lines
Quoted 2 lines
Please make the code generic if possible (i.e. accept both character and block devices).
I don't understand what you mean here. I assumed that it's better to use character devices when accessing disks in GRUB utils, isn't it so? Moreover, at least on NetBSD, when a block device is mounted, it cannot be opened (device busy), and this would be a problem with grub-probe.
I don't think it matters to us whether a device is character or block based, other than to perform sanity checks in it. Tools like grub-setup are supposed to be happy with either.
(I find it a bit odd that disks are represented by NetBSD as character devices, but, whatever...)
Quoted 5 lines
However, from a user view-point, it could be nice on NetBSD to accept stripped device names (e.g. only
wd0d' or evenwd0') and automatically get the associated device file (with opendisk(3)). This is what system tools do, e.g.disklabel wd0' orfdisk wd0' actually opens `/dev/rwd0d' (on i386).
I find this a bit confusing TBH. It seems unpredictable and would make GRUB inconsistent across platforms.
BUT
I think it's fine if you patch this up in the NetBSD version of GRUB, if you want it to be consistent with the other utilities.
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi