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 <rafal@milecki.pl>
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();