From: Rafał Miłecki Date: Wed, 12 Dec 2018 14:24:34 +0000 (+0100) Subject: blockd: unmount device explicitly when it disappears X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3bb3352a5f6c1cffd8a487b92eb762c857df75ed;p=oweals%2Ffstools.git blockd: unmount device explicitly when it disappears 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 --- 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