diff options
author | Karel Zak | 2015-02-03 13:20:45 +0100 |
---|---|---|
committer | Karel Zak | 2015-02-03 13:20:45 +0100 |
commit | 68fe4b2822018cb952e6b0c7dbca75a228cc7117 (patch) | |
tree | ac2e680f8e92c69c5bbde9e0b4624fab27fa3b02 /libfdisk/src | |
parent | cfdisk: improve ui_get_size() warnings (diff) | |
download | kernel-qcow2-util-linux-68fe4b2822018cb952e6b0c7dbca75a228cc7117.tar.gz kernel-qcow2-util-linux-68fe4b2822018cb952e6b0c7dbca75a228cc7117.tar.xz kernel-qcow2-util-linux-68fe4b2822018cb952e6b0c7dbca75a228cc7117.zip |
libfdisk: don't align very small partitions
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src')
-rw-r--r-- | libfdisk/src/dos.c | 5 | ||||
-rw-r--r-- | libfdisk/src/gpt.c | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 73b985b88..24b824c2e 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -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 diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index f1e4a65e7..4a3f7d594 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -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) |