[LEDE-DEV] [PATCH mountd 2/2] mount: fix removing mount point if it's expired

Rafał Miłecki zajec5 at gmail.com
Fri Feb 9 08:18:21 PST 2018


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

Kernel can report mount point as expired and when that happens mountd
unmounts it. It's still important to:
1) Cleanup directories
2) Call hotplug scripts
when device for such a mount disappears. Fix this by adding a new
EXPIRED status and checking it when block device disappears.

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 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.11.0




More information about the Lede-dev mailing list