[Ocfs2-tools-devel] [PATCH] debugfs.ocfs2: fix dump_block_check for big-endian

Joel Becker jlbec at evilplan.org
Thu Jul 28 03:20:45 PDT 2011


On Wed, Jul 06, 2011 at 05:19:39PM -0500, Goldwyn Rodrigues wrote:
> The block check or metaecc code expects the data to be in little-endian
> format for calculating CRC and ECC. However, with big-endian machines,
> the block is in big-endian format.
> 
> Convert the block to little-endian format before feeding to meta ecc
> computation. After computing, change data format back to CPU.
> 
 
> ---
> diff --git a/debugfs.ocfs2/dump.c b/debugfs.ocfs2/dump.c
> index ad58126..d54c31a 100644
> --- a/debugfs.ocfs2/dump.c
> +++ b/debugfs.ocfs2/dump.c
> @@ -166,10 +166,74 @@ void dump_block_check(FILE *out, struct
> ocfs2_block_check *bc, void *block)
>  {
>  	struct ocfs2_block_check tmp = *bc;
>  	int crc_fail;
> +	enum dump_block_type bt = detect_block(block);
> +
> +	/* Swap block to little endian for compute_meta_ecc */
> +	switch (bt) {
> +		case DUMP_BLOCK_INODE:
> +			ocfs2_swap_inode_from_cpu(gbls.fs, block);
> +			break;

	Instead, why not allocate a temporary block, copy the data over,
and then swap the temporary buffer.  That way you aren't having to swap
back?

Joel

-- 

Life's Little Instruction Book #232

	"Keep your promises."

			http://www.jlbec.org/
			jlbec at evilplan.org



More information about the Ocfs2-tools-devel mailing list