Subject: Re: newfs: determining file system parameters
To: None <tech-kern@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 10/17/2003 00:20:32
> > In addition to these parameters, newfs interprets the last letter of
> > the device name as a partition identifier.  This can fail badly if a
> > device has a name like 'baz'.
> > 
> > I'd suggest that the following method would solve the "problem":
> > 
> > - implement an ioctl DIOCGMEDIASIZE to return the size of a special
> >   device.  
> 
> I'd like to change your suggestion some. I think this new ioctl should 
> return _all_ the info newfs needs. It should contain all the info in 
> struct partition, and enough other info (like device sector size) from the 
> disklabel.

Actually it is easy, and mostly done.

All newfs needs from the disklabel is the partition size and sector size.
The size always has been available via fstat for open block devices [1],
a minor change to spec_open has made it available for open character
disk devices (which newfs uses by default).
A simple check that the partition number generated from the name matches
that from the minor device number also sanities the selection of the
partition in the label.

Nothing extra is required.

	David

[1] and via stat(1) if anything has it open!

-- 
David Laight: david@l8s.co.uk