* [PATCH] kpartx: Fix check whether to detach loop device
@ 2016-07-13 17:23 Christian Kastner
2016-07-22 9:45 ` Christophe Varoqui
0 siblings, 1 reply; 2+ messages in thread
From: Christian Kastner @ 2016-07-13 17:23 UTC (permalink / raw)
To: dm-devel; +Cc: Christian Kastner
From: Christian Kastner <ckk@kvr.at>
When invoking kpartx -d $FOO with $FOO being a regular file, the intention is
to also detach the loop device backing $FOO using del_loop(), but this
currently doesn't happen, as can be seen by calling losetup -a afterwards.
This is because the check for the type of $FOO, prior to the del_loop() call, is
broken. S_ISREG() is called on a buffer that initially did contain the status of
$FOO, but was later overwritten with the status of the backing loop device.
This replaces the S_ISREG() test with a check for whether the loop device path
is not NULL. If it isn't, then we know that it contains the correct path, and
del_loop() can be called safely on that.
Reported as Debian bug #829496; that bug also has more information.
Signed-off-by: Christian Kastner <ckk@kvr.at>
---
kpartx/kpartx.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
index 4de13fa..b7b4047 100644
--- a/kpartx/kpartx.c
+++ b/kpartx/kpartx.c
@@ -482,14 +482,14 @@ main(int argc, char **argv){
printf("del devmap : %s\n", partname);
}
- if (S_ISREG (buf.st_mode)) {
- if (del_loop(device)) {
+ if (loopdev) {
+ if (del_loop(loopdev)) {
if (verbose)
printf("can't del loop : %s\n",
- device);
+ loopdev);
exit(1);
}
- printf("loop deleted : %s\n", device);
+ printf("loop deleted : %s\n", loopdev);
}
break;
--
2.8.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kpartx: Fix check whether to detach loop device
2016-07-13 17:23 [PATCH] kpartx: Fix check whether to detach loop device Christian Kastner
@ 2016-07-22 9:45 ` Christophe Varoqui
0 siblings, 0 replies; 2+ messages in thread
From: Christophe Varoqui @ 2016-07-22 9:45 UTC (permalink / raw)
To: Christian Kastner; +Cc: Christian Kastner, device-mapper development
[-- Attachment #1.1: Type: text/plain, Size: 2237 bytes --]
Merged.
Thanks.
On Wed, Jul 13, 2016 at 7:23 PM, Christian Kastner <ckk@debian.org> wrote:
> From: Christian Kastner <ckk@kvr.at>
>
> When invoking kpartx -d $FOO with $FOO being a regular file, the intention
> is
> to also detach the loop device backing $FOO using del_loop(), but this
> currently doesn't happen, as can be seen by calling losetup -a afterwards.
>
> This is because the check for the type of $FOO, prior to the del_loop()
> call, is
> broken. S_ISREG() is called on a buffer that initially did contain the
> status of
> $FOO, but was later overwritten with the status of the backing loop device.
>
> This replaces the S_ISREG() test with a check for whether the loop device
> path
> is not NULL. If it isn't, then we know that it contains the correct path,
> and
> del_loop() can be called safely on that.
>
> Reported as Debian bug #829496; that bug also has more information.
>
> Signed-off-by: Christian Kastner <ckk@kvr.at>
> ---
> kpartx/kpartx.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
> index 4de13fa..b7b4047 100644
> --- a/kpartx/kpartx.c
> +++ b/kpartx/kpartx.c
> @@ -482,14 +482,14 @@ main(int argc, char **argv){
> printf("del devmap : %s\n",
> partname);
> }
>
> - if (S_ISREG (buf.st_mode)) {
> - if (del_loop(device)) {
> + if (loopdev) {
> + if (del_loop(loopdev)) {
> if (verbose)
> printf("can't del loop :
> %s\n",
> - device);
> + loopdev);
> exit(1);
> }
> - printf("loop deleted : %s\n", device);
> + printf("loop deleted : %s\n", loopdev);
> }
> break;
>
> --
> 2.8.1
>
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel
>
[-- Attachment #1.2: Type: text/html, Size: 3286 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-07-22 9:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-13 17:23 [PATCH] kpartx: Fix check whether to detach loop device Christian Kastner
2016-07-22 9:45 ` Christophe Varoqui
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox