From: Rafał Miłecki Date: Fri, 9 Feb 2018 16:18:21 +0000 (+0100) Subject: mount: fix removing mount point if it's expired X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=36f91971b00f9f57875307b99a0f13b339a66baa;p=project%2Fmountd.git mount: fix removing mount point if it's expired 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 --- 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);