diff options
author | Karel Zak | 2012-09-26 13:30:44 +0200 |
---|---|---|
committer | Karel Zak | 2012-09-27 13:38:13 +0200 |
commit | 02460b8aae3f44cb56d7a23bff2a420e2241c4be (patch) | |
tree | 1e14ec2f5d0ffa6de18e839b5ed220c0579d7c0c /fdisks/fdiskbsdlabel.c | |
parent | fdisk: add fdisk_get_partition_type() (diff) | |
download | kernel-qcow2-util-linux-02460b8aae3f44cb56d7a23bff2a420e2241c4be.tar.gz kernel-qcow2-util-linux-02460b8aae3f44cb56d7a23bff2a420e2241c4be.tar.xz kernel-qcow2-util-linux-02460b8aae3f44cb56d7a23bff2a420e2241c4be.zip |
fdisk: add fdisk_set_partition_type()
- remove all label specific partition type stuff from fdisk.c to
label files
- add new fdisk_set_partition_type() to API
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdiskbsdlabel.c')
-rw-r--r-- | fdisks/fdiskbsdlabel.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fdisks/fdiskbsdlabel.c b/fdisks/fdiskbsdlabel.c index 3a23c02f0..b11bcf1cb 100644 --- a/fdisks/fdiskbsdlabel.c +++ b/fdisks/fdiskbsdlabel.c @@ -558,6 +558,7 @@ xbsd_write_bootstrap (struct fdisk_context *cxt) sync_disks (); } +/* TODO: remove this, use regular change_partition_type() in fdisk.c */ static void xbsd_change_fstype (struct fdisk_context *cxt) { @@ -856,6 +857,22 @@ static struct fdisk_parttype *xbsd_get_parttype(struct fdisk_context *cxt, int n return t; } +static int xbsd_set_parttype(struct fdisk_context *cxt, int partnum, + struct fdisk_parttype *t) +{ + struct xbsd_partition *p; + + if (partnum >= xbsd_dlabel.d_npartitions || !t || t->type > UINT8_MAX) + return -EINVAL; + + p = &xbsd_dlabel.d_partitions[partnum]; + if (t->type == p->p_fstype) + return 0; + + p->p_fstype = t->type; + return 0; +} + const struct fdisk_label bsd_label = { .name = "bsd", @@ -869,4 +886,5 @@ const struct fdisk_label bsd_label = .part_add = xbsd_add_part, .part_delete = xbsd_delete_part, .part_get_type = xbsd_get_parttype, + .part_set_type = xbsd_set_parttype, }; |