[Ocfs-tools-commits] smushran commits r154 - in trunk/ocfs2/debugfs.ocfs2: . include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Jul 9 20:50:15 CDT 2004


Author: smushran
Date: 2004-07-09 19:50:12 -0500 (Fri, 09 Jul 2004)
New Revision: 154

Modified:
   trunk/ocfs2/debugfs.ocfs2/commands.c
   trunk/ocfs2/debugfs.ocfs2/dump.c
   trunk/ocfs2/debugfs.ocfs2/include/dump.h
   trunk/ocfs2/debugfs.ocfs2/include/journal.h
   trunk/ocfs2/debugfs.ocfs2/journal.c
   trunk/ocfs2/debugfs.ocfs2/main.c
   trunk/ocfs2/debugfs.ocfs2/readfs.c
   trunk/ocfs2/debugfs.ocfs2/utils.c
Log:
logdump reorged

Modified: trunk/ocfs2/debugfs.ocfs2/commands.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/commands.c	2004-07-09 23:17:05 UTC (rev 153)
+++ trunk/ocfs2/debugfs.ocfs2/commands.c	2004-07-10 00:50:12 UTC (rev 154)
@@ -25,10 +25,10 @@
 
 #include <main.h>
 #include <commands.h>
-#include <dump.h>
 #include <readfs.h>
 #include <utils.h>
 #include <journal.h>
+#include <dump.h>
 
 typedef void (*PrintFunc) (void *buf);
 typedef gboolean (*WriteFunc) (char **data, void *buf);
@@ -663,7 +663,7 @@
 		if ((len = read_file (gbls.dev_fd, blknum, -1, &logbuf)) == -1)
 			goto bail;
 		out = open_pager ();
-		read_journal (logbuf, (__u64)len, out);
+		read_journal (out, logbuf, (__u64)len);
 		close_pager (out);
 	}
 

Modified: trunk/ocfs2/debugfs.ocfs2/dump.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/dump.c	2004-07-09 23:17:05 UTC (rev 153)
+++ trunk/ocfs2/debugfs.ocfs2/dump.c	2004-07-10 00:50:12 UTC (rev 154)
@@ -25,10 +25,10 @@
 
 #include <main.h>
 #include <commands.h>
-#include <dump.h>
 #include <readfs.h>
 #include <utils.h>
 #include <journal.h>
+#include <dump.h>
 
 extern dbgfs_gbls gbls;
 
@@ -392,3 +392,185 @@
 
 	return ;
 }				/* dump_vote */
+
+/*
+ * dump_jbd_header()
+ *
+ */
+void dump_jbd_header (FILE *out, journal_header_t *header)
+{
+	GString *jstr = NULL;
+
+	jstr = g_string_new (NULL);
+	get_journal_blktyp (ntohl(header->h_blocktype), jstr);
+
+	fprintf (out, "\tSeq: %u   Type: %d (%s)\n", ntohl(header->h_sequence),
+		 ntohl(header->h_blocktype), jstr->str);
+
+	if (jstr)
+		g_string_free (jstr, 1);
+	return;
+}				/* dump_jbd_header */
+
+/*
+ * dump_jbd_superblock()
+ *
+ */
+void dump_jbd_superblock (FILE *out, journal_superblock_t *jsb)
+{
+	int i;
+
+	fprintf (out, "\tBlock 0: Journal Superblock\n");
+
+	dump_jbd_header (out, &(jsb->s_header));
+
+	fprintf (out, "\tBlocksize: %u   Total Blocks: %u   First Block: %u\n",
+		 jsb->s_blocksize, jsb->s_maxlen, jsb->s_first);
+	fprintf (out, "\tFirst Commit ID: %u   Start Log Blknum: %u\n",
+		 jsb->s_sequence, jsb->s_start);
+
+	fprintf (out, "\tError: %d\n", jsb->s_errno);
+
+	fprintf (out, "\tFeatures Compat: %u   Incompat: %u   RO Compat: %u\n",
+		 jsb->s_feature_compat, jsb->s_feature_incompat,
+		 jsb->s_feature_ro_compat);
+
+	fprintf (out, "\tJournal UUID: ");
+	for(i = 0; i < 16; i++)
+		fprintf (out, "%02X", jsb->s_uuid[i]);
+	fprintf (out, "\n");
+
+	fprintf (out, "\tFS Share Cnt: %u   Dynamic Superblk Blknum: %u\n",
+		 jsb->s_nr_users, jsb->s_dynsuper);
+
+	fprintf (out, "\tPer Txn Block Limit    Journal: %u    Data: %u\n",
+		 jsb->s_max_transaction, jsb->s_max_trans_data);
+
+	fprintf (out, "\n");
+
+	return;
+}				/* dump_jbd_superblock */
+
+/*
+ * dump_jbd_block()
+ *
+ */
+void dump_jbd_block (FILE *out, journal_header_t *header, __u64 blknum)
+{
+	int i;
+	int j;
+	int count = 0;
+	GString *tagflg = NULL;
+	/* for descriptors */
+	journal_block_tag_t *tag;
+	journal_revoke_header_t *revoke;
+	char *blk = (char *) header;
+	__u32 *blocknr;
+	char *uuid;
+
+	tagflg = g_string_new (NULL);
+
+	fprintf (out, "\tBlock %llu: ", blknum);
+
+	switch (ntohl(header->h_blocktype)) {
+	case JFS_DESCRIPTOR_BLOCK:
+		fprintf (out, "Journal Descriptor\n");
+		dump_jbd_header (out, header);
+
+		fprintf (out, "\t%3s %-15s %-s\n", "No.", "Blocknum", "Flags");
+
+		for (i = sizeof(journal_header_t); i < (1 << gbls.blksz_bits);
+		     i+=sizeof(journal_block_tag_t)) {
+			tag = (journal_block_tag_t *) &blk[i];
+
+			get_tag_flag(ntohl(tag->t_flags), tagflg);
+			fprintf (out, "\t%2d. %-15u %-s\n",
+				 count, ntohl(tag->t_blocknr), tagflg->str);
+			g_string_truncate (tagflg, 0);
+
+			if (tag->t_flags & htonl(JFS_FLAG_LAST_TAG))
+				break;
+
+			/* skip the uuid. */
+			if (!(tag->t_flags & htonl(JFS_FLAG_SAME_UUID))) {
+				uuid = &blk[i + sizeof(journal_block_tag_t)];
+				fprintf (out, "\tUUID: ");
+				for(j = 0; j < 16; j++)
+					fprintf (out, "%02X",uuid[j]);
+				fprintf (out, "\n");
+				i += 16;
+			}
+			count++;
+		}
+		break;
+
+	case JFS_COMMIT_BLOCK:
+		fprintf(out, "Journal Commit Block\n");
+		dump_jbd_header (out, header);
+		break;
+
+	case JFS_REVOKE_BLOCK:							/*TODO*/
+		fprintf(out, "Journal Revoke Block\n");
+		dump_jbd_header (out, header);
+		revoke = (journal_revoke_header_t *) blk;
+
+		fprintf(out, "\tr_count:\t\t%d\n", ntohl(revoke->r_count));
+		count = (ntohl(revoke->r_count) - 
+			 sizeof(journal_revoke_header_t)) / sizeof(__u32);
+		blocknr = (__u32 *) &blk[sizeof(journal_revoke_header_t)];
+		for(i = 0; i < count; i++)
+			fprintf(out, "\trevoke[%d]:\t\t%u\n", i, ntohl(blocknr[i]));
+		break;
+
+	default:
+		fprintf(out, "Unknown Block Type\n");
+		break;
+	}
+	fprintf (out, "\n");
+
+	if (tagflg)
+		g_string_free (tagflg, 1);
+
+	return;
+}				/* dump_jbd_block */
+
+/*
+ * dump_jbd_metadata()
+ *
+ */
+void dump_jbd_metadata (FILE *out, int type, char *buf, __u64 blknum)
+{
+	fprintf (out, "\tBlock %llu: ", blknum);
+	switch (type) {
+	case 1:
+		fprintf(out, "Inode\n");
+		dump_inode (out, (ocfs2_dinode *)buf);
+		fprintf (out, "\n");
+		break;
+	case 2:
+		fprintf(out, "Extent\n");
+		dump_extent_block (out, (ocfs2_extent_block *)buf);
+		fprintf (out, "\n");
+		break;
+	default:
+		fprintf (out, "TODO\n\n");
+		break;
+	}
+
+	return ;
+}				/* dump_jbd_metadata */
+
+/*
+ * dump_jbd_unknown()
+ *
+ */
+void dump_jbd_unknown (FILE *out, __u64 start, __u64 end)
+{
+	if (start == end - 1)
+		fprintf (out, "\tBlock %llu: ", start);
+	else
+		fprintf (out, "\tBlock %llu to %llu: ", start, end - 1);
+	fprintf (out, "Unknown -- Probably Data\n\n");
+
+	return ;
+}				/* dump_jbd_unknown */

