diff options
author | Karel Zak | 2014-09-11 13:53:35 +0200 |
---|---|---|
committer | Karel Zak | 2014-10-07 14:55:31 +0200 |
commit | 6936c081aba8cc590fdebfcc38574f09aecb5503 (patch) | |
tree | f4fb3b2dab1bc253673e5a9cc5b55acc3caeaab0 /disk-utils/fdisk-menu.c | |
parent | libfdisk: (gpt) implement fdisk_set_partition() backend (diff) | |
download | kernel-qcow2-util-linux-6936c081aba8cc590fdebfcc38574f09aecb5503.tar.gz kernel-qcow2-util-linux-6936c081aba8cc590fdebfcc38574f09aecb5503.tar.xz kernel-qcow2-util-linux-6936c081aba8cc590fdebfcc38574f09aecb5503.zip |
libfdisk: (gpt) use generic API to change UUID and name
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/fdisk-menu.c')
-rw-r--r-- | disk-utils/fdisk-menu.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c index e9bdc4554..c973833a0 100644 --- a/disk-utils/fdisk-menu.c +++ b/disk-utils/fdisk-menu.c @@ -563,6 +563,7 @@ static int gpt_menu_cb(struct fdisk_context **cxt0, { struct fdisk_context *cxt = *cxt0; struct fdisk_context *mbr; + struct fdisk_partition *pa = NULL; size_t n; int rc = 0; @@ -594,10 +595,34 @@ static int gpt_menu_cb(struct fdisk_context **cxt0, switch(ent->key) { case 'u': - rc = fdisk_gpt_partition_set_uuid(cxt, n); + pa = fdisk_new_partition(); /* new template */ + if (!pa) + rc = -ENOMEM; + else { + char *str = NULL; + rc = fdisk_ask_string(cxt, _("New UUID (in 8-4-4-4-12 format)"), &str); + if (!rc) + rc = fdisk_partition_set_uuid(pa, str); + if (!rc) + rc = fdisk_set_partition(cxt, n, pa); + free(str); + fdisk_unref_partition(pa); + } break; case 'n': - rc = fdisk_gpt_partition_set_name(cxt, n); + pa = fdisk_new_partition(); /* new template */ + if (!pa) + rc = -ENOMEM; + else { + char *str = NULL; + rc = fdisk_ask_string(cxt, _("New name"), &str); + if (!rc) + rc = fdisk_partition_set_name(pa, str); + if (!rc) + rc = fdisk_set_partition(cxt, n, pa); + free(str); + fdisk_unref_partition(pa); + } break; case 'A': rc = fdisk_partition_toggle_flag(cxt, n, GPT_FLAG_LEGACYBOOT); @@ -613,6 +638,7 @@ static int gpt_menu_cb(struct fdisk_context **cxt0, break; } } + return rc; } |