[Ocfs2-tools-devel] [PATCH 1/2] extras/check_metaecc: fix of check_metaecc(), v2
Sunil Mushran
sunil.mushran at oracle.com
Tue May 25 13:14:12 PDT 2010
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
On 05/25/2010 01:27 AM, Coly Li wrote:
> check_metaecc() should clean zero to the memory area which an ocfs2_block_check
> type pointer pointed to. This patch fixes the error.
>
> Reported-by: Jiaju Zhang<JJZhang at novell.com>
> Signed-off-by: Coly Li<coly.li at suse.de>
> ---
> extras/check_metaecc.c | 30 +++++++++++++++---------------
> 1 files changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/extras/check_metaecc.c b/extras/check_metaecc.c
> index 86bbb08..ff06068 100644
> --- a/extras/check_metaecc.c
> +++ b/extras/check_metaecc.c
> @@ -59,7 +59,7 @@ static errcode_t check_metaecc(ocfs2_filesys *fs,
> {
> char signature[8];
> char name[256] = {0, };
> - struct ocfs2_block_check check;
> + struct ocfs2_block_check *check;
> int do_check = 1;
> errcode_t err = 0;
>
> @@ -68,49 +68,49 @@ static errcode_t check_metaecc(ocfs2_filesys *fs,
> if (!strncmp(signature, OCFS2_SUPER_BLOCK_SIGNATURE,
> sizeof(OCFS2_SUPER_BLOCK_SIGNATURE))) {
> struct ocfs2_dinode *di = (struct ocfs2_dinode *)block;
> - check = di->i_check;
> + check =&di->i_check;
> snprintf(name, sizeof(name), OCFS2_SUPER_BLOCK_SIGNATURE);
> } else if (!strncmp(signature, OCFS2_INODE_SIGNATURE,
> sizeof(OCFS2_INODE_SIGNATURE))) {
> struct ocfs2_dinode *di;
> di = (struct ocfs2_dinode *)block;
> - check = di->i_check;
> + check =&di->i_check;
> snprintf(name, sizeof(name), OCFS2_INODE_SIGNATURE);
> } else if (!strncmp(signature, OCFS2_EXTENT_BLOCK_SIGNATURE,
> sizeof(OCFS2_EXTENT_BLOCK_SIGNATURE))) {
> struct ocfs2_extent_block *eb;
> eb = (struct ocfs2_extent_block *)block;
> - check = eb->h_check;
> + check =&eb->h_check;
> snprintf(name, sizeof(name), OCFS2_EXTENT_BLOCK_SIGNATURE);
> } else if (!strncmp(signature, OCFS2_GROUP_DESC_SIGNATURE,
> sizeof(OCFS2_GROUP_DESC_SIGNATURE))) {
> struct ocfs2_group_desc *gd;
> gd = (struct ocfs2_group_desc *)block;
> - check = gd->bg_check;
> + check =&gd->bg_check;
> snprintf(name, sizeof(name), OCFS2_GROUP_DESC_SIGNATURE);
> } else if (!strncmp(signature, OCFS2_XATTR_BLOCK_SIGNATURE,
> sizeof(OCFS2_XATTR_BLOCK_SIGNATURE))) {
> struct ocfs2_xattr_block *xb;
> xb = (struct ocfs2_xattr_block *)block;
> - check = xb->xb_check;
> + check =&xb->xb_check;
> snprintf(name, sizeof(name), OCFS2_XATTR_BLOCK_SIGNATURE);
> } else if (!strncmp(signature, OCFS2_REFCOUNT_BLOCK_SIGNATURE,
> sizeof(OCFS2_REFCOUNT_BLOCK_SIGNATURE))) {
> struct ocfs2_refcount_block *rb;
> rb = (struct ocfs2_refcount_block *)block;
> - check = rb->rf_check;
> + check =&rb->rf_check;
> snprintf(name, sizeof(name), OCFS2_REFCOUNT_BLOCK_SIGNATURE);
> } else if (!strncmp(signature, OCFS2_DX_ROOT_SIGNATURE,
> sizeof(OCFS2_DX_ROOT_SIGNATURE))) {
> struct ocfs2_dx_root_block *dx_root;
> dx_root = (struct ocfs2_dx_root_block *)block;
> - check = dx_root->dr_check;
> + check =&dx_root->dr_check;
> snprintf(name, sizeof(name), OCFS2_DX_ROOT_SIGNATURE);
> } else if (!strncmp(signature, OCFS2_DX_LEAF_SIGNATURE,
> sizeof(OCFS2_DX_LEAF_SIGNATURE))) {
> struct ocfs2_dx_leaf *dx_leaf;
> dx_leaf = (struct ocfs2_dx_leaf *)block;
> - check = dx_leaf->dl_check;
> + check =&dx_leaf->dl_check;
> snprintf(name, sizeof(name), OCFS2_DX_LEAF_SIGNATURE);
> } else {
> if (ocfs2_supports_dir_trailer(fs)) {
> @@ -119,7 +119,7 @@ static errcode_t check_metaecc(ocfs2_filesys *fs,
> if (!strncmp((char *)trailer->db_signature,
> OCFS2_DIR_TRAILER_SIGNATURE,
> sizeof(OCFS2_DIR_TRAILER_SIGNATURE))) {
> - check = trailer->db_check;
> + check =&trailer->db_check;
> snprintf(name, sizeof(name),
> OCFS2_DIR_TRAILER_SIGNATURE);
> }
> @@ -145,9 +145,9 @@ static errcode_t check_metaecc(ocfs2_filesys *fs,
> int crc_offset, result_offset, offset;
> char outbuf[256] = {0,};
>
> - new_check.bc_crc32e = le32_to_cpu(check.bc_crc32e);
> - new_check.bc_ecc = le16_to_cpu(check.bc_ecc);
> - memset(&check, 0, sizeof(struct ocfs2_block_check));
> + new_check.bc_crc32e = le32_to_cpu(check->bc_crc32e);
> + new_check.bc_ecc = le16_to_cpu(check->bc_ecc);
> + memset(check, 0, sizeof(struct ocfs2_block_check));
>
> crc_offset = snprintf(outbuf, sizeof(outbuf),
> "Block %4"PRIu64" ", blk);
> @@ -193,8 +193,8 @@ static errcode_t check_metaecc(ocfs2_filesys *fs,
> fprintf(stderr, outbuf);
> err = -1;
> do_check_end:
> - check.bc_crc32e = cpu_to_le32(new_check.bc_crc32e);
> - check.bc_ecc = cpu_to_le16(new_check.bc_ecc);
> + check->bc_crc32e = cpu_to_le32(new_check.bc_crc32e);
> + check->bc_ecc = cpu_to_le16(new_check.bc_ecc);
> }
>
> return err;
>
More information about the Ocfs2-tools-devel
mailing list