]> err.no Git - util-linux/commitdiff
blkid: add DDF raid
authorKarel Zak <kzak@redhat.com>
Mon, 8 Sep 2008 22:52:46 +0000 (00:52 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Feb 2009 22:21:43 +0000 (23:21 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libs/blkid/src/probe.c
libs/blkid/src/probers/Makefile.am
libs/blkid/src/probers/ddf_raid.c [new file with mode: 0644]
libs/blkid/src/probers/probers.h

index 370ec4c6fbb9b30d5d1c4028a3e7a9ee70846da3..eafb76f7b0d9ae87882767785d22bbdf62ea1eff 100644 (file)
@@ -38,7 +38,8 @@ static const struct blkid_idinfo *idinfos[] =
        &swsuspend_idinfo,
        &cramfs_idinfo,
        &swap_idinfo,
-       &adraid_idinfo
+       &adraid_idinfo,
+       &ddfraid_idinfo
 };
 
 #ifndef ARRAY_SIZE
index d966ef487469a08f1b7b5fea07dbf74182cee836..fcca51dc299c23b513e7f4d458f602d90c01d611 100644 (file)
@@ -4,9 +4,10 @@ AM_CPPFLAGS += -I$(top_builddir)/libs/blkid/src
 
 lib_LIBRARIES = libprobers.a
 libprobers_a_CFLAGS = -fPIC
-libprobers_a_SOURCES =         probers.h \
+libprobers_a_SOURCES = probers.h \
                        cramfs.c \
                        swap.c \
-                       adaptec_raid.c
+                       adaptec_raid.c \
+                       ddf_raid.c
 
 all-local: $(lib_LIBRARIES)
diff --git a/libs/blkid/src/probers/ddf_raid.c b/libs/blkid/src/probers/ddf_raid.c
new file mode 100644 (file)
index 0000000..5c6f652
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
+ * Copyright (C) 2007 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdint.h>
+
+#include "blkidP.h"
+
+/* http://www.snia.org/standards/home */
+#define DDF_HEADER                     0xDE11DE11
+#define DDF_GUID_LENGTH                        24
+#define DDF_REV_LENGTH                 8
+
+struct ddf_header {
+       uint32_t        signature;
+       uint32_t        crc;
+       uint8_t         guid[DDF_GUID_LENGTH];
+       uint8_t         ddf_rev[DDF_REV_LENGTH];
+};
+
+static int probe_ddf(blkid_probe pr, const struct blkid_idmag *mag)
+{
+       uint64_t ddf_off;
+       struct ddf_header *ddf;
+
+       if (pr->size < 0x10000)
+               return -1;
+
+       ddf_off = ((pr->size / 0x200) - 1) * 0x200;
+       ddf = (struct ddf_header *) blkid_probe_get_buffer(pr, ddf_off, 0x200);
+       if (!ddf)
+               return -1;
+       if (ddf->signature != cpu_to_be32(DDF_HEADER))
+               return -1;
+       if (blkid_probe_sprintf_uuid(pr, ddf->guid,
+                               sizeof(ddf->guid), "%s", ddf->guid) != 0)
+               return -1;
+       if (blkid_probe_set_version(pr, (char *) ddf->ddf_rev) != 0)
+               return -1;
+       return 0;
+}
+
+const struct blkid_idinfo ddfraid_idinfo = {
+       .name           = "ddf_raid_member",
+       .usage          = BLKID_USAGE_RAID,
+       .probefunc      = probe_ddf
+};
+
+
index 7be9ae8ea4d9c2ffbd8e1e94dabb5c3b5dfc9c6b..8e23b6b438ac0b51c79b01a71617779300d24ae4 100644 (file)
@@ -19,5 +19,6 @@ extern const struct blkid_idinfo cramfs_idinfo;
 extern const struct blkid_idinfo swap_idinfo;
 extern const struct blkid_idinfo swsuspend_idinfo;
 extern const struct blkid_idinfo adraid_idinfo;
+extern const struct blkid_idinfo ddfraid_idinfo;
 
 #endif /* _BLKID_PROBE_H */