summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/gpt.c
diff options
context:
space:
mode:
authorKarel Zak2013-04-30 11:57:30 +0200
committerKarel Zak2013-09-16 16:46:53 +0200
commit3c5fb4757fa2ca0e4c30b9ec65ec87af2cc60bcb (patch)
tree1915a4de29b114721dfb11e4d27e7f4cd2017cf5 /libfdisk/src/gpt.c
parentlibfdisk: (gpt) use lib/tt.c to list partitions (diff)
downloadkernel-qcow2-util-linux-3c5fb4757fa2ca0e4c30b9ec65ec87af2cc60bcb.tar.gz
kernel-qcow2-util-linux-3c5fb4757fa2ca0e4c30b9ec65ec87af2cc60bcb.tar.xz
kernel-qcow2-util-linux-3c5fb4757fa2ca0e4c30b9ec65ec87af2cc60bcb.zip
libfdisk: add list() label operation
... and use it for GPT Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/gpt.c')
-rw-r--r--libfdisk/src/gpt.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
index bceb09b05..5a434e946 100644
--- a/libfdisk/src/gpt.c
+++ b/libfdisk/src/gpt.c
@@ -1137,9 +1137,9 @@ static char *encode_to_utf8(unsigned char *src, size_t count)
* requirements, but once partition semantics are added to the fdisk
* API it can be removed for custom implementation (see gpt_label struct).
*/
-void gpt_list_table(struct fdisk_context *cxt,
- int xtra __attribute__ ((__unused__)))
+static int gpt_list_disklabel(struct fdisk_context *cxt)
{
+ int rc;
uint32_t i;
struct fdisk_gpt_label *gpt;
uint64_t fu;
@@ -1156,7 +1156,8 @@ void gpt_list_table(struct fdisk_context *cxt,
tb = tt_new_table(TT_FL_FREEDATA);
if (!tb)
- return; /* ENOMEM */
+ return -ENOMEM;
+
tt_define_column(tb, "#", 2, TT_FL_RIGHT);
tt_define_column(tb, "Start", 12, TT_FL_RIGHT);
tt_define_column(tb, "End", 12, TT_FL_RIGHT);
@@ -1203,8 +1204,10 @@ void gpt_list_table(struct fdisk_context *cxt,
fdisk_free_parttype(t);
}
- fdisk_print_table(cxt, tb);
+ rc = fdisk_print_table(cxt, tb);
tt_free_table(tb);
+
+ return rc;
}
/*
@@ -1856,6 +1859,7 @@ static const struct fdisk_label_operations gpt_operations =
.write = gpt_write_disklabel,
.verify = gpt_verify_disklabel,
.create = gpt_create_disklabel,
+ .list = gpt_list_disklabel,
.part_add = gpt_add_partition,
.part_delete = gpt_delete_partition,
.part_get_type = gpt_get_partition_type,