From: Karel Zak Date: Tue, 3 Feb 2015 12:44:16 +0000 (+0100) Subject: libfdisk: grain is in bytes, fix previous patches X-Git-Tag: v2.26-rc2~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d527d2dd6463b47612f6a5da17ac6f60c349fbd2;p=thirdparty%2Futil-linux.git libfdisk: grain is in bytes, fix previous patches Signed-off-by: Karel Zak --- diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 8557408b6c..08533bbe48 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -1197,10 +1197,13 @@ static int add_partition(struct fdisk_context *cxt, size_t n, if (stop > limit) stop = limit; - if (isrel && stop - start < cxt->grain) + if (isrel && stop - start < (cxt->grain / fdisk_get_sector_size(cxt))) { /* Don't try to be smart on very small partitions and don't * align so small sizes, just follow the resurst */ isrel = 0; + DBG(LABEL, ul_debug("DOS: don't align end os tiny partition [start=%ju, stop=%ju, grain=%ju]", + start, stop, cxt->grain)); + } if (stop < limit) { if (isrel && alignment_required(cxt)) { diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index 4a3f7d5943..7a2997cccc 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -2072,7 +2072,7 @@ static int gpt_add_partition( DBG(LABEL, ul_debug("size defined: %ju, end: %ju (last possible: %ju)", pa->size, user_l, dflt_l)); if (user_l != dflt_l && !pa->size_explicit - && user_l - user_f > cxt->grain) { + && user_l - user_f > (cxt->grain / fdisk_get_sector_size(cxt))) { user_l = fdisk_align_lba_in_range(cxt, user_l, user_f, dflt_l); if (user_l > user_f) user_l -= 1;