NoMoreDevfs

Revision 19 as of 2006-06-23 10:16:50

Clear message

Summary

As of Ubuntu 5.10 (and to some extent still in 6.06), the Ubuntu installer relies on devfs pathnames, which are non-standard. We should stop using them.

Rationale

Many components of the Ubuntu installer (both text-mode and graphical) are descended from code that was written in Debian for use on Linux 2.4, where the installer used devfs. In fact, the same code upstream still optionally runs on Linux 2.4. As a result, there are various assumptions of devfs pathnames scattered around the codebase, which require extra support code in udev just for the installer (and udev's support for enumerated devices is sometimes unreliable, so should be avoided), break Ubiquity in the event we accidentally run across it, and cause confusion. We should make all installer code work in the absence of devfs paths.

Use cases

This is an infrastructure specification; there are no concrete use cases, although this work will probably fix a number of complicated bugs in the area of installer hardware detection.

Scope

Remove hardcoded device paths where possible; otherwise introduce abstraction layers that can cope with either devfs or normal device paths. Where possible, ensure that the modified code will still work with devfs, so that the code can be contributed upstream.

Design

The following is a pared-down list of suspicious uses of /dev (note that this was generated from an upstream d-i tree, so contains packages not relevant to Ubuntu): attachment:d-i-dev.txt

As a general guide, the following paths are devfs-style: /dev/discs/*, /dev/ide/*, /dev/scsi/*, /dev/md/*, /dev/vc/*, /dev/loop/*, /dev/rd/* (when used to describe ramdisks). /dev/md/* may be OK anyway as these device nodes are handled entirely by mdadm based on what is specified on its command line, but the implementor should verify that there are no hidden issues here. The following paths which at first glance look suspicious are in fact safe for use with udev: /dev/mapper/*, /dev/cciss/*.

Implementation

Code

lilo-installer looks at /dev/md/*; this needs to be checked for correctness. There are some other device path handling fixes in Ubuntu which should be pushed upstream.

While the bootfs_no_dev code in sibyl-installer is correct, it is unused and should be removed unless it's going to be used very soon.

s390-dasd has commented code which uses /dev/dasd/<number>/device; this should be changed to try /dev/dasd<number> too.

autopartkit/mapdevfs.c is correct because it's only turning devfs names into real ones, but why doesn't it use the perfectly good function from libdebian-installer?

hw-detect/disk-detect.sh has a fallback case if parted_devices is not available that checks for /dev/discs to find out whether any disks have been detected; lowmem/partman/init.d/05lowmem_modules does the same thing. This should check through udevinfo -e for ID_TYPE=disk, or some equivalent check.

mdcfg and partman-md have many /dev/md/* assumptions; as discussed above, these should generally be OK since mdadm handles all its own device creation. However, this still might be inconsistent with the installed system, so we should check that.

mountfloppy looks through /dev/floppy, /dev/scsi, /dev/ide, and /dev/disc (sic) for devices; this should be fixed for udev by borrowing /sys/block handling code from os-prober. It also tries /dev/floppy/0 as a default floppy device, and should be fixed to try /dev/fd0 too.

nobootloader's Pegasos case parses devfs-style IDE and SCSI device names to work out the host, bus, target, etc. If /sys/block is available, it should parse basename $(readlink /sys/block/*/device) instead.

oldsys-preseed looks for device names based on paths (relative to /dev) that it fetches from /proc/mtd. Since this comes straight from the kernel, it should be sane if we switch off devfs, but the implementor should verify this.

os-prober's parse_proc_mdstat function relies on partition names matching /part, so will break. This filter should be corrected to something more reliable.

partconf uses /dev/md/* and /dev/evms/*; as above, these should be checked. It parses /dev/ide/* and /dev/scsi/* paths to generate human-readable descriptions of them (an older version of the code in partman-base/definitions.sh); this should be adapted to handle /dev/hd* and /dev/sd* too. fstab-common contains devfs-style fallback device names, which are used in case the CD or floppy cannot be found in /proc/mounts; some other scheme should be found for this.

partitioner's get_all_disks function looks through /dev/discs. This should be replaced with essentially the same code as in parted_devices. (This is code duplication, but partitioner is obsolete and will eventually be removed; it's currently used for a few architectures where partman is too slow. The reason to bother modifying it is to establish consistent device handling anywhere that new developers might look for example code.)

partman-base's humandev function handles /dev/md/*, but should possibly handle /dev/md* as well; it handles /dev/loop/*, but should handle /dev/loop* as well (note that Dapper's udev got this wrong). The script that starts up parted_server has cosmetic sorting code that handles /dev/ide/* and /dev/scsi/*, but should handle /dev/hd* and /dev/sd* as well.

partman-crypto uses /dev/loop/* in a few places (although, curiously, it seems to handle /dev/loop* elsewhere). We should investigate this and see if it needs to be changed to try /dev/loop* too.

partman-target iterates over /dev/cdroms and /dev/floppy; this should use /sys/block and check for ID_TYPE=cd or ID_TYPE=floppy respectively in udevinfo output if available. Floppy enumeration also needs to check /dev/fd*. It iterates over /dev/scsi/host* when looking for usb-storage devices, and should just look through /sys/block for devices with the usb-storage driver.

rootskel's bootfloppy init script looks through /dev/floppy and /dev/scsi for storage devices; it should look through everything in /sys/block too. The detect-console-linux script needs to be educated about non-devfs-style serial and virtual terminal device names. init-udev-devices creates /dev/rd, /dev/vc, and /dev/tts (for the benefit of busybox init which needs these to start up), and should either just create the non-devfs device names too or perhaps copy /lib/udev/devices; the implementor should investigate the exact requirements of busybox init here. src/sbin/init cleans up some nodes in /dev/vc/* in a serial terminal corner case and should clean up the corresponding /dev/tty* nodes too.

userdevfs creates many devfs-style device nodes as a compatibility shim for systems that have neither devfs nor udev. While this arguably does not matter since the d-i codebase will continue to support (though not require) devfs paths, it would probably be a good idea to switch these device nodes to non-devfs paths once the rest of the codebase has been fixed, to encourage more installer developers to account for non-devfs paths.


CategorySpec