summaryrefslogtreecommitdiffstats
path: root/fdisks/fdisk.c
diff options
context:
space:
mode:
authorKarel Zak2013-12-18 10:38:43 +0100
committerKarel Zak2014-03-11 11:35:13 +0100
commit9f670072f42d7e0e8403385defc69e93b636cb93 (patch)
tree05a7ba02cbbe607874f09fde3af3f9e53475bc05 /fdisks/fdisk.c
parentlibfdisk: use fdisk_table to generate output (diff)
downloadkernel-qcow2-util-linux-9f670072f42d7e0e8403385defc69e93b636cb93.tar.gz
kernel-qcow2-util-linux-9f670072f42d7e0e8403385defc69e93b636cb93.tar.xz
kernel-qcow2-util-linux-9f670072f42d7e0e8403385defc69e93b636cb93.zip
libfdisk: remove tt stuff from API
The include/tt.h has to be used only internally by the library (for example to convert fdisk_table to string). The fdisk_ask API should not be more used for complex tasks like print partition table. The application has to use fdisk_get_table() and fdisk_table_to_string() or something else. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdisk.c')
-rw-r--r--fdisks/fdisk.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c
index 3e0d75205..19658be9a 100644
--- a/fdisks/fdisk.c
+++ b/fdisks/fdisk.c
@@ -232,6 +232,24 @@ void list_disk_geometry(struct fdisk_context *cxt)
fdisk_colon(cxt, _("Disk identifier: %s"), id);
}
+void list_disklabel(struct fdisk_context *cxt)
+{
+ struct fdisk_table *tb = NULL;
+ char *str;
+
+ /* print label specific stuff by libfdisk FDISK_ASK_INFO API */
+ fdisk_list_disklabel(cxt);
+
+ /* print partitions */
+ if (fdisk_get_table(cxt, &tb))
+ return;
+ if (fdisk_table_to_string(tb, cxt, NULL, 0, &str) == 0) {
+ fputc('\n', stdout);
+ fputs(str, stdout);
+ }
+ fdisk_unref_table(tb);
+}
+
static size_t skip_empty(const unsigned char *buf, size_t i, size_t sz)
{
size_t next;
@@ -338,7 +356,7 @@ static void print_device_pt(struct fdisk_context *cxt, char *device)
list_disk_geometry(cxt);
if (fdisk_dev_has_disklabel(cxt))
- fdisk_list_disklabel(cxt);
+ list_disklabel(cxt);
fputc('\n', stdout);
}