<div dir="ltr">Merged.<div>Thanks.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 13, 2016 at 7:23 PM, Christian Kastner <span dir="ltr"><<a href="mailto:ckk@debian.org" target="_blank">ckk@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Christian Kastner <<a href="mailto:ckk@kvr.at">ckk@kvr.at</a>><br>
<br>
When invoking kpartx -d $FOO with $FOO being a regular file, the intention is<br>
to also detach the loop device backing $FOO using del_loop(), but this<br>
currently doesn't happen, as can be seen by calling losetup -a afterwards.<br>
<br>
This is because the check for the type of $FOO, prior to the del_loop() call, is<br>
broken. S_ISREG() is called on a buffer that initially did contain the status of<br>
$FOO, but was later overwritten with the status of the backing loop device.<br>
<br>
This replaces the S_ISREG() test with a check for whether the loop device path<br>
is not NULL. If it isn't, then we know that it contains the correct path, and<br>
del_loop() can be called safely on that.<br>
<br>
Reported as Debian bug #829496; that bug also has more information.<br>
<br>
Signed-off-by: Christian Kastner <<a href="mailto:ckk@kvr.at">ckk@kvr.at</a>><br>
---<br>
 kpartx/kpartx.c | 8 ++++----<br>
 1 file changed, 4 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c<br>
index 4de13fa..b7b4047 100644<br>
--- a/kpartx/kpartx.c<br>
+++ b/kpartx/kpartx.c<br>
@@ -482,14 +482,14 @@ main(int argc, char **argv){<br>
                                        printf("del devmap : %s\n", partname);<br>
                        }<br>
<br>
-                       if (S_ISREG (buf.st_mode)) {<br>
-                               if (del_loop(device)) {<br>
+                       if (loopdev) {<br>
+                               if (del_loop(loopdev)) {<br>
                                        if (verbose)<br>
                                                printf("can't del loop : %s\n",<br>
-                                                       device);<br>
+                                                       loopdev);<br>
                                        exit(1);<br>
                                }<br>
-                               printf("loop deleted : %s\n", device);<br>
+                               printf("loop deleted : %s\n", loopdev);<br>
                        }<br>
                        break;<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.8.1<br>
<br>
--<br>
dm-devel mailing list<br>
<a href="mailto:dm-devel@redhat.com">dm-devel@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/dm-devel" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/dm-devel</a><br>
</font></span></blockquote></div><br></div>