summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2015-02-11 18:06:47 -0500
committerAnthony G. Basile <blueness@gentoo.org>2015-02-11 18:06:47 -0500
commit79bf63bcff0c397b99626c845406d0b125c015a3 (patch)
tree0d3debfdd4f2017a2cca1d2c68dfae3e4c1af19c /src/udev
parent158c3f34cf25652aeb90ec4a24a6f5c7a5bd8f00 (diff)
src/udev/udev-builtin-kmod.c: remove the modprobe alt to kmod code
Diffstat (limited to 'src/udev')
-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
4 files changed, 9 insertions, 42 deletions
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;