[Ocfs2-tools-devel] [PATCH 1/3] Mess up superblock's ECC

Sunil Mushran sunil.mushran at oracle.com
Thu Jun 23 18:31:20 PDT 2011


Ack

On 06/22/2011 07:44 AM, Goldwyn Rodrigues wrote:
> Signed-off-by: Goldwyn Rodrigues<rgoldwyn at suse.de>
> ---
>   fswreck/Makefile            |    2 +-
>   fswreck/corrupt.c           |    7 +++++++
>   fswreck/include/corrupt.h   |    2 ++
>   fswreck/include/fsck_type.h |    1 +
>   fswreck/include/main.h      |    1 +
>   fswreck/include/super.h     |   24 ++++++++++++++++++++++++
>   fswreck/main.c              |    2 ++
>   fswreck/super.c             |   38 ++++++++++++++++++++++++++++++++++++++
>   8 files changed, 76 insertions(+), 1 deletions(-)
>   create mode 100644 fswreck/include/super.h
>   create mode 100644 fswreck/super.c
>
> diff --git a/fswreck/Makefile b/fswreck/Makefile
> index b1ee546..b870af7 100644
> --- a/fswreck/Makefile
> +++ b/fswreck/Makefile
> @@ -10,7 +10,7 @@ INCLUDES += $(GLIB_CFLAGS)
>
>   UNINST_PROGRAMS = fswreck
>
> -CFILES = main.c corrupt.c chain.c extent.c group.c inode.c
> local_alloc.c truncate_log.c special.c symlink.c dir.c journal.c
> quota.c refcount.c discontig_bg.c
> +CFILES = main.c corrupt.c chain.c extent.c group.c inode.c
> local_alloc.c truncate_log.c special.c symlink.c dir.c journal.c
> quota.c refcount.c discontig_bg.c super.c
>
>   HFILES = 			\
>   	include/chain.h		\
> diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
> index aa76dcc..03e1acd 100644
> --- a/fswreck/corrupt.c
> +++ b/fswreck/corrupt.c
> @@ -462,3 +462,10 @@ void corrupt_discontig_bg(ocfs2_filesys *fs, enum
> fsck_type type,
>   {
>   	mess_up_discontig_bg(fs, type, slotnum);
>   }
> +
> +void corrupt_super(ocfs2_filesys *fs, enum fsck_type type,
> +		uint16_t slotnum)
> +{
> +	mess_up_super(fs, type);
> +}
> +
> diff --git a/fswreck/include/corrupt.h b/fswreck/include/corrupt.h
> index 0fb7193..70c4b95 100644
> --- a/fswreck/include/corrupt.h
> +++ b/fswreck/include/corrupt.h
> @@ -37,5 +37,7 @@ void corrupt_truncate_log(ocfs2_filesys *fs, enum
> fsck_type type,
>   void corrupt_refcount(ocfs2_filesys *fs, enum fsck_type type,
> uint16_t slotnum);
>   void corrupt_discontig_bg(ocfs2_filesys *fs, enum fsck_type type,
>   			  uint16_t slotnum);
> +void corrupt_super(ocfs2_filesys *fs, enum fsck_type type,
> +			  uint16_t slotnum);
>
>   #endif		/* __CORRUPT_H */
> diff --git a/fswreck/include/fsck_type.h b/fswreck/include/fsck_type.h
> index e58d343..e15940b 100644
> --- a/fswreck/include/fsck_type.h
> +++ b/fswreck/include/fsck_type.h
> @@ -162,6 +162,7 @@ enum fsck_type
>   	REFCOUNT_REC_REDUNDANT,
>   	REFCOUNT_COUNT_INVALID,
>   	DUP_CLUSTERS_ADD_REFCOUNT,
> +	SUPERBLOCK_INVALID_ECC,
>   	NUM_FSCK_TYPE
>   };
>
> diff --git a/fswreck/include/main.h b/fswreck/include/main.h
> index 3175305..5d94c46 100644
> --- a/fswreck/include/main.h
> +++ b/fswreck/include/main.h
> @@ -92,5 +92,6 @@
>   #include "quota.h"
>   #include "refcount.h"
>   #include "discontig_bg.h"
> +#include "super.h"
>
>   #endif		/* __MAIN_H__ */
> diff --git a/fswreck/include/super.h b/fswreck/include/super.h
> new file mode 100644
> index 0000000..43f9fbe
> --- /dev/null
> +++ b/fswreck/include/super.h
> @@ -0,0 +1,24 @@
> +/*
> + * super.h
> + *
> + * Function prototypes, macros, etc. for related 'C' files
> + *
> + * Copyright (C) 2011 Suse/Attachmate.  All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public
> + * License version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + */
> +
> +
> +#ifndef _FSWRECK_SUPER_H_
> +#define _FSWRECK_SUPER_H_
> +
> +void mess_up_super(ocfs2_filesys *fs, enum fsck_type type);
> +#endif          /* _FSWRECK_SUPER_H_ */
> +
> diff --git a/fswreck/main.c b/fswreck/main.c
> index b1b2fcb..1fffd37 100644
> --- a/fswreck/main.c
> +++ b/fswreck/main.c
> @@ -316,6 +316,8 @@ static struct prompt_code prompt_codes[NUM_FSCK_TYPE] = {
>   			   "corrupt extent rec for a discontig bg"),
>   	define_prompt_code(DISCONTIG_BG_LEAF_CLUSTERS, corrupt_discontig_bg,
>   			   "corrupt extent rec's clusters for a discontig bg"),
> +	define_prompt_code(SUPERBLOCK_INVALID_ECC, corrupt_super,
> +			   "corrupt superblock's ecc"),
>   };
>
>   #undef define_prompt_code
> diff --git a/fswreck/super.c b/fswreck/super.c
> new file mode 100644
> index 0000000..2fc795c
> --- /dev/null
> +++ b/fswreck/super.c
> @@ -0,0 +1,38 @@
> +/* -*- mode: c; c-basic-offset: 8; -*-
> + * vim: noexpandtab sw=8 ts=8 sts=0:
> + *
> + * super.c
> + *
> + * Copyright (C) 2011 Suse/Attachmate.  All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public
> + * License version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + */
> +
> +#include "main.h"
> +
> +void mess_up_super(ocfs2_filesys *fs, enum fsck_type type)
> +{
> +	struct ocfs2_dinode *di;
> +	struct ocfs2_block_check bc;
> +	char *buf;
> +	errcode_t ret = ocfs2_malloc_block(fs->fs_io,&buf);
> +	if (ret)
> +		return;
> +
> +	memcpy(buf, fs->fs_super, fs->fs_blocksize);
> +	di = (char *) buf;
> +	bc = di->i_check;
> +	bc.bc_ecc ^= 7;
> +	bc.bc_crc32e ^= 15;
> +	di->i_check = bc;
> +	ocfs2_swap_inode_from_cpu(fs, di);
> +	io_write_block(fs->fs_io, di->i_blkno, 1, buf);
> +	ocfs2_free(&buf);
> +}




More information about the Ocfs2-tools-devel mailing list