[Ocfs2-tools-devel] [PATCH 1/1] ocfs2-tools: add testi command support for debugfs.ocfs2 V2
Jeff Liu
jeff.liu at oracle.com
Thu Mar 19 09:40:42 PDT 2009
add code to check whether a block# is valid or not, replay com_err with
fprintf to display if an inode is in use.
Signed-off-by: Jeff Liu <jeff.liu at oracle.com>
---
debugfs.ocfs2/commands.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
index 0dea23f..dcf4972 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,45 @@ static void do_icheck(char **args)
return;
}
+
+/*
+ * do_testi()
+ *
+ */
+static void do_testi(char **args)
+{
+ struct ocfs2_dinode *inode;
+ char *buf = NULL;
+ errcode_t ret = 0;
+ uint64_t blkno;
+ int set;
+
+ if (process_inode_args(args, &blkno) != 0)
+ return ;
+
+ buf = gbls.blockbuf;
+ ret = ocfs2_read_inode(gbls.fs, blkno, buf);
+ if (ret) {
+ com_err(args[0], ret, "while reading inode %"PRIu64"", blkno);
+ return ;
+ }
+
+ inode = (struct ocfs2_dinode *)buf;
+ if (!(inode->i_flags & OCFS2_VALID_FL)) {
+ com_err(args[0], ret, "Inode %"PRIu64" is invalid", blkno);
+ 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)
+ fprintf(stdout, "Inode %"PRIu64" is marked in use\n", blkno);
+ else
+ fprintf(stdout, "Inode %"PRIu64" is not in use\n", blkno);
+
+ return ;
+}
--
1.5.4.3
More information about the Ocfs2-tools-devel
mailing list