LWN.net Logo

Linus smoking crack

Linus smoking crack

Posted Jan 9, 2004 8:45 UTC (Fri) by iabervon (subscriber, #722)
In reply to: Linus smoking crack by Ross
Parent article: The future of device numbers

Linus is actually talking about randomization of the devices that the
kernel can't necessarily keep stable. So it's only really hotpluggable
devices, disks that can show up in surprising places, and that sort of
thing. I doubt /dev/zero will be change around between boots (which would
potentially cause problems with memory allocation in udev necessary to
create a device node with the right number...), and IDE disks and
floppies will probably stay the same. TTYs, PTYs, and so forth might as
well stay the same, since they're mostly kernel constructs anyway.
What'll be different is things like SCSI disks (which includes USB
storage), which will probably get random numbers instead of getting
numbered sequentially by when they're detected; if you're depending on
those being static, you could be in for an unpleasant surprise if you
boot a SCSI machine with a USB camera plugged in (even today, maybe).

The point is that the kernel can't necessarily identify the same device
is you unplug it and replug it, or if you reboot with different hardware
attached than you did last time. There are some cases where it is
reliable, and some cases where hardware doesn't matter, but there are
other cases where it can't do it reliably; in this case, it's far better
to fail the first time than wait to fail until it really matters.


(Log in to post comments)

No he really means ALL device numbers

Posted Jan 10, 2004 4:58 UTC (Sat) by giraffedata (subscriber, #1954) [Link]

Linus is actually talking about randomization of the devices that the kernel can't necessarily keep stable.

That's exactly what he's not talking about. Linus says that the fact that the kernel can't provide stable device numbers for everything means that anyone who expects the kernel to provide static device numbers for anything is fooling himself. Therefore, he suggests making device numbers random even when they don't have to be so someone can't possibly think that device numbers are stable.

He backpedals a little and says that might be a little too hostile and out of practicality, some device numbers should be kept unrandom. But what he really believes is that all the device numbers should be random.

This whole thing assumes udev, of course. If you have static device special files in /dev that you created with mknod, as we have for 30 years, you obviously can't make all the device numbers random.

I wish we'd get away from device numbers altogether. Naming things with integers is really archaic. In the modern world, we either name them with long text strings or with temporary handles that have reference counts and are in reality memory addresses.

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds