dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

Blame SOURCES/0119-fdisk-improve-menu-and-u-for-GPT.patch

531551
From 846f494a89cfe00bcea5e12d9526df76be9196a6 Mon Sep 17 00:00:00 2001
531551
From: Karel Zak <kzak@redhat.com>
531551
Date: Tue, 4 Apr 2017 11:12:29 +0200
531551
Subject: [PATCH] fdisk: improve menu and 'u' for GPT
531551
531551
* print 't' in the menu for GPT
531551
* don't toggle to cylinders for GPT
531551
* force sectors if GPT detected
531551
* improve expert 'd' command description
531551
531551
Addresses: Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1344720
531551
Signed-off-by: Karel Zak <kzak@redhat.com>
531551
---
531551
 fdisks/fdisk.c | 16 +++++++++++++---
531551
 1 file changed, 13 insertions(+), 3 deletions(-)
531551
531551
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c
531551
index 177921a..b47b975 100644
531551
--- a/fdisks/fdisk.c
531551
+++ b/fdisks/fdisk.c
531551
@@ -70,7 +70,7 @@ static const struct menulist_descr menulist[] = {
531551
 	{'c', N_("toggle the dos compatibility flag"), {FDISK_DISKLABEL_DOS, 0}},
531551
 	{'c', N_("toggle the mountable flag"), {FDISK_DISKLABEL_SUN, 0}},
531551
 	{'d', N_("delete a partition"), {FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_OSF | FDISK_DISKLABEL_GPT, 0}},
531551
-	{'d', N_("print the raw data in the partition table"), {0, FDISK_DISKLABEL_ANY}},
531551
+	{'d', N_("print the raw data in the first sector"), {0, FDISK_DISKLABEL_ANY}},
531551
 	{'e', N_("change number of extra sectors per cylinder"), {0, FDISK_DISKLABEL_SUN}},
531551
 	{'e', N_("edit drive data"), {FDISK_DISKLABEL_OSF, 0}},
531551
 	{'e', N_("list extended partitions"), {0, FDISK_DISKLABEL_DOS}},
531551
@@ -94,7 +94,7 @@ static const struct menulist_descr menulist[] = {
531551
 	{'s', N_("change number of sectors/track"), {0, FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN}},
531551
 	{'s', N_("create a new empty Sun disklabel"), {~FDISK_DISKLABEL_OSF, 0}},
531551
 	{'s', N_("show complete disklabel"), {FDISK_DISKLABEL_OSF, 0}},
531551
-	{'t', N_("change a partition's system id"), {FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_OSF, 0}},
531551
+	{'t', N_("change a partition's system id"), {FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_OSF | FDISK_DISKLABEL_GPT, 0}},
531551
 	{'u', N_("change display/entry units"), {FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_OSF, 0}},
531551
 	{'v', N_("verify the partition table"), {FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_GPT,
531551
 						 FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_GPT}},
531551
@@ -1018,6 +1018,11 @@ static void command_prompt(struct fdisk_context *cxt)
531551
 		fdisk_context_switch_label(cxt, "dos");
531551
 	}
531551
 
531551
+	if (fdisk_is_disklabel(cxt, GPT) && fdisk_context_use_cylinders(cxt)) {
531551
+		printf(_("Use cylinders for GPT is unsupported. "));
531551
+		toggle_units(cxt);
531551
+	}
531551
+
531551
 	while (1) {
531551
 
531551
 		assert(cxt->label);
531551
@@ -1073,6 +1078,8 @@ static void command_prompt(struct fdisk_context *cxt)
531551
 			break;
531551
 		case 'g':
531551
 			fdisk_create_disklabel(cxt, "gpt");
531551
+			if (fdisk_is_disklabel(cxt, GPT) && fdisk_context_use_cylinders(cxt))
531551
+				toggle_units(cxt);
531551
 			break;
531551
 		case 'G':
531551
 			fdisk_create_disklabel(cxt, "sgi");
531551
@@ -1107,7 +1114,10 @@ static void command_prompt(struct fdisk_context *cxt)
531551
 			change_partition_type(cxt);
531551
 			break;
531551
 		case 'u':
531551
-			toggle_units(cxt);
531551
+			if (fdisk_is_disklabel(cxt, GPT) && !fdisk_context_use_cylinders(cxt))
531551
+				printf(_("Use cylinders for GPT is unsupported."));
531551
+			else
531551
+				toggle_units(cxt);
531551
 			break;
531551
 		case 'v':
531551
 			verify(cxt);
531551
-- 
531551
2.9.3
531551