diff mbox series

[LEDE-DEV,mountd,2/2] mount: call hotplug-call with ACTION=remove before trying to unmount

Message ID 20180221123217.28211-2-zajec5@gmail.com
State Accepted
Headers show
Series [LEDE-DEV,mountd,1/2] mount: try lazy unmount if normal one fails | expand

Commit Message

Rafał Miłecki Feb. 21, 2018, 12:32 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

This increases a chance of successfully unmounting a drive as calling
hotplug.d scripts may result in stopping applications using it.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 mount.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/mount.c b/mount.c
index 3994149..00fe91d 100644
--- a/mount.c
+++ b/mount.c
@@ -774,11 +774,13 @@  static void mount_enum_drives(void)
 		}
 		if(!check_block(q->dev)||del)
 		{
-			int err;
-
-			err = mount_dev_del(q);
 			if (q->status == STATUS_MOUNTED || q->status == STATUS_EXPIRED) {
 				char dev_link[64];
+				int err;
+
+				system_printf("ACTION=remove DEVICE=%s NAME=%s /sbin/hotplug-call mount", q->dev, q->name);
+
+				err = mount_dev_del(q);
 
 				snprintf(dev_link, sizeof(dev_link), "%s%s", uci_path, q->name);
 				if (err == -EBUSY) {
@@ -792,7 +794,6 @@  static void mount_enum_drives(void)
 					log_printf("unlinking %s\n", dev_link);
 					unlink(dev_link);
 				}
-				system_printf("ACTION=remove DEVICE=%s NAME=%s /sbin/hotplug-call mount", q->dev, q->name);
 			}
 
 			p->prev->next = p->next;