[OpenWrt-Devel,fstools] blockd: print symlink error code and string message
diff mbox series

Message ID 20191228212903.11660-1-zajec5@gmail.com
State Under Review
Delegated to: Rafał Miłecki
Headers show
  • [OpenWrt-Devel,fstools] blockd: print symlink error code and string message
Related show

Commit Message

Rafał Miłecki Dec. 28, 2019, 9:29 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff mbox series

diff --git a/blockd.c b/blockd.c
index e07530c..a04ea5b 100644
--- 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);
 		block("autofs", "available", device->name);
@@ -158,7 +158,7 @@  device_move(struct device *device_o, struct device *device_n)
 		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))