summaryrefslogtreecommitdiffstats
path: root/fdisks/fdisksgilabel.c
diff options
context:
space:
mode:
authorKarel Zak2012-12-11 12:56:27 +0100
committerKarel Zak2013-03-11 12:47:29 +0100
commit0c5d095e46306ed4d6009f56e0339857d733d72e (patch)
treeea751328b6a158c199c7595faf3200a8039dd176 /fdisks/fdisksgilabel.c
parentlibfdisk: cleanup the rest of fdisks/utils.c stuff (diff)
downloadkernel-qcow2-util-linux-0c5d095e46306ed4d6009f56e0339857d733d72e.tar.gz
kernel-qcow2-util-linux-0c5d095e46306ed4d6009f56e0339857d733d72e.tar.xz
kernel-qcow2-util-linux-0c5d095e46306ed4d6009f56e0339857d733d72e.zip
libfdisk: split label and label operations
Changes: - fdisk_label is a private label driver struct - generic header of the fdisk_label points to fdisk_label_operations - the private fdisk_label stuff is always allocated for all drivers during fdisk_context initialization - context->labels[] contains pointers to all supported labels (drivers) - context->label is a pointer to the currently used label This change allows to: - store label specific global settings (e.g. dos compatible mode, display units, ...) independently on the current label - add label specific function to the API Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdisksgilabel.c')
-rw-r--r--fdisks/fdisksgilabel.c55
1 files changed, 42 insertions, 13 deletions
diff --git a/fdisks/fdisksgilabel.c b/fdisks/fdisksgilabel.c
index cf20445e4..c58e7263b 100644
--- a/fdisks/fdisksgilabel.c
+++ b/fdisks/fdisksgilabel.c
@@ -35,6 +35,15 @@
#include "fdisksgilabel.h"
#include "fdiskdoslabel.h"
+
+/*
+ * in-memory fdisk SGI stuff
+ */
+struct fdisk_sgi_label {
+ struct fdisk_label head; /* generic part */
+};
+
+
static int other_endian = 0;
static int debug = 0;
static short volumes=1;
@@ -929,18 +938,38 @@ static int sgi_set_parttype(struct fdisk_context *cxt, int i,
return 0;
}
-const struct fdisk_label sgi_label =
+static const struct fdisk_label_operations sgi_operations =
{
- .name = "sgi",
- .parttypes = sgi_parttypes,
- .nparttypes = ARRAY_SIZE(sgi_parttypes),
-
- .probe = sgi_probe_label,
- .write = sgi_write_disklabel,
- .verify = sgi_verify_disklabel,
- .create = sgi_create_disklabel,
- .part_add = sgi_add_partition,
- .part_delete = sgi_delete_partition,
- .part_get_type = sgi_get_parttype,
- .part_set_type = sgi_set_parttype,
+ .probe = sgi_probe_label,
+ .write = sgi_write_disklabel,
+ .verify = sgi_verify_disklabel,
+ .create = sgi_create_disklabel,
+ .part_add = sgi_add_partition,
+ .part_delete = sgi_delete_partition,
+ .part_get_type = sgi_get_parttype,
+ .part_set_type = sgi_set_parttype
};
+
+/*
+ * allocates SGI label driver
+ */
+struct fdisk_label *fdisk_new_sgi_label(struct fdisk_context *cxt)
+{
+ struct fdisk_label *lb;
+ struct fdisk_sgi_label *sgi;
+
+ assert(cxt);
+
+ sgi = calloc(1, sizeof(*sgi));
+ if (!sgi)
+ return NULL;
+
+ /* initialize generic part of the driver */
+ lb = (struct fdisk_label *) sgi;
+ lb->name = "sgi";
+ lb->op = &sgi_operations;
+ lb->parttypes = sgi_parttypes;
+ lb->nparttypes = ARRAY_SIZE(sgi_parttypes);
+
+ return lb;
+}