2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2 of the License.
26 #include "libvolume_id.h"
29 static struct mdp_super_block {
31 uint32_t major_version;
32 uint32_t minor_version;
33 uint32_t patch_version;
34 uint32_t gvalid_words;
42 uint32_t not_persistent;
48 #define MD_RESERVED_BYTES 0x10000
49 #define MD_MAGIC "\xfc\x4e\x2b\xa9"
50 #define MD_MAGIC_SWAP "\xa9\x2b\x4e\xfc"
52 int volume_id_probe_linux_raid(struct volume_id *id, uint64_t off, uint64_t size)
58 info("probing at offset 0x%llx, size 0x%llx",
59 (unsigned long long) off, (unsigned long long) size);
63 sboff = (size & ~(MD_RESERVED_BYTES - 1)) - MD_RESERVED_BYTES;
64 buf = volume_id_get_buffer(id, off + sboff, 0x800);
67 mdp = (struct mdp_super_block *) buf;
69 if ((memcmp(mdp->md_magic, MD_MAGIC, 4) != 0) &&
70 (memcmp(mdp->md_magic, MD_MAGIC_SWAP, 4) != 0))
73 memcpy(uuid, &mdp->set_uuid0, 4);
74 memcpy(&uuid[4], &mdp->set_uuid1, 12);
75 volume_id_set_uuid(id, uuid, UUID_DCE);
76 snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u.%u",
77 le32_to_cpu(mdp->major_version),
78 le32_to_cpu(mdp->minor_version),
79 le32_to_cpu(mdp->patch_version));
80 dbg("found raid signature");
81 volume_id_set_usage(id, VOLUME_ID_RAID);
82 id->type = "linux_raid_member";