[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Major dead code cleanup



I've prepared a series of patches that remove quite a bit of code that 
AFAICT is no longer used. It is code specific to the 2.4 kernel series, 
code that used discover for hardware detection, and code to support old 
versions of udev.

Removing this code should not affect the current functioning of the 
installer, but as it still is quite invasive I'd appreciate a review 
before committing.

The patches for hw-detect have been split out into 4 stages:
01: removes 2.4 specific code
02: removes support for discover; the blacklisting code for the de4x5
    module is obsolete as that module has no PCI ID's associated with it
03: cleans up udev support
04: some final bits

I suspect that there is quite a bit more code in hw-detect that can be 
removed because some modules will now be reliably loaded automatically by 
the kernel/udev, but that is for later.

Cheers,
FJP
Only in hw-detect/debian/po: .svn
Only in hw-detect/debian: .svn
diff -ur hw-detect/discover-mac-io.sh hw-detect.no-2.4/discover-mac-io.sh
--- hw-detect/discover-mac-io.sh	2007-04-11 15:33:59.000000000 +0200
+++ hw-detect.no-2.4/discover-mac-io.sh	2007-04-11 15:33:50.000000000 +0200
@@ -46,31 +46,17 @@
 		register-module mesh
 	# sound/ppc, sound/oss/dmasound
 	elif [ "$name" = awacs ]; then
-		case "$(uname -r)" in
-		2.4*)
-			register-module dmasound_pmac
-			;;
-		2.6*)
-			# probably best to go for ALSA
-			register-module snd-powermac
-			;;
-		esac
+		# probably best to go for ALSA
+		register-module snd-powermac
 	elif [ "$name" = davbus ] || [ "$name" = i2s-a ]; then
 		for child in "$dir"/*; do
 			if [ -f "$child/name" ]; then
 				childname="$(cat "$child/name" 2>/dev/null || true)"
 				if [ "$childname" = sound ]; then
-					case "$(uname -r)" in
-					2.4*)
-						register-module dmasound_pmac
-						;;
-					2.6*)
-						# Loading snd-powermac locks up G5 systems
-						if  [ "$name" != i2s-a ]; then
-							register-module snd-powermac
-						fi
-						;;
-					esac
+					# Loading snd-powermac locks up G5 systems
+					if  [ "$name" != i2s-a ]; then
+						register-module snd-powermac
+					fi
 				fi
 			fi
 		done
diff -ur hw-detect/hotplug-pcmcia.sh hw-detect.no-2.4/hotplug-pcmcia.sh
--- hw-detect/hotplug-pcmcia.sh	2007-04-11 15:33:59.000000000 +0200
+++ hw-detect.no-2.4/hotplug-pcmcia.sh	2007-04-11 15:33:49.000000000 +0200
@@ -20,56 +20,10 @@
 		echo $INTERFACE >>/etc/network/devhotplug
 	;;
 
-	# PCI hotplugging for Cardbus cards on 2.4 kernels only
+	# PCI hotplugging is deprecated (2.4 kernels only)
 	pci)
-		if [ "$PCI_SLOT_NAME" = "" ]; then
-			log "Got pci event without slot name"
-			exit 1
-		fi
-
-		# Sanity check
-		if ! [ -f /tmp/pcmcia-discover-snapshot ]; then
-			log "Got PCI event but have no discover snapshot! 2.6 kernel?"
-			exit 1
-		fi
-
-		log "Detected Cardbus device at $PCI_SLOT_NAME"
-
-		# Take another snapshot of discover information and compare it
-		# with the old one to find out the module for the new device
-
-		log "Searching for module..."
-
-		modules_before=`cat /tmp/pcmcia-discover-snapshot`
-
-		DISCOVER_TEST=$(discover --version 2> /dev/null) || true
-		if expr "$DISCOVER_TEST" : 'discover 2.*' > /dev/null 2>&1; then
-			dpath=linux/module/name
-			dver=`uname -r|cut -d. -f1,2` # Kernel version (e.g. 2.4)
-			dflags="-d all -e pci scsi fixeddisk modem network removabledisk"
-	    
-			echo `discover --data-path=$dpath --data-version=$dver $dflags` \
-				| sed 's/ $//' >/tmp/pcmcia-discover-snapshot
-		else
-			discover --format="%m " --disable-all --enable=pci \
-				scsi ide ethernet \
-				| sed 's/ $//' >/tmp/pcmcia-discover-snapshot
-		fi
-	    
-		modules_after=`cat /tmp/pcmcia-discover-snapshot`
-		module=`echo "${modules_after#$modules_before}" | sed 's/^ //'`
-
-		if [ -n "$module" ]; then
-			log "Found module $module, loading"
-			if modprobe $module >/dev/null 2>&1; then
-				log "Module $module loaded successfully"
-			else
-				log "Failed loading $module (queuing)"
-				echo "$module" >>/etc/pcmcia/cb_mod_queue
-			fi
-		else
-			log "No module found for Cardbus device at $PCI_SLOT_NAME"
-		fi
+		log "PCI event is deprecated."
+		exit 1
 	;;
 
 	pcmcia_socket)
@@ -78,5 +32,6 @@
 	
 	*)
 		log "Got unsupported event type \"$TYPE\""
+		exit 1
 	;;
 esac
diff -ur hw-detect/hw-detect.sh hw-detect.no-2.4/hw-detect.sh
--- hw-detect/hw-detect.sh	2007-04-11 15:33:59.000000000 +0200
+++ hw-detect.no-2.4/hw-detect.sh	2007-04-11 16:15:57.000000000 +0200
@@ -104,24 +104,6 @@
 	echo $old > /proc/sys/kernel/printk
 }
 
-load_sr_mod () {
-	case "$(uname -r)" in
-	2.4*)
-		if is_not_loaded "sr_mod"; then
-			if is_available "sr_mod"; then
-				db_subst hw-detect/load_progress_step CARDNAME "SCSI CDROM support"
-				db_subst hw-detect/load_progress_step MODULE "sr_mod"
-				db_progress INFO hw-detect/load_progress_step
-				load_module sr_mod
-				register-module sr_mod
-			else
-				missing_module sr_mod "SCSI CDROM"
-			fi
-		fi
-		;;
-	esac
-}
-
 blacklist_de4x5 () {
 	cat << EOF >> $finish_install
 if [ -e /target/etc/discover.conf ]; then
@@ -164,7 +146,7 @@
 	case "$DISCOVER_VERSION" in
 	2)
 		dpath=linux/module/name
-		dver=`uname -r|cut -d. -f1,2` # Kernel version (e.g. 2.4)
+		dver=`uname -r|cut -d. -f1,2` # Kernel version (e.g. 2.6)
 		dflags="-d all -e ata -e pci -e pcmcia -e \
 			scsi bridge broadband fixeddisk humaninput modem \
 			network optical removabledisk"
@@ -251,24 +233,6 @@
 	esac
 }
 
-get_input_info() {
-	case "$(uname -r)" in
-	2.4*)
-		case "$(udpkg --print-architecture)" in
-			i386|ia64|amd64)
-				register-module psmouse
-			;;
-		esac
-	
-		case $SUBARCH in
-			powerpc/chrp*|powerpc/prep)
-				register-module psmouse
-			;;
-		esac
-		;;
-	esac
-}
-
 # Modules that should load before autodetection.
 get_early_manual_hw_info() {
 	# Load explicitly rather than implicitly to allow the user to
@@ -281,17 +245,12 @@
 # The order of these modules are important.
 get_manual_hw_info() {
 	get_floppy_info
-	# ide-mod and ide-probe-mod are needed for older (2.4.20) kernels
-	echo "ide-mod:Linux IDE driver"
-	echo "ide-probe-mod:Linux IDE probe driver"
 	get_ide_chipset_info
-	echo "ide-detect:Linux IDE detection" # 2.4.x > 20
-	echo "ide-generic:Linux IDE support" # 2.6
+	echo "ide-generic:Linux IDE support"
 	get_ide_floppy_info
 	echo "ide-disk:Linux ATA DISK"
 	echo "ide-cd:Linux ATAPI CD-ROM"
 	echo "isofs:Linux ISO 9660 filesystem"
-	get_input_info
 
 	# on some hppa systems, nic and scsi won't be found because they're
 	# not on a bus that discover understands ... 
@@ -314,31 +273,14 @@
 # Should be greater than the number of kernel modules we can reasonably
 # expect it will ever need to load.
 MAX_STEPS=1000
-OTHER_STEPS=7
+OTHER_STEPS=4
 # Use 1/10th of the progress bar for the non-module-load steps.
 OTHER_STEPSIZE=$(expr $MAX_STEPS / 10 / $OTHER_STEPS)
 db_progress START 0 $MAX_STEPS $PROGRESSBAR
 
-# Load queued Cardbus modules, if any, and catch hotplug events.
-# We need to do this before the regular PCI detection so that we can
-# determine which network cards are Cardbus.
-if [ -f /etc/pcmcia/cb_mod_queue ]; then
-	if [ "$HOTPLUG_TYPE" = fake ]; then
-		saved_hotplug=`cat /proc/sys/kernel/hotplug`
-		echo /bin/hotplug-pcmcia >/proc/sys/kernel/hotplug
-	fi
-	for module in $(cat /etc/pcmcia/cb_mod_queue); do
-		log "Loading queued Cardbus module $module"
-		modprobe -v $module | logger -t hw-detect
-	done
-	if [ "$HOTPLUG_TYPE" = fake ]; then
-		echo $saved_hotplug >/proc/sys/kernel/hotplug
-	fi
-fi
-
 db_progress INFO hw-detect/detect_progress_step
 
-# Load yenta_socket on 2.6 kernels, if hardware is available, so that
+# Load yenta_socket, if hardware is available, so that
 # discover will see Cardbus cards.
 if [ -d /sys/bus/pci/devices ] && grep -q 0x060700 \
 	/sys/bus/pci/devices/*/class && \
