[Ocfs-tools-commits]
smushran commits r123 - in trunk/ocfs2/debugfs.ocfs2: . include
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Jun 30 19:32:03 CDT 2004
Author: smushran
Date: 2004-06-30 18:32:01 -0500 (Wed, 30 Jun 2004)
New Revision: 123
Modified:
trunk/ocfs2/debugfs.ocfs2/include/main.h
trunk/ocfs2/debugfs.ocfs2/readfs.c
Log:
dump allocates max 1MB buffer
Modified: trunk/ocfs2/debugfs.ocfs2/include/main.h
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/include/main.h 2004-06-30 21:47:29 UTC (rev 122)
+++ trunk/ocfs2/debugfs.ocfs2/include/main.h 2004-06-30 23:32:01 UTC (rev 123)
@@ -75,6 +75,10 @@
#define DBGFS_WARN_STR(str) DBGFS_WARN(str, "")
+#undef max
+#define max(a,b) ((a) > (b) ? (a) : (b))
+#undef min
+#define min(a,b) ((a) < (b) ? (a) : (b))
/* Publish flags */
#define FLAG_FILE_CREATE 0x00000001
Modified: trunk/ocfs2/debugfs.ocfs2/readfs.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/readfs.c 2004-06-30 21:47:29 UTC (rev 122)
+++ trunk/ocfs2/debugfs.ocfs2/readfs.c 2004-06-30 23:32:01 UTC (rev 123)
@@ -276,9 +276,9 @@
__u64 off, foff, len;
int i;
char *newbuf = NULL;
- __u32 newlen = 0;
+ __u64 newlen = 0;
char *inode_buf = NULL;
- int buflen = 0;
+ __u64 buflen = 0;
int ret = -1;
arr = g_array_new(0, 1, sizeof(ocfs2_extent_rec));
@@ -296,16 +296,20 @@
traverse_extents (fd, &(inode->id2.i_list), arr, 0);
if (fdo == -1) {
- if (!(*buf = malloc (inode->i_size)))
- DBGFS_FATAL("%s", strerror(errno));
- p = *buf;
+ newlen = inode->i_size;
} else {
+ newlen = 1024 * 1024;
if (fdo > 2) {
fchmod (fdo, inode->i_mode);
fchown (fdo, inode->i_uid, inode->i_gid);
}
}
+ if (!(newbuf = malloc (newlen)))
+ DBGFS_FATAL("%s", strerror(errno));
+
+ p = newbuf;
+
for (i = 0; i < arr->len; ++i) {
rec = &(g_array_index(arr, ocfs2_extent_rec, i));
off = rec->e_blkno << blksz_bits;
@@ -314,32 +318,30 @@
if ((foff + len) > inode->i_size)
len = inode->i_size - foff;
- if (fdo != -1) {
- if (newlen <= len) {
- safefree (newbuf);
- if (!(newbuf = malloc (len)))
- DBGFS_FATAL("%s", strerror(errno));
- newlen = len;
- p = newbuf;
- }
- }
+ while (len) {
+ buflen = min (newlen, len);
- if ((pread64(fd, p, len, off)) == -1)
- DBGFS_FATAL("%s", strerror(errno));
+ if ((pread64(fd, p, buflen, off)) == -1)
+ DBGFS_FATAL("%s", strerror(errno));
- if (fdo != -1) {
- if (len)
- if (!(write (fdo, p, len)))
+ if (fdo != -1) {
+ if (!(write (fdo, p, buflen)))
DBGFS_FATAL("%s", strerror(errno));
- } else
- p += len;
+ } else
+ p += buflen;
+ len -= buflen;
+ off += buflen;
+ }
}
ret = 0;
+ if (buf)
+ *buf = newbuf;
bail:
safefree (inode_buf);
- safefree (newbuf);
+ if (ret == -1 || !buf)
+ safefree (newbuf);
if (arr)
g_array_free (arr, 1);
More information about the Ocfs-tools-commits
mailing list