]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (sun) fix creation of whole disk partition
authorMikhail Vorobyov <m.vorobyov@cs.msu.ru>
Thu, 2 Nov 2017 01:04:42 +0000 (04:04 +0300)
committerKarel Zak <kzak@redhat.com>
Thu, 2 Nov 2017 09:43:27 +0000 (10:43 +0100)
sun_add_partition() allowed the 1st sector to be 0 for the 3rd partition
only if that sector was free or if other partitions covered the whole
disk. Now it's always allowed for the 1st sector to be set to 0 for
the 3rd partition.

[kzak@redhat.com: - print info about "wholedisk" before "First sector" dialog for 3rd partition
                  - default to 0 for 3rd partition start sector]

Signed-off-by: Mikhail Vorobyov <m.vorobyov@cs.msu.ru>
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/sun.c

index 0526227ce58d2a8246dd86f663ca5455706492c7..d10fea0d7b91d64c825c366a0d86777812a75cdd 100644 (file)
@@ -529,6 +529,11 @@ static int sun_add_partition(
        } else {
                struct fdisk_ask *ask;
 
+               if (n == 2)
+                       fdisk_info(cxt, _("It is highly recommended that the "
+                                          "third partition covers the whole disk "
+                                          "and is of type `Whole disk'"));
+
                snprintf(mesg, sizeof(mesg), _("First %s"),
                                fdisk_get_unit(cxt, FDISK_SINGULAR));
                for (;;) {
@@ -543,6 +548,10 @@ static int sun_add_partition(
                                fdisk_ask_number_set_low(ask,     0);   /* minimal */
                                fdisk_ask_number_set_default(ask, 0);   /* default */
                                fdisk_ask_number_set_high(ask,    0);   /* maximal */
+                       } else if (n == 2) {
+                               fdisk_ask_number_set_low(ask,     0);                           /* minimal */
+                               fdisk_ask_number_set_default(ask, 0);                           /* default */
+                               fdisk_ask_number_set_high(ask,    fdisk_scround(cxt, stop));    /* maximal */
                        } else {
                                fdisk_ask_number_set_low(ask,     fdisk_scround(cxt, start));   /* minimal */
                                fdisk_ask_number_set_default(ask, fdisk_scround(cxt, start));   /* default */
@@ -584,10 +593,6 @@ static int sun_add_partition(
                }
        }
 
-       if (n == 2 && first != 0)
-               fdisk_warnx(cxt, _("It is highly recommended that the "
-                                  "third partition covers the whole disk "
-                                  "and is of type `Whole disk'"));
 
        if (!fdisk_use_cylinders(cxt)) {
                /* Starting sector has to be properly aligned */