@@ -466,47 +408,6 @@
 	db_progress STEP $MODULE_STEPS
 fi
 
-# If there is an ide bus, then register the ide CD modules so they'll be
-# available on the target system for base-config. Disk too, in case root is
-# not ide but ide is still used. udev should handle this for 2.6.
-if [ -e /proc/ide/ -a "`find /proc/ide/* -type d 2>/dev/null`" != "" ]; then
-	case "$(uname -r)" in
-	2.4*)
-		register-module ide-detect
-		register-module ide-cd
-		register-module ide-disk
-	;;
-	esac
-fi
-
-case "$(uname -r)" in
-2.4*)
-	# always load sd_mod and sr_mod if a scsi controller module was loaded.
-	# sd_mod to find the disks, and sr_mod to find the CD-ROMs
-	if [ -e /proc/scsi/scsi ] && ! grep -q "Attached devices: none" /proc/scsi/scsi; then
-		if grep -q 'Type:[ ]\+Direct-Access' /proc/scsi/scsi && \
-		   is_not_loaded "sd_mod" && \
-		   ! grep -q '^[^[:alpha:]]\+sd$' /proc/devices; then
-		   	if is_available "sd_mod"; then
-				db_subst hw-detect/load_progress_step CARDNAME "SCSI disk support"
-				db_subst hw-detect/load_progress_step MODULE "sd_mod"
-				db_progress INFO hw-detect/load_progress_step
-				load_module sd_mod
-				register-module sd_mod
-			else
-				missing_module sd_mod "SCSI disk"
-			fi
-		fi
-		db_progress STEP $OTHER_STEPSIZE
-		if grep -q 'Type:[ ]\+CD-ROM' /proc/scsi/scsi && \
-		   ! grep -q '^[^[:alpha:]]\+sr$' /proc/devices; then
-			load_sr_mod
-		fi
-		db_progress STEP $OTHER_STEPSIZE
-	fi
-	;;
-esac
-	
 if ! is_not_loaded ohci1394; then
 	# if firewire was found, try to enable firewire cd support
 	if is_not_loaded sbp2 && is_available scsi_mod; then
