From: Rafał Miłecki Date: Wed, 21 Feb 2018 12:32:16 +0000 (+0100) Subject: mount: try lazy unmount if normal one fails X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=97da4edeb9eb3b26c9843d3a5ab605e7bcf2573f;p=oweals%2Fmountd.git mount: try lazy unmount if normal one fails If umount call fails (e.g. because of some application accessing old path) the only chance of getting mount entry cleaned is receiving autofs expire packet. This isn't fully reliable: 1) Sometimes expire can happen before closing all handles. In such case a second unmount try will fail as well and there won't be a next one. 2) Expire happens after specified timeout. If device reappears quickly (e.g. due to being replugged or USB controller restart) it may be worth having old mount cleaned up earlier for better user experience. This problem can be easily handled by using MNT_DETACH (lazy) umount as a fallback. Signed-off-by: Rafał Miłecki --- diff --git a/mount.c b/mount.c index ddcd5b3..3994149 100644 --- a/mount.c +++ b/mount.c @@ -604,6 +604,7 @@ static int mount_dev_del(struct mount *mount) log_printf("device %s has disappeared ... unmounting %s\n", mount->dev, tmp); if (umount(tmp)) { err = -errno; + umount2(tmp, MNT_DETACH); } rmdir(tmp); mount_dump_uci_state();