From 02dc119b64355dcd9f7a4517920aca929cf2cfe2 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 16 Sep 2009 15:55:58 +0200 Subject: [PATCH] libblkid: add AIX partitions support Signed-off-by: Karel Zak --- shlibs/blkid/src/partitions/Makefile.am | 4 +- shlibs/blkid/src/partitions/aix.c | 58 ++++++++++++++++++++++++ shlibs/blkid/src/partitions/aix.h | 7 +++ shlibs/blkid/src/partitions/partitions.c | 1 + shlibs/blkid/src/partitions/partitions.h | 5 ++ 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 shlibs/blkid/src/partitions/aix.c create mode 100644 shlibs/blkid/src/partitions/aix.h diff --git a/shlibs/blkid/src/partitions/Makefile.am b/shlibs/blkid/src/partitions/Makefile.am index c029bfdb..d57298f4 100644 --- a/shlibs/blkid/src/partitions/Makefile.am +++ b/shlibs/blkid/src/partitions/Makefile.am @@ -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 index 00000000..be0ad2b4 --- /dev/null +++ b/shlibs/blkid/src/partitions/aix.c @@ -0,0 +1,58 @@ +/* + * aix partitions + * + * Copyright (C) 2009 Karel Zak + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License. + */ +#include +#include +#include +#include + +#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 index 00000000..f767c5a3 --- /dev/null +++ b/shlibs/blkid/src/partitions/aix.h @@ -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 diff --git a/shlibs/blkid/src/partitions/partitions.c b/shlibs/blkid/src/partitions/partitions.c index 16be7ed7..dbf8db0c 100644 --- a/shlibs/blkid/src/partitions/partitions.c +++ b/shlibs/blkid/src/partitions/partitions.c @@ -102,6 +102,7 @@ static void partitions_free_data(blkid_probe pr, void *data); */ static const struct blkid_idinfo *idinfos[] = { + &aix_pt_idinfo }; /* diff --git a/shlibs/blkid/src/partitions/partitions.h b/shlibs/blkid/src/partitions/partitions.h index d283b326..59d3a88b 100644 --- a/shlibs/blkid/src/partitions/partitions.h +++ b/shlibs/blkid/src/partitions/partitions.h @@ -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 */ -- 2.39.5