kpartx supports being called for a regular file, in which case it assumes that it should set up a loop device or use an existing one. Because the loopinfo.lo_name field contains an absolute path, matching with existing loop devices fails for relative paths. Matching by basename only would be unreliable. Therefore, convert relative to absolute path for regular files. Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> --- kpartx/kpartx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c index d9057fba..3bd16452 100644 --- a/kpartx/kpartx.c +++ b/kpartx/kpartx.c @@ -350,7 +350,13 @@ main(int argc, char **argv){ if (S_ISREG (buf.st_mode)) { /* already looped file ? */ - loopdev = find_loop_by_file(device); + char rpath[PATH_MAX]; + if (realpath(device, rpath) == NULL) { + fprintf(stderr, "Error: %s: %s\n", device, + strerror(errno)); + exit (1); + } + loopdev = find_loop_by_file(rpath); if (!loopdev && what == DELETE) exit (0); -- 2.12.2 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel