Subject: Writing NetBSD disklabels directly to disk (disklabel -r)
To: None <firstname.lastname@example.org>
From: David Laight <email@example.com>
Date: 07/14/2005 22:10:02
I'm trying to sanitise disklabel(8), this is a slow process made slower
by trying to understand why the current code is doing what is seems to do!
Most of the command variants have a '-r' flags which 'causes the label to be
read from or written to the disk directly, rather than going through the
system's in-core copy of the label'.
This all seems reasonable until you look what the code does, '-r makes it:
- Tell the kernel to use the new label (ioctl DIOCSDINFO).
- Write the label to (some part of) the disk
And, since rev 1.122 of disklabel.c (now main.c)
- Tell the kernel to write the new label to the disk (ioctl DIOCWDINFO)
If you don't specify '-r' then the DIOCWDINFO ioctl is used to get the
kernel to write the label.
This means that '-r' definitely doesn't 'do what it says on the tin'.
I THINK the DIOCWDINFO was added to 'fix' sparc - where the kernel
will write a sun label that the disklabel program doesn't understand.
But the raw write will already have trampled over things.
Anyone any thoughts as to the correctness of this behaviour?
David Laight: firstname.lastname@example.org