.list = bsd_list_disklabel,
.write = bsd_write_disklabel,
.create = bsd_create_disklabel,
- .part_delete = bsd_delete_part,
+ .del_part = bsd_delete_part,
.get_part = bsd_get_partition,
.add_part = bsd_add_partition,
.get_part = dos_get_partition,
.add_part = dos_add_partition,
+ .del_part = dos_delete_partition,
- .part_delete = dos_delete_partition,
.part_set_type = dos_set_parttype,
.part_toggle_flag = dos_toggle_partition_flag,
/* set disk label ID */
int (*set_id)(struct fdisk_context *cxt);
- /* new partition */
- int (*add_part)(struct fdisk_context *cxt, struct fdisk_partition *pa, size_t *partno);
+ /* new partition */
+ int (*add_part)(struct fdisk_context *cxt, struct fdisk_partition *pa,
+ size_t *partno);
/* delete partition */
- int (*part_delete)(struct fdisk_context *cxt,
- size_t partnum);
+ int (*del_part)(struct fdisk_context *cxt, size_t partnum);
+
+ /* fill in partition struct */
+ int (*get_part)(struct fdisk_context *cxt, size_t n,
+ struct fdisk_partition *pa);
+
+/*** TODO use set_part() */
/* get partition type */
struct fdisk_parttype *(*part_get_type)(struct fdisk_context *cxt,
size_t partnum);
int (*part_set_type)(struct fdisk_context *cxt,
size_t partnum,
struct fdisk_parttype *t);
-
/* return state of the partition */
int (*part_is_used)(struct fdisk_context *cxt, size_t partnum);
- /* fill in partition struct */
- int (*get_part)(struct fdisk_context *cxt,
- size_t n,
- struct fdisk_partition *pa);
-
int (*part_toggle_flag)(struct fdisk_context *cxt, size_t i, unsigned long flag);
+/******/
/* refresh alignment setting */
int (*reset_alignment)(struct fdisk_context *cxt);
.get_part = gpt_get_partition,
.add_part = gpt_add_partition,
-
- .part_delete = gpt_delete_partition,
+ .del_part = gpt_delete_partition,
.part_is_used = gpt_part_is_used,
.part_set_type = gpt_set_partition_type,
extern int fdisk_set_disklabel_id(struct fdisk_context *cxt);
extern int fdisk_get_partition(struct fdisk_context *cxt, size_t partno, struct fdisk_partition **pa);
-
extern int fdisk_add_partition(struct fdisk_context *cxt, struct fdisk_partition *pa, size_t *partno);
-extern int fdisk_delete_partition(struct fdisk_context *cxt, size_t partnum);
+extern int fdisk_delete_partition(struct fdisk_context *cxt, size_t partno);
+
extern int fdisk_delete_all_partitions(struct fdisk_context *cxt);
extern int fdisk_set_partition_type(struct fdisk_context *cxt, size_t partnum,
/**
* fdisk_get_partition:
- * @cxt:
- * @partno:
- * @pa: pointer to partition struct
+ * @cxt: context
+ * @partno: partition nuymber
+ * @pa: returns data about partition
*
* Fills in @pa with data about partition @n. Note that partno may address
* unused partition and then this function does not fill anything to @pa.
- * See fdisk_is_partition_used().
+ * See fdisk_is_partition_used(). If @pa points to NULL then the function
+ * allocates a newly allocated fdisk_partition struct.
*
* Returns: 0 on success, otherwise, a corresponding error.
*/
return rc;
}
-/*
- * This is faster than fdisk_get_partition() + fdisk_partition_is_used()
- */
-int fdisk_is_partition_used(struct fdisk_context *cxt, size_t n)
-{
- if (!cxt || !cxt->label)
- return -EINVAL;
- if (!cxt->label->op->part_is_used)
- return -ENOSYS;
-
- return cxt->label->op->part_is_used(cxt, n);
-}
/**
* fdisk_add_partition:
* @cxt: fdisk context
* @pa: template for the partition (or NULL)
- * @partno: returns new partition number (optional)
+ * @partno: NULL or returns new partition number
*
* If @pa is not specified or any @pa item is missiong the libfdisk will ask by
* fdisk_ask_ API.
*
* Creates a new partition.
*
- * Returns 0.
+ * Returns: 0 on success, <0 on error.
*/
int fdisk_add_partition(struct fdisk_context *cxt,
struct fdisk_partition *pa,
/**
* fdisk_delete_partition:
* @cxt: fdisk context
- * @partnum: partition number to delete
+ * @partno: partition number to delete
*
- * Deletes a @partnum partition.
+ * Deletes a @partno partition.
*
- * Returns 0 on success, otherwise, a corresponding error.
+ * Returns: 0 on success, <0 on error
*/
-int fdisk_delete_partition(struct fdisk_context *cxt, size_t partnum)
+int fdisk_delete_partition(struct fdisk_context *cxt, size_t partno)
{
if (!cxt || !cxt->label)
return -EINVAL;
- if (!cxt->label->op->part_delete)
+ if (!cxt->label->op->del_part)
return -ENOSYS;
DBG(CXT, ul_debugobj(cxt, "deleting %s partition number %zd",
- cxt->label->name, partnum));
- return cxt->label->op->part_delete(cxt, partnum);
+ cxt->label->name, partno));
+ return cxt->label->op->del_part(cxt, partno);
}
/**
return rc;
}
+/*
+ * This is faster than fdisk_get_partition() + fdisk_partition_is_used()
+ */
+int fdisk_is_partition_used(struct fdisk_context *cxt, size_t n)
+{
+ if (!cxt || !cxt->label)
+ return -EINVAL;
+ if (!cxt->label->op->part_is_used)
+ return -ENOSYS;
+
+ return cxt->label->op->part_is_used(cxt, n);
+}
+
.get_part = sgi_get_partition,
.add_part = sgi_add_partition,
+ .del_part = sgi_delete_partition,
- .part_delete = sgi_delete_partition,
.part_set_type = sgi_set_parttype,
-
.part_is_used = sgi_partition_is_used,
.part_toggle_flag = sgi_toggle_partition_flag
};
.get_part = sun_get_partition,
.add_part = sun_add_partition,
+ .del_part = sun_delete_partition,
- .part_delete = sun_delete_partition,
.part_set_type = sun_set_parttype,
-
.part_is_used = sun_partition_is_used,
.part_toggle_flag = sun_toggle_partition_flag,