diff mbox series

[OpenWrt-Devel,1/2] blockd: unmount device explicitly when it disappears

Message ID 20181212142435.6495-1-zajec5@gmail.com
State Accepted
Delegated to: Rafał Miłecki
Headers show
Series [OpenWrt-Devel,1/2] blockd: unmount device explicitly when it disappears | expand

Commit Message

Rafał Miłecki Dec. 12, 2018, 2:24 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

To keep autofs behavior consistent blockd should request both: mounting
and unmounting when needed. It's important as autofs-related actions may
require slightly different handling.

Without this patch:
1) autofs mounts were handled using TYPE_AUTOFS
2) autofs unmounts were handled using TYPE_HOTPLUG

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 blockd.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/blockd.c b/blockd.c
index 29d16f2..a00a5b3 100644
--- a/blockd.c
+++ b/blockd.c
@@ -111,8 +111,19 @@  block(char *cmd, char *action, char *device)
 static void
 device_free(struct device *device)
 {
-	if (device->autofs && device->target)
+	char *mp;
+
+	if (!device->autofs)
+		return;
+
+	if (device->target)
 		unlink(device->target);
+
+	mp = _find_mount_point(device->name);
+	if (mp) {
+		block("autofs", "remove", device->name);
+		free(mp);
+	}
 }
 
 static void