[PATCH 06/13] losetup: allow -j option argument to be relative path

Sami Kerola
2013-04-02T19:43:19Z

sys-utils/losetup.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index 45e46c8..8f3614e 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -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);
--
1.8.2