diff options
author | Karel Zak | 2017-02-17 13:15:09 +0100 |
---|---|---|
committer | Karel Zak | 2017-02-17 13:17:48 +0100 |
commit | e1cfb3046608f9c4543d5e3e3d405c39995a1f86 (patch) | |
tree | c7fff99da40e3e4c21a1273c883b014610bc0140 | |
parent | tests: (sfdisk) tell kernel about new partition (diff) | |
download | kernel-qcow2-util-linux-e1cfb3046608f9c4543d5e3e3d405c39995a1f86.tar.gz kernel-qcow2-util-linux-e1cfb3046608f9c4543d5e3e3d405c39995a1f86.tar.xz kernel-qcow2-util-linux-e1cfb3046608f9c4543d5e3e3d405c39995a1f86.zip |
libfdisk: verify partno from template
* verify partno from template when create a new partition
* remove unnecessary l->ext_offset check
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | libfdisk/src/dos.c | 2 | ||||
-rw-r--r-- | libfdisk/src/partition.c | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index c7c7772e8..0c2006ed6 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -1548,7 +1548,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) && l->ext_offset) { + } else if (pa && fdisk_partition_has_start(pa)) { DBG(LABEL, ul_debug("DOS: pa template %p: add primary", pa)); rc = get_partition_unused_primary(cxt, pa, &res); if (rc == 0) { diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c index f507f20e3..1e8c1eb32 100644 --- a/libfdisk/src/partition.c +++ b/libfdisk/src/partition.c @@ -733,7 +733,8 @@ int fdisk_partition_next_partno( DBG(PART, ul_debugobj(pa, "next partno (specified=%zu)", pa->partno)); - if (pa->partno >= cxt->label->nparts_max) + if (pa->partno >= cxt->label->nparts_max || + fdisk_is_partition_used(cxt, pa->partno)) return -ERANGE; *n = pa->partno; } else |