From 3bb3352a5f6c1cffd8a487b92eb762c857df75ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Wed, 12 Dec 2018 15:24:34 +0100 Subject: [PATCH] blockd: unmount device explicitly when it disappears MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- blockd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 -- 2.25.1