]> err.no Git - util-linux/commitdiff
libblkid: add AIX partitions support
authorKarel Zak <kzak@redhat.com>
Wed, 16 Sep 2009 13:55:58 +0000 (15:55 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Sep 2009 13:55:58 +0000 (15:55 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/partitions/Makefile.am
shlibs/blkid/src/partitions/aix.c [new file with mode: 0644]
shlibs/blkid/src/partitions/aix.h [new file with mode: 0644]
shlibs/blkid/src/partitions/partitions.c
shlibs/blkid/src/partitions/partitions.h

index c029bfdb8cf1f29624b247e6320800c09be179af..d57298f46281bb2c04db6ec4ba2ac376634ac78f 100644 (file)
@@ -6,4 +6,6 @@ libblkid_partitions_la_LIBADD =
 noinst_LTLIBRARIES = libblkid_partitions.la
 libblkid_partitions_la_SOURCES = partitions.c \
                                partitions.h \
-                               blkid_parttypes.h
+                               blkid_parttypes.h \
+                               aix.c \
+                               aix.h
diff --git a/shlibs/blkid/src/partitions/aix.c b/shlibs/blkid/src/partitions/aix.c
new file mode 100644 (file)
index 0000000..be0ad2b
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * aix partitions
+ *
+ * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+ *
+ * This file may be redistributed under the terms of the
+ * GNU Lesser General Public License.
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#include "partitions.h"
+#include "aix.h"
+
+static int probe_aix_pt(blkid_probe pr, const struct blkid_idmag *mag)
+{
+       blkid_partlist ls;
+       blkid_parttable tab;
+
+       if (blkid_partitions_need_typeonly(pr))
+               /* caller does not ask for details about partitions */
+               return 0;
+
+       ls = blkid_probe_get_partlist(pr);
+       if (!ls)
+               goto err;
+
+       tab = blkid_partlist_new_parttable(ls, "aix", 0);
+       if (!tab)
+               goto err;
+
+       return 0;
+err:
+       return -1;
+}
+
+/*
+ * We know nothing about AIX on-disk structures. Everything what we know is the
+ * magic number at begin of the disk.
+ *
+ * Note, Linux kernel is tring to be smart and AIX signature is ignored when
+ * there is a valid DOS partitions table. We don't support such behaviour. All
+ * fdisk-like programs has to properly wipe the fist sector. Everything other
+ * is a bug.
+ */
+const struct blkid_idinfo aix_pt_idinfo =
+{
+       .name           = "aix",
+       .probefunc      = probe_aix_pt,
+       .magics         =
+       {
+               { .magic = BLKID_AIX_MAGIC_STRING, .len = BLKID_AIX_MAGIC_STRLEN },
+               { NULL }
+       }
+};
+
diff --git a/shlibs/blkid/src/partitions/aix.h b/shlibs/blkid/src/partitions/aix.h
new file mode 100644 (file)
index 0000000..f767c5a
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef BLKID_PARTITIONS_AIX_H
+#define BLKID_PARTITIONS_AIX_H
+
+#define BLKID_AIX_MAGIC_STRING "\xC9\xC2\xD4\xC1"
+#define BLKID_AIX_MAGIC_STRLEN (sizeof(BLKID_AIX_MAGIC_STRING) - 1)
+
+#endif
index 16be7ed7d8e3a0993fcd80a8cdc04c6a295b7af5..dbf8db0ca4acc274030e21a460da7dd45308b676 100644 (file)
@@ -102,6 +102,7 @@ static void partitions_free_data(blkid_probe pr, void *data);
  */
 static const struct blkid_idinfo *idinfos[] =
 {
+       &aix_pt_idinfo
 };
 
 /*
index d283b32646b6e06e4cd3a8fbc0fa6ce13f922b0c..59d3a88b4ef2a7ad58396e47bceb8d81da223adf 100644 (file)
@@ -32,4 +32,9 @@ extern int blkid_partition_set_utf8name(blkid_partition par,
 extern int blkid_partition_set_uuid(blkid_partition par,
                const unsigned char *uuid);
 
+/*
+ * partition probers
+ */
+extern const struct blkid_idinfo aix_pt_idinfo;
+
 #endif /* BLKID_PARTITIONS_H */