summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LEGACY1
-rw-r--r--configure.ac46
-rw-r--r--rules/80-drivers-modprobe.rules13
-rw-r--r--rules/Makefile.am7
-rw-r--r--src/udev/Makefile.am11
-rw-r--r--src/udev/udev-builtin-kmod.c34
-rw-r--r--src/udev/udev-builtin.c2
-rw-r--r--src/udev/udev.h4
-rw-r--r--test/Makefile.am5
9 files changed, 27 insertions, 96 deletions
diff --git a/LEGACY b/LEGACY
index 0946f89aa4..bbac057ddd 100644
--- a/LEGACY
+++ b/LEGACY
@@ -5,4 +5,5 @@ v1.X - preserves the old userland firmware loading code
v2.X - preserves the older rules generator code
- preserves the old static nodes created from modules code
+ - preserves the the old modprobe alt to kmod code
diff --git a/configure.ac b/configure.ac
index 83e2363e46..5ddf386c19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -299,40 +299,20 @@ AM_CONDITIONAL(ENABLE_MANPAGES, [test "x$have_manpages" = "xyes"])
AC_SUBST(XSLTPROC_FLAGS)
# ------------------------------------------------------------------------------
-
-AC_ARG_ENABLE(modules, [AS_HELP_STRING([--disable-modules], [Disable loadable module support @<:@default=enabled@:>@])], [], [enable_modules=yes])
-AC_ARG_ENABLE(libkmod, [AS_HELP_STRING([--enable-libkmod], [Enable module loading through kmod @<:@default=disabled@:>@])], [], [enable_libkmod=no])
-
-if test "x${enable_modules}" = xyes; then
-
- AC_DEFINE([HAVE_MODULES], [1], [Define if we support loading modules])
-
- AS_IF([test "x${enable_libkmod}" = xyes],
- [AC_CHECK_LIB([kmod], [main],
- [PKG_CHECK_MODULES(KMOD, [libkmod >= 5])
- AC_SUBST([LIBKMOD], ["-lkmod"])
- AC_DEFINE([HAVE_LIBKMOD], [1],
- [Define if you have libkmod])
- ],
- [AC_MSG_FAILURE(
- [--enable-libkmod was given, but test for kmod failed])],
- [-lkmod])])
-
+have_kmod=no
+AC_ARG_ENABLE(kmod, AS_HELP_STRING([--disable-kmod], [disable loadable modules support]))
+if test "x$enable_kmod" != "xno"; then
+ PKG_CHECK_EXISTS([ libkmod ], have_kmod=yes, have_kmod=no)
+ if test "x$have_kmod" = "xyes"; then
+ PKG_CHECK_MODULES(KMOD, [ libkmod >= 15 ],
+ [AC_DEFINE(HAVE_KMOD, 1, [Define if kmod is available])],
+ AC_MSG_ERROR([*** kmod version >= 15 not found]))
+ fi
+ if test "x$have_kmod" = xno -a "x$enable_kmod" = xyes; then
+ AC_MSG_ERROR([*** kmod support requested, but libraries not found])
+ fi
fi
-
-AM_CONDITIONAL([HAVE_MODULES], [test "x${enable_modules}" = xyes])
-AM_CONDITIONAL([HAVE_LIBKMOD], [test "x${enable_libkmod}" = xyes])
-
-
-# ------------------------------------------------------------------------------
-
-AC_ARG_WITH([modprobe],
- [AS_HELP_STRING([--with-modprobe=modprobe],
- [specify location of modprobe when -- @<:@default=$sbindir/modprobe@:>@])],
- [],
- [with_modprobe="${sbindir}/modprobe"])
-
-AC_SUBST([MODPROBE], ["${with_modprobe}"])
+AM_CONDITIONAL(HAVE_KMOD, [test "$have_kmod" = "yes"])
# ------------------------------------------------------------------------------
diff --git a/rules/80-drivers-modprobe.rules b/rules/80-drivers-modprobe.rules
deleted file mode 100644
index 14c5b873bb..0000000000
--- a/rules/80-drivers-modprobe.rules
+++ /dev/null
@@ -1,13 +0,0 @@
-# do not edit this file, it will be overwritten on update
-
-ACTION=="remove", GOTO="drivers_end"
-
-ENV{MODALIAS}=="?*", RUN+="/sbin/modprobe $env{MODALIAS}"
-SUBSYSTEM=="tifm", ENV{TIFM_CARD_TYPE}=="SD", RUN+="/sbin/modprobe tifm_sd"
-SUBSYSTEM=="tifm", ENV{TIFM_CARD_TYPE}=="MS", RUN+="/sbin/modprobe tifm_ms"
-SUBSYSTEM=="memstick", RUN+="/sbin/modprobe ms_block mspro_block"
-SUBSYSTEM=="i2o", RUN+="/sbin/modprobe i2o_block"
-SUBSYSTEM=="module", KERNEL=="parport_pc", RUN+="/sbin/modprobe ppdev"
-KERNEL=="mtd*ro", ENV{MTD_FTL}=="smartmedia", RUN+="/sbin/modprobe sm_ftl"
-
-LABEL="drivers_end"
diff --git a/rules/Makefile.am b/rules/Makefile.am
index 408a23c976..15a3a903f4 100644
--- a/rules/Makefile.am
+++ b/rules/Makefile.am
@@ -26,14 +26,9 @@ dist_udevrules_DATA += \
60-persistent-storage.rules
endif
-if HAVE_MODULES
-if HAVE_LIBKMOD
+if HAVE_KMOD
dist_udevrules_DATA += \
80-drivers.rules
-else
-dist_udevrules_DATA += \
- 80-drivers-modprobe.rules
-endif
endif
if ENABLE_KEYMAP
diff --git a/src/udev/Makefile.am b/src/udev/Makefile.am
index 652cb67006..4a47f63063 100644
--- a/src/udev/Makefile.am
+++ b/src/udev/Makefile.am
@@ -2,7 +2,6 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
AM_CPPFLAGS = \
-include $(top_builddir)/config.h \
- -DMODPROBE=\"$(MODPROBE)\" \
-DROOTPREFIX=\"$(rootprefix)\" \
-DUDEV_HWDB_DIR=\"$(udevhwdbdir)\" \
-DUDEV_HWDB_BIN=\"$(udevhwdbbin)\" \
@@ -77,13 +76,13 @@ libudev_core_la_SOURCES += \
udev-builtin-blkid.c
endif
-if HAVE_MODULES
+if HAVE_KMOD
libudev_core_la_SOURCES += \
udev-builtin-kmod.c
-if HAVE_LIBKMOD
-libudev_core_la_CFLAGS += $(KMOD_CFLAGS)
-libudev_core_la_LIBADD += $(KMOD_LIBS)
-endif
+libudev_core_la_CFLAGS += \
+ $(KMOD_CFLAGS)
+libudev_core_la_LIBADD += \
+ $(KMOD_LIBS)
endif
#
diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c
index f39b01a452..ad2829e500 100644
--- a/src/udev/udev-builtin-kmod.c
+++ b/src/udev/udev-builtin-kmod.c
@@ -27,20 +27,16 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/wait.h>
-
-#ifdef HAVE_LIBKMOD
#include <libkmod.h>
-#endif
#include "udev.h"
static struct kmod_ctx *ctx = NULL;
static int load_module(struct udev *udev, const char *alias) {
- int err;
-#ifdef HAVE_LIBKMOD
struct kmod_list *list = NULL;
struct kmod_list *l;
+ int err;
err = kmod_module_new_from_lookup(ctx, alias, &list);
if (err < 0)
@@ -64,24 +60,6 @@ static int load_module(struct udev *udev, const char *alias) {
}
kmod_module_unref_list(list);
-#else
-
- /*
- These 3 temporaries are needed because argv (below) is a const pointer, not pointer to const
- */
- char *tmp_alias = strdup(alias);
- char *tmp_modprobe = strdup(MODPROBE);
- char *tmp_bq = strdup("-bq");
- char *const argv[] = { tmp_modprobe, tmp_bq, tmp_alias, 0 };
-
- err = execute_command(MODPROBE, argv);
-
- free(tmp_alias);
- free(tmp_modprobe);
- free(tmp_bq);
-#endif
- /* both 'kmod_module_new_from_lookup' and 'execute_command' return <0 on error
- so it is ok to assign both to 'err' */
return err;
}
@@ -93,10 +71,8 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te
struct udev *udev = udev_device_get_udev(dev);
int i;
-#ifdef HAVE_LIBKMOD
if (!ctx)
return 0;
-#endif
if (argc < 3 || !streq(argv[1], "load")) {
log_error("expect: %s load <module>", argv[0]);
@@ -113,7 +89,6 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te
/* called at udev startup and reload */
static int builtin_kmod_init(struct udev *udev) {
-#ifdef HAVE_LIBKMOD
if (ctx)
return 0;
@@ -124,19 +99,15 @@ static int builtin_kmod_init(struct udev *udev) {
log_debug("Load module index");
kmod_set_log_fn(ctx, udev_kmod_log, udev);
kmod_load_resources(ctx);
-#endif
return 0;
}
/* called on udev shutdown and reload request */
static void builtin_kmod_exit(struct udev *udev) {
-#ifdef HAVE_LIBKMOD
log_debug("Unload module index");
ctx = kmod_unref(ctx);
-#endif
}
-#ifdef HAVE_LIBKMOD
/* 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");
@@ -144,16 +115,13 @@ static bool builtin_kmod_validate(struct udev *udev) {
return false;
return (kmod_validate_resources(ctx) != KMOD_RESOURCES_OK);
}
-#endif
const struct udev_builtin udev_builtin_kmod = {
.name = "kmod",
.cmd = builtin_kmod,
.init = builtin_kmod_init,
.exit = builtin_kmod_exit,
-#ifdef HAVE_LIBKMOD
.validate = builtin_kmod_validate,
-#endif
.help = "Kernel module loader",
.run_once = false,
};
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c
index e4440a6e99..40dfeb6f30 100644
--- a/src/udev/udev-builtin.c
+++ b/src/udev/udev-builtin.c
@@ -39,7 +39,7 @@ static const struct udev_builtin *builtins[] = {
#ifdef ENABLE_KEYMAP
[UDEV_BUILTIN_KEYBOARD] = &udev_builtin_keyboard,
#endif
-#ifdef HAVE_MODULES
+#ifdef HAVE_KMOD
[UDEV_BUILTIN_KMOD] = &udev_builtin_kmod,
#endif
[UDEV_BUILTIN_NET_ID] = &udev_builtin_net_id,
diff --git a/src/udev/udev.h b/src/udev/udev.h
index fae0408672..13bb1dc82a 100644
--- a/src/udev/udev.h
+++ b/src/udev/udev.h
@@ -154,7 +154,7 @@ enum udev_builtin_cmd {
#ifdef ENABLE_KEYMAP
UDEV_BUILTIN_KEYBOARD,
#endif
-#ifdef HAVE_MODULES
+#ifdef HAVE_KMOD
UDEV_BUILTIN_KMOD,
#endif
UDEV_BUILTIN_NET_ID,
@@ -180,7 +180,7 @@ extern const struct udev_builtin udev_builtin_input_id;
#ifdef ENABLE_KEYMAP
extern const struct udev_builtin udev_builtin_keyboard;
#endif
-#ifdef HAVE_MODULES
+#ifdef HAVE_KMOD
extern const struct udev_builtin udev_builtin_kmod;
#endif
extern const struct udev_builtin udev_builtin_net_id;
diff --git a/test/Makefile.am b/test/Makefile.am
index 01db6d061a..0920e5a9b4 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -53,8 +53,9 @@ test_device_nodes_LDADD = \
$(top_builddir)/src/shared/libudev_shared.la \
$(top_builddir)/src/libudev/libudev-private.la
-if HAVE_LIBKMOD
-test_udev_LDADD += $(KMOD_LIBS)
+if HAVE_KMOD
+test_udev_LDADD += \
+ $(KMOD_LIBS)
endif
test_udev_CPPFLAGS = \