From: Karel Zak Date: Mon, 8 Sep 2008 22:52:46 +0000 (+0200) Subject: blkid: add DDF raid X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4eaf9d9ded5559032fe0ee8a51b4da8ab2c2ebf6;p=util-linux blkid: add DDF raid Signed-off-by: Karel Zak --- diff --git a/libs/blkid/src/probe.c b/libs/blkid/src/probe.c index 370ec4c6..eafb76f7 100644 --- a/libs/blkid/src/probe.c +++ b/libs/blkid/src/probe.c @@ -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 diff --git a/libs/blkid/src/probers/Makefile.am b/libs/blkid/src/probers/Makefile.am index d966ef48..fcca51dc 100644 --- a/libs/blkid/src/probers/Makefile.am +++ b/libs/blkid/src/probers/Makefile.am @@ -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 index 00000000..5c6f6522 --- /dev/null +++ b/libs/blkid/src/probers/ddf_raid.c @@ -0,0 +1,64 @@ +/* + * 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" + +/* 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 +}; + + diff --git a/libs/blkid/src/probers/probers.h b/libs/blkid/src/probers/probers.h index 7be9ae8e..8e23b6b4 100644 --- a/libs/blkid/src/probers/probers.h +++ b/libs/blkid/src/probers/probers.h @@ -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 */