[Ocfs-tools-commits]
smushran commits r92 - in trunk/ocfs2/debugfs.ocfs2: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue Jun 22 20:25:00 CDT 2004
Author: smushran
Date: 2004-06-22 19:24:57 -0500 (Tue, 22 Jun 2004)
New Revision: 92
Modified:
trunk/ocfs2/debugfs.ocfs2/Makefile
trunk/ocfs2/debugfs.ocfs2/commands.c
trunk/ocfs2/debugfs.ocfs2/dump.c
trunk/ocfs2/debugfs.ocfs2/inc/readfs.h
trunk/ocfs2/debugfs.ocfs2/main.c
trunk/ocfs2/debugfs.ocfs2/readfs.c
Log:
new dump format
Modified: trunk/ocfs2/debugfs.ocfs2/Makefile
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/Makefile 2004-06-22 21:11:03 UTC (rev 91)
+++ trunk/ocfs2/debugfs.ocfs2/Makefile 2004-06-23 00:24:57 UTC (rev 92)
@@ -2,7 +2,7 @@
include $(TOPDIR)/Preamble.make
-BIN_PROGRAMS = debugfs.ocfs
+BIN_PROGRAMS = debugfs.ocfs2
DEFINES = -DLINUX -DDEBUGOCFS -DDEBUG -DDEBUGOCFS_VERSION=\"0.0.1\"
@@ -18,7 +18,7 @@
DIST_FILES = $(CFILES) $(HFILES) README
-debugfs.ocfs: $(OBJS)
+debugfs.ocfs2: $(OBJS)
$(LINK) $(GLIB_LIBS) -lreadline -lncurses
include $(TOPDIR)/Postamble.make
Modified: trunk/ocfs2/debugfs.ocfs2/commands.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/commands.c 2004-06-22 21:11:03 UTC (rev 91)
+++ trunk/ocfs2/debugfs.ocfs2/commands.c 2004-06-23 00:24:57 UTC (rev 92)
@@ -56,14 +56,17 @@
static void do_lcd (char **args);
static void do_curdev (char **args);
static void do_super (char **args);
+static void do_inode (char **args);
extern gboolean allow_write;
static char *device = NULL;
static int dev_fd = -1;
+static __u32 blksz_bits = 0;
static char *curdir = NULL;
-static char header[512];
+static char superblk[512];
+static char rootin[512];
static Command commands[] =
{
@@ -92,7 +95,12 @@
{ "cat", do_dump },
{ "curdev", do_curdev },
+
{ "show_super_stats", do_super },
+ { "stats", do_super },
+
+ { "show_inode_info", do_inode },
+ { "stat", do_inode }
};
@@ -142,6 +150,7 @@
static void do_open (char **args)
{
char *dev = args[1];
+ ocfs2_dinode *inode;
if (device)
do_close (NULL);
@@ -155,8 +164,18 @@
device = g_strdup (dev);
- read_super_block (dev_fd, header, sizeof(header));
+ if (read_super_block (dev_fd, superblk, sizeof(superblk), &blksz_bits) != -1)
+ curdir = g_strdup ("/");
+ /* read root inode */
+ inode = (ocfs2_dinode *)superblk;
+ if ((pread64(dev_fd, rootin, sizeof(rootin),
+ (inode->id2.i_super.s_root_blkno << blksz_bits))) == -1) {
+ LOG_INTERNAL("%s", strerror(errno));
+ goto bail;
+ }
+
+bail:
return ;
} /* do_open */
@@ -173,9 +192,10 @@
dev_fd = -1;
g_free (curdir);
- curdir = g_strdup ("/");
+ curdir = NULL;
- memset (header, 0, sizeof(header));
+ memset (superblk, 0, sizeof(superblk));
+ memset (rootin, 0, sizeof(rootin));
} else
printf ("device not open\n");
@@ -685,13 +705,28 @@
ocfs2_dinode *in;
ocfs2_super_block *sb;
- if (opts && !strncmp(opts, "-h", 2)) {
- in = (ocfs2_dinode *)header;
- sb = &(in->id2.i_super);
+ in = (ocfs2_dinode *)superblk;
+ sb = &(in->id2.i_super);
+ dump_super_block(sb);
+
+ if (!opts || strncmp(opts, "-h", 2))
dump_inode(in);
- dump_super_block(sb);
- }
return ;
} /* do_super */
+/*
+ * do_inode()
+ *
+ */
+static void do_inode (char **args)
+{
+ char *opts = args[1];
+ ocfs2_dinode *inode;
+
+ inode = (ocfs2_dinode *)rootin;
+ dump_inode(inode);
+
+ return ;
+} /* do_inode */
+
Modified: trunk/ocfs2/debugfs.ocfs2/dump.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/dump.c 2004-06-22 21:11:03 UTC (rev 91)
+++ trunk/ocfs2/debugfs.ocfs2/dump.c 2004-06-23 00:24:57 UTC (rev 92)
@@ -11,25 +11,31 @@
void dump_super_block(ocfs2_super_block *sb)
{
int i;
+ char *str;
- printf("\trevision = %u.%u\n", sb->s_major_rev_level, sb->s_minor_rev_level);
- printf("\tmount count = %u\n", sb->s_mnt_count);
- printf("\tmax mount cnt = %u\n", sb->s_max_mnt_count);
- printf("\tstate = %u\n", sb->s_state);
- printf("\terrors = %u\n", sb->s_errors);
- printf("\tcheck interval = %u\n", sb->s_checkinterval);
- printf("\tlast check = %llu\n", sb->s_lastcheck);
- printf("\tcreator os = %u\n", sb->s_creator_os);
- printf("\tfeature compat = %u\n", sb->s_feature_compat);
- printf("\tfeature incompat = %u\n", sb->s_feature_incompat);
- printf("\tfeature ro compat = %u\n", sb->s_feature_ro_compat);
- printf("\troot blknum = %llu\n", sb->s_root_blkno);
- printf("\tsys dir blknum = %llu\n", sb->s_system_dir_blkno);
- printf("\tblksize bits = %u\n", sb->s_blocksize_bits);
- printf("\tclustersize bits = %u\n", sb->s_clustersize_bits);
- printf("\tmax nodes = %u\n", sb->s_max_nodes);
- printf("\tlabel = %s\n", sb->s_label);
- printf("\tuuid = ");
+ printf("Revision: %u.%u\n", sb->s_major_rev_level, sb->s_minor_rev_level);
+ printf("Mount Count: %u Max Mount Count: %u\n", sb->s_mnt_count,
+ sb->s_max_mnt_count);
+
+ printf("State: %u Errors: %u\n", sb->s_state, sb->s_errors);
+
+ str = ctime((time_t*)&sb->s_lastcheck);
+ printf("Check Interval: %u Last Check: %s", sb->s_checkinterval, str);
+
+ printf("Creator OS: %u\n", sb->s_creator_os);
+ printf("Feature Compat: %u Incompat: %u RO Compat: %u\n",
+ sb->s_feature_compat, sb->s_feature_incompat,
+ sb->s_feature_ro_compat);
+
+ printf("Root Blknum: %llu System Dir Blknum: %llu\n",
+ sb->s_root_blkno, sb->s_system_dir_blkno);
+
+ printf("Block Size Bits: %u Cluster Size Bits: %u\n",
+ sb->s_blocksize_bits, sb->s_clustersize_bits);
+
+ printf("Max Nodes: %u\n", sb->s_max_nodes);
+ printf("Label: %s\n", sb->s_label);
+ printf("UUID: ");
for (i = 0; i < 16; i++)
printf("%02X ", sb->s_uuid[i]);
printf("\n");
@@ -45,33 +51,88 @@
{
struct passwd *pw;
struct group *gr;
- char *s;
+ char *str;
+ ocfs2_disk_lock *dl;
+ int i;
+ __u16 mode;
- printf("\tsignature = %s\n", in->i_signature);
- printf("\tgeneration = %u\n", in->i_generation);
- printf("\tsuballoc node = %u\n", in->i_suballoc_node); /* ?? */
- printf("\tsuballoc blkno = %llu\n", in->i_suballoc_blkno);
+/*
+Inode: 32001 Type: directory Mode: 0755 Flags: 0x0 Generation: 721849
+User: 0 Group: 0 Size: 4096
+File ACL: 0 Directory ACL: 0
+Links: 10 Blockcount: 8
+Fragment: Address: 0 Number: 0 Size: 0
+ctime: 0x40075ba0 -- Thu Jan 15 22:33:52 2004
+atime: 0x40075b9d -- Thu Jan 15 22:33:49 2004
+mtime: 0x40075ba0 -- Thu Jan 15 22:33:52 2004
+BLOCKS:
+(0):66040
+TOTAL: 1
+
+Inode: 64004 Type: regular Mode: 0644 Flags: 0x0 Generation: 721925
+User: 0 Group: 0 Size: 1006409
+File ACL: 0 Directory ACL: 0
+Links: 1 Blockcount: 1976
+Fragment: Address: 0 Number: 0 Size: 0
+ctime: 0x40075b9d -- Thu Jan 15 22:33:49 2004
+atime: 0x40075b9d -- Thu Jan 15 22:33:49 2004
+mtime: 0x40075b9d -- Thu Jan 15 22:33:49 2004
+BLOCKS:
+(0-11):132071-132082, (IND):132083, (12-245):132084-132317
+TOTAL: 247
+*/
+
+ if (S_ISREG(in->i_mode))
+ str = "regular";
+ else if (S_ISDIR(in->i_mode))
+ str = "directory";
+ else if (S_ISCHR(in->i_mode))
+ str = "char device";
+ else if (S_ISBLK(in->i_mode))
+ str = "block device";
+ else if (S_ISFIFO(in->i_mode))
+ str = "fifo";
+ else if (S_ISLNK(in->i_mode))
+ str = "symbolic link";
+ else if (S_ISSOCK(in->i_mode))
+ str = "socket";
+ else
+ str = "unknown";
+
+ mode = in->i_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+
+ printf("Inode: %llu Type: %s Mode: 0%0u Flags: 0x%x Generation: %u\n",
+ in->i_blkno, str, mode, in->i_flags, in->i_generation);
+
pw = getpwuid(in->i_uid);
- printf("\tuid = %u (%s)\n", in->i_uid, (pw ? pw->pw_name : "unknown"));
gr = getgrgid(in->i_gid);
- printf("\tgid = %u (%s)\n", in->i_gid, (gr ? gr->gr_name : "unknown"));
- printf("\tsize = %llu\n", in->i_size);
- printf("\tmode = 0%0u\n", in->i_mode);
- printf("\tlinks cnt = %u\n", in->i_links_count);
- printf("\tflags = %u\n", in->i_flags);
+ printf("User: %d (%s) Group: %d (%s) Size: %llu\n",
+ in->i_uid, (pw ? pw->pw_name : "unknown"),
+ in->i_gid, (gr ? gr->gr_name : "unknown"),
+ in->i_size);
- s = ctime((time_t*)&in->i_atime);
- printf("\tatime = %s", s);
- s = ctime((time_t*)&in->i_ctime);
- printf("\tctime = %s", s);
- s = ctime((time_t*)&in->i_mtime);
- printf("\tmtime = %s", s);
- s = ctime((time_t*)&in->i_dtime);
+ printf("Links: %u Blockcount: %u\n", in->i_links_count, in->i_clusters);
- printf("\tdtime = %s", s);
- printf("\tblock num = %llu\n", in->i_blkno);
- printf("\tclusters = %u\n", in->i_clusters);
- printf("\tlast extblk = %llu\n", in->i_last_eb_blk);
+ dl = &(in->i_disk_lock);
+ printf("Lock Master: %u Level: 0x%0x Seqnum: %llu\n",
+ dl->dl_master, dl->dl_level, dl->dl_seq_num);
+ printf("Lock Node Map:");
+ for (i = 0; i < 8; ++i)
+ printf(" 0x%08x", dl->dl_node_map[i]);
+ printf("\n");
+ str = ctime((time_t*)&in->i_ctime);
+ printf("ctime: 0x%llx -- %s", in->i_ctime, str);
+ str = ctime((time_t*)&in->i_atime);
+ printf("atime: 0x%llx -- %s", in->i_atime, str);
+ str = ctime((time_t*)&in->i_mtime);
+ printf("mtime: 0x%llx -- %s", in->i_mtime, str);
+ str = ctime((time_t*)&in->i_dtime);
+ printf("dtime: 0x%llx -- %s", in->i_dtime, str);
+
+ printf("Last Extblk: %llu\n", in->i_last_eb_blk);
+ printf("Sub Alloc Node: %u Sub Alloc Blknum: %llu\n",
+ in->i_suballoc_node, in->i_suballoc_blkno); /* ?? */
+
return ;
} /* dump_inode */
Modified: trunk/ocfs2/debugfs.ocfs2/inc/readfs.h
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/inc/readfs.h 2004-06-22 21:11:03 UTC (rev 91)
+++ trunk/ocfs2/debugfs.ocfs2/inc/readfs.h 2004-06-23 00:24:57 UTC (rev 92)
@@ -2,6 +2,6 @@
#ifndef __READFS_H__
#define __READFS_H__
-int read_super_block(int fd, char *buf, int len);
+int read_super_block(int fd, char *buf, int len, __u32 *bits);
#endif /* __READFS_H__ */
Modified: trunk/ocfs2/debugfs.ocfs2/main.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/main.c 2004-06-22 21:11:03 UTC (rev 91)
+++ trunk/ocfs2/debugfs.ocfs2/main.c 2004-06-23 00:24:57 UTC (rev 92)
@@ -17,7 +17,7 @@
#include "inc/commands.h"
#endif
-#define PROMPT "debugocfs: "
+#define PROMPT "debugfs: "
static void usage (char *progname);
static void print_version (void);
Modified: trunk/ocfs2/debugfs.ocfs2/readfs.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/readfs.c 2004-06-22 21:11:03 UTC (rev 91)
+++ trunk/ocfs2/debugfs.ocfs2/readfs.c 2004-06-23 00:24:57 UTC (rev 92)
@@ -8,12 +8,11 @@
* read_super_block()
*
*/
-int read_super_block(int fd, char *buf, int buflen)
+int read_super_block(int fd, char *buf, int buflen, __u32 *bits)
{
int ret = -1;
__u64 off;
ocfs1_vol_disk_hdr *hdr;
- __u32 blksize;
ocfs2_dinode *di;
if ((ret = pread64(fd, buf, buflen, 0)) == -1) {
@@ -33,8 +32,8 @@
* blocksizes. 4096 is the maximum blocksize because it is
* the minimum clustersize.
*/
- for (blksize = 512; blksize <= OCFS2_MAX_BLOCKSIZE; blksize <<= 1) {
- off = blksize * OCFS2_SUPER_BLOCK_BLKNO;
+ for (*bits = 9; *bits < 13; (*bits)++) {
+ off = OCFS2_SUPER_BLOCK_BLKNO << *bits;
if ((ret = pread64(fd, buf, buflen, off)) == -1) {
LOG_INTERNAL("%s", strerror(errno));
More information about the Ocfs-tools-commits
mailing list