mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2024-11-23 18:14:25 +08:00
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.
This commit is contained in:
parent
d21ae6c5cd
commit
becf36f6ac
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user