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

[PATCH] updated usb detection in live-initramfs for newer kernels



Hi all,

Detection of usb flash drives does no longer work correctly with linux
2.6.29 because sysfs changed a little. The attached patch fixes this
problem.

Regards

Ronny Standtke

-- 
Ronny Standtke                 Fachhochschule Nordwestschweiz
Dozent Medienpädagogik / ICT   Pädagogische Hochschule
Telefon: +41 32 627 92 47      Obere Sternengasse 7
Mobil  : +41 79 786 81 82      4502 Solothurn
--- live-initramfs.orig	2009-04-28 14:45:19.000000000 +0200
+++ live-initramfs	2009-04-28 14:49:30.000000000 +0200
@@ -85,7 +85,19 @@
 	[ "$(expr substr ${DEVICE} 1 2)" != "sd" ] && return 1
 
 	# check that the device is an USB device
-	if readlink /sys/block/${DEVICE}/device | grep -q usb
+	KERNEL_VERSION=$(uname -r)
+	PATCH_LEVEL=$(echo ${KERNEL_VERSION} | awk -F. '{ print $3 }')
+	PATCH_LEVEL=$(echo ${PATCH_LEVEL} | awk -F- '{ print $1 }')
+	if [ ${PATCH_LEVEL} -lt 29 ];
+	then
+		# for linux kernels older than 2.6.29
+		LINK=/sys/block/${DEVICE}/device
+	else
+		# for linux kernels >= 2.6.29
+		LINK=/sys/block/${DEVICE}
+	fi
+
+	if readlink ${LINK} | grep -q usb
 	then
 		return 0
 	fi

Reply to: