2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include "volume_id.h"
39 #include "linux_raid.h"
41 struct mdp_super_block {
43 uint32_t major_version;
44 uint32_t minor_version;
45 uint32_t patch_version;
46 uint32_t gvalid_words;
54 uint32_t not_persistent;
58 } __attribute__((packed)) *mdp;
60 #define MD_RESERVED_BYTES 0x10000
61 #define MD_MAGIC 0xa92b4efc
63 int volume_id_probe_linux_raid(struct volume_id *id, uint64_t off, uint64_t size)
69 dbg("probing at offset 0x%llx, size 0x%llx",
70 (unsigned long long) off, (unsigned long long) size);
75 sboff = (size & ~(MD_RESERVED_BYTES - 1)) - MD_RESERVED_BYTES;
76 buf = volume_id_get_buffer(id, off + sboff, 0x800);
80 mdp = (struct mdp_super_block *) buf;
82 if (le32_to_cpu(mdp->md_magic) != MD_MAGIC)
85 memcpy(uuid, &mdp->set_uuid0, 4);
86 memcpy(&uuid[4], &mdp->set_uuid1, 12);
87 volume_id_set_uuid(id, uuid, UUID_DCE);
89 snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u.%u",
90 le32_to_cpu(mdp->major_version),
91 le32_to_cpu(mdp->minor_version),
92 le32_to_cpu(mdp->patch_version));
94 dbg("found raid signature");
95 volume_id_set_usage(id, VOLUME_ID_RAID);
96 id->type = "linux_raid_member";