diff options
author | Karel Zak | 2013-01-21 17:10:23 +0100 |
---|---|---|
committer | Karel Zak | 2013-03-11 12:47:31 +0100 |
commit | 47b8e7c00207dfcb34de66f1f9458268d4a90f9d (patch) | |
tree | a2f5cf0f894bdcfab9934ed200204f46721d9d2e /fdisks/gpt.c | |
parent | libfdisk: cleanup fdisk_get_partition_type() returns (diff) | |
download | kernel-qcow2-util-linux-47b8e7c00207dfcb34de66f1f9458268d4a90f9d.tar.gz kernel-qcow2-util-linux-47b8e7c00207dfcb34de66f1f9458268d4a90f9d.tar.xz kernel-qcow2-util-linux-47b8e7c00207dfcb34de66f1f9458268d4a90f9d.zip |
libfdisk: add part_get_status operation
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/gpt.c')
-rw-r--r-- | fdisks/gpt.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/fdisks/gpt.c b/fdisks/gpt.c index 115dcd4eb..6070d479b 100644 --- a/fdisks/gpt.c +++ b/fdisks/gpt.c @@ -1729,6 +1729,29 @@ static int gpt_set_partition_type( return 0; } +static int gpt_get_partition_status( + struct fdisk_context *cxt, + struct fdisk_label *lb __attribute__((__unused__)), + int i, + int *status) +{ + struct fdisk_gpt_label *gpt = gpt_label(cxt); + struct gpt_entry *e; + + if (!cxt || !gpt || i < 0 || !status + || (uint32_t) i >= le32_to_cpu(gpt->pheader->npartition_entries)) + return -EINVAL; + + e = &gpt->ents[i]; + *status = FDISK_PARTSTAT_NONE; + + if (!partition_unused(&gpt->ents[i]) || gpt_partition_size(e)) + *status = FDISK_PARTSTAT_USED; + + return 0; +} + + /* * Deinitialize fdisk-specific variables */ @@ -1761,6 +1784,8 @@ static const struct fdisk_label_operations gpt_operations = .part_get_type = gpt_get_partition_type, .part_set_type = gpt_set_partition_type, + .part_get_status = gpt_get_partition_status, + .deinit = gpt_deinit }; |