diff options
author | Davidlohr Bueso | 2012-10-07 16:33:37 +0200 |
---|---|---|
committer | Karel Zak | 2012-10-18 12:15:33 +0200 |
commit | 1f5eb51b79275e32d045fd6718753bf04cde8374 (patch) | |
tree | 208809ee5e82cd2440c0c8b77ee59470dbc2ce43 /fdisks/gpt.c | |
parent | docs: update deprecated file (diff) | |
download | kernel-qcow2-util-linux-1f5eb51b79275e32d045fd6718753bf04cde8374.tar.gz kernel-qcow2-util-linux-1f5eb51b79275e32d045fd6718753bf04cde8374.tar.xz kernel-qcow2-util-linux-1f5eb51b79275e32d045fd6718753bf04cde8374.zip |
fdisk: api: propagate partition deletion to users
The generic fdisk_delete_partition() function returns 0 when a partition
is correctly deleted, otherwise it's corresponding error (negative values).
This, however, does not include problems that can occur in actual label
specific contexts, so we need to propagate the corresponding return code,
back to the user visible api.
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Diffstat (limited to 'fdisks/gpt.c')
-rw-r--r-- | fdisks/gpt.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fdisks/gpt.c b/fdisks/gpt.c index 91c731278..eca1a2bf1 100644 --- a/fdisks/gpt.c +++ b/fdisks/gpt.c @@ -1223,19 +1223,21 @@ static int gpt_verify_disklabel(struct fdisk_context *cxt) } /* Delete a single GPT partition, specified by partnum. */ -static void gpt_delete_partition(struct fdisk_context *cxt, int partnum) +static int gpt_delete_partition(struct fdisk_context *cxt, int partnum) { if (!cxt || partition_unused(ents[partnum]) || partnum < 0) - return; + return -EINVAL; /* hasta la vista, baby! */ memset(&ents[partnum], 0, sizeof(ents[partnum])); if (!partition_unused(ents[partnum])) - printf(_("Could not delete partition %d\n"), partnum + 1); + return -EINVAL; else { gpt_recompute_crc(pheader, ents); gpt_recompute_crc(bheader, ents); } + + return 0; } static void gpt_entry_set_type(struct gpt_entry *e, struct gpt_guid *type) |