[OpenWrt-Devel] [PATCH fstools] Revert "block: mount_action: handle mount/umount deps"
Rafał Miłecki
zajec5 at gmail.com
Fri Dec 27 03:53:35 EST 2019
From: Rafał Miłecki <rafal at milecki.pl>
This reverts commit 32c3126b2f0464106d74317336b6aef1d7d5f82f.
Internal list of devices guarantees some basic sorting (by device type
and then a name) but nothing more. In particular it's not guaranteed
(and it's actually quite uncommon) that all preceding entries are parent
devices.
Mounting all preceding devices may easily result in unrelated mounts.
They can fail easily basically breaking original mounting attempt, e.g.:
daemon.err blockd: kernel is requesting a mount -> sda2
daemon.err block: /dev/sda1 is already mounted on /tmp/run/blockd/sda1
daemon.err block: autofs: "add" action has failed: -1
daemon.err blockd: failed to run block. add/sda2
If some dependency handling is required it should be implemented
explicitly as current solution isn't reliable and it breaks autofs when
using multiple devices (partitions).
Cc: Yousong Zhou <yszhou4tech at gmail.com>
Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
block.c | 43 +++++++++++++------------------------------
1 file changed, 13 insertions(+), 30 deletions(-)
diff --git a/block.c b/block.c
index b6d49a8..e07cbc5 100644
--- a/block.c
+++ b/block.c
@@ -1199,47 +1199,30 @@ static int umount_device(char *path, int type, bool all)
static int mount_action(char *action, char *device, int type)
{
- struct device *the_dev, *dev;
char path[32];
if (!action || !device)
return -1;
-
- if (config_load(NULL))
- return -1;
- cache_load(0);
-
- the_dev = find_block_device(NULL, NULL, device);
+ snprintf(path, sizeof(path), "/dev/%s", device);
if (!strcmp(action, "remove")) {
if (type == TYPE_HOTPLUG)
blockd_notify(device, NULL, NULL);
- if (!the_dev || !the_dev->m || the_dev->m->type != TYPE_MOUNT) {
- snprintf(path, sizeof(path), "/dev/%s", device);
- umount_device(path, type, true);
- } else
- vlist_for_element_to_last_reverse(&devices, the_dev, dev, node)
- if (dev->m && dev->m->type == TYPE_MOUNT)
- umount_device(dev->pr->dev, type, true);
+ umount_device(path, type, true);
+
return 0;
- } else if (!strcmp(action, "add")) {
- if (!the_dev)
- return -1;
- if (the_dev->m && the_dev->m->type == TYPE_MOUNT) {
- vlist_for_first_to_element(&devices, the_dev, dev, node) {
- if (dev->m && dev->m->type == TYPE_MOUNT) {
- int err = mount_device(dev, type);
- if (err)
- return err;
- }
- }
- return 0;
- } else
- return mount_device(the_dev, type);
+ } else if (strcmp(action, "add")) {
+ ULOG_ERR("Unkown action %s\n", action);
+
+ return -1;
}
- ULOG_ERR("Unkown action %s\n", action);
- return -1;
+
+ if (config_load(NULL))
+ return -1;
+ cache_load(0);
+
+ return mount_device(find_block_device(NULL, NULL, path), type);
}
static int main_hotplug(int argc, char **argv)
--
2.21.0
_______________________________________________
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