diff options
author | Daniel Golle <daniel@makrotopia.org> | 2021-07-23 23:20:43 +0100 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2021-07-23 23:35:37 +0100 |
commit | 5114595bc37e441a905db6b05b4487ad67fcb3d1 (patch) | |
tree | 8dcef8e9daba947c598babcb0af7d3bb1ac79eeb | |
parent | 9ab3551c64620a3a5c79bcdcfb270890b4e6cf1a (diff) | |
download | fstools-5114595bc37e441a905db6b05b4487ad67fcb3d1.tar.gz |
block: allow remove hotplug event to arrive at blockd
As the hotplug event fires after the device has been removed, it will
never be found by _cache_load(). Hence the 'remove' event needs to
propagate in all cases and we only need to populate the cache in case
of 'add' events.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r-- | block.c | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -1141,23 +1141,11 @@ static int mount_action(char *action, char *device, int type) if (!action || !device) return -1; - if (config_load(NULL)) - return -1; - - cache_load(1); - - list_for_each_entry(pr, &devices, list) - if (!strcmp(basename(pr->dev), device)) - path = pr->dev; - - if (!path) - return -1; - if (!strcmp(action, "remove")) { if (type == TYPE_HOTPLUG) blockd_notify("hotplug", device, NULL, NULL); - umount_device(path, type, true); + umount_device(device, type, true); return 0; } else if (strcmp(action, "add")) { @@ -1166,6 +1154,18 @@ static int mount_action(char *action, char *device, int type) return -1; } + if (config_load(NULL)) + return -1; + + cache_load(1); + + list_for_each_entry(pr, &devices, list) + if (!strcmp(basename(pr->dev), device)) + path = pr->dev; + + if (!path) + return -1; + return mount_device(find_block_info(NULL, NULL, path), type); } |