kpartx -l does not remove it's loop device
authorHannes Reinecke <hare@suse.de>
Tue, 14 Oct 2008 06:38:29 +0000 (08:38 +0200)
committerChristophe Varoqui <christophe.varoqui@free.fr>
Tue, 21 Apr 2009 21:32:21 +0000 (23:32 +0200)
When doing a kpartx -l it does not remove it's loop device when done.

The appended patch to multipath-tools could fix this.

References: 417266

Signed-off-by: Philipp Zimmer <pzimmer@novell.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
kpartx/kpartx.c

index 237d958..d1c06d2 100644 (file)
@@ -198,6 +198,7 @@ main(int argc, char **argv){
        char *mapname = NULL;
        int loopro = 0;
        int hotplug = 0;
+       int loopcreated = 0;
        struct stat buf;
 
        initpts();
@@ -292,6 +293,7 @@ main(int argc, char **argv){
                                fprintf(stderr, "can't set up loop\n");
                                exit (1);
                        }
+                       loopcreated = 1;
                }
                device = loopdev;
        }
@@ -389,6 +391,15 @@ main(int argc, char **argv){
                                        break;
                        }
 
+                       if (loopcreated && S_ISREG (buf.st_mode)) {
+                               if (del_loop(device)) {
+                                       if (verbose)
+                                               printf("can't del loop : %s\n",
+                                                       device);
+                                       exit(1);
+                               }
+                               printf("loop deleted : %s\n", device);
+                       }
                        break;
 
                case DELETE: