block: recognize /dev/fit* block devices
[project/fstools.git] / blockd.c
index 3bfdea10313fc59a49cae407e8fbe936078aa55f..9572fd0087d5c98d385e2fac492c7a6876970710 100644 (file)
--- a/blockd.c
+++ b/blockd.c
@@ -14,6 +14,7 @@
 #include <linux/auto_fs4.h>
 
 #include <libubox/uloop.h>
+#include <libubox/utils.h>
 #include <libubox/vlist.h>
 #include <libubox/ulog.h>
 #include <libubox/avl-cmp.h>
@@ -152,6 +153,9 @@ static int hotplug_call_mount(struct ubus_context *ctx, const char *action,
        pid = fork();
        switch (pid) {
        case -1:
+               if (c)
+                       free(c);
+
                err = -errno;
                ULOG_ERR("fork() failed\n");
                return err;
@@ -345,13 +349,11 @@ block_hotplug(struct ubus_context *ctx, struct ubus_object *obj,
 
                vlist_add(&devices, &device->node, device->name);
 
-               if (old && !device_move(old, device)) {
-                       if (device->autofs) {
-                               device_mount_remove(ctx, old);
-                               device_mount_add(ctx, device);
-                       } else {
+               if (old && device_move(old, device)) {
+                       device_mount_remove(ctx, old);
+                       device_mount_add(ctx, device);
+                       if (!device->autofs)
                                block("mount", NULL, NULL, 0, NULL);
-                       }
                } else if (device->autofs) {
                        device_mount_add(ctx, device);
                }