blockd: unmount device explicitly when it disappears
authorRafał Miłecki <rafal@milecki.pl>
Wed, 12 Dec 2018 14:24:34 +0000 (15:24 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Fri, 28 Dec 2018 22:10:32 +0000 (23:10 +0100)
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

index 29d16f27080310ddfd3982ea1a1a6c0f67a0dc6f..a00a5b328e7074d4f3bcc7fc1f3e35e2eec3d69d 100644 (file)
--- 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