diff options
author | Karel Zak | 2014-02-03 12:23:18 +0100 |
---|---|---|
committer | Karel Zak | 2014-03-11 11:35:14 +0100 |
commit | a3e37fa7af93622e2217b7f020f41104b005b848 (patch) | |
tree | e2dff700703f84c06821c28796e52af2900d6a2d /libfdisk/src/dos.c | |
parent | cfdisk: follow default end if possible (diff) | |
download | kernel-qcow2-util-linux-a3e37fa7af93622e2217b7f020f41104b005b848.tar.gz kernel-qcow2-util-linux-a3e37fa7af93622e2217b7f020f41104b005b848.tar.xz kernel-qcow2-util-linux-a3e37fa7af93622e2217b7f020f41104b005b848.zip |
libfdisk: don't ask for pri/log if wanted start within extended partition
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/dos.c')
-rw-r--r-- | libfdisk/src/dos.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 01e203268..cb34be8ab 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -830,7 +830,8 @@ static int get_start_from_user( struct fdisk_context *cxt, (uintmax_t) pa->start, (uintmax_t) low, (uintmax_t) limit)); *start = pa->start; if (*start < low || *start > limit) { - fdisk_warnx(cxt, _("Start sector out of range.")); + fdisk_warnx(cxt, _("Start sector %ju out of range."), + (uintmax_t) *start); return -ERANGE; } } else { @@ -1293,12 +1294,32 @@ static int dos_add_partition(struct fdisk_context *cxt, size_t i, free_primary = 0; int rc = 0; struct fdisk_dos_label *l = self_label(cxt); + struct dos_partition *ext = l->ext_offset ? + self_partition(cxt, l->ext_index) : NULL; assert(cxt); assert(cxt->label); assert(fdisk_is_disklabel(cxt, DOS)); - /* TODO: use pa->type */ + + /* pa specifies start within extended partition, add logical */ + if (pa && pa->start + && pa->start >= l->ext_offset + && pa->start <= l->ext_offset + dos_partition_get_size(ext)) { + rc = add_logical(cxt, pa); + goto done; + + /* pa specifies start, but outside extended partition */ + } else if (pa && pa->start && l->ext_offset) { + int j; + + j = get_partition_unused_primary(cxt, pa); + if (j >= 0) { + rc = add_partition(cxt, j, pa); + goto done; + } + + } for (i = 0; i < 4; i++) { struct dos_partition *p = self_partition(cxt, i); @@ -1611,7 +1632,6 @@ static int dos_get_partition(struct fdisk_context *cxt, size_t n, return 0; } - /* * Fix the chain of logicals. * ext_offset is unchanged, the set of sectors used is unchanged |