diff options
author | Davidlohr Bueso | 2012-11-26 05:29:18 +0100 |
---|---|---|
committer | Karel Zak | 2012-11-30 13:48:27 +0100 |
commit | 8254c3a59480c2727ae8d3a903e16a0d9fac0a8b (patch) | |
tree | 787d4b786bdd723d1718268242a38163402fb75f /fdisks/gpt.c | |
parent | fdisk: remove dead code (diff) | |
download | kernel-qcow2-util-linux-8254c3a59480c2727ae8d3a903e16a0d9fac0a8b.tar.gz kernel-qcow2-util-linux-8254c3a59480c2727ae8d3a903e16a0d9fac0a8b.tar.xz kernel-qcow2-util-linux-8254c3a59480c2727ae8d3a903e16a0d9fac0a8b.zip |
fdisk: api: propagate add partitions to users
Similarly to commit 1f5eb51b79275e32d045fd6718753bf04cde8374 we
do not propagate problems when adding partitions to user visible
api.
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Diffstat (limited to 'fdisks/gpt.c')
-rw-r--r-- | fdisks/gpt.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/fdisks/gpt.c b/fdisks/gpt.c index abb2e1131..cc20ba937 100644 --- a/fdisks/gpt.c +++ b/fdisks/gpt.c @@ -1453,7 +1453,7 @@ static int gpt_create_new_partition(int partnum, uint64_t fsect, uint64_t lsect, } /* Performs logical checks to add a new partition entry */ -static void gpt_add_partition(struct fdisk_context *cxt, int partnum, +static int gpt_add_partition(struct fdisk_context *cxt, int partnum, struct fdisk_parttype *t) { char msg[256]; @@ -1464,20 +1464,20 @@ static void gpt_add_partition(struct fdisk_context *cxt, int partnum, /* check basic tests before even considering adding a new partition */ if (!cxt || partnum < 0) - return; + return -EINVAL; if (!partition_unused(ents[partnum])) { printf(_("Partition %d is already defined. " "Delete it before re-adding it.\n"), partnum +1); - return; + return -EINVAL; } if (le32_to_cpu(pheader->npartition_entries) == partitions_in_use(pheader, ents)) { printf(_("All partitions are already in use.\n")); - return; + return -EINVAL; } if (!get_free_sectors(cxt, pheader, ents, &tmp, &f0)) { printf(_("No free sectors available.\n")); - return; + return -ENOSPC; } first_sect = find_first_available(pheader, ents, 0); @@ -1504,6 +1504,8 @@ static void gpt_add_partition(struct fdisk_context *cxt, int partnum, printf(_("Could not create partition %d\n"), partnum + 1); else printf(_("Created partition %d\n"), partnum + 1); + + return 0; } /* |