From 06316d9f1a91b4d3efdb7402e72498cb3deb1806 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Fri, 23 Dec 2011 04:50:33 +0100 Subject: builtin: kmod - switch modprobe to builtin --- udev/udev-builtin-kmod.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'udev/udev-builtin-kmod.c') diff --git a/udev/udev-builtin-kmod.c b/udev/udev-builtin-kmod.c index 4e8ec653fe..a84f08cf93 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; } -- cgit v1.2.3-54-g00ecf