diff options
author | Karel Zak | 2014-10-15 12:17:40 +0200 |
---|---|---|
committer | Karel Zak | 2014-10-15 12:17:40 +0200 |
commit | ecf40cda764496d3d1b29435ea64a65335ae0acf (patch) | |
tree | 9ef1d00a3906fd495194b88ca5023c9729353df0 /libfdisk/src/sgi.c | |
parent | tests: check for wipefs and helpers in fdisk tests (diff) | |
download | kernel-qcow2-util-linux-ecf40cda764496d3d1b29435ea64a65335ae0acf.tar.gz kernel-qcow2-util-linux-ecf40cda764496d3d1b29435ea64a65335ae0acf.tar.xz kernel-qcow2-util-linux-ecf40cda764496d3d1b29435ea64a65335ae0acf.zip |
libfdisk: make it possible to use zero for size and start
The zero may be valid size and start of the partition. This patch
introduces:
fdisk_partition_has_start()
fdisk_partition_has_size()
fdisk_partition_unset_size()
fdisk_partition_unset_start()
to make it possible to work with zero. The feature is internally
implemented by magic constant ((type) -1) for undefined sizes and
offsets.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/sgi.c')
-rw-r--r-- | libfdisk/src/sgi.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c index 20ae59c03..e2eff9bb4 100644 --- a/libfdisk/src/sgi.c +++ b/libfdisk/src/sgi.c @@ -816,7 +816,7 @@ static int sgi_add_partition(struct fdisk_context *cxt, /* first sector */ if (pa && pa->start_follow_default) ; - else if (pa && pa->start) { + else if (pa && fdisk_partition_has_start(pa)) { first = pa->start; last = is_in_freelist(cxt, first); @@ -856,7 +856,7 @@ static int sgi_add_partition(struct fdisk_context *cxt, /* last sector */ if (pa && pa->end_follow_default) last -= 1ULL; - else if (pa && pa->size) { + else if (pa && fdisk_partition_has_size(pa)) { if (first + pa->size - 1ULL > last) return -ERANGE; last = first + pa->size - 1ULL; @@ -1050,9 +1050,9 @@ static int sgi_set_partition(struct fdisk_context *cxt, sgilabel->partitions[i].type = cpu_to_be32(t->code); } - if (pa->start) + if (fdisk_partition_has_start(pa)) sgilabel->partitions[i].first_block = cpu_to_be32(pa->start); - if (pa->size) + if (fdisk_partition_has_size(pa)) sgilabel->partitions[i].num_blocks = cpu_to_be32(pa->size); fdisk_label_set_changed(cxt->label, 1); |