]> err.no Git - util-linux/commitdiff
partx: do not add nonexistent partitions
authorPhillip Susi <psusi@cfl.rr.com>
Wed, 31 Mar 2010 13:52:08 +0000 (15:52 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 31 Mar 2010 13:52:08 +0000 (15:52 +0200)
This simple patch fixes partx -a to not add nonexistent zero length
partitions for unused primary partition slots to to the kernel. This
makes partx conform to the usual kernel behavior.

Signed-off-by: Phillip Susi <psusi@cfl.rr.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
partx/partx.c

index 16ea1fab01ef04404db08c3c94223295d574371c..3d60bf6977f03b775d52c26485a57f769b915448 100644 (file)
@@ -295,6 +295,9 @@ main(int argc, char **argv){
                                }
                            }
                            for (j=0; j<n; j++) {
+                               /* skip unused/empty partitions */
+                               if (slices[j].size == 0)
+                                   continue;
                                pt.pno = lower+j;
                                pt.start = 512 * (long long) slices[j].start;
                                pt.length = 512 * (long long) slices[j].size;