diff options
author | Karel Zak | 2017-07-11 14:24:32 +0200 |
---|---|---|
committer | Karel Zak | 2017-07-11 14:24:32 +0200 |
commit | 167d7e95375405bd94d95e7c95b00c8f619ea0d5 (patch) | |
tree | cc6cae48afe0c7bffeec5a7e46dea1fe5c1c69fb /libfdisk | |
parent | tests: check for missing programs in last(1) test (diff) | |
download | kernel-qcow2-util-linux-167d7e95375405bd94d95e7c95b00c8f619ea0d5.tar.gz kernel-qcow2-util-linux-167d7e95375405bd94d95e7c95b00c8f619ea0d5.tar.xz kernel-qcow2-util-linux-167d7e95375405bd94d95e7c95b00c8f619ea0d5.zip |
libfdisk: (dos) accept start for log.partitions on template
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk')
-rw-r--r-- | libfdisk/src/dos.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index da21b0956..44d022155 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -1606,16 +1606,22 @@ static int dos_add_partition(struct fdisk_context *cxt, rc = add_partition(cxt, res, pa); goto done; - /* D) template specifies default start, partno >= 4; add logical */ - } else if (pa && fdisk_partition_start_is_default(pa) + /* D) template specifies start (or default), partno >= 4; add logical */ + } else if (pa && (fdisk_partition_start_is_default(pa) || fdisk_partition_has_start(pa)) && fdisk_partition_has_partno(pa) && pa->partno >= 4) { DBG(LABEL, ul_debug("DOS: pa template %p: add logical (by partno)", pa)); if (!ext_pe) { - fdisk_warnx(cxt, _("Extended partition does not exists. Failed to add logical partition")); + fdisk_warnx(cxt, _("Extended partition does not exists. Failed to add logical partition.")); + return -EINVAL; + } else if (fdisk_partition_has_start(pa) + && pa->start < l->ext_offset + && pa->start > get_abs_partition_end(ext_pe)) { + DBG(LABEL, ul_debug("DOS: pa template specifies partno>=4, but start out of extended")); return -EINVAL; } + rc = add_logical(cxt, pa, &res); goto done; } |