dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

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

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