extern struct fdisk_context *fdisk_new_context_from_filename(const char *fname, int readonly);
extern int fdisk_dev_has_topology(struct fdisk_context *cxt);
-extern int fdisk_dev_has_disklabel(struct fdisk_context *cxt);
-extern int fdisk_dev_is_disklabel(struct fdisk_context *cxt, enum fdisk_labeltype l);
extern int fdisk_dev_sectsz_is_default(struct fdisk_context *cxt);
extern void fdisk_free_context(struct fdisk_context *cxt);
extern void fdisk_zeroize_firstsector(struct fdisk_context *cxt);
extern int fdisk_context_set_user_geometry(struct fdisk_context *cxt,
unsigned int cylinders, unsigned int heads,
unsigned int sectors);
-extern int fdisk_delete_partition(struct fdisk_context *cxt, int partnum);
-extern int fdisk_add_partition(struct fdisk_context *cxt, int partnum, struct fdisk_parttype *t);
-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_reset_alignment(struct fdisk_context *cxt);
extern struct fdisk_parttype *fdisk_get_partition_type(struct fdisk_context *cxt, int partnum);
&mac_label,
};
-/**
- * fdisk_write_disklabel:
- * @cxt: fdisk context
- *
- * Write in-memory changes to disk
- *
- * Returns 0 on success, otherwise, a corresponding error.
- */
-int fdisk_write_disklabel(struct fdisk_context *cxt)
-{
- if (!cxt || !cxt->label)
- return -EINVAL;
- if (!cxt->label->write)
- return -ENOSYS;
-
- return cxt->label->write(cxt);
-}
-
-/**
- * fdisk_verify_disklabel:
- * @cxt: fdisk context
- *
- * Verifies the partition table.
- *
- * Returns 0.
- */
-int fdisk_verify_disklabel(struct fdisk_context *cxt)
-{
- if (!cxt || !cxt->label)
- return -EINVAL;
- if (!cxt->label->verify)
- return -ENOSYS;
-
- return cxt->label->verify(cxt);
-}
-
-/**
- * fdisk_add_partition:
- * @cxt: fdisk context
- * @partnum: partition number to create
- * @t: partition type to create or NULL for label-specific default
- *
- * Creates a new partition, with number @partnum and type @parttype.
- *
- * Returns 0.
- */
-int fdisk_add_partition(struct fdisk_context *cxt, int partnum,
- struct fdisk_parttype *t)
-{
- if (!cxt || !cxt->label)
- return -EINVAL;
- if (!cxt->label->part_add)
- return -ENOSYS;
-
- DBG(LABEL, dbgprint("adding new partition number %d", partnum));
- cxt->label->part_add(cxt, partnum, t);
- return 0;
-}
-
-/**
- * fdisk_delete_partition:
- * @cxt: fdisk context
- * @partnum: partition number to delete
- *
- * Deletes a @partnum partition.
- *
- * Returns 0 on success, otherwise, a corresponding error.
- */
-int fdisk_delete_partition(struct fdisk_context *cxt, int partnum)
-{
- if (!cxt || !cxt->label)
- return -EINVAL;
- if (!cxt->label->part_delete)
- return -ENOSYS;
-
- DBG(LABEL, dbgprint("deleting %s partition number %d",
- cxt->label->name, partnum));
- return cxt->label->part_delete(cxt, partnum);
-}
static int __probe_labels(struct fdisk_context *cxt)
{
return rc;
}
-/**
- * fdisk_dev_has_disklabel:
- * @cxt: fdisk context
- *
- * Returns: return 1 if there is label on the device.
- */
-int fdisk_dev_has_disklabel(struct fdisk_context *cxt)
-{
- return cxt && cxt->disklabel != FDISK_DISKLABEL_ANY;
-}
-
-/**
- * fdisk_dev_is_disklabel:
- * @cxt: fdisk context
- * @l: disklabel type
- *
- * Returns: return 1 if there is @l disklabel on the device.
- */
-int fdisk_dev_is_disklabel(struct fdisk_context *cxt, enum fdisk_labeltype l)
-{
- return cxt && cxt->disklabel == l;
-}
/**
* fdisk_create_disklabel:
\
libfdisk/src/init.c \
libfdisk/src/alignment.c \
+ libfdisk/src/label.c \
libfdisk/src/parttype.c
typedef unsigned long long sector_t;
-/*
- * Supported partition table types (labels)
- */
-enum fdisk_labeltype {
- FDISK_DISKLABEL_DOS = 1,
- FDISK_DISKLABEL_SUN = 2,
- FDISK_DISKLABEL_SGI = 4,
- FDISK_DISKLABEL_AIX = 8,
- FDISK_DISKLABEL_OSF = 16,
- FDISK_DISKLABEL_MAC = 32,
- FDISK_DISKLABEL_GPT = 64,
- FDISK_DISKLABEL_ANY = -1
-};
-
/*
* Partition types
*/
const struct fdisk_label *label;
};
-#define fdisk_is_disklabel(c, x) fdisk_dev_is_disklabel(c, FDISK_DISKLABEL_ ## x)
-
/*
* Label specific operations
*/
--- /dev/null
+
+#include "fdiskP.h"
+
+/**
+ * fdisk_dev_has_disklabel:
+ * @cxt: fdisk context
+ *
+ * Returns: return 1 if there is label on the device.
+ */
+int fdisk_dev_has_disklabel(struct fdisk_context *cxt)
+{
+ return cxt && cxt->disklabel != FDISK_DISKLABEL_ANY;
+}
+
+/**
+ * fdisk_dev_is_disklabel:
+ * @cxt: fdisk context
+ * @l: disklabel type
+ *
+ * Returns: return 1 if there is @l disklabel on the device.
+ */
+int fdisk_dev_is_disklabel(struct fdisk_context *cxt, enum fdisk_labeltype l)
+{
+ return cxt && cxt->disklabel == l;
+}
+
+/**
+ * fdisk_write_disklabel:
+ * @cxt: fdisk context
+ *
+ * Write in-memory changes to disk
+ *
+ * Returns 0 on success, otherwise, a corresponding error.
+ */
+int fdisk_write_disklabel(struct fdisk_context *cxt)
+{
+ if (!cxt || !cxt->label)
+ return -EINVAL;
+ if (!cxt->label->write)
+ return -ENOSYS;
+
+ return cxt->label->write(cxt);
+}
+
+/**
+ * fdisk_verify_disklabel:
+ * @cxt: fdisk context
+ *
+ * Verifies the partition table.
+ *
+ * Returns 0.
+ */
+int fdisk_verify_disklabel(struct fdisk_context *cxt)
+{
+ if (!cxt || !cxt->label)
+ return -EINVAL;
+ if (!cxt->label->verify)
+ return -ENOSYS;
+
+ return cxt->label->verify(cxt);
+}
+
+/**
+ * fdisk_add_partition:
+ * @cxt: fdisk context
+ * @partnum: partition number to create
+ * @t: partition type to create or NULL for label-specific default
+ *
+ * Creates a new partition, with number @partnum and type @parttype.
+ *
+ * Returns 0.
+ */
+int fdisk_add_partition(struct fdisk_context *cxt, int partnum,
+ struct fdisk_parttype *t)
+{
+ if (!cxt || !cxt->label)
+ return -EINVAL;
+ if (!cxt->label->part_add)
+ return -ENOSYS;
+
+ DBG(LABEL, dbgprint("adding new partition number %d", partnum));
+ cxt->label->part_add(cxt, partnum, t);
+ return 0;
+}
+
+/**
+ * fdisk_delete_partition:
+ * @cxt: fdisk context
+ * @partnum: partition number to delete
+ *
+ * Deletes a @partnum partition.
+ *
+ * Returns 0 on success, otherwise, a corresponding error.
+ */
+int fdisk_delete_partition(struct fdisk_context *cxt, int partnum)
+{
+ if (!cxt || !cxt->label)
+ return -EINVAL;
+ if (!cxt->label->part_delete)
+ return -ENOSYS;
+
+ DBG(LABEL, dbgprint("deleting %s partition number %d",
+ cxt->label->name, partnum));
+ return cxt->label->part_delete(cxt, partnum);
+}
struct fdisk_context;
struct fdisk_parttype;
+/*
+ * Supported partition table types (labels)
+ */
+enum fdisk_labeltype {
+ FDISK_DISKLABEL_DOS = 1,
+ FDISK_DISKLABEL_SUN = 2,
+ FDISK_DISKLABEL_SGI = 4,
+ FDISK_DISKLABEL_AIX = 8,
+ FDISK_DISKLABEL_OSF = 16,
+ FDISK_DISKLABEL_MAC = 32,
+ FDISK_DISKLABEL_GPT = 64,
+ FDISK_DISKLABEL_ANY = -1
+};
+
/* init.c */
extern void fdisk_init_debug(int mask);
extern void fdisk_free_parttype(struct fdisk_parttype *type);
extern size_t fdisk_get_nparttypes(struct fdisk_context *cxt);
+/* label.c */
+extern int fdisk_dev_has_disklabel(struct fdisk_context *cxt);
+
+extern int fdisk_dev_is_disklabel(struct fdisk_context *cxt, enum fdisk_labeltype l);
+#define fdisk_is_disklabel(c, x) fdisk_dev_is_disklabel(c, FDISK_DISKLABEL_ ## x)
+
+extern int fdisk_write_disklabel(struct fdisk_context *cxt);
+extern int fdisk_verify_disklabel(struct fdisk_context *cxt);
+
+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);
+
#ifdef __cplusplus
}
#endif