1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include "volume_id_internal.h"
22
23struct mdp_super_block {
24 uint32_t md_magic;
25 uint32_t major_version;
26 uint32_t minor_version;
27 uint32_t patch_version;
28 uint32_t gvalid_words;
29 uint32_t set_uuid0;
30 uint32_t ctime;
31 uint32_t level;
32 uint32_t size;
33 uint32_t nr_disks;
34 uint32_t raid_disks;
35 uint32_t md_minor;
36 uint32_t not_persistent;
37 uint32_t set_uuid1;
38 uint32_t set_uuid2;
39 uint32_t set_uuid3;
40} PACKED;
41
42#define MD_RESERVED_BYTES 0x10000
43#define MD_MAGIC 0xa92b4efc
44
45int FAST_FUNC volume_id_probe_linux_raid(struct volume_id *id , uint64_t size)
46{
47 typedef uint32_t aliased_uint32_t FIX_ALIASING;
48#define off ((uint64_t)0)
49 uint64_t sboff;
50 uint8_t uuid[16];
51 struct mdp_super_block *mdp;
52
53 dbg("probing at offset 0x%llx, size 0x%llx",
54 (unsigned long long) off, (unsigned long long) size);
55
56 if (size < 0x10000)
57 return -1;
58
59 sboff = (size & ~(MD_RESERVED_BYTES - 1)) - MD_RESERVED_BYTES;
60 mdp = volume_id_get_buffer(id, off + sboff, 0x800);
61 if (mdp == NULL)
62 return -1;
63
64 if (mdp->md_magic != cpu_to_le32(MD_MAGIC))
65 return -1;
66
67 *(aliased_uint32_t*)uuid = mdp->set_uuid0;
68 memcpy(&uuid[4], &mdp->set_uuid1, 12);
69 volume_id_set_uuid(id, uuid, UUID_DCE);
70
71
72
73
74
75
76 dbg("found raid signature");
77
78
79
80 return 0;
81}
82