]> err.no Git - util-linux/commitdiff
blkid: add highpoint{37x,45x} RAIDs
authorKarel Zak <kzak@redhat.com>
Fri, 21 Nov 2008 11:24:07 +0000 (12:24 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Feb 2009 22:21:47 +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/highpoint_raid.c [new file with mode: 0644]
libs/blkid/src/probers/probers.h

index ff75898c4d6a26582f61aa3513593b5e535fecd8..7324be9f2ec0f54b283e0b07404f257b1682f33c 100644 (file)
@@ -45,8 +45,8 @@ static const struct blkid_idinfo *idinfos[] =
        &silraid_idinfo,
        &nvraid_idinfo,
        &pdcraid_idinfo,
-       /* TODO: 45x highpoint_raid */
-       /* TODO: 37x highpoint_raid */
+       &highpoint45x_idinfo,
+       &highpoint37x_idinfo,
        &adraid_idinfo,
        &jmraid_idinfo,
        &lvm2_idinfo,
index 5bca88c4e21e6a9aa82daf4e244b1ae35f128e4b..06fcdd9c6d84ec090fceb6a40e3b4a400cc77671 100644 (file)
@@ -30,6 +30,7 @@ libprobers_a_SOURCES =        probers.h \
                        udf.c \
                        vfat.c \
                        luks.c \
+                       highpoint_raid.c \
                        lvm.c
 
 all-local: $(lib_LIBRARIES)
diff --git a/libs/blkid/src/probers/highpoint_raid.c b/libs/blkid/src/probers/highpoint_raid.c
new file mode 100644 (file)
index 0000000..8d9de70
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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"
+
+struct hpt45x_meta {
+       uint32_t        magic;
+};
+
+#define HPT37X_CONFIG_OFF              0x1200
+#define HPT37X_MAGIC_OK                        0x5a7816f0
+#define HPT37X_MAGIC_BAD               0x5a7816fd
+
+#define HPT45X_MAGIC_OK                        0x5a7816f3
+#define HPT45X_MAGIC_BAD               0x5a7816fd
+
+static int probe_highpoint45x(blkid_probe pr, const struct blkid_idmag *mag)
+{
+       const uint8_t *buf;
+       struct hpt45x_meta *hpt;
+       uint64_t meta_off;
+       uint32_t magic;
+
+       if (pr->size < 0x10000)
+               return -1;
+
+       meta_off = ((pr->size / 0x200) - 11) * 0x200;
+       buf = blkid_probe_get_buffer(pr, meta_off, 0x200);
+       if (buf == NULL)
+               return -1;
+
+       hpt = (struct hpt45x_meta *) buf;
+       magic = le32_to_cpu(hpt->magic);
+       if (magic != HPT45X_MAGIC_OK && magic != HPT45X_MAGIC_BAD)
+               return -1;
+       return 0;
+}
+
+const struct blkid_idinfo highpoint45x_idinfo = {
+       .name           = "highpoint_raid_member",
+       .usage          = BLKID_USAGE_RAID,
+       .probefunc      = probe_highpoint45x,
+       .magics         = BLKID_NONE_MAGIC
+};
+
+const struct blkid_idinfo highpoint37x_idinfo = {
+       .name           = "highpoint_raid_member",
+       .usage          = BLKID_USAGE_RAID,
+       .magics         = {
+               { .magic = "\xf0\x16\x78\x5a", .len = 4, .sboff = 32 },
+               { .magic = "\xfd\x16\x78\x5a", .len = 4, .sboff = 32 },
+               { NULL }
+       }
+};
+
+
index ee1603b3b64ed886f04d4664d33eb0f4a55955eb..cdf0682ec51fdf5758b73140588ed01390ae5c93 100644 (file)
@@ -51,5 +51,7 @@ extern const struct blkid_idinfo udf_idinfo;
 extern const struct blkid_idinfo vfat_idinfo;
 extern const struct blkid_idinfo lvm2_idinfo;
 extern const struct blkid_idinfo luks_idinfo;
+extern const struct blkid_idinfo highpoint37x_idinfo;
+extern const struct blkid_idinfo highpoint45x_idinfo;
 
 #endif /* _BLKID_PROBE_H */