summaryrefslogtreecommitdiffstats
path: root/fdisks/fdisk-menu.c
diff options
context:
space:
mode:
authorKarel Zak2013-05-21 15:29:01 +0200
committerKarel Zak2013-09-16 16:46:56 +0200
commitb9e94cd7f8d0b141492e601eeb4339b12d0f59bf (patch)
tree17b0d210e9d9d2d6c9fdf7ceef81d318599cb84b /fdisks/fdisk-menu.c
parentfdisk: use new menu infrastructure to verify keys (diff)
downloadkernel-qcow2-util-linux-b9e94cd7f8d0b141492e601eeb4339b12d0f59bf.tar.gz
kernel-qcow2-util-linux-b9e94cd7f8d0b141492e601eeb4339b12d0f59bf.tar.xz
kernel-qcow2-util-linux-b9e94cd7f8d0b141492e601eeb4339b12d0f59bf.zip
fdisk: add GPT specific callback to menu
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdisk-menu.c')
-rw-r--r--fdisks/fdisk-menu.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/fdisks/fdisk-menu.c b/fdisks/fdisk-menu.c
index 997d82b8e..b8cea8237 100644
--- a/fdisks/fdisk-menu.c
+++ b/fdisks/fdisk-menu.c
@@ -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; }