diff options
author | Karel Zak | 2014-08-29 11:18:29 +0200 |
---|---|---|
committer | Karel Zak | 2014-08-29 11:18:29 +0200 |
commit | 3c0e6b1530a089c592f0149a3e976f0d403eefd7 (patch) | |
tree | 712d082ba9fa23c6a01428ef4e32be9af86c551f /libfdisk/src/partition.c | |
parent | libfdisk: improve debug messages (diff) | |
download | kernel-qcow2-util-linux-3c0e6b1530a089c592f0149a3e976f0d403eefd7.tar.gz kernel-qcow2-util-linux-3c0e6b1530a089c592f0149a3e976f0d403eefd7.tar.xz kernel-qcow2-util-linux-3c0e6b1530a089c592f0149a3e976f0d403eefd7.zip |
libfdisk: add fdisk_apply_table() and fdisk_delete_all_partitions()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/partition.c')
-rw-r--r-- | libfdisk/src/partition.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c index 822ca23d4..f84968f21 100644 --- a/libfdisk/src/partition.c +++ b/libfdisk/src/partition.c @@ -631,3 +631,31 @@ int fdisk_delete_partition(struct fdisk_context *cxt, size_t partnum) cxt->label->name, partnum)); return cxt->label->op->part_delete(cxt, partnum); } + +/** + * fdisk_delete_all_partitions: + * @cxt: fdisk context + * + * Delete all used partitions. + * + * Returns: 0 on success, otherwise, a corresponding error. + */ +int fdisk_delete_all_partitions(struct fdisk_context *cxt) +{ + size_t i; + + if (!cxt || !cxt->label) + return -EINVAL; + + for (i = 0; i < cxt->label->nparts_max; i++) { + + if (!fdisk_is_partition_used(cxt, i)) + continue; + rc = fdisk_delete_partition(cxt, i); + if (rc) + break; + } + + return rc; +} + |