]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: grain is in bytes, fix previous patches
authorKarel Zak <kzak@redhat.com>
Tue, 3 Feb 2015 12:44:16 +0000 (13:44 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Feb 2015 12:44:16 +0000 (13:44 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/dos.c
libfdisk/src/gpt.c

index 8557408b6c30b39f9d806596b8167db1493b831e..08533bbe48faaa9e006672fb099cd7d5e221cbff 100644 (file)
@@ -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)) {
index 4a3f7d5943d6a335318e91a445270261f9deadc5..7a2997cccc74ac7f396ae9d74aef226095dfdf77 100644 (file)
@@ -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;