Re: [PATCH] Add metadata signature check for IMSM on 4Kn drives

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 10, 2016 at 03:51:55PM +0200, Alexey Obitotskiy wrote:
> Drives with 512 and 4K sectors have different offset for
> metadata signature. Without signature detected on 4Kn drives
> those drives will not be recognized as raid member. This
> patch adds checking for IMSM signature for 4Kn drives.
> 
> Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@xxxxxxxxx>
> ---
>  libblkid/src/superblocks/isw_raid.c | 25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/libblkid/src/superblocks/isw_raid.c b/libblkid/src/superblocks/isw_raid.c
> index 065c2b2..e9ecf05 100644
> --- a/libblkid/src/superblocks/isw_raid.c
> +++ b/libblkid/src/superblocks/isw_raid.c
> @@ -26,6 +26,14 @@ struct isw_metadata {
>  #define ISW_SIGNATURE		"Intel Raid ISM Cfg Sig. "
>  
>  
> +static struct isw_metadata *get_isw_metadata(blkid_probe pr, unsigned int sector_size,
> +		uint64_t *off)
> +{
> +	*off = ((pr->size / sector_size) - 2) * sector_size;
> +	return (struct isw_metadata *)blkid_probe_get_buffer(pr,
> +			*off, sizeof(struct isw_metadata));
> +}
> +
>  static int probe_iswraid(blkid_probe pr,
>  		const struct blkid_idmag *mag __attribute__((__unused__)))
>  {
> @@ -37,16 +45,19 @@ static int probe_iswraid(blkid_probe pr,
>  	if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr))
>  		return 1;
>  
> -	off = ((pr->size / 0x200) - 2) * 0x200;
> -	isw = (struct isw_metadata *)
> -			blkid_probe_get_buffer(pr,
> -					off,
> -					sizeof(struct isw_metadata));
> +	isw = get_isw_metadata(pr, 512, &off);
>  	if (!isw)
>  		return errno ? -errno : 1;
>  
> -	if (memcmp(isw->sig, ISW_SIGNATURE, sizeof(ISW_SIGNATURE)-1) != 0)
> -		return 1;
> +	if (memcmp(isw->sig, ISW_SIGNATURE, sizeof(ISW_SIGNATURE)-1) != 0) {
> +		isw = get_isw_metadata(pr, 4096, &off);

We have blkid_probe_get_sectorsize(pr), would be possible to use it
rather than try it two times with 512 and then 4096?

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux