From 36f91971b00f9f57875307b99a0f13b339a66baa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Fri, 9 Feb 2018 17:18:21 +0100 Subject: [PATCH] mount: fix removing mount point if it's expired MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Kernel can report mount point as expired and when that happens mountd unmounts it. When such a device disappears it's still important to: 1) Cleanup directories 2) Call hotplug scripts Fix this by adding a new EXPIRED status and checking it when block device disappears. Signed-off-by: Rafał Miłecki --- mount.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mount.c b/mount.c index 2d34a91..cb3e03c 100644 --- a/mount.c +++ b/mount.c @@ -38,11 +38,13 @@ static struct list_head mounts; * * @STATUS_UNMOUNTED: currently not mounted * @STATUS_MOUNTED: mounted & ready for usage + * @STATUS_EXPIRED: mount expired & *temporary* unmounted * @STATUS_IGNORE: entry should be ignored and never mounted */ enum status { STATUS_UNMOUNTED = 0, STATUS_MOUNTED, + STATUS_EXPIRED, STATUS_IGNORE, }; @@ -330,7 +332,7 @@ int mount_remove(char *path, char *dev) rmdir(tmp); mount = mount_find(0, dev); if(mount) - mount->status = STATUS_UNMOUNTED; + mount->status = STATUS_EXPIRED; log_printf("finished unmounting\n"); mount_dump_uci_state(); return 0; @@ -762,7 +764,7 @@ static void mount_enum_drives(void) p->next->prev = p->prev; p = p->next; log_printf("removing %s\n", q->dev); - if (q->status == STATUS_MOUNTED) { + if (q->status == STATUS_MOUNTED || q->status == STATUS_EXPIRED) { snprintf(tmp, 64, "%s%s", "/tmp/run/mountd/", q->dev); rmdir(tmp); snprintf(tmp, 64, "%s%s", uci_path, q->name); -- 2.25.1