diff options
author | Karel Zak | 2013-04-29 15:29:48 +0200 |
---|---|---|
committer | Karel Zak | 2013-09-16 16:46:53 +0200 |
commit | 0c870c1c73985a5e153a35209a650bcacce94c5b (patch) | |
tree | 655307d6d85d41c47d707563a244d936d4c26429 /libfdisk/src/ask.c | |
parent | lib/tt: add TT_FL_FREEDATA (diff) | |
download | kernel-qcow2-util-linux-0c870c1c73985a5e153a35209a650bcacce94c5b.tar.gz kernel-qcow2-util-linux-0c870c1c73985a5e153a35209a650bcacce94c5b.tar.xz kernel-qcow2-util-linux-0c870c1c73985a5e153a35209a650bcacce94c5b.zip |
libfdisk: add new 'ask' type TABLE
The new type could be used to print table-like output (for example
list of the partitions).
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/ask.c')
-rw-r--r-- | libfdisk/src/ask.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libfdisk/src/ask.c b/libfdisk/src/ask.c index 1b4791af3..a95d54233 100644 --- a/libfdisk/src/ask.c +++ b/libfdisk/src/ask.c @@ -408,6 +408,33 @@ int fdisk_ask_yesno_set_result(struct fdisk_ask *ask, uint64_t result) return 0; } +struct tt *fdisk_ask_get_table(struct fdisk_ask *ask) +{ + assert(ask); + assert(fdisk_is_ask(ask, TABLE)); + return ask->data.table; +} + +int fdisk_print_table(struct fdisk_context *cxt, struct tt *tb) +{ + struct fdisk_ask *ask; + int rc; + + assert(cxt); + assert(tb); + + ask = fdisk_new_ask(); + if (!ask) + return -ENOMEM; + + fdisk_ask_set_type(ask, FDISK_ASKTYPE_TABLE); + ask->data.table = tb; + + rc = fdisk_do_ask(cxt, ask); + + fdisk_free_ask(ask); + return rc; +} #define is_print_ask(a) (fdisk_is_ask(a, WARN) || fdisk_is_ask(a, WARNX) || fdisk_is_ask(a, INFO)) |