Modified: trunk/ocfs2/debugfs.ocfs2/include/dump.h
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/include/dump.h	2004-07-09 23:17:05 UTC (rev 153)
+++ trunk/ocfs2/debugfs.ocfs2/include/dump.h	2004-07-10 00:50:12 UTC (rev 154)
@@ -36,5 +36,10 @@
 void dump_config (FILE *out, char *buf);
 void dump_publish (FILE *out, char *buf);
 void dump_vote (FILE *out, char *buf);
+void dump_jbd_header (FILE *out, journal_header_t *header);
+void dump_jbd_superblock (FILE *out, journal_superblock_t *jsb);
+void dump_jbd_block (FILE *out, journal_header_t *header, __u64 blknum);
+void dump_jbd_metadata (FILE *out, int type, char *buf, __u64 blknum);
+void dump_jbd_unknown (FILE *out, __u64 start, __u64 end);
 
 #endif		/* __DUMP_H__ */

Modified: trunk/ocfs2/debugfs.ocfs2/include/journal.h
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/include/journal.h	2004-07-09 23:17:05 UTC (rev 153)
+++ trunk/ocfs2/debugfs.ocfs2/include/journal.h	2004-07-10 00:50:12 UTC (rev 154)
@@ -28,13 +28,7 @@
 
 #include <jbd.h>
 
-void read_journal (char *buf, __u64 buflen, FILE *out);
-void dump_metadata (int type, char *buf, __u64 buflen, FILE *out);
+void read_journal (FILE *out, char *buf, __u64 buflen);
 int detect_block (char *buf);
-void dump_unknown (__u64 start, __u64 end, FILE *out);
-void print_header (journal_header_t *header, FILE *out);
-void print_super_block (journal_superblock_t *sb, FILE *out);
-void print_tag_flag (__u32 flags, FILE *out);
-void print_jbd_block (journal_header_t *header, FILE *out);
 
 #endif		/* _JOURNAL_H_ */

Modified: trunk/ocfs2/debugfs.ocfs2/journal.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/journal.c	2004-07-09 23:17:05 UTC (rev 153)
+++ trunk/ocfs2/debugfs.ocfs2/journal.c	2004-07-10 00:50:12 UTC (rev 154)
@@ -25,10 +25,10 @@
 
 #include <main.h>
 #include <commands.h>
-#include <dump.h>
 #include <readfs.h>
 #include <utils.h>
 #include <journal.h>
+#include <dump.h>
 
 extern dbgfs_gbls gbls;
 
@@ -36,7 +36,7 @@
  * read_journal()
  *
  */
-void read_journal (char *buf, __u64 buflen, FILE *out)
+void read_journal (FILE *out, char *buf, __u64 buflen)
 {
 	char *block;
 	__u64 blocknum;
@@ -47,8 +47,7 @@
 	__u64 last_unknown = 0;
 	int type;
 
-	fprintf (out, "\tBlock 0: ");
-	print_super_block ((journal_superblock_t *) buf, out);
+	dump_jbd_superblock (out, (journal_superblock_t *) buf);
 
 	blocknum = 1;
 	p = buf + blksize;
@@ -59,11 +58,10 @@
 		header = (journal_header_t *) block;
 		if (header->h_magic == ntohl(JFS_MAGIC_NUMBER)) {
 			if (last_unknown) {
-				dump_unknown (last_unknown, blocknum, out);
+				dump_jbd_unknown (out, last_unknown, blocknum);
 				last_unknown = 0;
 			}
-			fprintf (out, "\tBlock %llu: ", blocknum);
-			print_jbd_block (header, out);
+			dump_jbd_block (out, header, blocknum);
 		} else {
 			type = detect_block (block);
 			if (type < 0) {
@@ -71,11 +69,10 @@
 					last_unknown = blocknum;
 			} else {
 				if (last_unknown) {
-					dump_unknown (last_unknown, blocknum, out);
+					dump_jbd_unknown (out, last_unknown, blocknum);
 					last_unknown = 0;
 				}
-				fprintf (out, "\tBlock %llu: ", blocknum);
-				dump_metadata (type, block, blksize, out);
+				dump_jbd_metadata (out, type, block, blocknum);
 			}
 		}
 		blocknum++;
@@ -84,7 +81,7 @@
 	}
 
 	if (last_unknown) {
-		dump_unknown (last_unknown, blocknum, out);
+		dump_jbd_unknown (out, last_unknown, blocknum);
 		last_unknown = 0;
 	}
 
