blockd: print symlink error code and string message
authorRafał Miłecki <rafal@milecki.pl>
Sat, 28 Dec 2019 21:29:03 +0000 (22:29 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Sat, 21 Mar 2020 21:39:03 +0000 (22:39 +0100)
It may help understanding failure reason, e.g.:
blockd: failed to symlink /mnt/sda1->/tmp/run/blockd/sda1 (17) - File exists

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
blockd.c

index e07530c6cbb15d3d02ce0a7bca03ca620bf60b67..a04ea5bf4b2831281376fc9609f60cc32f85869a 100644 (file)
--- a/blockd.c
+++ b/blockd.c
@@ -138,7 +138,7 @@ device_add(struct device *device)
 
        snprintf(path, sizeof(path), "/tmp/run/blockd/%s", device->name);
        if (symlink(path, device->target))
-               ULOG_ERR("failed to symlink %s->%s\n", device->target, path);
+               ULOG_ERR("failed to symlink %s->%s (%d) - %m\n", device->target, path, errno);
        else
                block("autofs", "available", device->name);
 }
@@ -158,7 +158,7 @@ device_move(struct device *device_o, struct device *device_n)
                unlink(device_o->target);
                snprintf(path, sizeof(path), "/tmp/run/blockd/%s", device_n->name);
                if (symlink(path, device_n->target))
-                       ULOG_ERR("failed to symlink %s->%s\n", device_n->target, path);
+                       ULOG_ERR("failed to symlink %s->%s (%d) - %m\n", device_n->target, path, errno);
        } else {
                mkdir(device_n->target, 0755);
                if (mount(device_o->target, device_n->target, NULL, MS_MOVE, NULL))