[Ocfs2-tools-devel] [PATCH 1/1] ocfs2-tools: add testi command support for debugfs.ocfs2

Sunil Mushran sunil.mushran at oracle.com
Thu Mar 19 05:12:26 PDT 2009


Considering inodes are dynamically allocated, we should first indicate
whether the block# is a valid inode# or not. If valid inode, then
indicate whether inuse or not.

Also, only use com_err for errors. The prints after if (set) should be
fprintf()s. Like in dump.c.

On Thu, Mar 19, 2009 at 04:41:09PM +0800, Jeff Liu wrote:
> This patch add testi command for debugfs.ocfs2, it used for testing
> if the inode filespec is marked as allocated in the inode bitmap.
> 
> Signed-off-by: Jeff Liu <jeff.liu at oracle.com>
> ---
>  debugfs.ocfs2/commands.c |   29 +++++++++++++++++++++++++++++
>  1 files changed, 29 insertions(+), 0 deletions(-)
> 
> diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
> index 0dea23f..b78bceb 100644
> --- a/debugfs.ocfs2/commands.c
> +++ b/debugfs.ocfs2/commands.c
> @@ -74,6 +74,7 @@ static void do_icheck (char **args);
>  static void do_dlm_locks (char **args);
>  static void do_controld(char **args);
>  static void do_dirblocks(char **args);
> +static void do_testi(char **args);
>  
>  dbgfs_gbls gbls;
>  
> @@ -110,6 +111,7 @@ static Command commands[] = {
>  	{ "encode",	do_encode_lockres },
>  	{ "decode",	do_decode_lockres },
>  	{ "dirblocks",	do_dirblocks },
> +	{ "testi",	do_testi },
>  };
>  
>  /*
> @@ -1769,3 +1771,30 @@ static void do_icheck(char **args)
>  
>  	return;
>  }
> +
> +/*
> + * do_testi()
> + *
> + */
> +static void do_testi(char **args)
> +{
> +	errcode_t ret = 0;
> +	uint64_t blkno;
> +	int set;
> +
> +	if (process_inode_args(args, &blkno) != 0)
> +		return ;
> +
> +	ret = ocfs2_test_inode_allocated(gbls.fs, blkno, &set);
> +	if (ret) {
> +		com_err(args[0], ret, "while reading inode %"PRIu64"", blkno);
> +		return ;
> +	}
> +
> +	if (set)
> +		com_err(args[0], ret, "Inode %"PRIu64" is marked in use", blkno);
> +	else
> +		com_err(args[0], ret, "Inode %"PRIu64" is not in use", blkno);
> +
> +	return ;
> +}
> -- 
> 1.5.4.3
> 
> 
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> http://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel



More information about the Ocfs2-tools-devel mailing list