diff options
author | Karel Zak | 2014-10-09 12:02:17 +0200 |
---|---|---|
committer | Karel Zak | 2014-10-09 12:02:17 +0200 |
commit | 892c89eb76e7c274cade8cbd8b4cdc5f5f5c9790 (patch) | |
tree | 13ec249f271c394db8fcd6f23b0ad1912964556f /libfdisk/src/partition.c | |
parent | libfdisk: use skip_blank() in scripts (diff) | |
download | kernel-qcow2-util-linux-892c89eb76e7c274cade8cbd8b4cdc5f5f5c9790.tar.gz kernel-qcow2-util-linux-892c89eb76e7c274cade8cbd8b4cdc5f5f5c9790.tar.xz kernel-qcow2-util-linux-892c89eb76e7c274cade8cbd8b4cdc5f5f5c9790.zip |
libfdisk: allow to specify partition size by explicit number of sectors
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/partition.c')
-rw-r--r-- | libfdisk/src/partition.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c index c9b596b6b..c6142900e 100644 --- a/libfdisk/src/partition.c +++ b/libfdisk/src/partition.c @@ -337,6 +337,25 @@ int fdisk_partition_end_is_default(struct fdisk_partition *pa) return pa->end_follow_default; } +/** + * fdisk_partition_size_explicit: + * @pa: partition + * @enable: 0|1 + * + * By default libfdisk aligns the size when add the new partition (by + * fdisk_add_partrition()). If you want to disable this functionality use + * @enable = 1. + * + * Returns: 0 on success, <0 on error. + */ +int fdisk_partition_size_explicit(struct fdisk_partition *pa, int enable) +{ + if (!pa) + return -EINVAL; + pa->size_explicit = enable ? 1 : 0; + return 0; +} + const char *fdisk_partition_get_uuid(struct fdisk_partition *pa) { return pa ? pa->uuid : NULL; @@ -601,7 +620,8 @@ int fdisk_get_partition(struct fdisk_context *cxt, size_t partno, *pa = NULL; } else fdisk_reset_partition(*pa); - } + } else + (*pa)->size_explicit = 1; return rc; } |