@@ -92,32 +89,6 @@
 }				/* read_journal */
 
 /*
- * dump_metadata()
- *
- */
-void dump_metadata (int type, char *buf, __u64 buflen, FILE *out)
-{
-	switch (type) {
-	case 1:
-		fprintf(out, "Inode\n");
-		dump_inode (out, (ocfs2_dinode *)buf);
-		fprintf (out, "\n");
-		break;
-	case 2:
-		fprintf(out, "Extent\n");
-		dump_extent_block (out, (ocfs2_extent_block *)buf);
-		fprintf (out, "\n");
-		break;
-	default:
-		fprintf (out, "TODO\n\n");
-		break;
-	}
-
-	return ;
-}				/* dump_metadata */
-
-
-/*
  * detect_block()
  *
  */
@@ -144,158 +115,3 @@
 bail:
 	return ret;
 }				/* detect_block */
-
-
-/*
- * dump_unknown()
- *
- */
-void dump_unknown (__u64 start, __u64 end, FILE *out)
-{
-	if (start == end - 1)
-		fprintf (out, "\tBlock %llu: ", start);
-	else
-		fprintf (out, "\tBlock %llu to %llu: ", start, end - 1);
-	fprintf (out, "Unknown -- Probably Data\n\n");
-
-	return ;
-}				/* dump_unknown */
-
-/*
- * print_header()
- *
- */
-void print_header (journal_header_t *header, FILE *out)
-{
-	GString *jstr = NULL;
-
-	jstr = g_string_new (NULL);
-	get_journal_blktyp (ntohl(header->h_blocktype), jstr);
-
-	fprintf (out, "\tSeq: %u   Type: %d (%s)\n", ntohl(header->h_sequence),
-		 ntohl(header->h_blocktype), jstr->str);
-
-	if (jstr)
-		g_string_free (jstr, 1);
-	return;
-}				/* print_header */
-
-/*
- * print_super_block()
- *
- */
-void print_super_block (journal_superblock_t *jsb, FILE *out) 
-{
-	int i;
-
-	fprintf (out, "Journal Superblock\n");
-
-	print_header (&(jsb->s_header), out);
-
-	fprintf (out, "\tBlocksize: %u   Total Blocks: %u   First Block: %u\n",
-		 jsb->s_blocksize, jsb->s_maxlen, jsb->s_first);
-	fprintf (out, "\tFirst Commit ID: %u   Start Log Blknum: %u\n",
-		 jsb->s_sequence, jsb->s_start);
-
-	fprintf (out, "\tError: %d\n", jsb->s_errno);
-
-	fprintf (out, "\tFeatures Compat: %u   Incompat: %u   RO Compat: %u\n",
-		 jsb->s_feature_compat, jsb->s_feature_incompat,
-		 jsb->s_feature_ro_compat);
-
-	fprintf (out, "\tJournal UUID: ");
-	for(i = 0; i < 16; i++)
-		fprintf (out, "%02X", jsb->s_uuid[i]);
-	fprintf (out, "\n");
-
-	fprintf (out, "\tFS Share Cnt: %u   Dynamic Superblk Blknum: %u\n",
-		 jsb->s_nr_users, jsb->s_dynsuper);
-
-	fprintf (out, "\tPer Txn Block Limit    Journal: %u    Data: %u\n",
-		 jsb->s_max_transaction, jsb->s_max_trans_data);
-
-	fprintf (out, "\n");
-
-	return;
-}				/* print_super_block */
-
-/*
- * print_jbd_block()
- *
- */
-void print_jbd_block (journal_header_t *header, FILE *out)
-{
-	int i;
-	int j;
-	int count = 0;
-	GString *tagflg = NULL;
-	/* for descriptors */
-	journal_block_tag_t *tag;
-	journal_revoke_header_t *revoke;
-	char *blk = (char *) header;
-	__u32 *blocknr;
-	char *uuid;
-
-	tagflg = g_string_new (NULL);
-
-	switch (ntohl(header->h_blocktype)) {
-	case JFS_DESCRIPTOR_BLOCK:
-		fprintf (out, "Journal Descriptor\n");
-		print_header (header, out);
-
-		fprintf (out, "\t%3s %-15s %-s\n", "No.", "Blocknum", "Flags");
-
-		for (i = sizeof(journal_header_t); i < (1 << gbls.blksz_bits);
-		     i+=sizeof(journal_block_tag_t)) {
-			tag = (journal_block_tag_t *) &blk[i];
-
-			get_tag_flag(ntohl(tag->t_flags), tagflg);
-			fprintf (out, "\t%2d. %-15u %-s\n",
-				 count, ntohl(tag->t_blocknr), tagflg->str);
-			g_string_truncate (tagflg, 0);
-
-			if (tag->t_flags & htonl(JFS_FLAG_LAST_TAG))
-				break;
-
-			/* skip the uuid. */
-			if (!(tag->t_flags & htonl(JFS_FLAG_SAME_UUID))) {
-				uuid = &blk[i + sizeof(journal_block_tag_t)];
-				fprintf (out, "\tUUID: ");
-				for(j = 0; j < 16; j++)
-					fprintf (out, "%02X",uuid[j]);
-				fprintf (out, "\n");
-				i += 16;
-			}
-			count++;
-		}
-		break;
-
-	case JFS_COMMIT_BLOCK:
-		fprintf(out, "Journal Commit Block\n");
-		print_header (header, out);
-		break;
-
-	case JFS_REVOKE_BLOCK:							/*TODO*/
-		fprintf(out, "Journal Revoke Block\n");
-		print_header (header, out);
-		revoke = (journal_revoke_header_t *) blk;
-
-		fprintf(out, "\tr_count:\t\t%d\n", ntohl(revoke->r_count));
-		count = (ntohl(revoke->r_count) - 
-			 sizeof(journal_revoke_header_t)) / sizeof(__u32);
-		blocknr = (__u32 *) &blk[sizeof(journal_revoke_header_t)];
-		for(i = 0; i < count; i++)
-			fprintf(out, "\trevoke[%d]:\t\t%u\n", i, ntohl(blocknr[i]));
-		break;
-
-	default:
-		fprintf(out, "Unknown Block Type\n");
-		break;
-	}
-	fprintf (out, "\n");
-
-	if (tagflg)
-		g_string_free (tagflg, 1);
-
-	return;
-}				/* print_jbd_block */

