diff options
author | Karel Zak | 2019-02-18 16:38:11 +0100 |
---|---|---|
committer | Karel Zak | 2019-02-18 16:38:11 +0100 |
commit | 3c21e32245b2c5c57574f39c1c0832465483b187 (patch) | |
tree | 07f012edc833d47c98df844840a86562bdd15535 /libfdisk | |
parent | docs: fix typos [codespell] (diff) | |
download | kernel-qcow2-util-linux-3c21e32245b2c5c57574f39c1c0832465483b187.tar.gz kernel-qcow2-util-linux-3c21e32245b2c5c57574f39c1c0832465483b187.tar.xz kernel-qcow2-util-linux-3c21e32245b2c5c57574f39c1c0832465483b187.zip |
libfdisk: (dos) improve first unused sector for logical partitions
Make sure we probe within extended partition.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk')
-rw-r--r-- | libfdisk/src/dos.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 8e9678da3..4f81970db 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -913,6 +913,13 @@ static fdisk_sector_t get_unused_start(struct fdisk_context *cxt, { size_t i; + if (part_n >= 4) { + struct fdisk_dos_label *l = self_label(cxt); + fdisk_sector_t ex_start = l->ext_offset + cxt->first_lba; + if (start < ex_start) + start = ex_start; + } + for (i = 0; i < cxt->label->nparts_max; i++) { fdisk_sector_t lastplusoff; struct pte *pe = self_pte(cxt, i); @@ -925,6 +932,8 @@ static fdisk_sector_t get_unused_start(struct fdisk_context *cxt, start = lastplusoff + 1; } + DBG(LABEL, ul_debug("DOS: fist unused start for #%d is %ju", + part_n, (uintmax_t) start)); return start; } @@ -939,7 +948,7 @@ static void fill_bounds(struct fdisk_context *cxt, for (i = 0; i < cxt->label->nparts_max; pe++,i++) { p = pe->pt_entry; if (is_cleared_partition(p) || IS_EXTENDED (p->sys_ind)) { - first[i] = 0xffffffff; + first[i] = SIZE_MAX; last[i] = 0; } else { first[i] = get_abs_partition_start(pe); |