chiark / gitweb /
volume_id: really fix endianess bug in linux_raid detection
authorKay Sievers <kay.sievers@vrfy.org>
Sat, 3 Feb 2007 00:12:34 +0000 (01:12 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Sat, 3 Feb 2007 00:12:34 +0000 (01:12 +0100)
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.

extras/volume_id/lib/Makefile
extras/volume_id/lib/linux_raid.c

index a3e947ceac3be7a26418ac905bf6d549b00b16e4..5ad9f2e56134ec11e542d98f110de13e28a631db 100644 (file)
@@ -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)
 
index b8a819f67172068bee9059ae31d0f5b36b5fcdd6..a9c5d61adca9b20f83799e7eb97e020061844abe 100644 (file)
@@ -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);