{
fdisk_sector_t res;
- start = fdisk_align_lba(cxt, start, FDISK_ALIGN_UP);
- stop = fdisk_align_lba(cxt, stop, FDISK_ALIGN_DOWN);
+ DBG(CXT, ul_debugobj(cxt, "LBA: align in range <%ju..%ju>", (uintmax_t) start, (uintmax_t) stop));
- if (lba > start && lba < stop
- && (lba - start) < (cxt->grain / cxt->sector_size)) {
+ if (start + (cxt->grain / cxt->sector_size) <= stop) {
+ start = fdisk_align_lba(cxt, start, FDISK_ALIGN_UP);
+ stop = fdisk_align_lba(cxt, stop, FDISK_ALIGN_DOWN);
+ }
+ if (start + (cxt->grain / cxt->sector_size) > stop) {
DBG(CXT, ul_debugobj(cxt, "LBA: area smaller than grain, don't align"));
res = lba;
goto done;
struct pte *pe = self_pte(cxt, n);
assert(pe);
+ assert(start >= cxt->first_lba);
+
pe->offset = start - cxt->first_lba;
+ DBG(LABEL, ul_debug("DOS: setting EBR offset to %ju [start=%ju]", pe->offset, start));
+
if (pe->offset == l->ext_offset) { /* must be corrected */
pe->offset++;
if (cxt->first_lba == 1)
set_partition(cxt, n, 0, start, stop, sys, fdisk_partition_is_bootable(pa));
if (n > 4) {
struct pte *pe = self_pte(cxt, n);
-
assert(pe);
set_partition(cxt, n - 1, 1, pe->offset, stop,
MBR_DOS_EXTENDED_PARTITION, 0);