[OpenWrt-Devel] [PATCH fstools 2/2] block: don't duplicate unmounting code in the mount_action()

Rafał Miłecki zajec5 at gmail.com
Fri Nov 30 12:26:12 EST 2018


From: Rafał Miłecki <rafal at milecki.pl>

Use umount_device() helper instead.

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 block.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/block.c b/block.c
index bef5550..2ceee8d 100644
--- a/block.c
+++ b/block.c
@@ -1132,27 +1132,17 @@ static int umount_device(char *path)
 static int mount_action(char *action, char *device, int type)
 {
 	char path[32];
-	char *mount_point;
 
 	if (!action || !device)
 		return -1;
 	snprintf(path, sizeof(path), "/dev/%s", device);
 
 	if (!strcmp(action, "remove")) {
-		int err = 0;
-
 		if (type == TYPE_HOTPLUG)
 			blockd_notify(device, NULL, NULL);
 
-		mount_point = find_mount_point(path);
-		if (mount_point)
-			err = umount2(mount_point, MNT_DETACH);
-
-		if (err)
-			ULOG_ERR("umount of %s failed (%d) - %m\n",
-			         mount_point, errno);
+		umount_device(path);
 
-		free(mount_point);
 		return 0;
 	} else if (strcmp(action, "add")) {
 		ULOG_ERR("Unkown action %s\n", action);
-- 
2.13.7


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list