Subject: Re: Disklabel's bug ? (or feature ?)
To: None <tech-userlevel@netbsd.org>
From: Arnaud Lacombe <al@sigfpe.info>
List: tech-userlevel
Date: 06/13/2006 10:36:16
On Mon, Jun 12, 2006 at 08:29:48PM +0100, David Laight wrote:
> IMHO no, disklabel cannot know what are valid disk names, and there
> are some very good reasons why it (and opendisk() in general) can be
> run on a regular file.
>
Yes, I perfectly understand that.
Now, opendisk() works as follow: it tries to open the path given by
disklabel, if it fails, it tries to open the path with the rawpart
appended, if it fails again, it will try (after check) to concatenate
"/dev/" + the path , and finally, "/dev/" + the path + 'X' [1]
If I pass "sd0" to disklabel, opendisk will try to open the following
files: "./sd0", "./sd0X", "/dev/sd0", "/dev/sd0X". What I propose is
to check that file opened under '/dev' are *really* device file. I don't
see any reason to have a regular file named 'sd0' under /dev, except
manipulation mistake, which could be avoided by adding the extra check.
regards,
Arnaud
[1]: X = 'a' + value returned by getrawpartition()