]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
losetup: allow -j option argument to be relative path
authorSami Kerola <kerolasa@iki.fi>
Tue, 2 Apr 2013 19:42:50 +0000 (20:42 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 5 Apr 2013 11:56:03 +0000 (13:56 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/losetup.c

index 45e46c8c1bc81468c62aacbbd80b5011198c0834..8f3614e1f5fd2e71e86c2ebc6d0a396026a8952a 100644 (file)
@@ -23,6 +23,7 @@
 #include "closestream.h"
 #include "optutils.h"
 #include "xalloc.h"
+#include "canonicalize.h"
 
 enum {
        A_CREATE = 1,           /* setup a new device */
@@ -167,9 +168,15 @@ static int show_all_loops(struct loopdev_cxt *lc, const char *file,
                st = NULL;
 
        while (loopcxt_next(lc) == 0) {
-
-               if (file && !loopcxt_is_used(lc, st, file, offset, flags))
-                       continue;
+               if (file && !loopcxt_is_used(lc, st, file, offset, flags)) {
+                       char *canonized;
+                       int ret;
+                       canonized = canonicalize_path(file);
+                       ret = loopcxt_is_used(lc, st, canonized, offset, flags);
+                       free(canonized);
+                       if (!ret)
+                               continue;
+               }
                printf_loopdev(lc);
        }
        loopcxt_deinit_iterator(lc);