Subject: Re: CFR: The Auto-Generation Block/Character Device Switch Tables
To: David Laight <david@l8s.co.uk>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 05/15/2002 14:17:41
On Wed, 15 May 2002, David Laight wrote:

> > >
> > > Maybe. Doing something like that would let us pick our own major numbers
> > > whereever we wanted. We would have to make sure our major numbers avoided
> > > all of the vendor ones we emulated, since we can't tell where the device
> > > node was that was opened.
> >
> > Hmmm, that's not as convienient as I hoped it would be.
> >
> > But won't netscape being run (say) under solaris emulation try and open
> > /emul/dev/sd0c first, before /dev/sd0c ?  Couldn't you have a per-emulation
> > table to map major numbers from one to another ?  The problem might be how
> > to get emul information that far down, if this was a good idea.

That's actually not the problem. The problem is that we need to be able to
boot a new kernel on an old (say a restore of a backup) file system with
old device nodes. So whatever was say /dev/wd1a needs to still be wd1a.

That means that whatever we've allocated so far for device nodes can't get
reused. We can make new ones, we just can't reuse what we have used so
far. We can even make new, replacement ones (a new major/minor for wd1a
for instance). We just can't reuse old ones.

> I haven't looked into it (a quick find | xargs | grep) but does
> any device drivers ever need to know the major number that is in
> on-disk /dev entries?

They don't, it's just the layers between a file descriptor and the device
driver that need to know.

> I was wondering whether you could convert from 'external' to
> 'internal' major numbers somewhere.  Possibly even with a
> filesystem dependant table?

That's not really the problem. The problem is making sure we tie the
driver with whatever device the code that made the device node (possibly
years ago) had in mind. :-)

Take care,

Bill