summaryrefslogtreecommitdiff
blob: 843f324eb21852f98e94211bbe9af76625fad44e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
volume_id: really fix endianess bug in linux_raid detection

Seems we find the md signature in cpu-order on the disk. Let's
look for both endian encodings ...

Thanks to Michael Prokop for his help finding the bug.

---
commit ac77e95948edc199cdd690de38f08e4d1e615840
tree 640db7d14b7ee0745cf9abc7f01ba93625ccf473
parent 273bebdba66cd5543dc1b076447e3275c81c221c
author Kay Sievers <kay.sievers@vrfy.org> Sa, 03 Feb 2007 01:12:34 +0100
committer Kay Sievers <kay.sievers@vrfy.org> Sa, 03 Feb 2007 01:12:34 +0100

 extras/volume_id/lib/Makefile     |    2 +-
 extras/volume_id/lib/linux_raid.c |    6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/extras/volume_id/lib/Makefile b/extras/volume_id/lib/Makefile
index a3e947c..5ad9f2e 100644
--- a/extras/volume_id/lib/Makefile
+++ b/extras/volume_id/lib/Makefile
@@ -13,7 +13,7 @@ INSTALL_DATA  = ${INSTALL} -m 644
 INSTALL_LIB = ${INSTALL} -m 755
 
 SHLIB_CUR = 0
-SHLIB_REV = 74
+SHLIB_REV = 75
 SHLIB_AGE = 0
 SHLIB = libvolume_id.so.$(SHLIB_CUR).$(SHLIB_REV).$(SHLIB_AGE)
 
diff --git a/extras/volume_id/lib/linux_raid.c b/extras/volume_id/lib/linux_raid.c
index b8a819f..a9c5d61 100644
--- a/extras/volume_id/lib/linux_raid.c
+++ b/extras/volume_id/lib/linux_raid.c
@@ -46,7 +46,8 @@ static struct mdp_super_block {
 } PACKED *mdp;
 
 #define MD_RESERVED_BYTES		0x10000
-#define MD_MAGIC			"\xa9\x2b\x4e\xfc"
+#define MD_MAGIC			"\xfc\x4e\x2b\xa9"
+#define MD_MAGIC_SWAP			"\xa9\x2b\x4e\xfc"
 
 int volume_id_probe_linux_raid(struct volume_id *id, uint64_t off, uint64_t size)
 {
@@ -65,7 +66,8 @@ int volume_id_probe_linux_raid(struct volume_id *id, uint64_t off, uint64_t size
 		return -1;
 	mdp = (struct mdp_super_block *) buf;
 
-	if (memcmp(mdp->md_magic, MD_MAGIC, 4) != 0)
+	if ((memcmp(mdp->md_magic, MD_MAGIC, 4) != 0) &&
+	    (memcmp(mdp->md_magic, MD_MAGIC_SWAP, 4) != 0))
 		return -1;
 
 	memcpy(uuid, &mdp->set_uuid0, 4);