diff options
author | Daniel Golle <daniel@makrotopia.org> | 2021-07-24 00:52:44 +0100 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2021-07-24 00:52:44 +0100 |
commit | 1d681ca59cada118633c6e2d65b882b4c8f0db58 (patch) | |
tree | afb19a31003c9e6900ac2a78e316767377b5cd61 | |
parent | a846c6b98d59b55f1e761ffc5aa75077f6944689 (diff) | |
download | fstools-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.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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) |