@@ -521,36 +422,20 @@
 	fi
 	register-module sbp2
 	db_progress STEP $OTHER_STEPSIZE
-	load_sr_mod
-	db_progress STEP $OTHER_STEPSIZE
-	case "$(uname -r)" in
-	2.4*)
-		# rescan bus for firewire CD after loading sr_mod
-		# (Sometimes this echo fails.)
-		echo "scsi add-single-device 0 0 0 0" > /proc/scsi/scsi || true
-	;;
-	esac
 
 	# also try to enable firewire ethernet (The right way to do this is
 	# really to catch the hotplug events from the kernel.)
 	if is_not_loaded eth1394; then
-		case "$(uname -r)" in
-		2.4*)
-			:
-		;;
-		*)
-			if is_available eth1394; then
-				db_subst hw-detect/load_progress_step CARDNAME "FireWire ethernet support"
-				db_subst hw-detect/load_progress_step MODULE "eth1394"
-				db_progress INFO hw-detect/load_progress_step
-				load_module eth1394 "FireWire ethernet"
-				# do not call register-module; udev/hotplug will load it
-				# on the installed system
-			else
-				missing_module eth1394 "FireWire ethernet"
-			fi
-		;;
-		esac
+		if is_available eth1394; then
+			db_subst hw-detect/load_progress_step CARDNAME "FireWire ethernet support"
+			db_subst hw-detect/load_progress_step MODULE "eth1394"
+			db_progress INFO hw-detect/load_progress_step
+			load_module eth1394 "FireWire ethernet"
+			# do not call register-module; udev/hotplug will load it
+			# on the installed system
+		else
+			missing_module eth1394 "FireWire ethernet"
+		fi
 	fi
 fi
 
@@ -621,31 +506,8 @@
 		fi
 
 		# If hotplugging is available in the kernel, we can use it to
-		# load modules for Cardbus cards and tell which network
-		# interfaces belong to PCMCIA devices. The former is only
-		# necessary on 2.4 kernels, though.
+		# tell which network interfaces belong to PCMCIA devices.
 		if [ "$HOTPLUG_TYPE" = fake ]; then
-			# Snapshot discover information so we can detect
-			# modules for Cardbus cards by later comparison in
-			# the hotplug handler. (Only on 2.4 kernels.)
-			if expr `uname -r` : "2.4.*" >/dev/null 2>&1; then
-				case "$DISCOVER_VERSION" in
-				2)
-					dpath=linux/module/name
-					dver=`uname -r|cut -d. -f1,2` # Kernel version (e.g. 2.4)
-					dflags="-d all -e pci scsi fixeddisk modem network removabledisk bridge"
-			
-					echo `discover --data-path=$dpath --data-version=$dver $dflags` \
-						| sed 's/ $//' >/tmp/pcmcia-discover-snapshot
-					;;
-				1)
-					discover --format="%m " --disable-all --enable=pci \
-						scsi ide ethernet bridge \
-						| sed 's/ $//' >/tmp/pcmcia-discover-snapshot
-					;;
-				esac
-			fi
-		
 			# Simple handling of hotplug events during PCMCIA
 			# detection
 			saved_hotplug=`cat /proc/sys/kernel/hotplug`
@@ -657,7 +519,6 @@
 	    
 		if [ "$HOTPLUG_TYPE" = fake ]; then
 			echo $saved_hotplug >/proc/sys/kernel/hotplug
-			rm -f /tmp/pcmcia-discover-snapshot
 		fi
 
 		db_progress STEP $OTHER_STEPSIZE
@@ -691,20 +552,11 @@
 }
 
 have_pcmcia=0
