]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: add basic structs
authorKarel Zak <kzak@redhat.com>
Fri, 30 Nov 2012 15:31:04 +0000 (16:31 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 11 Mar 2013 10:20:40 +0000 (11:20 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisks/fdisk.h
libfdisk/src/Makemodule.am
libfdisk/src/fdiskP.h

index 14b0a7a6a248ddad776fa3ef2de10e4bb8361e18..efc9969b688dde155cdfab2afae38949059cabb8 100644 (file)
@@ -63,111 +63,6 @@ enum failure {
        unable_to_write
 };
 
-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
- */
-struct fdisk_parttype {
-       unsigned int    type;           /* type as number or zero */
-       const char      *name;          /* description */
-       char            *typestr;       /* type as string or NULL */
-
-       unsigned int    flags;          /* FDISK_PARTTYPE_* flags */
-};
-
-enum {
-       FDISK_PARTTYPE_UNKNOWN          = (1 << 1),
-       FDISK_PARTTYPE_INVISIBLE        = (1 << 2),
-       FDISK_PARTTYPE_ALLOCATED        = (1 << 3)
-};
-
-#define fdisk_parttype_is_unknown(_x)  ((_x) && ((_x)->flags & FDISK_PARTTYPE_UNKNONW))
-#define fdisk_parttype_is_invisible(_x)        ((_x) && ((_x)->flags & FDISK_PARTTYPE_INVISIBLE))
-#define fdisk_parttype_is_allocated(_x)        ((_x) && ((_x)->flags & FDISK_PARTTYPE_ALLOCATED))
-
-/*
- * Legacy CHS based geometry
- */
-struct fdisk_geometry {
-       unsigned int heads;
-       sector_t sectors;
-       sector_t cylinders;
-};
-
-struct fdisk_context {
-       int dev_fd;         /* device descriptor */
-       char *dev_path;     /* device path */
-       unsigned char *firstsector; /* buffer with master boot record */
-
-       /* topology */
-       unsigned long io_size;          /* I/O size used by fdisk */
-       unsigned long optimal_io_size;  /* optional I/O returned by device */
-       unsigned long min_io_size;      /* minimal I/O size */
-       unsigned long phy_sector_size;  /* physical size */
-       unsigned long sector_size;      /* logical size */
-       unsigned long alignment_offset;
-
-       enum fdisk_labeltype disklabel; /* current disklabel */
-
-       /* alignment */
-       unsigned long grain;            /* alignment unit */
-       sector_t first_lba;             /* recommended begin of the first partition */
-
-       /* geometry */
-       sector_t total_sectors; /* in logical sectors */
-       struct fdisk_geometry geom;
-
-       /* label operations and description */
-       const struct fdisk_label *label;
-};
-
-#define fdisk_is_disklabel(c, x) fdisk_dev_is_disklabel(c, FDISK_DISKLABEL_ ## x)
-
-/*
- * Label specific operations
- */
-struct fdisk_label {
-       const char *name;
-
-       /* array with partition types */
-       struct fdisk_parttype   *parttypes;
-       size_t                  nparttypes;     /* number of items in parttypes[] */
-
-       /* probe disk label */
-       int (*probe)(struct fdisk_context *cxt);
-       /* write in-memory changes to disk */
-       int (*write)(struct fdisk_context *cxt);
-       /* verify the partition table */
-       int (*verify)(struct fdisk_context *cxt);
-       /* create new disk label */
-       int (*create)(struct fdisk_context *cxt);
-       /* new partition */
-       int (*part_add)(struct fdisk_context *cxt, int partnum, struct fdisk_parttype *t);
-       /* delete partition */
-       int (*part_delete)(struct fdisk_context *cxt, int partnum);
-       /* get partition type */
-       struct fdisk_parttype *(*part_get_type)(struct fdisk_context *cxt, int partnum);
-       /* set partition type */
-       int (*part_set_type)(struct fdisk_context *cxt, int partnum, struct fdisk_parttype *t);
-       /* refresh alignment setting */
-       int (*reset_alignment)(struct fdisk_context *cxt);
-};
-
 /*
  * labels
  */
index a24b8f90d8ad47f410812f042128ded4cb5ac56f..4b2d0e7f14c0fca4c34e4aad1967a5fbfeb8344f 100644 (file)
@@ -10,6 +10,7 @@ libfdisk_la_SOURCES = \
        \
        libfdisk/src/init.c
 
+
 nodist_libfdisk_la_SOURCES = libfdisk/src/fdiskP.h
 
 libfdisk_la_LIBADD = libcommon.la
index 5349166105bca9cfc3d23b78a711293bf1171018..82443453aa999f9eb61bb9a0a02d87243934a8b4 100644 (file)
@@ -84,4 +84,109 @@ extern int fdisk_debug_mask;
 # define DBG_FLUSH do { ; } while(0)
 #endif
 
+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
+ */
+struct fdisk_parttype {
+       unsigned int    type;           /* type as number or zero */
+       const char      *name;          /* description */
+       char            *typestr;       /* type as string or NULL */
+
+       unsigned int    flags;          /* FDISK_PARTTYPE_* flags */
+};
+
+enum {
+       FDISK_PARTTYPE_UNKNOWN          = (1 << 1),
+       FDISK_PARTTYPE_INVISIBLE        = (1 << 2),
+       FDISK_PARTTYPE_ALLOCATED        = (1 << 3)
+};
+
+#define fdisk_parttype_is_unknown(_x)  ((_x) && ((_x)->flags & FDISK_PARTTYPE_UNKNONW))
+#define fdisk_parttype_is_invisible(_x)        ((_x) && ((_x)->flags & FDISK_PARTTYPE_INVISIBLE))
+#define fdisk_parttype_is_allocated(_x)        ((_x) && ((_x)->flags & FDISK_PARTTYPE_ALLOCATED))
+
+/*
+ * Legacy CHS based geometry
+ */
+struct fdisk_geometry {
+       unsigned int heads;
+       sector_t sectors;
+       sector_t cylinders;
+};
+
+struct fdisk_context {
+       int dev_fd;         /* device descriptor */
+       char *dev_path;     /* device path */
+       unsigned char *firstsector; /* buffer with master boot record */
+
+       /* topology */
+       unsigned long io_size;          /* I/O size used by fdisk */
+       unsigned long optimal_io_size;  /* optional I/O returned by device */
+       unsigned long min_io_size;      /* minimal I/O size */
+       unsigned long phy_sector_size;  /* physical size */
+       unsigned long sector_size;      /* logical size */
+       unsigned long alignment_offset;
+
+       enum fdisk_labeltype disklabel; /* current disklabel */
+
+       /* alignment */
+       unsigned long grain;            /* alignment unit */
+       sector_t first_lba;             /* recommended begin of the first partition */
+
+       /* geometry */
+       sector_t total_sectors; /* in logical sectors */
+       struct fdisk_geometry geom;
+
+       /* label operations and description */
+       const struct fdisk_label *label;
+};
+
+#define fdisk_is_disklabel(c, x) fdisk_dev_is_disklabel(c, FDISK_DISKLABEL_ ## x)
+
+/*
+ * Label specific operations
+ */
+struct fdisk_label {
+       const char *name;
+
+       /* array with partition types */
+       struct fdisk_parttype   *parttypes;
+       size_t                  nparttypes;     /* number of items in parttypes[] */
+
+       /* probe disk label */
+       int (*probe)(struct fdisk_context *cxt);
+       /* write in-memory changes to disk */
+       int (*write)(struct fdisk_context *cxt);
+       /* verify the partition table */
+       int (*verify)(struct fdisk_context *cxt);
+       /* create new disk label */
+       int (*create)(struct fdisk_context *cxt);
+       /* new partition */
+       int (*part_add)(struct fdisk_context *cxt, int partnum, struct fdisk_parttype *t);
+       /* delete partition */
+       int (*part_delete)(struct fdisk_context *cxt, int partnum);
+       /* get partition type */
+       struct fdisk_parttype *(*part_get_type)(struct fdisk_context *cxt, int partnum);
+       /* set partition type */
+       int (*part_set_type)(struct fdisk_context *cxt, int partnum, struct fdisk_parttype *t);
+       /* refresh alignment setting */
+       int (*reset_alignment)(struct fdisk_context *cxt);
+};
+
 #endif /* _LIBFDISK_PRIVATE_H */