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/fdiskbsdlabel.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/fdiskbsdlabel.c')
-rw-r--r-- | fdisks/fdiskbsdlabel.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/fdisks/fdiskbsdlabel.c b/fdisks/fdiskbsdlabel.c index 9fd658ed1..54c0327c4 100644 --- a/fdisks/fdiskbsdlabel.c +++ b/fdisks/fdiskbsdlabel.c @@ -151,16 +151,17 @@ static int xbsd_write_disklabel (struct fdisk_context *cxt) return 0; } -static void xbsd_add_part (struct fdisk_context *cxt, +static int xbsd_add_part (struct fdisk_context *cxt, int partnum __attribute__((__unused__)), struct fdisk_parttype *t __attribute__((__unused__))) { unsigned int begin, end; char mesg[256]; - int i; + int i, rc; - if (!xbsd_check_new_partition (&i)) - return; + rc = xbsd_check_new_partition(&i); + if (rc) + return rc; #if !defined (__alpha__) && !defined (__powerpc__) && !defined (__hppa__) begin = get_start_sect(xbsd_part); @@ -188,6 +189,8 @@ static void xbsd_add_part (struct fdisk_context *cxt, xbsd_dlabel.d_partitions[i].p_size = end - begin + 1; xbsd_dlabel.d_partitions[i].p_offset = begin; xbsd_dlabel.d_partitions[i].p_fstype = BSD_FS_UNUSED; + + return 0; } static int xbsd_create_disklabel (struct fdisk_context *cxt) @@ -603,7 +606,7 @@ xbsd_check_new_partition (int *i) { if (t == BSD_MAXPARTITIONS) { fprintf (stderr, _("The maximum number of partitions " "has been created\n")); - return 0; + return -EINVAL; } } @@ -614,10 +617,10 @@ xbsd_check_new_partition (int *i) { if (xbsd_dlabel.d_partitions[*i].p_size != 0) { fprintf (stderr, _("This partition already exists.\n")); - return 0; + return -EINVAL; } - return 1; + return 0; } static unsigned short @@ -815,7 +818,7 @@ xbsd_link_part (struct fdisk_context *cxt) k = get_partition (cxt, 1, partitions); - if (!xbsd_check_new_partition (&i)) + if (xbsd_check_new_partition (&i)) return; p = get_part_table(k); |