-case "$(uname -r)" in
-	2.4*)
-		if [ -e "/proc/bus/pccard/drivers" ]; then
-			have_pcmcia=1
-		fi
-	;;
-	2.6*)
-		if ls /sys/class/pcmcia_socket/* >/dev/null 2>&1; then
-			have_pcmcia=1
-		fi
-	;;
-esac
+if ls /sys/class/pcmcia_socket/* >/dev/null 2>&1; then
+	have_pcmcia=1
+fi
 
-# find Cardbus network cards on 2.6 kernels
+# find Cardbus network cards
 cardbus_check_netdev()
 {
 	local socket="$1"
@@ -728,12 +580,10 @@
 
 # Try to do this only once..
 if [ "$have_pcmcia" -eq 1 ] && ! grep -q pcmcia-cs /var/lib/apt-install/queue 2>/dev/null; then
-	log "Detected PCMCIA, installing pcmcia-cs."
-	apt-install pcmcia-cs || true
-	if expr "$(uname -r)" : 2.6 >/dev/null; then
-		log "Detected PCMCIA, installing pcmciautils."
-		apt-install pcmciautils || true
-	fi
+	#log "Detected PCMCIA, installing pcmcia-cs."
+	#apt-install pcmcia-cs || true
+	log "Detected PCMCIA, installing pcmciautils."
+	apt-install pcmciautils || true
 
 	echo "mkdir /target/etc/pcmcia 2>/dev/null || true" \
 		>>$finish_install
@@ -769,7 +619,7 @@
 	apt-install usbutils || true
 fi
 
-# Install acpi (works only for 2.6 kernels)
+# Install acpi
 if [ -d /proc/acpi ]; then
 	apt-install acpi || true
 	apt-install acpid || true
Only in hw-detect: .svn
diff -ur hw-detect.no-2.4/hw-detect.sh hw-detect.no-discover/hw-detect.sh
--- hw-detect.no-2.4/hw-detect.sh	2007-04-11 16:15:57.000000000 +0200
+++ hw-detect.no-discover/hw-detect.sh	2007-04-11 16:16:10.000000000 +0200
@@ -21,9 +21,6 @@
 	depmod -a > /dev/null 2>&1 || true
 fi
 
-# Which discover version to use.  Updated by discover_version()
-DISCOVER_VERSION=1
-
 # Is hotplug available?  Updated by hotplug_type()
 HOTPLUG_TYPE=fake
 
@@ -104,68 +101,6 @@
 	echo $old > /proc/sys/kernel/printk
 }
 
-blacklist_de4x5 () {
-	cat << EOF >> $finish_install
-if [ -e /target/etc/discover.conf ]; then
-	touch /target/etc/discover-autoskip.conf
-	(echo "# blacklisted since tulip is used instead"; echo skip de4x5 ) >> /target/etc/discover-autoskip.conf
-fi
-EOF
-}
-
-discover_version () {
-	if type discover >/dev/null 2>&1; then
-		# Ugh, Discover 1.x didn't exit with nonzero status if given an
-		# unrecognized option!
-		DISCOVER_TEST=$(discover --version 2> /dev/null) || true
-		if expr "$DISCOVER_TEST" : 'discover 2.*' > /dev/null 2>&1; then
-			log "Testing experimental discover version 2."
-			DISCOVER_VERSION=2
-		else
-			log "Using discover version 1."
-			DISCOVER_VERSION=1
-		fi
-	else
-		DISCOVER_VERSION=
-	fi
-}
-
-# join hack for discover 2
-dumb_join_discover (){
-	IFS_SAVE="$IFS"
-	IFS="$NEWLINE"
-	for i in $MODEL_INFOS; do
-		echo $1:$i;
-		shift
-	done
-	IFS="$IFS_SAVE"
-}
-
-# wrapper for discover command that can distinguish Discover 1.x and 2.x
-discover_hw () {
-	case "$DISCOVER_VERSION" in
-	2)
-		dpath=linux/module/name
-		dver=`uname -r|cut -d. -f1,2` # Kernel version (e.g. 2.6)
-		dflags="-d all -e ata -e pci -e pcmcia -e \
-			scsi bridge broadband fixeddisk humaninput modem \
-			network optical removabledisk"
-
-		MODEL_INFOS=$(discover -t $dflags)
-		MODULES=$(discover --data-path=$dpath --data-version=$dver $dflags)
-		dumb_join_discover $MODULES
-		;;
-	1)
-		case "$SUBARCH" in
-		  sparc/*) sbus=",sbus" ;;
-		esac
-		discover --format="%m:%V %M\n" --disable-all \
-		          --enable=pci,ide,scsi${sbus},pcmcia ide scsi cdrom ethernet bridge |
-			sed 's/ $//'
-		;;
-	esac
-}
-
 hotplug_type () {
 	if [ -f /proc/sys/kernel/hotplug ]; then
 		HOTPLUG_HANDLER="$(cat /proc/sys/kernel/hotplug)"
@@ -191,11 +126,7 @@
 	for ide_module in $(find /lib/modules/*/kernel/drivers/ide/pci/ -type f 2>/dev/null); do
 		if [ -e $ide_module ]; then
 			baseidemod=$(echo $ide_module | sed 's/\.o$//' | sed 's/\.ko$//' | sed 's/.*\///')
-			# hpt366 is in the discover database, and causes
-			# problems with some other hardware (bug #269823)
-			if [ "$baseidemod" != hpt366 ]; then
-				echo "$baseidemod:IDE chipset support"
-			fi
+			echo "$baseidemod:IDE chipset support"
 		fi
 	done
 }
@@ -211,7 +142,6 @@
 	if [ "${SUBARCH%%/*}" = sparc ]; then
 		discover-sbus
 	fi
-	discover_hw
 	if [ -d /proc/bus/usb ]; then
 		echo "usb-storage:USB storage"
 	fi
@@ -253,7 +183,7 @@
 	echo "isofs:Linux ISO 9660 filesystem"
 
 	# on some hppa systems, nic and scsi won't be found because they're
