+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
.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
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
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);
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)
{
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);