From 6b13880f365b78329e5423426617f0bf12bab326 Mon Sep 17 00:00:00 2001 From: Mikhail Vorobyov Date: Thu, 2 Nov 2017 04:04:42 +0300 Subject: [PATCH] libfdisk: (sun) fix creation of whole disk partition 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 Signed-off-by: Karel Zak --- libfdisk/src/sun.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c index 0526227ce5..d10fea0d7b 100644 --- a/libfdisk/src/sun.c +++ b/libfdisk/src/sun.c @@ -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 */ -- 2.47.2