kpartx: on delete process partitions in reverse order
authorGuido Guenther <agx@sigxcpu.org>
Mon, 26 Nov 2007 15:27:32 +0000 (16:27 +0100)
committerChristophe Varoqui <christophe.varoqui@free.fr>
Mon, 26 Nov 2007 22:04:26 +0000 (23:04 +0100)
otherwise we try to remove the extended partition of MSDOS labels
(/dev/mapper/mpathX-part[1-4]) before the logical partition
/dev/mapper/mpathX-partY (Y>5) which fails.

Signed-Off-By: Guido Guenther <agx@sigxcpu.org>
kpartx/kpartx.c

index 6d64e30..1b0f059 100644 (file)
@@ -403,7 +403,7 @@ main(int argc, char **argv){
                        break;
 
                case DELETE:
-                       for (j = 0; j < n; j++) {
+                       for (j = n-1; j >= 0; j--) {
                                if (safe_sprintf(partname, "%s%s%d",
                                             mapname, delim, j+1)) {
                                        fprintf(stderr, "partname too small\n");