[TUHS] Device special files

Bakul Shah bakul at bitblocks.com
Wed Feb 7 12:13:50 AEST 2018


On Wed, 07 Feb 2018 12:48:35 +1100 Dave Horsfall <dave at horsfall.org> wrote:
Dave Horsfall writes:
> On Wed, 7 Feb 2018, Greg 'groggy' Lehey wrote:
> 
> >> V3 and earlier still *called* them special files, but it seems they 
> >> were essentially just magic inode numbers (there was no physical file 
> >> on disk, just any directory entry with the given inode would be the 
> >> special file).
> >
> > Isn't that still the case?
> 
> Wasn't that "devfs" (which Penguin/OS calls "udev")?  I've never grokked 
> that concept.

In the old days where a limited types of devices were
available for a particular kind of machine, they could be
statically assigned a major dev number (matching their index
in the {b,c}devsw table). To make them accessible to users you
did

    mknod <name> <b or c> <major> <minor>

Usually via /dev/MAKEDEV.  But this soon fell apart on PCs
where you any number of devices can be attached. Even on
Fortune Systems (pre PC) the system had an IO bus and static
assignments listing out every possible device would've needed
a lot of inodes. Recall that on a floppy space taken by each
inode matters so we had to find a way!  IIRC, the kernel
essentially returned a list of mknod commands which was then
run at boot time.

So the point of devfs is to avoid having to do mknod manually
and yet provide access to all found devices from the userland.
As a side effect you can also use it for programs that run in
their own sandbox or for jails and require access to a device.


More information about the TUHS mailing list