531551
From 2181ce4a5726c4c72e68e6964b7ef7442e507707 Mon Sep 17 00:00:00 2001
531551
From: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
531551
Date: Fri, 24 Jun 2016 11:59:35 +0200
531551
Subject: [PATCH] libblkid: Add metadata signature check for IMSM on 4Kn drives
531551
531551
Drives with 512 and 4K sectors have different offset for
531551
metadata signature. Without signature detected on 4Kn drives
531551
those drives will not be recognized as raid member. This
531551
patch adds checking for IMSM signature for 4Kn drives.
531551
531551
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1451704
531551
Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
531551
Signed-off-by: Karel Zak <kzak@redhat.com>
531551
---
531551
 libblkid/src/superblocks/isw_raid.c | 13 +++++++------
531551
 1 file changed, 7 insertions(+), 6 deletions(-)
531551
531551
diff --git a/libblkid/src/superblocks/isw_raid.c b/libblkid/src/superblocks/isw_raid.c
531551
index 065c2b2..81d53a1 100644
531551
--- a/libblkid/src/superblocks/isw_raid.c
531551
+++ b/libblkid/src/superblocks/isw_raid.c
531551
@@ -25,11 +25,11 @@ struct isw_metadata {
531551
 
531551
 #define ISW_SIGNATURE		"Intel Raid ISM Cfg Sig. "
531551
 
531551
-
531551
 static int probe_iswraid(blkid_probe pr,
531551
 		const struct blkid_idmag *mag __attribute__((__unused__)))
531551
 {
531551
 	uint64_t off;
531551
+	unsigned int sector_size;
531551
 	struct isw_metadata *isw;
531551
 
531551
 	if (pr->size < 0x10000)
531551
@@ -37,16 +37,17 @@ static int probe_iswraid(blkid_probe pr,
531551
 	if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr))
531551
 		return 1;
531551
 
531551
-	off = ((pr->size / 0x200) - 2) * 0x200;
531551
-	isw = (struct isw_metadata *)
531551
-			blkid_probe_get_buffer(pr,
531551
-					off,
531551
-					sizeof(struct isw_metadata));
531551
+	sector_size = blkid_probe_get_sectorsize(pr);
531551
+	off = ((pr->size / sector_size) - 2) * sector_size;
531551
+
531551
+	isw = (struct isw_metadata *)blkid_probe_get_buffer(pr,
531551
+			off, sizeof(struct isw_metadata));
531551
 	if (!isw)
531551
 		return errno ? -errno : 1;
531551
 
531551
 	if (memcmp(isw->sig, ISW_SIGNATURE, sizeof(ISW_SIGNATURE)-1) != 0)
531551
 		return 1;
531551
+
531551
 	if (blkid_probe_sprintf_version(pr, "%6s",
531551
 			&isw->sig[sizeof(ISW_SIGNATURE)-1]) != 0)
531551
 		return 1;
531551
-- 
531551
2.9.4
531551