]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (sun) fix n-1 bug and whole-disk
authorKarel Zak <kzak@redhat.com>
Thu, 11 Jan 2018 13:23:57 +0000 (14:23 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 11 Jan 2018 13:23:57 +0000 (14:23 +0100)
* 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>
libfdisk/src/sun.c

index 0be4d8df68933a665841665a568e9367eb2a5bc8..a247dbcf570155082db8946cc21a96d917bc570a 100644 (file)
@@ -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;