-	# not on a bus that discover understands ... 
+	# not on a bus that udev understands ... 
 	if [ "`udpkg --print-architecture`" = hppa ]; then
 		echo "lasi_82596:LASI Ethernet"
 		register-module lasi_82596
@@ -264,9 +194,6 @@
 	fi
 }
 
-# Detect discover version
-discover_version
-
 # Detect hotplug type
 hotplug_type
 
@@ -280,10 +207,11 @@
 
 db_progress INFO hw-detect/detect_progress_step
 
+# TODO: Can possibly be removed if udev will load yenta_socket automatically
 # Load yenta_socket, if hardware is available, so that
 # discover will see Cardbus cards.
-if [ -d /sys/bus/pci/devices ] && grep -q 0x060700 \
-	/sys/bus/pci/devices/*/class && \
+if [ -d /sys/bus/pci/devices ] && \
+	grep -q 0x060700 /sys/bus/pci/devices/*/class && \
 	! grep -q ^yenta_socket /proc/modules; then
 	db_subst hw-detect/load_progress_step CARDNAME "Cardbus bridge"
 	db_subst hw-detect/load_progress_step MODULE "yenta_socket"
@@ -328,13 +256,6 @@
 			cardname="[Unknown]"
 		fi
 		
-		if [ "$module" = de4x5 ] && ! in_list "$module" "$AVAIL_MODULES"; then
-			log "Using tulip rather than unavailable de4x5"
-			blacklist_de4x5
-			module=tulip
-			tulip_de4x5_hack=1
-		fi
-		
 		if in_list "$module" "$AVAIL_MODULES"; then
 			if [ -n "$LIST" ]; then
 				LIST="$LIST, "
@@ -392,11 +313,6 @@
 		else
 			load_module "$module" "$cardname"
 		fi
-
-		if [ "$module" = tulip ] && [ "$tulip_de4x5_hack" = 1 ]; then
-			log "Forcing use of tulip in installed system (de4x hack)"
-			register-module tulip
-		fi
 	fi
 
 	db_progress STEP $MODULE_STEPSIZE
@@ -597,22 +513,8 @@
 	fi
 fi
 
-# Install appropriate hardware detection tool into target.
-if type udevd >/dev/null 2>&1; then
-	apt-install udev || true
-else
-	case "$DISCOVER_VERSION" in
-		2)
-			apt-install discover || true
-			;;
-		1|'')
-			apt-install discover1 || true
-			;;
-	esac
-	if [ -f /proc/sys/kernel/hotplug ]; then
-		apt-install hotplug || true
-	fi
-fi
+# Install udev into target
+apt-install udev || true
 
 # TODO: should this really be conditional on hotplug support?
 if [ -f /proc/sys/kernel/hotplug ]; then
Index: debian/postinst
===================================================================
--- debian/postinst	(revision 46357)
+++ debian/postinst	(working copy)
@@ -93,40 +93,31 @@
 			fi
 		fi
 
-		if [ -d /sys/block ] && type udevinfo >/dev/null 2>&1; then
-			bootfs_disk_syspath="$(dirname "$(udevinfo -q path -n "$bootfs_devfs")")"
-			# TODO: device symlinks are allegedly slated to go
-			# away, but it's not entirely clear what their
-			# replacement will be yet ...
-			bootfs_disk="$(basename "$(readlink "/sys$bootfs_disk_syspath/device")")"
-			kind="$(basename "$(readlink "/sys$bootfs_disk_syspath/device/bus")")"
-			case $kind in
-				ide)
-					host="$(basename "$(dirname "$(readlink "/sys$bootfs_disk_syspath/device")")" | sed 's/[^0-9]*//')"
-					# TODO: devfs set bus to hwif->channel, which
-					# doesn't appear to be exposed. Since we only
-					# support the first controller anyway, I'm hoping
-					# that the host (hwif->index) will be good enough.
-					bus="$(echo "$bootfs_disk" | cut -d. -f1)"
-					target="$(echo "$bootfs_disk" | cut -d. -f2)"
-					lun=
-					;;
-				scsi)
-					host="$(echo "$bootfs_disk" | cut -d: -f1)"
-					bus="$(echo "$bootfs_disk" | cut -d: -f2)"
-					target="$(echo "$bootfs_disk" | cut -d: -f3)"
-					lun="$(echo "$bootfs_disk" | cut -d: -f4)"
-					;;
-			esac
-			part="$(($(echo "$bootfs_devfs" | sed 's/^.*[^0-9]//') - $partition_offset))"
-		else
-			kind=`echo $bootfs_devfs | sed -e 's%/dev/%%' -e 's%/host.*$%%'`
-			host=`echo $bootfs_devfs | sed -e 's%^.*host%%' -e 's%/bus.*$%%'`
-			bus=`echo $bootfs_devfs | sed -e 's%^.*bus%%' -e 's%/target.*$%%'`
-			target=`echo $bootfs_devfs | sed -e 's%^.*target%%' -e 's%/lun.*$%%'`
-			lun=`echo $bootfs_devfs | sed -e 's%^.*lun%%' -e 's%/part.*$%%'`
-			part="$(($(echo "$bootfs_devfs" | sed -e 's%^.*part%%') - $partition_offset))"
-		fi
+		bootfs_disk_syspath="$(dirname "$(udevinfo -q path -n "$bootfs_devfs")")"
+		# TODO: device symlinks are allegedly slated to go
+		# away, but it's not entirely clear what their
+		# replacement will be yet ...
+		bootfs_disk="$(basename "$(readlink "/sys$bootfs_disk_syspath/device")")"
+		kind="$(basename "$(readlink "/sys$bootfs_disk_syspath/device/bus")")"
+		case $kind in
+			ide)
+				host="$(basename "$(dirname "$(readlink "/sys$bootfs_disk_syspath/device")")" | sed 's/[^0-9]*//')"
+				# TODO: devfs set bus to hwif->channel, which
+				# doesn't appear to be exposed. Since we only
+				# support the first controller anyway, I'm hoping
+				# that the host (hwif->index) will be good enough.
+				bus="$(echo "$bootfs_disk" | cut -d. -f1)"
+				target="$(echo "$bootfs_disk" | cut -d. -f2)"
+				lun=
+				;;
+			scsi)
+				host="$(echo "$bootfs_disk" | cut -d: -f1)"
+				bus="$(echo "$bootfs_disk" | cut -d: -f2)"
+				target="$(echo "$bootfs_disk" | cut -d: -f3)"
+				lun="$(echo "$bootfs_disk" | cut -d: -f4)"
+				;;
+		esac
+		part="$(($(echo "$bootfs_devfs" | sed 's/^.*[^0-9]//') - $partition_offset))"
 
 		# We don't know how to map non ide or scsi disks
 		# and we have trouble when there is more than one such controller.
