Skip to contentSkip to conversation

Use modinfo to gather module dependencies

PATCH In review Dennis Schridde 3 participants 6 messages Feb 25, 2012 – Feb 27, 2012 4 messages not in the archive Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use modinfo to gather module dependencies

Hello!

I just switched from module-init-tools to kmod and found dracut broken, because it uses modprobe --show-depends to find out about module locations and dependencies, which apparently is not implemented in kmod.

Hence I wrote attached patch, switching from modprobe to modinfo, which also seem to be the tool intended for the job. This method appears to work reliable in kmod-5, but I have not tested with module-init-tools.

Kind regards,
Dennis

usr/lib/dracut/dracut-functions renamed from usr/lib/dracut/dracut-functions.orig +28 -10
@@ -964,6 +964,28 @@
     return 0
 }
 
+get_kmod_filename_with_deps_recursive() {
+    local _kmod=$1 _field _value _modpath _dep _deps
+	shift 1
+    modinfo "$@" $_kmod 2>&${_fderr} | (
+		while read _field _value ; do
+			case $_field in
+				filename:)
+					_modpath=$_value
+					;;
+				depends:)
+					_deps=${_value//,/ }
+					for _dep in $_deps ; do
+						get_kmod_filename_with_deps_recursive $_dep "$@"
+					done
+					;;
+			esac
+		done
+		echo $_modpath
+		[[ $_modpath ]] || exit 1
+	)
+}
+
 # Do something with all the dependencies of a kernel module.
 # Note that kernel modules depend on themselves using the technique we use
 # $1 = function to call for each dependency we find
@@ -972,17 +994,13 @@
 # rest of args = arguments to modprobe
 # _fderr specifies FD passed from surrounding scope
 for_each_kmod_dep() {
-    local _func=$1 _kmod=$2 _cmd _modpath _options _found=0
+    local _func=$1 _kmod=$2 _modpath _found=0
     shift 2
-    modprobe "$@" --ignore-install --show-depends $_kmod 2>&${_fderr} | (
-        while read _cmd _modpath _options; do
-            [[ $_cmd = insmod ]] || continue
-            $_func ${_modpath} || exit $?
-            _found=1
-        done
-        [[ $_found -eq 0 ]] && exit 1
-        exit 0
-    )
+    for _modpath in `get_kmod_filename_with_deps_recursive ${_kmod} "$@"` ; do
+       	$_func ${_modpath}
+        _found=1
+	done
+    [[ $_found -ne 0 ]]
 }
 
 # filter kernel modules to install certain modules that meet specific
#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 25.02.2012 22:09, schrieb Dennis Schridde:

Quoted 11 lines

Hello!

I just switched from module-init-tools to kmod and found dracut broken, because it uses modprobe --show-depends to find out about module locations and dependencies, which apparently is not implemented in kmod.

Hence I wrote attached patch, switching from modprobe to modinfo, which also seem to be the tool intended for the job. This method appears to work reliable in kmod-5, but I have not tested with module-init-tools.

Kind regards, Dennis

You need this patch for kmod:

http://git.profusion.mobi/cgit.cgi/kmod.git/commit/?id=269de2e0bf5011072da2f40f4f2d4023fad696b9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPS1nvAAoJEANOs3ABTfJwhbgP/iasuIv8UUjNT6GO6oGU5nPN CBulsqlfSyYHedi2mg6owI4sDb/UU6Ii5gs1fYI4pzlRGJwUTD0/eR2yAZ0Cpyht eEliTS9zb/UqZcXRvDQi245IvKD4cM1xKAQhwSzGwAEBEbuD10RXLkNm8x5LmwpW ZhjlMl58s1FjYC54Ezrqd2H3dD6d0oWEkDW6pU0wn34QQOemaZEgNcXXXn62qR1X j4Br8ambBaByTqhOBX8xZGXPa7K6Uz6BM5vvd5CTRpZ/uODJ1r6ngUz/hWS+zzwl iBjrM2DHBEJdg7HJjwn7Dt8FH5ifxWdIN42Pkp//NyozwBbbfSyeGczYn4tHQPs8 W2EyiIkTwzp09UT5JmLCbULyrg12YgSI7jreW3Mb37Hyvzll1846rBSrUWP5Ujx2 bqzajMiPXgZx9hJR6N3YxFlGw96ORbSfpnrbIlTrfN8qdCEeOx6IZRteM/Pkyzza 1m+T08WwCzQE2MLkIStLX//zmHDRVZErBsUHp0rSu9ya68/N0lFlJvPrOc1HsNaF kcnnmOy9Anak21UCO4+QMIzhNG1C0wujZUiWu0W37eQLpCGBBUAZTXQSrJhmsNj+ V2gx10+/W3mnKHbhdjGbcr0ds87oJFMIfT3XKdn1aJ88PtVtdfwd97ZA8gQ5omv5 SVet9vwoaupvgfsaETqq
=Oc+u
-----END PGP SIGNATURE-----

