summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2020-04-02 14:12:12 +0200
committerRafał Miłecki <rafal@milecki.pl>2020-05-02 12:59:34 +0200
commit0b93429329e9f403cf4fc45043b73e3a8d4e8e0d (patch)
treeb2078be5b3bf0cf359ff44494140c5f5bd4ff352
parentc80f7002114f65dc40895c9064c077d9631b8f6e (diff)
downloadfstools-0b93429329e9f403cf4fc45043b73e3a8d4e8e0d.tar.gz
Revert "block: mount_action: handle mount/umount deps"
This reverts commit 32c3126b2f0464106d74317336b6aef1d7d5f82f. Internally stored list of devices is implemented using struct vlist_tree and keeps devices sorted by their mount target paths. This DOESN'T mean that all preceding entires of a given device are its parent devices. Making such an assumption and mounting all preceding devices results in unwanted mounts in most cases. For example having devices like: /dev/sda1 (mount target: /mnt/foo1) /dev/sda2 (mount target: /mnt/foo2) /dev/sdb1 (mount target: /mnt/bar1) /dev/sdb2 (mount target: /mnt/bar2) will result in devices vlist_tree having entries sorted like: /dev/sdb1 (bar1), /dev/sdb2 (bar2), /dev/sda1 (foo1), /dev/sda2 (foo2) Using autofs and accessing /mnt/foo2 would result in mounting all 4 partitions and spinning unneeded /dev/sdb. Cc: Yousong Zhou <yszhou4tech@gmail.com> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-rw-r--r--block.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/block.c b/block.c
index 9e530f1..f743e75 100644
--- a/block.c
+++ b/block.c
@@ -1202,47 +1202,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)