summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Yao <ryao@gentoo.org>2012-11-16 23:15:39 -0500
committerRichard Yao <ryao@cs.stonybrook.edu>2012-11-17 01:07:22 -0500
commita91a7609b204ba01037df4ab314dc81c0589c8cb (patch)
tree797bbf0406430343ed5e14699e157c0ffe307a4e
parent74126789861b5a87bb9fa5ebd1982e475ed3f5b2 (diff)
Eliminate kmod dependency
Changes to rules were introduced by 06316d9f1a91b4d3efdb7402e72498cb3deb1806 while kmod support was introduced in other commits. A ton of commits were made involving kmod and it is quite clear that it is broken, so we remove it. This changes our rules to depend on modprobe. As long as the modprobe binary is in /, and not /usr, udev module loading should function properly. Signed-off-by: Richard Yao <ryao@gentoo.org>
-rw-r--r--configure.ac4
-rw-r--r--rules/75-probe_mtd.rules2
-rw-r--r--rules/80-drivers.rules12
-rw-r--r--src/test/Makefile.am1
-rw-r--r--src/udev/Makefile.am7
-rw-r--r--src/udev/udev-builtin-kmod.c134
-rw-r--r--src/udev/udev-builtin.c1
-rw-r--r--src/udev/udev.h2
8 files changed, 10 insertions, 153 deletions
diff --git a/configure.ac b/configure.ac
index 8d096bacac..00f928640e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,9 +38,7 @@ if test -z "$GPERF" ; then
AC_MSG_ERROR([*** gperf not found])
fi
-# TODO check this --- we don't want kmod necessarily
-PKG_CHECK_MODULES(KMOD, [libkmod >= 5])
-PKG_CHECK_MODULES(BLKID,[blkid >= 2.20])
+# PKG_CHECK_MODULES(BLKID,[blkid >= 2.20])
# Checks for header files.
AC_CHECK_HEADERS(
diff --git a/rules/75-probe_mtd.rules b/rules/75-probe_mtd.rules
index c0e0839785..a17c8252ff 100644
--- a/rules/75-probe_mtd.rules
+++ b/rules/75-probe_mtd.rules
@@ -3,6 +3,6 @@
ACTION!="add", GOTO="mtd_probe_end"
KERNEL=="mtd*ro", IMPORT{program}="mtd_probe $devnode"
-KERNEL=="mtd*ro", ENV{MTD_FTL}=="smartmedia", IMPORT{builtin}="kmod load sm_ftl"
+KERNEL=="mtd*ro", ENV{MTD_FTL}=="smartmedia", RUN+="@sbindir@/modprobe -bv sm_ftl"
LABEL="mtd_probe_end"
diff --git a/rules/80-drivers.rules b/rules/80-drivers.rules
index 692510c912..04e30f5b04 100644
--- a/rules/80-drivers.rules
+++ b/rules/80-drivers.rules
@@ -2,11 +2,11 @@
ACTION=="remove", GOTO="drivers_end"
-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", RUN{builtin}="kmod load ppdev"
+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"
LABEL="drivers_end"
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index fa061d87f8..9ff6e164cc 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -16,6 +16,5 @@ test_udev_SOURCES = \
test_udev_LDADD = \
libudev-core.la \
$(BLKID_LIBS) \
- $(KMOD_LIBS) \
$(SELINUX_LIBS)
diff --git a/src/udev/Makefile.am b/src/udev/Makefile.am
index 78e1bff269..7034028c74 100644
--- a/src/udev/Makefile.am
+++ b/src/udev/Makefile.am
@@ -52,7 +52,6 @@ libudev_core_la_SOURCES = \
udev-builtin-firmware.c \
udev-builtin-hwdb.c \
udev-builtin-input_id.c \
- udev-builtin-kmod.c \
udev-builtin-net_id.c \
udev-builtin-path_id.c \
udev-builtin-usb_id.c \
@@ -76,13 +75,11 @@ libudev_core_la_SOURCES = \
libudev_core_la_CFLAGS = \
$(AM_CFLAGS) \
- $(BLKID_CFLAGS) \
- $(KMOD_CFLAGS)
+ $(BLKID_CFLAGS)
libudev_core_la_LIBADD = \
$(top_srcdir)/src/libudev/libudev-private.la \
- $(BLKID_LIBS) \
- $(KMOD_LIBS)
+ $(BLKID_LIBS)
if HAVE_ACL
libudev_core_la_SOURCES += \
diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c
deleted file mode 100644
index 17aca2944d..0000000000
--- a/src/udev/udev-builtin-kmod.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * load kernel modules
- *
- * Copyright (C) 2011-2012 Kay Sievers <kay@vrfy.org>
- * Copyright (C) 2011 ProFUSION embedded systems
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <libkmod.h>
-
-#include "udev.h"
-
-static struct kmod_ctx *ctx;
-
-static int load_module(struct udev *udev, const char *alias)
-{
- struct kmod_list *list = NULL;
- struct kmod_list *l;
- int err;
-
- err = kmod_module_new_from_lookup(ctx, alias, &list);
- if (err < 0)
- return err;
-
- if (list == NULL)
- log_debug("no module matches '%s'\n", alias);
-
- kmod_list_foreach(l, list) {
- struct kmod_module *mod = kmod_module_get_module(l);
-
- err = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST, NULL, NULL, NULL, NULL);
- if (err == KMOD_PROBE_APPLY_BLACKLIST)
- log_debug("module '%s' is blacklisted\n", kmod_module_get_name(mod));
- else if (err == 0)
- log_debug("inserted '%s'\n", kmod_module_get_name(mod));
- else
- log_debug("failed to insert '%s'\n", kmod_module_get_name(mod));
-
- kmod_module_unref(mod);
- }
-
- kmod_module_unref_list(list);
- return err;
-}
-
-static void udev_kmod_log(void *data, int priority, const char *file, int line,
- const char *fn, const char *format, va_list args)
-{
- udev_main_log(data, priority, file, line, fn, format, args);
-}
-
-static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test)
-{
- struct udev *udev = udev_device_get_udev(dev);
- int i;
-
- if (!ctx)
- return 0;
-
- if (argc < 3 || strcmp(argv[1], "load")) {
- log_error("expect: %s load <module>\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- for (i = 2; argv[i]; i++) {
- log_debug("execute '%s' '%s'\n", argv[1], argv[i]);
- load_module(udev, argv[i]);
- }
-
- return EXIT_SUCCESS;
-}
-
-/* called at udev startup and reload */
-static int builtin_kmod_init(struct udev *udev)
-{
- if (ctx)
- return 0;
-
- ctx = kmod_new(NULL, NULL);
- if (!ctx)
- return -ENOMEM;
-
- log_debug("load module index\n");
- kmod_set_log_fn(ctx, udev_kmod_log, udev);
- kmod_load_resources(ctx);
- return 0;
-}
-
-/* called on udev shutdown and reload request */
-static void builtin_kmod_exit(struct udev *udev)
-{
- log_debug("unload module index\n");
- ctx = kmod_unref(ctx);
-}
-
-/* called every couple of seconds during event activity; 'true' if config has changed */
-static bool builtin_kmod_validate(struct udev *udev)
-{
- log_debug("validate module index\n");
- if (!ctx)
- return false;
- return (kmod_validate_resources(ctx) != KMOD_RESOURCES_OK);
-}
-
-const struct udev_builtin udev_builtin_kmod = {
- .name = "kmod",
- .cmd = builtin_kmod,
- .init = builtin_kmod_init,
- .exit = builtin_kmod_exit,
- .validate = builtin_kmod_validate,
- .help = "kernel module loader",
- .run_once = false,
-};
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c
index ee81b2d713..e0e18d4ee9 100644
--- a/src/udev/udev-builtin.c
+++ b/src/udev/udev-builtin.c
@@ -35,7 +35,6 @@ static const struct udev_builtin *builtins[] = {
[UDEV_BUILTIN_FIRMWARE] = &udev_builtin_firmware,
[UDEV_BUILTIN_HWDB] = &udev_builtin_hwdb,
[UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id,
- [UDEV_BUILTIN_KMOD] = &udev_builtin_kmod,
[UDEV_BUILTIN_NET_ID] = &udev_builtin_net_id,
[UDEV_BUILTIN_PATH_ID] = &udev_builtin_path_id,
[UDEV_BUILTIN_USB_ID] = &udev_builtin_usb_id,
diff --git a/src/udev/udev.h b/src/udev/udev.h
index 82cd2ad6d0..c10610ea27 100644
--- a/src/udev/udev.h
+++ b/src/udev/udev.h
@@ -139,7 +139,6 @@ enum udev_builtin_cmd {
UDEV_BUILTIN_FIRMWARE,
UDEV_BUILTIN_HWDB,
UDEV_BUILTIN_INPUT_ID,
- UDEV_BUILTIN_KMOD,
UDEV_BUILTIN_NET_ID,
UDEV_BUILTIN_PATH_ID,
UDEV_BUILTIN_USB_ID,
@@ -162,7 +161,6 @@ extern const struct udev_builtin udev_builtin_btrfs;
extern const struct udev_builtin udev_builtin_firmware;
extern const struct udev_builtin udev_builtin_hwdb;
extern const struct udev_builtin udev_builtin_input_id;
-extern const struct udev_builtin udev_builtin_kmod;
extern const struct udev_builtin udev_builtin_net_id;
extern const struct udev_builtin udev_builtin_path_id;
extern const struct udev_builtin udev_builtin_usb_id;