summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2021-05-12 18:05:37 +0100
committerDaniel Golle <daniel@makrotopia.org>2021-05-16 00:28:11 +0100
commit67d229724865a157592f88863b788e1fd35a2bd4 (patch)
tree785d16dacfd84f48ca4222aaaa5951be8ec97802
parentd47909ea1e5f32cfc9f756a04edc052717c98ae6 (diff)
downloadfstools-67d229724865a157592f88863b788e1fd35a2bd4.tar.gz
block: match device path instead of assuming /dev/%s
Block devices created by device mapper are in /dev/mapper/ folder, hence the assumption of the 'block' tool expecting /dev/%s being the path of a device doesn't hold true. Match device path from cache instead. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--block.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/block.c b/block.c
index a613fd7..de6229d 100644
--- a/block.c
+++ b/block.c
@@ -1135,11 +1135,23 @@ static int umount_device(char *path, int type, bool all)
static int mount_action(char *action, char *device, int type)
{
- char path[32];
+ char *path = NULL;
+ struct probe_info *pr;
if (!action || !device)
return -1;
- snprintf(path, sizeof(path), "/dev/%s", device);
+
+ 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)
@@ -1154,10 +1166,6 @@ static int mount_action(char *action, char *device, int type)
return -1;
}
- if (config_load(NULL))
- return -1;
- cache_load(0);
-
return mount_device(find_block_info(NULL, NULL, path), type);
}