diff options
author | Karel Zak | 2018-01-11 14:23:57 +0100 |
---|---|---|
committer | Karel Zak | 2018-01-11 14:23:57 +0100 |
commit | f7606d2d9f8f7fc28b6b5e6cb295d4104b3df69b (patch) | |
tree | 2438111560479ebafb2a5f81ff806116b210c6f0 /libfdisk | |
parent | Merge branch 'fixes' of https://github.com/rudimeier/util-linux (diff) | |
download | kernel-qcow2-util-linux-f7606d2d9f8f7fc28b6b5e6cb295d4104b3df69b.tar.gz kernel-qcow2-util-linux-f7606d2d9f8f7fc28b6b5e6cb295d4104b3df69b.tar.xz kernel-qcow2-util-linux-f7606d2d9f8f7fc28b6b5e6cb295d4104b3df69b.zip |
libfdisk: (sun) fix n-1 bug and whole-disk
* set whole_disk variable if SUN_TAG_WHOLEDISK specified
* fix N-1 bug in add new partition according to template (script)
Addresses: https://github.com/karelzak/util-linux/issues/555
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk')
-rw-r--r-- | libfdisk/src/sun.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c index 0be4d8df6..a247dbcf5 100644 --- a/libfdisk/src/sun.c +++ b/libfdisk/src/sun.c @@ -522,6 +522,9 @@ static int sun_add_partition( fetch_sun(cxt, starts, lens, &start, &stop); + if (pa && pa->type && pa->type->code == SUN_TAG_WHOLEDISK) + whole_disk = 1; + if (stop <= start) { if (n == 2) whole_disk = 1; @@ -629,8 +632,9 @@ static int sun_add_partition( /* last */ if (pa && pa->end_follow_default) last = whole_disk || (n == 2 && !first) ? stop2 : stop; + else if (pa && fdisk_partition_has_size(pa)) { - last = first + pa->size - 1ULL; + last = first + pa->size; if (!whole_disk && last > stop) return -ERANGE; |