]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: add GPT specific callback to menu
authorKarel Zak <kzak@redhat.com>
Tue, 21 May 2013 13:29:01 +0000 (15:29 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Sep 2013 14:46:56 +0000 (16:46 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisks/fdisk-menu.c
fdisks/fdisk.c

index 997d82b8e91360e507639f165d310251b76d4681..b8cea823731e5cd7e575fb490c2d4e5c13437059 100644 (file)
@@ -39,6 +39,10 @@ struct menu_context {
 
 #define MENU_CXT_EMPTY { 0, 0 }
 
+static int gpt_menu_cb(struct fdisk_context *cxt,
+                      const struct menu *menu,
+                      const struct menu_entry *ent);
+
 /*
  * Menu entry macros:
  *     MENU_X*    expert mode only
@@ -109,7 +113,7 @@ struct menu menu_createlabel = {
 };
 
 struct menu menu_gpt = {
-/*     .callback = gpt_menu_cb, */
+       .callback = gpt_menu_cb,
        .label = FDISK_DISKLABEL_GPT,
        .entries = {
                MENU_XSEP(N_("GPT")),
@@ -351,6 +355,39 @@ int process_fdisk_menu(struct fdisk_context *cxt)
        return key;
 }
 
+/*
+ * This is fdisk frontend for GPT specific libfdisk functions that
+ * are not expported by generic libfdisk API.
+ */
+static int gpt_menu_cb(struct fdisk_context *cxt,
+                      const struct menu *menu __attribute__((__unused__)),
+                      const struct menu_entry *ent)
+{
+       size_t n;
+       int rc;
+
+       assert(cxt);
+       assert(ent);
+       assert(fdisk_is_disklabel(cxt, GPT));
+
+       DBG(CONTEXT, dbgprint("enter GPT menu"));
+
+       rc = fdisk_ask_partnum(cxt, &n, FALSE);
+       if (rc)
+               return rc;
+
+       switch(ent->key) {
+       case 'u':
+               rc = fdisk_gpt_partition_set_uuid(cxt, n);
+               break;
+       case 'n':
+               /* not implemented yet
+               rc = fdisk_gpt_partition_set_name(cxt, n);*/
+               break;
+       }
+       return rc;
+}
+
 
 #ifdef TEST_PROGRAM
 struct fdisk_label *fdisk_new_dos_label(struct fdisk_context *cxt) { return NULL; }
index eba0026e9bbc5416f9573f2af66ff0065805db5f..e884ee743b3a0fc69a19a81841ea3b0a64b1648f 100644 (file)
@@ -819,11 +819,6 @@ expert_command_prompt(struct fdisk_context *cxt)
                                                user_heads, user_sectors);
                        }
                        break;
-               case 'u':
-                       if (fdisk_is_disklabel(cxt, GPT) &&
-                           fdisk_ask_partnum(cxt, &n, FALSE) == 0)
-                               fdisk_gpt_partition_set_uuid(cxt, n);
-                       break;
                case 'v':
                        verify(cxt);
                        break;