request do_logdump, "Dump the contents of the journal",
logdump;
+request do_hexdump_block, "Dump the contents of a block",
+ hexdump_block, hexdump;
+
request do_htree_dump, "Dump a hash-indexed directory",
htree_dump, htree;
Print a list of commands understood by
.BR debugfs .
.TP
+.BI hexdump_block " block"
+Dump the contents of
+.I block
+in hex and ASCII.
+.TP
.BI htree_dump " filespec"
Dump the hash-indexed directory
.IR filespec ,
/* logdump.c */
extern void do_logdump(int argc, char **argv);
+extern void do_hexdump_block(int argc, char **argv);
/* lsdel.c */
extern void do_lsdel(int argc, char **argv);
}
}
+void do_hexdump_block(int argc, char **argv)
+{
+ blk64_t block;
+ char *buf;
+ errcode_t errcode;
+ FILE *out;
+
+ if (common_args_process(argc, argv, 2, 2, argv[0],
+ "<block>", 0))
+ return;
+
+ if (strtoblk(argv[0], argv[1], "block number", &block))
+ return;
+
+ buf = malloc(current_fs->blocksize);
+ if (!buf) {
+ fprintf(stderr, "Couldn't allocate block buffer.\n");
+ return;
+ }
+ out = open_pager();
+
+ errcode = io_channel_read_blk64(current_fs->io, block, 1, buf);
+ if (errcode) {
+ com_err("hexdump_block", errcode,
+ "while reading block %llu\n", block);
+ goto errout;
+ }
+
+ do_hexdump(out, buf, current_fs->blocksize);
+
+errout:
+ free(buf);
+ close_pager(out);
+}
+