list_add_tail(&pa->parts, &tb->parts);
tb->nents++;
- DBG(TAB, dbgprint("add entry %p [start=%ju, size=%ju, freespace=%s]",
- pa, pa->start, pa->size,
+ DBG(TAB, dbgprint("add entry %p [start=%ju, end=%ju, size=%ju, freespace=%s]",
+ pa, pa->start, pa->end, pa->size,
pa->freespace ? "yes" : "no"));
return 0;
}
}
static int fdisk_table_add_freespace(
+ struct fdisk_context *cxt,
struct fdisk_table *tb,
uint64_t start,
uint64_t end)
pa->freespace = 1;
- pa->start = start;
+ pa->start = fdisk_align_lba_in_range(cxt, start, start, end);
pa->end = end;
pa->size = pa->end - pa->start + 1ULL;
/* add free-space (before partition) to the list */
if (fdisk_context_display_freespace(cxt) &&
last + grain < pa->start) {
- fdisk_table_add_freespace(*tb,
+ fdisk_table_add_freespace(cxt, *tb,
last + (last > cxt->first_lba ? 1 : 0),
pa->start - 1);
}
/* add free-space (behind last partition) to the list */
if (fdisk_context_display_freespace(cxt) &&
last + grain < cxt->total_sectors - 1) {
- fdisk_table_add_freespace(*tb,
+ fdisk_table_add_freespace(cxt, *tb,
last + (last > cxt->first_lba ? 1 : 0),
- cxt->total_sectors - 1);
+ cxt->last_lba);
}
return 0;