Subject: 32 bit dev_t proposal rev. 4
To: None <tech-kern@NetBSD.ORG>
From: Todd Vierling <tv@NetBSD.ORG>
Date: 01/15/1998 20:31:58
I've rewritten this from scratch and I'm going to make this as well
explained as possible, and show why it works without extra stuff like
splitting the minor or changing ls/mknod.
Changing ls(1) and mknod(8) is not part of this proposal. It doesn't need
to be. Those wishing to change the cosmetics of ls/mknod may discuss it
separately (the advantages/disadvantages have been spelled out fairly well).
In this proposal, the kernel retains standard use of major() and minor()
with only one split in dev_t.
1. The device number in 32-bit format is split 12 bits major, 20 bits minor,
contiguously. If the top sixteen bits are zero, the device is a 16-bit
node. Use of devices where the top twelve bits are zero but where the next
eight are not will fall back to the 32-bit device number 0, `notdef', and
fail. major() will always return the top 12 bits, and minor() will always
return the lower 20 bits.
2. The device numbers in 32-bit format follow a new, renumbered table of
devices. This table will be unified across all ports, using #if (_MACHINE
== <arch>) directives where necessary to control the inclusion of device
pointers. The new table will be an array of pointers rather than an array
3. The devices will use a new, merged devsw structure, with character
operations at the front and block operations at the back of the struct.
The block operations may then be left out of a structure definition as
desired. These structures will be declared either explicity or via a
dev_init_*() macro in the actual file where their functions are declared.
The functions may now be declared `static' at will. Character and block
device counterparts will share the same major number.
4. 16-bit device numbers will be translated to 32-bit device numbers only
upon declaration of COMPAT_13_DEV, and only when storing a value into the
si_dev field of struct specinfo (at vnode creation time). Some ports may,
upon portmaster discretion, implement other translation compatibility
options for 16-bit devices to match a different host OS. Any such options
and COMPAT_13_DEV are mutually exclusive.
5. Translation of block and character 16-bit device numbers to 32-bit
device numbers will be through the internal functions bdevcvt32() and
cdevcvt32(), used only in the place described in (4). These funtions will
be declared const, as all translations are constant. When COMPAT_13_DEV is
undefined (and any other similar compat options are undefined), these
functions will become no-op macros.
6. Translation of 16-bit device nodes to 32-bit device nodes is done through
a table of major numbers followed by pointers to minor number translation
functions. A minor number translation function must be declared for each
translated minor number, which may be the function `devcvt_none()' which
only returns what it is fed.
7. No translation is required of 32-bit nods, and the test of the top 32
bits of dev_t will short-circuit the translation in the place described in
(4) as necessary.
8. No translation is done in the stat() system calls, except when fitting a
32 bit node into a 4.3BSD stat structure in vfs_syscalls_43.c. That
`fitting' will use the lowest 8 bits of major and minor when translating a
32-bit device to a 16-bit device.
===== Todd Vierling (Personal email@example.com) =====
== "There's a myth that there is a scarcity of justice to go around, so
== that if we extend justice to 'those people,' it will somehow erode the
== quality of justice everyone else receives." -- Maria Price