block: support umount device basename
authorDaniel Golle <daniel@makrotopia.org>
Fri, 23 Jul 2021 23:52:44 +0000 (00:52 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Fri, 23 Jul 2021 23:52:44 +0000 (00:52 +0100)
blockd calls the umount action with the basename of the device rather
than the full path.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
block.c

diff --git a/block.c b/block.c
index ae5adf03ae1f7ed23b6144d051686c4f5d0cc5be..c9b61af587cb597e388755a11a23ee13ba0cbeb9 100644 (file)
--- 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)