From: Karel Zak Date: Fri, 21 Nov 2008 11:24:07 +0000 (+0100) Subject: blkid: add highpoint{37x,45x} RAIDs X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5784db20337a11e532878a0ec81da7144300399a;p=util-linux blkid: add highpoint{37x,45x} RAIDs Signed-off-by: Karel Zak --- diff --git a/libs/blkid/src/probe.c b/libs/blkid/src/probe.c index ff75898c..7324be9f 100644 --- a/libs/blkid/src/probe.c +++ b/libs/blkid/src/probe.c @@ -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, diff --git a/libs/blkid/src/probers/Makefile.am b/libs/blkid/src/probers/Makefile.am index 5bca88c4..06fcdd9c 100644 --- a/libs/blkid/src/probers/Makefile.am +++ b/libs/blkid/src/probers/Makefile.am @@ -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 index 00000000..8d9de70f --- /dev/null +++ b/libs/blkid/src/probers/highpoint_raid.c @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2008 Karel Zak + * Copyright (C) 2007 Kay Sievers + * + * 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 +#include +#include +#include +#include + +#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 } + } +}; + + diff --git a/libs/blkid/src/probers/probers.h b/libs/blkid/src/probers/probers.h index ee1603b3..cdf0682e 100644 --- a/libs/blkid/src/probers/probers.h +++ b/libs/blkid/src/probers/probers.h @@ -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 */