#3 lore raw
In reply to a message not in the archive

'Twas brillig, and Harald Hoyer at 27/02/12 10:25 did gyre and gimble:

Quoted 11 lines

Am 25.02.2012 22:09, schrieb Dennis Schridde:

Quoted 9 lines

Hello!

I just switched from module-init-tools to kmod and found dracut broken, because it uses modprobe --show-depends to find out about module locations and dependencies, which apparently is not implemented in kmod.

Hence I wrote attached patch, switching from modprobe to modinfo, which also seem to be the tool intended for the job. This method appears to work reliable in kmod-5, but I have not tested with module-init-tools.

Quoted 5 lines
Quoted 1 line

Kind regards, Dennis

You need this patch for kmod:

http://git.profusion.mobi/cgit.cgi/kmod.git/commit/?id=269de2e0bf5011072da2f40f4f2d4023fad696b9

What does this patch add?

I seem to get modprobe working happily with kmod 5 even for non-loaded modules. With patch applied or not, the output was the same.

I'd just like to understand the issue :)

Cheers

Col

(i915 is loaded, nouveau is not)

[colin@jimmy dracut (master)]$ modprobe --ignore-install --show-depends i915 insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/acpi/video.ko.xz insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/i2c/i2c-core.ko.xz insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/acpi/button.ko.xz insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/i2c/algos/i2c-algo-bit.ko.xz

insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/gpu/drm/drm.ko.xz insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/gpu/drm/drm_kms_helper.ko.xz

insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/gpu/drm/i915/i915.ko.xz i915_enable_fbc=0
[colin@jimmy dracut (master)]$ modprobe --ignore-install --show-depends nouveau
insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/acpi/button.ko.xz insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/acpi/video.ko.xz insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/platform/x86/wmi.ko.xz insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/platform/x86/mxm-wmi.ko.xz insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/i2c/i2c-core.ko.xz insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/i2c/algos/i2c-algo-bit.ko.xz

insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/gpu/drm/drm.ko.xz insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/gpu/drm/drm_kms_helper.ko.xz

insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/gpu/drm/ttm/ttm.ko.xz insmod /lib/modules/3.2.7-desktop-1.mga2/kernel/drivers/gpu/drm/nouveau/nouveau.ko.xz

Signature · 10 lines
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/
#4 lore raw

Am 27.02.2012 12:29, schrieb Colin Guthrie:

Quoted 16 lines

'Twas brillig, and Harald Hoyer at 27/02/12 10:25 did gyre and gimble:

Quoted 15 lines

Am 25.02.2012 22:09, schrieb Dennis Schridde:

Quoted 11 lines

Hello!

I just switched from module-init-tools to kmod and found dracut broken, because it uses modprobe --show-depends to find out about module locations and dependencies, which apparently is not implemented in kmod.

Hence I wrote attached patch, switching from modprobe to modinfo, which also seem to be the tool intended for the job. This method appears to work reliable in kmod-5, but I have not tested with module-init-tools.

Kind regards, Dennis

You need this patch for kmod:

Quoted 8 lines
Quoted 1 line

http://git.profusion.mobi/cgit.cgi/kmod.git/commit/?id=269de2e0bf5011072da2f40f4f2d4023fad696b9

What does this patch add?

I seem to get modprobe working happily with kmod 5 even for non-loaded modules. With patch applied or not, the output was the same.

I'd just like to understand the issue :)

Have you replaced module-init-tools with kmod? If not, then this problem does not affect you.

#6 lore raw
In reply to a message not in the archive

'Twas brillig, and Harald Hoyer at 27/02/12 12:08 did gyre and gimble:

Quoted 5 lines

Am 27.02.2012 12:29, schrieb Colin Guthrie:

Quoted 1 line

I'd just like to understand the issue :)

Have you replaced module-init-tools with kmod? If not, then this problem does not affect you.

Gah, it seems not. I had it in my head that we'd switched, but on closer inspection it was just ldetect and few other bits and bobs that moved over... not module-init-tools yet.

Sorry for the noise.

Col

Signature · 10 lines
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/
#9 lore raw
In reply to a message not in the archive

Hi Harald!

Am Samstag, 25. Februar 2012, 22:18:48 schrieben Sie:

Quoted 6 lines

Am 25.02.2012 22:09 schrieb "Dennis Schridde" <[email protected]>:

Quoted 2 lines

Hence I wrote attached patch, switching from modprobe to modinfo, which

also

Quoted 7 lines
Quoted 1 line

seem to be the tool intended for the job. This method appears to work

reliable

Quoted 1 line

in kmod-5, but I have not tested with module-init-tools.

Just update kmod... modprobe --show-depends was fixed

Thanks for the info.

I would like know your reasons for using modprobe instead of modinfo to gather information about modules, since it appears to be the wrong tool to me.

Kind regards,
Dennis