From: Kay Sievers Date: Fri, 23 Dec 2011 03:50:33 +0000 (+0100) Subject: builtin: kmod - switch modprobe to builtin X-Git-Tag: 176~46 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06316d9f1a91b4d3efdb7402e72498cb3deb1806;p=systemd builtin: kmod - switch modprobe to builtin --- diff --git a/INSTALL b/INSTALL index 8ad69a43..29620005 100644 --- a/INSTALL +++ b/INSTALL @@ -3,7 +3,6 @@ The options used used usually look like: --prefix=/usr \ --sysconfdir=/etc \ --bindir=/usr/bin \ - --sbindir=/usr/sbin \ --libdir=/usr/lib64 \ --libexecdir=/usr/lib/udev \ --with-systemdsystemunitdir=/usr/lib/systemd/system \ @@ -14,7 +13,6 @@ The options used in a RPM spec file look like: --prefix=%{_prefix} \ --sysconfdir=%{_sysconfdir} \ --bindir=%{_bindir} \ - --sbindir=%{_sbindir} \ --libdir=%{_libdir} \ --libexecdir=%{_prefix}/lib/udev \ --with-systemdsystemunitdir=%{_prefix}/lib/systemd/system \ @@ -23,7 +21,6 @@ The options used in a RPM spec file look like: The options to install udev in the rootfs instead of /usr, and udevadm in /sbin: --bindir=/sbin - --sbindir=/sbin --libexecdir=/lib/udev --with-systemdsystemunitdir=/lib/systemd/system --with-rootlibdir=/lib64 diff --git a/autogen.sh b/autogen.sh index ceb7e650..e7bd9c2a 100755 --- a/autogen.sh +++ b/autogen.sh @@ -25,7 +25,6 @@ libdir() { args="--prefix=/usr \ --sysconfdir=/etc \ --bindir=/sbin \ ---sbindir=/sbin \ --libdir=$(libdir /usr/lib) \ --with-rootlibdir=$(libdir /lib) \ --libexecdir=/lib/udev \ diff --git a/configure.ac b/configure.ac index f0d5d040..abfcb361 100644 --- a/configure.ac +++ b/configure.ac @@ -218,7 +218,6 @@ AC_MSG_RESULT([ prefix: ${prefix} sysconfdir: ${sysconfdir} bindir: ${bindir} - sbindir: ${sbindir} libdir: ${libdir} rootlibdir: ${rootlib_execdir} libexecdir: ${libexecdir} diff --git a/extras/mtd_probe/75-probe_mtd.rules.in b/extras/mtd_probe/75-probe_mtd.rules.in index 2e28d37f..6b0c1c27 100644 --- a/extras/mtd_probe/75-probe_mtd.rules.in +++ b/extras/mtd_probe/75-probe_mtd.rules.in @@ -3,6 +3,6 @@ ACTION!="add", GOTO="mtd_probe_end" KERNEL=="mtd*ro", IMPORT{program}="mtd_probe $tempnode" -KERNEL=="mtd*ro", ENV{MTD_FTL}=="smartmedia", RUN+="@sbindir@/modprobe -bv sm_ftl" +KERNEL=="mtd*ro", ENV{MTD_FTL}=="smartmedia", IMPORT{builtin}="kmod load sm_ftl" LABEL="mtd_probe_end" diff --git a/rules/rules.d/80-drivers.rules.in b/rules/rules.d/80-drivers.rules.in index 04e30f5b..38ebfeb0 100644 --- a/rules/rules.d/80-drivers.rules.in +++ b/rules/rules.d/80-drivers.rules.in @@ -2,11 +2,11 @@ ACTION=="remove", GOTO="drivers_end" -DRIVER!="?*", ENV{MODALIAS}=="?*", RUN+="@sbindir@/modprobe -bv $env{MODALIAS}" -SUBSYSTEM=="tifm", ENV{TIFM_CARD_TYPE}=="SD", RUN+="@sbindir@/modprobe -bv tifm_sd" -SUBSYSTEM=="tifm", ENV{TIFM_CARD_TYPE}=="MS", RUN+="@sbindir@/modprobe -bv tifm_ms" -SUBSYSTEM=="memstick", RUN+="@sbindir@/modprobe -bv --all ms_block mspro_block" -SUBSYSTEM=="i2o", RUN+="@sbindir@/modprobe -bv i2o_block" -SUBSYSTEM=="module", KERNEL=="parport_pc", RUN+="@sbindir@/modprobe -bv ppdev" +DRIVER!="?*", ENV{MODALIAS}=="?*", IMPORT{builtin}="kmod load $env{MODALIAS}" +SUBSYSTEM=="tifm", ENV{TIFM_CARD_TYPE}=="SD", IMPORT{builtin}="kmod load tifm_sd" +SUBSYSTEM=="tifm", ENV{TIFM_CARD_TYPE}=="MS", IMPORT{builtin}="kmod load tifm_ms" +SUBSYSTEM=="memstick", IMPORT{builtin}="kmod load ms_block mspro_block" +SUBSYSTEM=="i2o", IMPORT{builtin}="kmod load i2o_block" +SUBSYSTEM=="module", KERNEL=="parport_pc", IMPORT{builtin}="kmod load ppdev" LABEL="drivers_end" diff --git a/udev/udev-builtin-kmod.c b/udev/udev-builtin-kmod.c index 4e8ec653..a84f08cf 100644 --- a/udev/udev-builtin-kmod.c +++ b/udev/udev-builtin-kmod.c @@ -25,36 +25,52 @@ #include #include #include +#include #include "udev.h" -static char *kmod; - static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test) { struct udev *udev = udev_device_get_udev(dev); + pid_t pid; + char *m[5]; if (argc < 3) { err(udev, "missing command + argument\n"); return EXIT_FAILURE; } - printf("soon we '%s' the module '%s' (%i) here\n", argv[1], argv[2], argc); - printf("test: %s\n", kmod); + err(udev, "'%s' the module '%s' (%i)\n", argv[1], argv[2], argc); + + m[0] = "/sbin/modprobe"; + m[1] = "-bv"; + m[1] = argv[2]; + m[2] = argv[3]; + m[3] = NULL; + + pid = fork(); + switch(pid) { + case 0: + execv(m[0], m); + _exit(1); + case -1: + return EXIT_FAILURE; + default: + waitpid(pid, NULL, 0); + } + return EXIT_SUCCESS; } static int builtin_kmod_load(struct udev *udev) { info(udev, "load module index\n"); - asprintf(&kmod, "pid: %u", getpid()); return 0; } static int builtin_kmod_unload(struct udev *udev) { info(udev, "unload module index\n"); - free(kmod); return 0; }