Index: os-prober
===================================================================
--- os-prober	(revision 46357)
+++ os-prober	(working copy)
@@ -4,9 +4,7 @@
 . /usr/share/os-prober/common.sh
 
 partitions () {
-	if [ -d /dev/discs ]; then
-		find /dev/discs/ -follow -type b | grep /part
-	elif [ -d /sys/block ]; then
+	if [ -d /sys/block ]; then
 		for part in /sys/block/*/*[0-9]; do
 			if [ -f "$part/start" ]; then
 				name="$(echo "${part##*/}" | sed 's,[!.],/,g')"
@@ -40,12 +38,8 @@
 			dev="${word%%[*}"
 			# TODO: factor this out to something in di-utils if
 			# it's needed elsewhere
-			if [ -d /sys/block ] && type udevinfo >/dev/null 2>&1; then
-				if ! udevinfo -q path -n "/dev/$dev" 2>/dev/null | \
-				     grep -q '/.*/.*/'; then
-					continue
-				fi
-			elif ! echo "$dev" | grep -q "/part"; then
+			if ! udevinfo -q path -n "/dev/$dev" 2>/dev/null | \
+			     grep -q '/.*/.*/'; then
 				continue
 			fi
 			raidpart="/dev/$dev"
Index: finish.d/fstab_removable_media_entries
===================================================================
--- finish.d/fstab_removable_media_entries	(revision 46357)
+++ finish.d/fstab_removable_media_entries	(working copy)
@@ -83,45 +83,25 @@
     HD_MEDIA="$(mapdevfs $HD_MEDIA)"
 fi
 founddevs=
-if [ -d /sys/block ] && type udevinfo >/dev/null 2>&1; then
-    disk_containing () {
+disk_containing () {
 	dirname "$(udevinfo -q path -n "$dev")"
-    }
-    partitions="$(list-devices partition)"
-    for dev in $partitions; do
-	if ! udevinfo -q env -n "$dev" | grep -q '^ID_BUS=usb$'; then
-	    continue
+}
+partitions="$(list-devices partition)"
+for dev in $partitions; do
+    if ! udevinfo -q env -n "$dev" | grep -q '^ID_BUS=usb$'; then
+	continue
+    fi
+    disk="$(disk_containing "$dev")"
+    for otherdev in $partitions; do
+	if [ "$(disk_containing "$otherdev")" = "$disk" ] && \
+	   grep -q "^$otherdev " /target/etc/fstab; then
+	    continue 2
 	fi
-	disk="$(disk_containing "$dev")"
-	for otherdev in $partitions; do
-	    if [ "$(disk_containing "$otherdev")" = "$disk" ] && \
-	       grep -q "^$otherdev " /target/etc/fstab; then
-		continue 2
-	    fi
-	done
-	mapdev="$(mapdevfs $dev)"
-	founddevs="${founddevs:+$founddevs }$mapdev"
     done
-else
-    for dir in /proc/scsi/usb-storage-* /proc/scsi/usb-storage; do
-	if [ -d "$dir" ]; then
-	    for ent in $dir/*; do
-		if [ -f "$ent" ]; then
-		    host=$(grep "Host scsi" $ent | sed 's/.*scsi\([0-9]\).*/\1/')
-		    for dev in $(find /dev/scsi/host$host/ -type b); do
-			if [ -b "$dev" ]; then
-			    if grep -q "^$(mapdevfs $dev) " /target/etc/fstab; then
-				continue 2
-			    fi
-			fi
-		    done
-		    dev=$(mapdevfs $(find /dev/scsi/host$host/ -type b | grep /disc))
-		    founddevs="${founddevs:+$founddevs }$dev"
-		fi
-	    done
-	fi
-    done
-fi
+    mapdev="$(mapdevfs $dev)"
+    founddevs="${founddevs:+$founddevs }$mapdev"
+done
+
 USBDEVICES=
 for dev in $founddevs; do
     if [ -z "$USBDEVICES" ]; then
