]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (dos) fix primary/logical logic when follow template
authorKarel Zak <kzak@redhat.com>
Mon, 19 Jun 2017 09:41:02 +0000 (11:41 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 19 Jun 2017 09:41:02 +0000 (11:41 +0200)
This stupid bug has been introduced by e1cfb304 (v2.30) and it
disables to create extended partition by cfdisk :-(

Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/dos.c

index 0494c44c4d0dbfd4ea7c2d5bfc9746c8e8a4f458..73660d8ce965ce958545f964835305ac23586d13 100644 (file)
@@ -1580,7 +1580,7 @@ static int dos_add_partition(struct fdisk_context *cxt,
                }
 
        /* pa specifies start, but outside extended partition */
-       } else if (pa && fdisk_partition_has_start(pa)) {
+       } else if (pa && fdisk_partition_has_start(pa) && l->ext_offset) {
                DBG(LABEL, ul_debug("DOS: pa template %p: add primary", pa));
                rc = get_partition_unused_primary(cxt, pa, &res);
                if (rc == 0)
@@ -1590,7 +1590,7 @@ static int dos_add_partition(struct fdisk_context *cxt,
        /* pa follows default, but partno < 4, it means primary partition */
        } else if (pa && fdisk_partition_start_is_default(pa)
                   && fdisk_partition_has_partno(pa)
-                   && pa->partno < 4) {
+                  && pa->partno < 4) {
                DBG(LABEL, ul_debug("DOS: pa template %p: add primary (partno < 4)", pa));
                rc = get_partition_unused_primary(cxt, pa, &res);
                if (rc == 0)