From: Karel Zak Date: Mon, 19 Jun 2017 09:41:02 +0000 (+0200) Subject: libfdisk: (dos) fix primary/logical logic when follow template X-Git-Tag: v2.31-rc1~292 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ee9ba4fa5ec8b51fa300e9369d5993b2eab3182d;p=thirdparty%2Futil-linux.git libfdisk: (dos) fix primary/logical logic when follow template This stupid bug has been introduced by e1cfb304 (v2.30) and it disables to create extended partition by cfdisk :-( Signed-off-by: Karel Zak --- diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 0494c44c4d..73660d8ce9 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -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)