diff -ur hw-detect.no-discover/hw-detect.sh hw-detect.clean-udev/hw-detect.sh
--- hw-detect.no-discover/hw-detect.sh	2007-04-11 16:16:10.000000000 +0200
+++ hw-detect.clean-udev/hw-detect.sh	2007-04-11 16:14:28.000000000 +0200
@@ -21,9 +21,6 @@
 	depmod -a > /dev/null 2>&1 || true
 fi
 
-# Is hotplug available?  Updated by hotplug_type()
-HOTPLUG_TYPE=fake
-
 log () {
 	logger -t hw-detect "$@"
 }
@@ -101,26 +98,6 @@
 	echo $old > /proc/sys/kernel/printk
 }
 
-hotplug_type () {
-	if [ -f /proc/sys/kernel/hotplug ]; then
-		HOTPLUG_HANDLER="$(cat /proc/sys/kernel/hotplug)"
-		case $HOTPLUG_HANDLER in
-			''|/sbin/udevsend)
-				HOTPLUG_TYPE=udev
-				;;
-			*)
-				if [ -d /etc/hotplug ]; then
-					HOTPLUG_TYPE=real
-				else
-					HOTPLUG_TYPE=fake
-				fi
-				;;
-		esac
-	else
-		HOTPLUG_TYPE=
-	fi
-}
-
 # Some pci chipsets are needed or there can be DMA or other problems.
 get_ide_chipset_info() {
 	for ide_module in $(find /lib/modules/*/kernel/drivers/ide/pci/ -type f 2>/dev/null); do
@@ -225,14 +202,7 @@
 
 # If using real hotplug, re-run the rc scripts to pick up new modules.
 # TODO: this just loads modules itself, rather than handing back a list
-case $HOTPLUG_TYPE in
-	real)
-		/lib/debian-installer/coldplug
-		;;
-	udev)
-		update-dev
-		;;
-esac
+update-dev
 
 ALL_HW_INFO=$(get_early_manual_hw_info; get_detected_hw_info; get_manual_hw_info)
 db_progress STEP $OTHER_STEPSIZE
@@ -421,22 +391,9 @@
 			rm -f /var/run/cardmgr.pid
 		fi
 
-		# If hotplugging is available in the kernel, we can use it to
-		# tell which network interfaces belong to PCMCIA devices.
-		if [ "$HOTPLUG_TYPE" = fake ]; then
-			# Simple handling of hotplug events during PCMCIA
-			# detection
-			saved_hotplug=`cat /proc/sys/kernel/hotplug`
-			echo /bin/hotplug-pcmcia >/proc/sys/kernel/hotplug
-		fi
-	    
 		CARDMGR_OPTS="-f" $PCMCIA_INIT start </dev/null 3<&0 2>&1 \
 			| logger -t hw-detect
 	    
-		if [ "$HOTPLUG_TYPE" = fake ]; then
-			echo $saved_hotplug >/proc/sys/kernel/hotplug
-		fi
-
 		db_progress STEP $OTHER_STEPSIZE
 	fi
 	db_fset hw-detect/start_pcmcia seen true || true
diff -ur hw-detect.clean-udev/hw-detect.sh hw-detect.clean-various/hw-detect.sh
--- hw-detect.clean-udev/hw-detect.sh	2007-04-11 16:14:28.000000000 +0200
+++ hw-detect.clean-various/hw-detect.sh	2007-04-11 16:27:06.000000000 +0200
@@ -367,8 +367,6 @@
 PCMCIA_INIT=
 if [ -x /etc/init.d/pcmciautils ]; then
 	PCMCIA_INIT=/etc/init.d/pcmciautils
-elif [ -x /etc/init.d/pcmcia ]; then
-	PCMCIA_INIT=/etc/init.d/pcmcia
 fi
 if [ "$PCMCIA_INIT" ]; then
 	if ! [ -e /var/run/cardmgr.pid ]; then
@@ -452,9 +450,7 @@
 fi
 
 # Try to do this only once..
-if [ "$have_pcmcia" -eq 1 ] && ! grep -q pcmcia-cs /var/lib/apt-install/queue 2>/dev/null; then
-	#log "Detected PCMCIA, installing pcmcia-cs."
-	#apt-install pcmcia-cs || true
+if [ "$have_pcmcia" -eq 1 ] && ! grep -q pcmciautils /var/lib/apt-install/queue 2>/dev/null; then
 	log "Detected PCMCIA, installing pcmciautils."
 	apt-install pcmciautils || true
 
@@ -489,7 +485,7 @@
 	apt-install pbbuttonsd || true
 fi
 
-# Install optimised libc based on CPU type.
+# Install optimised libc based on CPU type
 case "$(udpkg --print-architecture)" in
 	i386)
 		case "$(grep '^cpu family' /proc/cpuinfo | cut -d: -f2)" in
Index: list-devices
===================================================================
--- list-devices	(revision 46357)
+++ list-devices	(working copy)
@@ -2,111 +2,72 @@
 TYPE="$1"
 
 case $TYPE in
-	cd|disk|partition|floppy|maybe-floppy)	;;
-	*)
-		echo "Usage: $0 cd|disk|partition|floppy|maybe-floppy" >&2
-		exit 2
-		;;
+    cd|disk|partition|floppy|maybe-floppy) ;;
+    *)
+	echo "Usage: $0 cd|disk|partition|floppy|maybe-floppy" >&2
+	exit 2
+	;;
 esac
 
-if [ -d /sys/block ] && type udevinfo >/dev/null 2>&1; then
-	syspaths=
+syspaths=
+case $TYPE in
+    partition)
+	for x in /sys/block/*/*; do
+		[ -d "$x" ] || continue
+		syspaths="${syspaths:+$syspaths }$x"
+	done
+	TYPE=disk
+	;;
+    *)
+	for x in /sys/block/*; do
+		[ -d "$x" ] || continue
+		syspaths="${syspaths:+$syspaths }$x"
+	done
+	;;
+esac
+for x in $syspaths; do
+	devpath="${x#/sys}"
+	match=false
 	case $TYPE in
-		partition)
-			for x in /sys/block/*/*; do
-				[ -d "$x" ] || continue
-				syspaths="${syspaths:+$syspaths }$x"
-			done
-			TYPE=disk
-			;;
-		*)
-			for x in /sys/block/*; do
-				[ -d "$x" ] || continue
-				syspaths="${syspaths:+$syspaths }$x"
-			done
-			;;
+	    maybe-floppy)
+		TYPE=floppy
+		;;
 	esac
-	for x in $syspaths; do
-		devpath="${x#/sys}"
-		match=false
-		case $TYPE in
-			maybe-floppy)
-				TYPE=floppy
-				;;
+	case $TYPE in
+	    floppy)
+		# TODO ugly special case for non-IDE floppies
+		case $devpath in
+		    /block/fd[0-9]*)
+			match=:
+			;;
 		esac
-		case $TYPE in
-			floppy)
-				# TODO ugly special case for non-IDE floppies
-				case $devpath in
-					/block/fd[0-9]*)
-						match=:
-						;;
-				esac
-				;;
-		esac
-		if ! $match && [ "$TYPE" = cd ]; then
-			if udevinfo -q env -p "$devpath" 2>/dev/null | \
-			   grep -q '^ID_CDROM='; then
-				match=:
-			fi
+		;;
+	esac
+	if ! $match && [ "$TYPE" = cd ]; then
+		if udevinfo -q env -p "$devpath" 2>/dev/null | \
+		   grep -q '^ID_CDROM='; then
+			match=:
 		fi
-		if ! $match; then
-			if udevinfo -q env -p "$devpath" 2>/dev/null | \
-			   grep -q "^ID_TYPE=$TYPE"; then
-				match=:
-			fi
+	fi
+	if ! $match; then
+		if udevinfo -q env -p "$devpath" 2>/dev/null | \
+		   grep -q "^ID_TYPE=$TYPE"; then
+			match=:
 		fi
-		if ! $match && [ "$TYPE" = disk ]; then
-			case $devpath in
-				/block/cciss\!*|/block/ida\!*|/block/rd\!*)
-					match=:
-					;;
-			esac
-		fi
-		if $match; then
-			if ! name="$(udevinfo -q name -p "$devpath" \
-					2>/dev/null)"; then
-				name="$(printf %s "${devpath##*/}" | \
-					sed 's,!,/,g')"
-			fi
-			echo "/dev/$name"
-		fi
-	done
-else
-	case $TYPE in
-		cd)
-			if [ -d /dev/cdroms ]; then
-				find /dev/cdroms -type b
-			fi
+	fi
+	if ! $match && [ "$TYPE" = disk ]; then
+		case $devpath in
+		    /block/cciss\!*|/block/ida\!*|/block/rd\!*)
+			match=:
 			;;
