aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2003-05-05 11:35:04 -0400
committerTheodore Ts'o <tytso@mit.edu>2003-05-05 11:35:04 -0400
commitbecf36f6ace508fd091052b9e9bcdea192bfbc48 (patch)
treed01850afc950ee4b11c5b95be15828c34cb93999
parentd21ae6c5cd91c15eaff0118a22aaba95f0956935 (diff)
downloadplatform_external_e2fsprogs-becf36f6ace508fd091052b9e9bcdea192bfbc48.tar.gz
platform_external_e2fsprogs-becf36f6ace508fd091052b9e9bcdea192bfbc48.tar.bz2
platform_external_e2fsprogs-becf36f6ace508fd091052b9e9bcdea192bfbc48.zip
debugfs.c (do_imap), debugfs.h, debug_cmds.ct, debugfs.8.in:
Added new command, imap, which prints the location of a specified inode in the inode table.
-rw-r--r--debugfs/ChangeLog6
-rw-r--r--debugfs/debug_cmds.ct3
-rw-r--r--debugfs/debugfs.8.in11
-rw-r--r--debugfs/debugfs.c34
-rw-r--r--debugfs/debugfs.h1
5 files changed, 55 insertions, 0 deletions
diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog
index de4a25e70..e178944b1 100644
--- a/debugfs/ChangeLog
+++ b/debugfs/ChangeLog
@@ -1,3 +1,9 @@
+2003-05-05 Theodore Ts'o <tytso@mit.edu>
+
+ * debugfs.c (do_imap), debugfs.h, debug_cmds.ct, debugfs.8.in:
+ Added new command, imap, which prints the location of a
+ specified inode in the inode table.
+
2003-04-21 Theodore Ts'o <tytso@mit.edu>
* Release of E2fsprogs 1.33
diff --git a/debugfs/debug_cmds.ct b/debugfs/debug_cmds.ct
index e1e271600..21cab096f 100644
--- a/debugfs/debug_cmds.ct
+++ b/debugfs/debug_cmds.ct
@@ -139,5 +139,8 @@ request do_dirsearch, "Search a directory for a particular filename",
request do_bmap, "Calculate the logical->physical block mapping for an inode",
bmap;
+request do_imap, "Calculate the location of an inode",
+ imap;
+
end;
diff --git a/debugfs/debugfs.8.in b/debugfs/debugfs.8.in
index 43d6e977c..f51f8fec9 100644
--- a/debugfs/debugfs.8.in
+++ b/debugfs/debugfs.8.in
@@ -144,6 +144,12 @@ This is a list of the commands which
.B debugfs
supports.
.TP
+.I bmap filespec logical_block
+Print the physical block number corresponding to the logical block number
+.I logical_block
+in the inode
+.IR filespec .
+.TP
.I cat filespec
Dump the contents of the inode
.I filespec
@@ -226,6 +232,11 @@ Print a list of commands understood by
Print a listing of the inodes which use the one or more blocks specified
on the command line.
.TP
+.I imap filespec
+Print the location of the inode data structure (in the inode table)
+of the inode
+.IR filespec .
+.TP
.I initialize device blocksize
Create an ext2 file system on
.I device
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index e6bcdbae2..651bd7bae 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -1463,6 +1463,8 @@ void do_bmap(int argc, char *argv[])
return;
ino = string_to_inode(argv[1]);
+ if (!ino)
+ return;
blk = parse_ulong(argv[2], argv[0], "logical_block", &err);
errcode = ext2fs_bmap(current_fs, ino, 0, 0, 0, blk, &pblk);
@@ -1474,6 +1476,38 @@ void do_bmap(int argc, char *argv[])
printf("%d\n", pblk);
}
+void do_imap(int argc, char *argv[])
+{
+ ext2_ino_t ino;
+ unsigned long group, block, block_nr, offset;
+
+ if (common_args_process(argc, argv, 2, 2, argv[0],
+ "<file>", 0))
+ return;
+ ino = string_to_inode(argv[1]);
+ if (!ino)
+ return 0;
+
+ group = (ino - 1) / EXT2_INODES_PER_GROUP(current_fs->super);
+ offset = ((ino - 1) % EXT2_INODES_PER_GROUP(current_fs->super)) *
+ EXT2_INODE_SIZE(current_fs->super);
+ block = offset >> EXT2_BLOCK_SIZE_BITS(current_fs->super);
+ if (!current_fs->group_desc[(unsigned)group].bg_inode_table) {
+ com_err(argv[0], 0, "Inode table for group %d is missing\n",
+ group);
+ return;
+ }
+ block_nr = current_fs->group_desc[(unsigned)group].bg_inode_table +
+ block;
+ offset &= (EXT2_BLOCK_SIZE(current_fs->super) - 1);
+
+ printf("Inode %d is part of block group %d\n"
+ "\tlocated at block %d, offset 0x%04x\n", ino, group,
+ block_nr, offset);
+
+}
+
+
static int source_file(const char *cmd_file, int sci_idx)
{
diff --git a/debugfs/debugfs.h b/debugfs/debugfs.h
index d8a5b8f9e..e30d95eb4 100644
--- a/debugfs/debugfs.h
+++ b/debugfs/debugfs.h
@@ -111,4 +111,5 @@ extern void do_show_debugfs_params(int argc, char **argv);
extern void do_expand_dir(int argc, char **argv);
extern void do_features(int argc, char **argv);
extern void do_bmap(int argc, char **argv);
+extern void do_imap(int argc, char **argv);