[Ocfs-tools-commits]
jlbec commits r101 - in trunk/ocfs2/debugfs.ocfs2: . include
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Jun 25 03:46:52 CDT 2004
Author: jlbec
Date: 2004-06-25 02:46:50 -0500 (Fri, 25 Jun 2004)
New Revision: 101
Modified:
trunk/ocfs2/debugfs.ocfs2/commands.c
trunk/ocfs2/debugfs.ocfs2/dump.c
trunk/ocfs2/debugfs.ocfs2/include/dump.h
Log:
o Fix directory reading.
Modified: trunk/ocfs2/debugfs.ocfs2/commands.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/commands.c 2004-06-25 01:47:45 UTC (rev 100)
+++ trunk/ocfs2/debugfs.ocfs2/commands.c 2004-06-25 07:46:50 UTC (rev 101)
@@ -249,7 +249,7 @@
int i;
GArray *arr = NULL;
__u32 len;
- __u64 off;
+ __u64 off, foff;
len = 1 << blksz_bits;
if (!(buf = malloc(len)))
@@ -280,12 +280,15 @@
for (i = 0; i < arr->len; ++i) {
rec = &(g_array_index(arr, ocfs2_extent_rec, i));
off = rec->e_blkno << blksz_bits;
+ foff = rec->e_cpos << clstrsz_bits;
len = rec->e_clusters << clstrsz_bits;
+ if ((foff + len) > inode->i_size)
+ len = inode->i_size - foff;
if (!(buf = malloc (len)))
DBGFS_FATAL("%s", strerror(errno));
if ((pread64(dev_fd, buf, len, off)) == -1)
DBGFS_FATAL("%s", strerror(errno));
- dump_dir_entry ((struct ocfs2_dir_entry *)buf);
+ dump_dir_entry ((struct ocfs2_dir_entry *)buf, len);
safefree (buf);
}
Modified: trunk/ocfs2/debugfs.ocfs2/dump.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/dump.c 2004-06-25 01:47:45 UTC (rev 100)
+++ trunk/ocfs2/debugfs.ocfs2/dump.c 2004-06-25 07:46:50 UTC (rev 101)
@@ -147,9 +147,9 @@
if (in->i_flags & OCFS2_SUPER_BLOCK_FL)
g_string_append (flags, "superblock ");
if (in->i_flags & OCFS2_LOCAL_ALLOC_FL)
- g_string_append (flags, "localbitmap ");
+ g_string_append (flags, "localalloc ");
if (in->i_flags & OCFS2_BITMAP_FL)
- g_string_append (flags, "globalbitmap ");
+ g_string_append (flags, "allocbitmap ");
if (in->i_flags & OCFS2_JOURNAL_FL)
g_string_append (flags, "journal ");
if (in->i_flags & OCFS2_DLM_FL)
@@ -245,7 +245,7 @@
* dump_dir_entry()
*
*/
-void dump_dir_entry (struct ocfs2_dir_entry *dir)
+void dump_dir_entry(struct ocfs2_dir_entry *dir, int len)
{
char *p;
struct ocfs2_dir_entry *rec;
@@ -255,13 +255,16 @@
printf("%-15s %-6s %-7s %-4s %-4s\n",
"Inode", "Reclen", "Namelen", "Type", "Name");
- while (1) {
+ while (p < (((char *)dir) + len)) {
rec = (struct ocfs2_dir_entry *)p;
- if (!rec->inode)
- break;
- null_term (rec->name, rec->name_len);
- printf("%-15llu %-6u %-7u %-4u %s\n", rec->inode,
- rec->rec_len, rec->name_len, rec->file_type, rec->name);
+ if (rec->inode) {
+ char buf[4096];
+ memcpy(buf, rec->name, rec->name_len);
+ buf[rec->name_len] = '\0';
+ printf("%-15llu %-6u %-7u %-4u %s\n", rec->inode,
+ rec->rec_len, rec->name_len, rec->file_type,
+ buf);
+ }
p += rec->rec_len;
}
Modified: trunk/ocfs2/debugfs.ocfs2/include/dump.h
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/include/dump.h 2004-06-25 01:47:45 UTC (rev 100)
+++ trunk/ocfs2/debugfs.ocfs2/include/dump.h 2004-06-25 07:46:50 UTC (rev 101)
@@ -30,6 +30,6 @@
void dump_inode (ocfs2_dinode *in);
void dump_extent_list (ocfs2_extent_list *ext);
void dump_extent_block (ocfs2_extent_block *blk);
-void dump_dir_entry (struct ocfs2_dir_entry *dir);
+void dump_dir_entry(struct ocfs2_dir_entry *dir, int len);
#endif /* __DUMP_H__ */
More information about the Ocfs-tools-commits
mailing list