[Ocfs2-tools-devel] [PATCH 36/37] debugfs: Add -T to logdump
Sunil Mushran
sunil.mushran at oracle.com
Mon Jan 31 11:15:30 PST 2011
logdump -T allows users to print just the summary of the inodes in
the journal.
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
debugfs.ocfs2/commands.c | 45 +++++++++++++++++++++++--------------
debugfs.ocfs2/debugfs.ocfs2.8.in | 5 ++-
2 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
index b36bad5..663164f 100644
--- a/debugfs.ocfs2/commands.c
+++ b/debugfs.ocfs2/commands.c
@@ -439,26 +439,22 @@ bail:
* get_slotnum()
*
*/
-static int get_slotnum(char **args, uint16_t *slotnum)
+static int get_slotnum(char *str, uint16_t *slotnum)
{
struct ocfs2_super_block *sb = OCFS2_RAW_SB(gbls.fs->fs_super);
char *endptr;
- if (args[1]) {
- *slotnum = strtoul(args[1], &endptr, 0);
- if (!*endptr) {
- if (*slotnum < sb->s_max_slots)
- return 0;
- else
- fprintf(stderr,
- "%s: Invalid node slot number\n",
- args[0]);
- } else
- fprintf(stderr, "usage: %s <slotnum>\n", args[0]);
- } else
- fprintf(stderr, "usage: %s <slotnum>\n", args[0]);
+ if (!str)
+ return -1;
- return -1;
+ *slotnum = strtoul(str, &endptr, 0);
+ if (*endptr)
+ return -1;
+
+ if (*slotnum >= sb->s_max_slots)
+ return -1;
+
+ return 0;
}
/*
@@ -865,7 +861,7 @@ static void do_help (char **args)
printf ("icheck block# ...\t\t\tDo block->inode translation\n");
printf ("lcd <directory>\t\t\t\tChange directory on a mounted flesystem\n");
printf ("locate <block#> ...\t\t\tList all pathnames of the inode(s)/lockname(s)\n");
- printf ("logdump <slot#>\t\t\t\tPrints journal file for the node slot\n");
+ printf ("logdump [-T] <slot#>\t\t\t\tPrints journal file for the node slot\n");
printf ("ls [-l] <filespec>\t\t\tList directory\n");
printf ("ncheck <block#> ...\t\t\tList all pathnames of the inode(s)/lockname(s)\n");
printf ("open <device> [-i] [-s backup#]\t\tOpen a device\n");
@@ -1233,12 +1229,27 @@ static void do_logdump (char **args)
uint16_t slotnum;
uint64_t blkno;
FILE *out;
+ int index = 1, traverse = 1;
+ const char *logdump_usage = "usage: logdump [-T] <slot#>";
if (check_device_open())
return ;
- if (get_slotnum(args, &slotnum))
+ if (!args[index]) {
+ fprintf(stderr, "%s\n", logdump_usage);
return ;
+ }
+
+ if (!strncmp(args[index], "-T", 2)) {
+ traverse = 0;
+ index++;
+ }
+
+ if (get_slotnum(args[index], &slotnum)) {
+ fprintf(stderr, "%s: Invalid node slot number\n", args[0]);
+ fprintf(stderr, "%s\n", logdump_usage);
+ return ;
+ }
blkno = gbls.jrnl_blkno[slotnum];
diff --git a/debugfs.ocfs2/debugfs.ocfs2.8.in b/debugfs.ocfs2/debugfs.ocfs2.8.in
index 848dc52..e738123 100644
--- a/debugfs.ocfs2/debugfs.ocfs2.8.in
+++ b/debugfs.ocfs2/debugfs.ocfs2.8.in
@@ -215,8 +215,9 @@ to the \fIdirectory\fR on the native filesystem.
Display all pathnames for the inode(s) specified by \fIlockname\fRs or \fIinode#\fRs.
.TP
-\fIlogdump node#\fR
-Display the contents of the journal for node \fInode#\fR.
+\fIlogdump [-T] slot#\fR
+Display the contents of the journal for slot \fIslot#\fR. Use \fI-T\fR to limit
+the output to just the summary of the inodes in the journal.
.TP
\fIls [\-l] filespec\fR
--
1.7.1
More information about the Ocfs2-tools-devel
mailing list