chiark / gitweb /
invalidate rules and kmod index with 'udevadm control --reload'
[elogind.git] / udev / udev-builtin-kmod.c
index 8e7a50a02046e4978ac159c7a63567a298054d77..6f3e2589c242333e895de79e0522db4edff754b4 100644 (file)
@@ -321,11 +321,17 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te
        struct udev *udev = udev_device_get_udev(dev);
        int i;
 
-       if (!ctx)
-               return EXIT_FAILURE;
+       if (!ctx) {
+               ctx = kmod_new(NULL, NULL);
+               if (!ctx)
+                       return -ENOMEM;
 
-       if (argc < 3) {
-               err(udev, "missing command + argument\n");
+               info(udev, "load module index\n");
+               kmod_load_resources(ctx);
+       }
+
+       if (argc < 3 || strcmp(argv[1], "load")) {
+               err(udev, "expect: %s load <module>\n", argv[0]);
                return EXIT_FAILURE;
        }
 
@@ -339,12 +345,15 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te
 
 static int builtin_kmod_init(struct udev *udev)
 {
-       kmod_unref(ctx);
+       if (ctx)
+               return 0;
+
        ctx = kmod_new(NULL, NULL);
        if (!ctx)
                return -ENOMEM;
 
        info(udev, "load module index\n");
+       kmod_load_resources(ctx);
        return 0;
 }