NoMoreDevfs

Revision 8 as of 2006-06-23 07:37:46

Clear message
  • Launchpad Entry: https://launchpad.net/distros/ubuntu/+spec/no-more-devfs

  • Created: Date(2006-06-05T16:09:16Z) by ColinWatson

  • Contributors: ColinWatson

  • Packages affected: aboot-installer autopartkit base-installer colo-installer hw-detect kbd-chooser libdebian-installer lilo-installer lowmem lvmcfg mdcfg mountfloppy nobootloader oldsys-preseed os-prober partconf partitioner partman-auto-lvm partman-base partman-crypto partman-lvm partman-md partman-target rootskel s390-dasd sibyl-installer userdevfs vmelilo-installer

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.

Outstanding issues

BoF agenda and discussion

Raw notes:

./arch/mips/sibyl-installer/debian/postinst:32:bootfs_no_dev=${bootfs#/dev/}
^ no problem there but code is unused and should be removed

./arch/s390/dasd/dasd.c:281:            snprintf (dev, sizeof (dev), "/dev/dasd/%04x/device", dasd_current->device);
^ becomes /dev/dasd[0-9]

./autopartkit/mapdevfs.c:107:        ret = snprintf(buf, n, "/dev/%s%c%c", e->name, 'a' + unit / 26, 'a' + unit % 26);
./autopartkit/mapdevfs.c:110:        ret = snprintf(buf, n, "/dev/%s%c", e->name, 'a' + unit);
./autopartkit/mapdevfs.c:90:      ret = snprintf(buf, n, "/dev/%s", e->name);
./autopartkit/mapdevfs.c:96:      ret = snprintf(buf, n, "/dev/%s%d", e->name, unit);
^ parsing devfs names into real ones?  probably ok, it's generating hda/sda names
^ mapdevfs is in libdebian-installer - why doesn't this use that?

./hw-detect/disk-detect.sh:42:                  if [ -n "$(ls /dev/discs/ 2>/dev/null)" ]; then
^ will often be ok as parted_devices is usually available, but fallback code should be fixed

./lowmem/partman/init.d/05lowmem_modules:8:if [ -d /dev/discs ]; then
^ needs to check for udev-land too

./mdcfg/mdcfg.sh:176:   `mdadm --create /dev/md/${MD_NUM} --auto=yes --force -R -l raid0 -n ${SELECTED} ${RAID_DEVICES}`
./mdcfg/mdcfg.sh:25:    db_subst mdcfg/deleteverify DEVICE "/dev/${DEVICE}"
./mdcfg/mdcfg.sh:312:   `mdadm --create /dev/md/${MD_NUM} --auto=yes --force -R -l raid1 -n ${DEV_COUNT} -x ${SPARE_COUNT} ${RAID_DEVICES} ${MISSING_DEVICES} ${SPARE_DEVICES} ${MISSING_SPARES}`
./mdcfg/mdcfg.sh:36:      DEVICES=`mdadm -Q --detail /dev/md/${NUMBER} | grep "\(active\|spare\)" | sed -e 's/.* //'`
./mdcfg/mdcfg.sh:37:                    mdadm --stop /dev/md/${NUMBER}
./mdcfg/mdcfg.sh:38:                    echo "Removing /dev/md/$NUMBER" > /var/log/mdcfg.log
./mdcfg/mdcfg.sh:452:   `mdadm --create /dev/md/${MD_NUM} --auto=yes --force -R -l raid5 -n ${DEV_COUNT} -x ${SPARE_COUNT} ${RAID_DEVICES} ${SPARE_DEVICES} ${MISSING_SPARES}`
./mdcfg/mdcfg.sh:484:mkdir -p /dev/md
^ should all be ok (and thus anything that uses /dev/md/* is probably ok) because mdadm handles all its own device creation; it still might be inconsistent with the installed system so we should check that

./mountfloppy/mountfloppy:34:   FLOPPYDEV=/dev/floppy/0
./mountfloppy/mountfloppy:8:    for dev in `find /dev/floppy /dev/scsi /dev/ide /dev/disc`; do
^ eww
^ copy /sys/block handling code from os-prober; fix default floppy device somehow?

./nobootloader/debian/postinst:33:              kind=`echo $bootfs_devfs | sed -e 's%/dev/%%' -e 's%/host.*$%%'`
^ this is parsing devfs-style SCSI device names; should shift to fetching bus/target/lun by parsing `basename $(readlink /sys/block/*/device)`

./oldsys-preseed/oldsys-preseed:48:             parse_sysconf "/dev/$sysconf"
./oldsys-preseed/oldsys-preseed:81:                     mount -t minix /dev/$config $path/mnt
^ passed in, comes from /proc/mtd in the kernel so should be sane if we switch off devfs

./os-prober/os-prober:35:                               raidpart="/dev/$(echo $word | sed "s:\[.*$::")"
^ is looking for stuff matching /part in /proc/mdstat, so will break

./partconf/find-parts.c:102:        sprintf(name, "/dev/md/%d", volno);
./partconf/find-parts.c:206:            if (strstr(p->path, "/dev/ide/") == p->path) {
./partconf/find-parts.c:210:                if (sscanf(p->path, "/dev/ide/host%d/bus%d/target%d/lun%d/part%d",
./partconf/find-parts.c:217:            } else if (strstr(p->path, "/dev/scsi/") == p->path) {
./partconf/find-parts.c:220:                if (sscanf(p->path, "/dev/scsi/host%d/bus%d/target%d/lun%d/part%d",
./partconf/find-parts.c:54:// /dev/evms/<volume> and there's info in
./partconf/find-parts.c:65:    if (strstr(p->path, "/dev/evms/") != p->path)
./partconf/find-parts.c:83:// RAID volumes are /dev/md/# for numbers #
./partconf/find-parts.c:84:// Stats are found in /dev/mdstats
^ /proc/mdstat surely?
./partconf/find-parts.c:94:    if (strstr(p->path, "/dev/md/") != p->path)
./partconf/fstab-common:1:$/dev/floppy/0        /floppy auto    rw,user,noauto
./partconf/fstab-common:2:$/dev/cdroms/cdrom0   /cdrom  auto    ro,user,noauto
./partitioner/main.c:32:        devdir = opendir("/dev/discs");
./partitioner/main.c:50:                asprintf(&fullname, "%s/%s/%s", "/dev/discs",
^ all of this needs to be fixed except perhaps for /dev/md/

./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