summaryrefslogtreecommitdiff
path: root/debugfs
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-07-09 12:13:40 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-07-09 12:13:40 -0400
commitaf0df2aa4a073f7e1a2d58b40010ecd891e80a60 (patch)
tree9fc556781dba13d8601647a2358b5963153a4941 /debugfs
parentb4db1e4c7461a50e18c9fd135b9f1ba6f27e4390 (diff)
downloade2fsprogs-af0df2aa4a073f7e1a2d58b40010ecd891e80a60.tar.gz
debugfs: add a new debugfs command 'blocks'
The blocks command prints out the blocks used by a particular inode, in a format which is useful for test suite automation. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'debugfs')
-rw-r--r--debugfs/debug_cmds.ct3
-rw-r--r--debugfs/debugfs.8.in5
-rw-r--r--debugfs/debugfs.c28
-rw-r--r--debugfs/debugfs.h1
4 files changed, 37 insertions, 0 deletions
diff --git a/debugfs/debug_cmds.ct b/debugfs/debug_cmds.ct
index 9b6c985a..4e9e8310 100644
--- a/debugfs/debug_cmds.ct
+++ b/debugfs/debug_cmds.ct
@@ -46,6 +46,9 @@ request do_stat, "Show inode information ",
request do_dump_extents, "Dump extents information ",
dump_extents, extents, ex;
+request do_blocks, "Dump blocks used by an inode ",
+ blocks;
+
request do_link, "Create directory link",
link, ln;
diff --git a/debugfs/debugfs.8.in b/debugfs/debugfs.8.in
index f5deb7ac..fe07f347 100644
--- a/debugfs/debugfs.8.in
+++ b/debugfs/debugfs.8.in
@@ -157,6 +157,11 @@ This is a list of the commands which
.B debugfs
supports.
.TP
+.I blocks filespace
+Print the blocks used by the inode
+.I filespec
+to stdout.
+.TP
.I bmap filespec logical_block
Print the physical block number corresponding to the logical block number
.I logical_block
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 12ee638a..e7d74363 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -912,6 +912,34 @@ void do_dump_extents(int argc, char **argv)
return;
}
+static int print_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
+ blk64_t *blocknr,
+ e2_blkcnt_t blockcnt,
+ blk64_t ref_block EXT2FS_ATTR((unused)),
+ int ref_offset EXT2FS_ATTR((unused)),
+ void *private EXT2FS_ATTR((unused)))
+{
+ printf("%llu ", *blocknr);
+ return 0;
+}
+
+void do_blocks(int argc, char *argv[])
+{
+ ext2_ino_t inode;
+
+ if (check_fs_open(argv[0]))
+ return;
+
+ if (common_inode_args_process(argc, argv, &inode, 0)) {
+ return;
+ }
+
+ ext2fs_block_iterate3(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL,
+ print_blocks_proc, NULL);
+ fputc('\n', stdout);
+ return;
+}
+
void do_chroot(int argc, char *argv[])
{
ext2_ino_t inode;
diff --git a/debugfs/debugfs.h b/debugfs/debugfs.h
index f7ec8da9..0ea24748 100644
--- a/debugfs/debugfs.h
+++ b/debugfs/debugfs.h
@@ -104,6 +104,7 @@ extern void do_find_free_block(int argc, char **argv);
extern void do_find_free_inode(int argc, char **argv);
extern void do_stat(int argc, char **argv);
extern void do_dump_extents(int argc, char **argv);
+extern void do_blocks(int argc, char *argv[]);
extern void do_chroot(int argc, char **argv);
extern void do_clri(int argc, char **argv);