From 625d00fefbcccda99bf507e41235bd25fc83225e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 2 Feb 2015 10:38:05 +0100 Subject: [PATCH] libfdisk: (dos) delete also logical with extended deleting an extended partition with cfdisk leaves its contained partitions in existence Reported-by: Benno Schulenberg Signed-off-by: Karel Zak --- libfdisk/src/dos.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 2cb11cb4a3..3a0a02bde1 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -382,7 +382,7 @@ static void reset_pte(struct pte *pe) assert(pe); if (pe->private_sectorbuffer) { - DBG(LABEL, ul_debug(" --> freeing pte sector buffer %p", + DBG(LABEL, ul_debug(" --> freeing pte sector buffer %p", pe->sectorbuffer)); free(pe->sectorbuffer); } @@ -416,6 +416,13 @@ static int dos_delete_partition(struct fdisk_context *cxt, size_t partnum) if (partnum < 4) { DBG(LABEL, ul_debug("--> delete primary")); if (IS_EXTENDED(p->sys_ind) && partnum == l->ext_index) { + size_t i; + DBG(LABEL, ul_debug(" --> delete extended")); + for (i = 4; i < cxt->label->nparts_max; i++) { + DBG(LABEL, ul_debug(" --> delete logical #%zu", i)); + reset_pte(&l->ptes[i]); + + } cxt->label->nparts_max = 4; l->ptes[l->ext_index].ex_entry = NULL; l->ext_offset = 0; -- 2.47.2