[OpenWrt-Devel] [PATCH fstools] block: remove target directory after unmounting

Rafał Miłecki zajec5 at gmail.com
Mon Dec 10 01:48:50 EST 2018

From: Rafał Miłecki <rafal at milecki.pl>

This removes dangling directory fixing two issues:

1) Non autofs case
   Leaving directory in /mnt/ and switching to autofs would result in
   blockd failing to symlink().
2) autofs case
   Leaving directory in /var/run/blockd/ could result in apps trying to
   access it causing errors like:
   blockd: kernel is requesting a mount -> sda1
   blockd: failed to run block. add/sda1

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
 block.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/block.c b/block.c
index 091375f..f7fdc27 100644
--- a/block.c
+++ b/block.c
@@ -1130,11 +1130,13 @@ static int umount_device(char *path)
 	hotplug_call_mount("remove", basename(path));
 	err = umount2(mp, MNT_DETACH);
-	if (err)
+	if (err) {
 		ULOG_ERR("unmounting %s (%s) failed (%d) - %m\n", path, mp,
-	else
+	} else {
 		ULOG_INFO("unmounted %s (%s)\n", path, mp);
+		rmdir(mp);
+	}
 	return err;

openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list