From 339ca8416c49553070c54b1f8f1043d59591ab3b Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 22 Apr 2015 17:13:48 +0200 Subject: [PATCH] libfdisk: allow to move start to first usable LBA Signed-off-by: Karel Zak --- libfdisk/src/partition.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c index 84de63280a..e892e9dd87 100644 --- a/libfdisk/src/partition.c +++ b/libfdisk/src/partition.c @@ -1037,12 +1037,12 @@ static int recount_resize( /* 2) verify that start is within the current partition or any freespace area */ if (!FDISK_IS_UNDEF(start)) { struct fdisk_partition *area = resize_get_by_offset(tb, start); - if (!area) - goto erange; if (area == cur) DBG(PART, ul_debugobj(tpl, "resize: start points to the current partition")); - else if (fdisk_partition_is_freespace(area)) + else if (area && fdisk_partition_is_freespace(area)) DBG(PART, ul_debugobj(tpl, "resize: start points to freespace")); + else if (!area && start >= cxt->first_lba && start < cxt->first_lba + (cxt->grain / cxt->sector_size)) + DBG(PART, ul_debugobj(tpl, "resize: start points before first partition")); else goto erange; } else { @@ -1096,7 +1096,7 @@ static int recount_resize( return 0; erange: DBG(PART, ul_debugobj(tpl, "resize: FAILED")); - fdisk_warnx(cxt, _("failed to resize partition #%zu."), partno + 1); + fdisk_warnx(cxt, _("Failed to resize partition #%zu."), partno + 1); fdisk_unref_table(tb); return -ERANGE; -- 2.47.2