summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2021-07-24 00:52:44 +0100
committerDaniel Golle <daniel@makrotopia.org>2021-07-24 00:52:44 +0100
commit1d681ca59cada118633c6e2d65b882b4c8f0db58 (patch)
treeafb19a31003c9e6900ac2a78e316767377b5cd61
parenta846c6b98d59b55f1e761ffc5aa75077f6944689 (diff)
downloadfstools-1d681ca59cada118633c6e2d65b882b4c8f0db58.tar.gz
block: support umount device basename
blockd calls the umount action with the basename of the device rather than the full path. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--block.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/block.c b/block.c
index ae5adf0..c9b61af 100644
--- a/block.c
+++ b/block.c
@@ -1108,10 +1108,19 @@ static int mount_device(struct probe_info *pr, int type)
static int umount_device(char *path, int type, bool all)
{
- char *mp;
+ char *mp, *devpath;
int err;
- mp = find_mount_point(path);
+ if (strlen(path) > 5 && !strncmp("/dev/", path, 5)) {
+ mp = find_mount_point(path);
+ } else {
+ devpath = malloc(strlen(path) + 6);
+ strcpy(devpath, "/dev/");
+ strcat(devpath, path);
+ mp = find_mount_point(devpath);
+ free(devpath);
+ }
+
if (!mp)
return -1;
if (!strcmp(mp, "/") && !all)