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

Bug#405102: installation-report: Include info on which PCI device is in used by which kernel module



Frans Pop wrote:
> +			module=$(cd $address/driver/module; pwd -P | xargs basename)

I'm concerned about the portability of pwd -P. /bin/pwd does not support
this, although all the major shells, including busybox sh, have builtins
that do support it.

Here's a patch that does the same thing, while avoiding the xargs, pwd -P,
and awk (and also the cd). I haven't tested it in d-i yet, but /sys should
be there, so it probably works.

-- 
see shy jo
Index: report-hw
===================================================================
--- report-hw	(revision 43888)
+++ report-hw	(working copy)
@@ -14,11 +14,29 @@
 	fi
 }
 
+list_loaded_modules () {
+	cd /sys/bus/pci/devices
+	for address in *; do
+		if [ -d "$address/driver/module" ]; then
+			module=$(basename "$(readlink $address/driver/module)")
+			if grep -q "^$module " /proc/modules; then
+				address=$(echo $address | sed s/0000://)
+				echo "$(lspci -n -s $address | tail -n 1 | cut -d ' ' -f 3) $module"
+			fi
+		fi
+	done
+}
+
 uname -a 2>&1 | addinfo "umame -a"
 
 if type lspci >/dev/null 2>&1; then
 	lspci -nn  2>&1 | addinfo "lspci -nn"
 	lspci -vnn 2>&1 | addinfo "lspci -vnn"
+
+	# List which modules are referring to which PCI devices
+	if [ -d /sys/bus/pci/devices ] ; then
+		list_loaded_modules | addinfo modulemap
+	fi
 else
 	addfile /proc/pci
 	addfile /proc/bus/pci/devices

Attachment: signature.asc
Description: Digital signature


Reply to: