diff options
author | Karel Zak | 2017-07-19 11:30:57 +0200 |
---|---|---|
committer | Karel Zak | 2017-07-19 11:30:57 +0200 |
commit | 992f7cbae420ab1b71fd9f2c2ae10c9804c1d213 (patch) | |
tree | 0ddb41ced462bf3fc0feebc1b5a14df76b4966aa /libfdisk/src/context.c | |
parent | libfdisk: (dos) return EINVAL when delete unused partition (diff) | |
download | kernel-qcow2-util-linux-992f7cbae420ab1b71fd9f2c2ae10c9804c1d213.tar.gz kernel-qcow2-util-linux-992f7cbae420ab1b71fd9f2c2ae10c9804c1d213.tar.xz kernel-qcow2-util-linux-992f7cbae420ab1b71fd9f2c2ae10c9804c1d213.zip |
libfdisk: add fdisk_disable_dialogs()
The default (for historical reasons) is to use dialog driven partitioning.
It's possible to avoid dialogs by fdisk_partition template for
fdisk_add_partition().
Unfortunately in some case (mostly DOS driver) it's not enough, because
we need to distinguish between logical and primary partitions. If we know
that dialogs are unwanted then we can default to primary partition, etc.
This function simplify semantic of the library for non-interactive
programs.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/context.c')
-rw-r--r-- | libfdisk/src/context.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index c7e8a4276..fb7ad4b44 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -344,6 +344,40 @@ int fdisk_enable_bootbits_protection(struct fdisk_context *cxt, int enable) cxt->protect_bootbits = enable ? 1 : 0; return 0; } +/** + * fdisk_disable_dialogs + * @cxt: fdisk context + * @enable: 1 or 0 + * + * The library uses dialog driven partitioning by default. + * + * Returns: 0 on success, < 0 on error. + * + * Since: 2.31 + */ +int fdisk_disable_dialogs(struct fdisk_context *cxt, int disable) +{ + if (!cxt) + return -EINVAL; + + cxt->no_disalogs = disable; + return 0; +} + +/** + * fdisk_has_dialogs + * @cxt: fdisk context + * + * See fdisk_disable_dialogs() + * + * Returns: 1 if dialog driven partitioning enabled (default), or 0. + * + * Since: 2.31 + */ +int fdisk_has_dialogs(struct fdisk_context *cxt) +{ + return cxt->no_disalogs == 0; +} /** * fdisk_enable_wipe |