diff options
author | Karel Zak | 2014-11-13 14:37:05 +0100 |
---|---|---|
committer | Karel Zak | 2014-11-13 14:37:05 +0100 |
commit | d0bdf18434bf116e2154b4895e0c3e0c815dbabf (patch) | |
tree | 69451bfe985bd0278c50878a635c4fb9f585eb74 | |
parent | libfdisk: fix table_add_freespace(), add debug messages (diff) | |
download | kernel-qcow2-util-linux-d0bdf18434bf116e2154b4895e0c3e0c815dbabf.tar.gz kernel-qcow2-util-linux-d0bdf18434bf116e2154b4895e0c3e0c815dbabf.tar.xz kernel-qcow2-util-linux-d0bdf18434bf116e2154b4895e0c3e0c815dbabf.zip |
libfdisk: (dos) be sure that sorted EBR list is terminated
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | libfdisk/src/dos.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index af0909718..b4456a947 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -1918,6 +1918,7 @@ static int cmp_ebr_offsets(const void *a, const void *b) static void fix_chain_of_logicals(struct fdisk_context *cxt) { struct fdisk_dos_label *l = self_label(cxt); + struct pte *last; size_t i; DBG(LABEL, print_chain_of_logicals(cxt)); @@ -1972,13 +1973,15 @@ again: set_partition(cxt, i, 1, nxt->offset, get_abs_partition_end(nxt), MBR_DOS_EXTENDED_PARTITION, 0); + } - if (i + 1 == cxt->label->nparts_max - 1) { - clear_partition(nxt->ex_entry); - partition_set_changed(cxt, i + 1, 1); - } - + /* always terminate the chain ! */ + last = self_pte(cxt, cxt->label->nparts_max - 1); + if (last) { + clear_partition(last->ex_entry); + partition_set_changed(cxt, cxt->label->nparts_max - 1, 1); } + DBG(LABEL, print_chain_of_logicals(cxt)); } |