]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: don't align very small partitions
authorKarel Zak <kzak@redhat.com>
Tue, 3 Feb 2015 12:20:45 +0000 (13:20 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Feb 2015 12:20:45 +0000 (13:20 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/dos.c
libfdisk/src/gpt.c

index 73b985b884b393cf70728e776e34c1e192c10030..24b824c2eeb1ae98eb5c51aedd09d031fce8b862 100644 (file)
@@ -1197,6 +1197,11 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
        if (stop > limit)
                stop = limit;
 
+       if (isrel && stop - start < cxt->grain)
+               /* Don't try to be smart on very small partitions and don't
+                * align so small sizes, just follow the resurst */
+               isrel = 0;
+
        if (stop < limit) {
                if (isrel && alignment_required(cxt)) {
                        /* the last sector has not been exactly requested (but
index f1e4a65e7f46d32ef5f6788d7f34e6be0862b711..4a3f7d5943d6a335318e91a445270261f9deadc5 100644 (file)
@@ -2071,9 +2071,12 @@ static int gpt_add_partition(
                user_l = user_f + pa->size - 1;
                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 = fdisk_align_lba_in_range(cxt, user_l, user_f, dflt_l) - 1;
-
+               if (user_l != dflt_l && !pa->size_explicit
+                   && user_l - user_f > cxt->grain) {
+                       user_l = fdisk_align_lba_in_range(cxt, user_l, user_f, dflt_l);
+                       if (user_l > user_f)
+                               user_l -= 1;
+               }
        } else {
                for (;;) {
                        if (!ask)