Modified: trunk/ocfs2/debugfs.ocfs2/main.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/main.c	2004-07-09 23:17:05 UTC (rev 153)
+++ trunk/ocfs2/debugfs.ocfs2/main.c	2004-07-10 00:50:12 UTC (rev 154)
@@ -25,10 +25,10 @@
 
 #include <main.h>
 #include <commands.h>
-#include <dump.h>
 #include <readfs.h>
 #include <utils.h>
 #include <journal.h>
+#include <dump.h>
 
 #define PROMPT "debugfs: "
 

Modified: trunk/ocfs2/debugfs.ocfs2/readfs.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/readfs.c	2004-07-09 23:17:05 UTC (rev 153)
+++ trunk/ocfs2/debugfs.ocfs2/readfs.c	2004-07-10 00:50:12 UTC (rev 154)
@@ -25,10 +25,10 @@
 
 #include <main.h>
 #include <commands.h>
-#include <dump.h>
 #include <readfs.h>
 #include <utils.h>
 #include <journal.h>
+#include <dump.h>
 
 extern dbgfs_gbls gbls;
 

Modified: trunk/ocfs2/debugfs.ocfs2/utils.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/utils.c	2004-07-09 23:17:05 UTC (rev 153)
+++ trunk/ocfs2/debugfs.ocfs2/utils.c	2004-07-10 00:50:12 UTC (rev 154)
@@ -25,10 +25,10 @@
 
 #include <main.h>
 #include <commands.h>
-#include <dump.h>
 #include <readfs.h>
 #include <utils.h>
 #include <journal.h>
+#include <dump.h>
 
 /*
  * add_extent_rec()



More information about the Ocfs-tools-commits mailing list