diff options
author | Karel Zak | 2012-12-06 15:22:43 +0100 |
---|---|---|
committer | Karel Zak | 2013-03-11 12:47:28 +0100 |
commit | 171372d37ce16e2a28e106a764a211237fe4df75 (patch) | |
tree | fa9446074bd82684cdb742a8d2c12e83ba59b9fb /libfdisk/src/label.c | |
parent | libfdisk: add context functions (diff) | |
download | kernel-qcow2-util-linux-171372d37ce16e2a28e106a764a211237fe4df75.tar.gz kernel-qcow2-util-linux-171372d37ce16e2a28e106a764a211237fe4df75.tar.xz kernel-qcow2-util-linux-171372d37ce16e2a28e106a764a211237fe4df75.zip |
libfdisk: cleanup the rest of fdisks/utils.c stuff
- remove obsolete code
- move fdisk_{set,get}_partition_type() to label.c (this is label
driver operation)
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/label.c')
-rw-r--r-- | libfdisk/src/label.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libfdisk/src/label.c b/libfdisk/src/label.c index fa7218c0f..5d0eb3ef8 100644 --- a/libfdisk/src/label.c +++ b/libfdisk/src/label.c @@ -194,3 +194,51 @@ int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name) return cxt->label->create(cxt); } + +/** + * fdisk_get_partition_type: + * @cxt: fdisk context + * @partnum: partition number + * + * Returns partition type or NULL upon failure. + */ +struct fdisk_parttype *fdisk_get_partition_type(struct fdisk_context *cxt, int partnum) +{ + if (!cxt || !cxt->label || !cxt->label->part_get_type) + return NULL; + + DBG(LABEL, dbgprint("partition: %d: get type", partnum)); + return cxt->label->part_get_type(cxt, partnum); +} + +/** + * fdisk_set_partition_type: + * @cxt: fdisk context + * @partnum: partition number + * @t: new type + * + * Returns 0 on success, < 0 on error. + */ +int fdisk_set_partition_type(struct fdisk_context *cxt, int partnum, + struct fdisk_parttype *t) +{ + if (!cxt || !cxt->label || !cxt->label->part_set_type) + return -EINVAL; + + DBG(LABEL, dbgprint("partition: %d: set type", partnum)); + return cxt->label->part_set_type(cxt, partnum, t); +} + +/** + * fdisk_get_nparttypes: + * @cxt: fdisk context + * + * Returns: number of partition types supported by the current label + */ +size_t fdisk_get_nparttypes(struct fdisk_context *cxt) +{ + if (!cxt || !cxt->label) + return 0; + + return cxt->label->nparttypes; +} |