]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: cleanup internal drivers' API
authorKarel Zak <kzak@redhat.com>
Thu, 11 Sep 2014 09:48:06 +0000 (11:48 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 7 Oct 2014 12:55:31 +0000 (14:55 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/bsd.c
libfdisk/src/dos.c
libfdisk/src/fdiskP.h
libfdisk/src/gpt.c
libfdisk/src/libfdisk.h
libfdisk/src/partition.c
libfdisk/src/sgi.c
libfdisk/src/sun.c

index 093925ef2f8e451bd63672207f4bbe15bcb504fa..fdd6ea7f9bce50c8ec9ad928d3ef7fefff4c2432 100644 (file)
@@ -872,8 +872,8 @@ static const struct fdisk_label_operations bsd_operations =
        .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,
 
index 443830ba8e73a2993105d1ddd55633cd3bd2cee3..69ca73d85348102fb6b21d6aacf265ea35f122b9 100644 (file)
@@ -2115,8 +2115,8 @@ static const struct fdisk_label_operations dos_operations =
 
        .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,
index 05ce28293b5d78f2e8e4e0999c13face36de5cdb..1382d9ae736a550abbbd59e8011fc54f83f387f2 100644 (file)
@@ -191,12 +191,18 @@ struct fdisk_label_operations {
        /* 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);
@@ -204,16 +210,11 @@ struct fdisk_label_operations {
        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);
index 8a3c8c6bddfc217bb4ffcd1005ab62ef6d61f494..4ab29f4fca3321be74f9a00ee7f7fb6458681c27 100644 (file)
@@ -2409,8 +2409,7 @@ static const struct fdisk_label_operations gpt_operations =
 
        .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,
index 31f0eee32de97eac35ee4758f8822e160ac660ec..c49b1db1d2a69361d3a2299ae07bafd159100f61 100644 (file)
@@ -198,9 +198,9 @@ extern int fdisk_get_disklabel_id(struct fdisk_context *cxt, char **id);
 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,
index 4e57c74b8ae5c3bc5d1202fa2f70e4c8dc6cbb95..bf60fb628bf37ebd86ed4a5ecd788168cfd71576 100644 (file)
@@ -545,13 +545,14 @@ int fdisk_partition_to_string(struct fdisk_partition *pa,
 
 /**
  * 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.
  */
@@ -588,31 +589,19 @@ int fdisk_get_partition(struct fdisk_context *cxt, size_t 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);
-}
 
 /**
  * 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,
@@ -652,22 +641,22 @@ int fdisk_add_partition(struct fdisk_context *cxt,
 /**
  * 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);
 }
 
 /**
@@ -698,3 +687,16 @@ int fdisk_delete_all_partitions(struct fdisk_context *cxt)
        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);
+}
+
index c0c6e33cbfb517a4066efcfb33cd8c86076b9bf1..aed8479550125225b8f2581f79a7aa3fda0dcb05 100644 (file)
@@ -1106,10 +1106,9 @@ static const struct fdisk_label_operations sgi_operations =
 
        .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
 };
index 68ad11eece8280bc4fd66fae3edfb7f610ce32b6..4f9e10a2a641161504fff415f80c90967f03bd75 100644 (file)
@@ -1020,10 +1020,9 @@ const struct fdisk_label_operations sun_operations =
 
        .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,