summaryrefslogtreecommitdiff
path: root/debugfs/debugfs.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2014-07-22 12:44:42 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-07-22 13:48:54 -0400
commite13ebfdd5f13876de1b978c8a5ed5a322ed7ba62 (patch)
treeefd8ba7411a677a2a592947c982f5ed2df75c3a0 /debugfs/debugfs.c
parentc7c539e8fd86de691475eea00409c6c030f312cd (diff)
downloade2fsprogs-e13ebfdd5f13876de1b978c8a5ed5a322ed7ba62.tar.gz
debugfs: create inode_dump command to dump an inode in hex
Create a command that will dump an entire inode's space in hex. [ Modified by tytso to add a description to the man page, and to add the more formal command name, inode_dump, in addition to short command name of "idump". ] Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'debugfs/debugfs.c')
-rw-r--r--debugfs/debugfs.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 1703aba8..b41626c1 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -2145,6 +2145,39 @@ void do_imap(int argc, char *argv[])
}
+void do_idump(int argc, char *argv[])
+{
+ ext2_ino_t ino;
+ char *buf;
+ errcode_t err;
+ int isize;
+
+ if (common_args_process(argc, argv, 2, 2, argv[0],
+ "<file>", 0))
+ return;
+ ino = string_to_inode(argv[1]);
+ if (!ino)
+ return;
+
+ isize = EXT2_INODE_SIZE(current_fs->super);
+ err = ext2fs_get_mem(isize, &buf);
+ if (err) {
+ com_err(argv[0], err, "while allocating memory");
+ return;
+ }
+
+ err = ext2fs_read_inode_full(current_fs, ino,
+ (struct ext2_inode *)buf, isize);
+ if (err) {
+ com_err(argv[0], err, "while reading inode %d", ino);
+ goto err;
+ }
+
+ do_byte_hexdump(stdout, buf, isize);
+err:
+ ext2fs_free_mem(&buf);
+}
+
#ifndef READ_ONLY
void do_set_current_time(int argc, char *argv[])
{