-		disk)
-			if [ -d /dev/discs ]; then
-				# busybox find has no -maxdepth
-				find /dev/discs -type b | \
-					grep -v '/.*/.*/.*/' || true
-			fi
-			;;
-		partition)
-			if [ -d /dev/discs ]; then
-				# busybox find has no -mindepth
-				find /dev/discs -type b | \
-					grep '/.*/.*/.*/' || true
-			fi
-			;;
-		floppy)
-			if [ -d /dev/floppy ]; then
-				find /dev/floppy -type b
-			fi
-			;;
-		maybe-floppy)
-			# Without udev, we can't necessarily tell floppies
-			# from other kinds of disks, so we have to offer
-			# everything.
-			for x in /dev/floppy /dev/scsi /dev/ide /dev/discs; do
-				if [ -d "$x" ]; then
-					find "$x" -type b
-				fi
-			done
-			;;
-	esac
-fi
+		esac
+	fi
+	if $match; then
+		if ! name="$(udevinfo -q name -p "$devpath" \
+				2>/dev/null)"; then
+			name="$(printf %s "${devpath##*/}" | \
+				sed 's,!,/,g')"
+		fi
+		echo "/dev/$name"
+	fi
+done
Index: update-dev
===================================================================
--- update-dev	(revision 46357)
+++ update-dev	(working copy)
@@ -3,17 +3,9 @@
 
 # Make sure /dev is up to date after loading modules.
 
-if [ -x /lib/userdevfs/update-dev ]; then
-	/lib/userdevfs/update-dev
-elif type udevtrigger >/dev/null 2>&1 && type udevsettle >/dev/null 2>&1; then
+if type udevtrigger >/dev/null 2>&1 && type udevsettle >/dev/null 2>&1; then
 	udevtrigger
 	udevsettle
-elif type udevplug >/dev/null 2>&1; then
-	udevplug
-elif type udevstart >/dev/null 2>&1; then
-	udevstart
-elif type udevsynthesize >/dev/null 2>&1; then
-	udevsynthesize
 fi
 
 exit 0

Attachment: pgpuBWaunv3t8.pgp
Description: PGP signature


Reply to: