cdown / rpms / util-linux

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