From e13ebfdd5f13876de1b978c8a5ed5a322ed7ba62 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Tue, 22 Jul 2014 12:44:42 -0400 Subject: 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 Signed-off-by: Theodore Ts'o --- debugfs/debugfs.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'debugfs/debugfs.c') 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], + "", 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[]) { -- cgit v1.2.1