NoMoreDevfs

Revision 14 as of 2006-06-23 09:36:26

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 requires extra support code in udev just for the installer (and udev's support for enumerated devices is sometimes unreliable, so should be avoided), breaks Ubiquity in the event we accidentally run across it, and causes 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 has 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.)

Outstanding issues

BoF agenda and discussion

Raw notes:

./partman/partman-base/definitions.sh:629:      /dev/md/*)
^ maybe handling /dev/md* as well would be a good idea

./partman/partman-base/definitions.sh:660:      /dev/loop/*)
./partman/partman-base/definitions.sh:661:          n=${1#/dev/loop/}
^ should handle /dev/loop* (dapper's udev got this wrong)

./partman/partman-base/init.d/parted:26:            sed 's,^/dev/ide,!/dev/ide,' | 
./partman/partman-base/init.d/parted:27:            sed 's,^/dev/scsi,!/dev/scsi,' | 
^ need to do the same for /dev/hd* and /dev/sd* to get proper sorting

./partman/partman-crypto/crypto_tools.sh:78:                    echo /dev/loop/$n
./partman/partman-crypto/finish.d/crypto_config:5:#                     from /dev/loop/.. to their real devices and adjusts options.
^ looks like there's still a little bit of devfsese here

./partman/partman-lvm/choose_method/lvm/choices:11:if grep -q "/dev/md" $dev/device; then
./partman/partman-md/init.d/md-devices:26:      echo "/dev/md/${NUMBER}" > ${DEVICE}/device
./partman/partman-md/init.d/md-devices:38:      open_dialog OPEN "/dev/md/${NUMBER}"
./partman/partman-md/init.d/md:62:#     echo "/dev/md/${NUMBER}" > ${DEVICE}/device
./partman/partman-md/init.d/md:65:#     open_dialog OPEN "/dev/md/${NUMBER}"
./partman/partman-target/finish.d/fstab_removable_media_entries:102:                dev=$(mapdevfs $(find /dev/scsi/host$host/ -type b | grep /disc))
./partman/partman-target/finish.d/fstab_removable_media_entries:51:for dev in /dev/cdroms/*; do
^ see os-prober again

./partman/partman-target/finish.d/fstab_removable_media_entries:71:for dev in /dev/floppy/?; do
^ /dev/fd*, and for ide-floppy look for ID_TYPE=floppy in udevinfo

./partman/partman-target/finish.d/fstab_removable_media_entries:94:             for dev in $(find /dev/scsi/host$host/ -type b); do
^ look for driver usb-storage

./rootskel/src-bootfloppy/sbin/init:101:                        if [ -d /dev/scsi ]; then
./rootskel/src-bootfloppy/sbin/init:102:                                DEVS="$DEVS `find /dev/scsi`"
./rootskel/src-bootfloppy/sbin/init:98:                 if [ -d /dev/floppy ]; then
./rootskel/src-bootfloppy/sbin/init:99:                         DEVS=/dev/floppy/?
./rootskel/src/lib/debian-installer/detect-console-linux:3:             /dev/console|/dev/tts/*)
./rootskel/src/lib/debian-installer/detect-console-linux:6:             /dev/vc/*)
./rootskel/src/lib/debian-installer/init-udev-devices:16:makedir 755 /dev/rd
./rootskel/src/lib/debian-installer/init-udev-devices:17:makedev 660 /dev/rd/0 b 1 0
./rootskel/src/lib/debian-installer/init-udev-devices:18:makedir 755 /dev/vc
./rootskel/src/lib/debian-installer/init-udev-devices:20:       makedev 600 /dev/vc/"$i" c 4 "$i"
./rootskel/src/lib/debian-installer/init-udev-devices:22:makedir 755 /dev/tts
./rootskel/src/lib/debian-installer/init-udev-devices:24:       makedev 600 /dev/tts/"$i" c 4 "$(($i + 64))"
^ maybe ship both, or copy /lib/udev/devices?

./rootskel/src/sbin/init:41:                            rm -f /dev/vc/$i

./userdevfs/S10userdevfs:5:   ( [ ! -e /.dev ] && [ ! -e /dev/.devfsd ] ); then
./userdevfs/debian/rules:26:    mknod debian/$(PACKAGE)/dev/rd/0 b 1 0
./userdevfs/debian/rules:31:    mknod debian/$(PACKAGE)/dev/vc/0 c 4 0
./userdevfs/debian/rules:32:    mknod debian/$(PACKAGE)/dev/vc/1 c 4 1
./userdevfs/debian/rules:33:    mknod debian/$(PACKAGE)/dev/vc/2 c 4 2
./userdevfs/debian/rules:34:    mknod debian/$(PACKAGE)/dev/vc/3 c 4 3
./userdevfs/debian/rules:35:    mknod debian/$(PACKAGE)/dev/vc/4 c 4 4
./userdevfs/debian/rules:37:    mknod debian/$(PACKAGE)/dev/fb/0 c 29 0
./userdevfs/init-dev:14:if [ ! -d $ROOT/dev/vc ]; then
./userdevfs/init-dev:16:        mkdir -p $ROOT/dev/vc
./userdevfs/init-dev:18:                mknod $ROOT/dev/vc/$i c 4 $i
./userdevfs/init-dev:22:if [ ! -d $ROOT/dev/loop ]; then
./userdevfs/init-dev:24:        mkdir -p $ROOT/dev/loop
./userdevfs/init-dev:26:                mknod $ROOT/dev/loop/$i b 7 $i 
./userdevfs/init-dev:30:if [ ! -d $ROOT/dev/floppy ]; then
./userdevfs/init-dev:32:        mkdir -p $ROOT/dev/floppy
./userdevfs/init-dev:33:        mknod $ROOT/dev/floppy/0 b 2 0
./userdevfs/init-dev:36:if [ ! -d $ROOT/dev/cdroms ]; then
./userdevfs/init-dev:38:        mkdir -p $ROOT/dev/cdroms
./userdevfs/init-dev:44:                        if [ ! -b $ROOT/dev/$i ]; then
./userdevfs/init-dev:54:                        ln -sf $ROOT/dev/$i /dev/cdroms/cdrom$CNT
./userdevfs/init-dev:64:                        if [ ! -b $ROOT/dev/$i ]; then
./userdevfs/init-dev:65:                                mknod $ROOT/dev/$i b 11 $CNT
./userdevfs/init-dev:67:                        ln -sf $ROOT/dev/$i $ROOT/dev/cdroms/cdrom$CNT
./userdevfs/init-dev:70:                if [ ! -e $ROOT/dev/cdrom ]; then
./userdevfs/init-dev:71:                        ln -sf $ROOT/dev/scd0 $ROOT/dev/cdrom
./userdevfs/update-dev:14:              mkdir -p $ROOT/dev/discs/disc$discnr
./userdevfs/update-dev:17:                      mkdir -p $ROOT/dev/$dir
./userdevfs/update-dev:19:              if [ ! -e $ROOT/dev/$disc ]; then
./userdevfs/update-dev:20:                      mknod $ROOT/dev/$disc b $major $minor
./userdevfs/update-dev:22:              ln -s $ROOT/dev/$disc $ROOT/dev/discs/disc$discnr/disc 
./userdevfs/update-dev:24:              if [ ! -e $ROOT/dev/$disc ]; then
./userdevfs/update-dev:25:                      mknod $ROOT/dev/$disc b $major $minor
./userdevfs/update-dev:27:              ln -s $ROOT/dev/$disc $ROOT/dev/discs/disc$discnr/part$minor
./userdevfs/update-dev:3:rm -rf $ROOT/dev/discs
./userdevfs/update-dev:4:mkdir -p $ROOT/dev/discs


CategorySpec