libfdisk: cleanup the rest of fdisks/utils.c stuff

- remove obsolete code
 - move fdisk_{set,get}_partition_type() to label.c (this is label
   driver operation)

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2012-12-06 15:22:43 +01:00
parent f4be9e2b99
commit 171372d37c
4 changed files with 53 additions and 53 deletions

View File

@ -60,13 +60,6 @@ enum failure {
unable_to_write
};
/*
* labels
*/
extern struct fdisk_parttype *fdisk_get_partition_type(struct fdisk_context *cxt, int partnum);
extern int fdisk_set_partition_type(struct fdisk_context *cxt, int partnum,
struct fdisk_parttype *t);
/* prototypes for fdisk.c */
extern char *line_ptr;
extern int partitions;

View File

@ -194,3 +194,51 @@ int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name)
return cxt->label->create(cxt);
}
/**
* fdisk_get_partition_type:
* @cxt: fdisk context
* @partnum: partition number
*
* Returns partition type or NULL upon failure.
*/
struct fdisk_parttype *fdisk_get_partition_type(struct fdisk_context *cxt, int partnum)
{
if (!cxt || !cxt->label || !cxt->label->part_get_type)
return NULL;
DBG(LABEL, dbgprint("partition: %d: get type", partnum));
return cxt->label->part_get_type(cxt, partnum);
}
/**
* fdisk_set_partition_type:
* @cxt: fdisk context
* @partnum: partition number
* @t: new type
*
* Returns 0 on success, < 0 on error.
*/
int fdisk_set_partition_type(struct fdisk_context *cxt, int partnum,
struct fdisk_parttype *t)
{
if (!cxt || !cxt->label || !cxt->label->part_set_type)
return -EINVAL;
DBG(LABEL, dbgprint("partition: %d: set type", partnum));
return cxt->label->part_set_type(cxt, partnum, t);
}
/**
* fdisk_get_nparttypes:
* @cxt: fdisk context
*
* Returns: number of partition types supported by the current label
*/
size_t fdisk_get_nparttypes(struct fdisk_context *cxt)
{
if (!cxt || !cxt->label)
return 0;
return cxt->label->nparttypes;
}

View File

@ -69,10 +69,15 @@ extern int fdisk_dev_is_disklabel(struct fdisk_context *cxt, enum fdisk_labeltyp
extern int fdisk_write_disklabel(struct fdisk_context *cxt);
extern int fdisk_verify_disklabel(struct fdisk_context *cxt);
extern int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name);
extern int fdisk_add_partition(struct fdisk_context *cxt, int partnum, struct fdisk_parttype *t);
extern int fdisk_delete_partition(struct fdisk_context *cxt, int partnum);
extern struct fdisk_parttype *fdisk_get_partition_type(struct fdisk_context *cxt, int partnum);
extern int fdisk_set_partition_type(struct fdisk_context *cxt, int partnum,
struct fdisk_parttype *t);
/* alignment.c */
extern int fdisk_reset_alignment(struct fdisk_context *cxt);

View File

@ -165,50 +165,4 @@ void fdisk_free_parttype(struct fdisk_parttype *t)
}
}
/**
* fdisk_get_partition_type:
* @cxt: fdisk context
* @partnum: partition number
*
* Returns partition type or NULL upon failure.
*/
struct fdisk_parttype *fdisk_get_partition_type(struct fdisk_context *cxt, int partnum)
{
if (!cxt || !cxt->label || !cxt->label->part_get_type)
return NULL;
DBG(LABEL, dbgprint("partition: %d: get type", partnum));
return cxt->label->part_get_type(cxt, partnum);
}
/**
* fdisk_set_partition_type:
* @cxt: fdisk context
* @partnum: partition number
* @t: new type
*
* Returns 0 on success, < 0 on error.
*/
int fdisk_set_partition_type(struct fdisk_context *cxt, int partnum,
struct fdisk_parttype *t)
{
if (!cxt || !cxt->label || !cxt->label->part_set_type)
return -EINVAL;
DBG(LABEL, dbgprint("partition: %d: set type", partnum));
return cxt->label->part_set_type(cxt, partnum, t);
}
/**
* fdisk_get_nparttypes:
* @cxt: fdisk context
*
* Returns: number of partition types supported by the current label
*/
size_t fdisk_get_nparttypes(struct fdisk_context *cxt)
{
if (!cxt || !cxt->label)
return 0;
return cxt->label->nparttypes;
}