summaryrefslogtreecommitdiff
path: root/fdisks/fdisk-ask.c
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2013-06-12 17:09:28 +0200
committerKarel Zak <kzak@redhat.com>2013-09-16 16:47:01 +0200
commit950edd1a71d76a9fe6bbc72bba4efcb26cf723b7 (patch)
treef72bd7be52313595da83c20080306be4bfe5eca9 /fdisks/fdisk-ask.c
parent2ff943c73250de803d6b0e6df70701e562dd84d7 (diff)
downloadutil-linux-950edd1a71d76a9fe6bbc72bba4efcb26cf723b7.tar.gz
fdisk: use libfdisk to ask for partition type
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdisk-ask.c')
-rw-r--r--fdisks/fdisk-ask.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/fdisks/fdisk-ask.c b/fdisks/fdisk-ask.c
index 0c4e200f..a7e86e1c 100644
--- a/fdisks/fdisk-ask.c
+++ b/fdisks/fdisk-ask.c
@@ -220,3 +220,30 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,
}
return rc;
}
+
+
+struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt)
+{
+ const char *q;
+
+ if (!cxt || !cxt->label || !cxt->label->nparttypes)
+ return NULL;
+
+ q = fdisk_is_parttype_string(cxt) ?
+ _("Partition type (type L to list all types): ") :
+ _("Hex code (type L to list all codes): ");
+ do {
+ char buf[256];
+ int rc = get_user_reply(cxt, q, buf, sizeof(buf));
+
+ if (rc)
+ break;
+
+ if (buf[1] == '\0' && toupper(*buf) == 'L')
+ list_partition_types(cxt);
+ else if (*buf)
+ return fdisk_parse_parttype(cxt, buf);
+ } while (1);
+
+ return NULL;
+}