debugfs: add the debugfs copy_inode subcommand

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
next
Theodore Ts'o 2016-08-31 18:13:16 -04:00
parent 9a23fa8334
commit b199291909
3 changed files with 38 additions and 0 deletions

View File

@ -73,6 +73,9 @@ request do_rm, "Remove a file (unlink and kill_file, if appropriate)",
request do_kill_file, "Deallocate an inode and its blocks",
kill_file;
request do_copy_inode, "Copy the inode structure",
copy_inode;
request do_clri, "Clear an inode's contents",
clri;

View File

@ -225,6 +225,12 @@ master superblock.
Clear the contents of the inode
.IR filespec .
.TP
.BI copy_inode " source_inode destination_inode"
Copy the conents of the inode structure in
.I source_inode
and use it to overwrite the inode structure at
.IR destination_inode .
.TP
.BI dirsearch " filespec filename"
Search the directory
.I filespec

View File

@ -1584,6 +1584,35 @@ void do_unlink(int argc, char *argv[])
unlink_file_by_name(argv[1]);
}
void do_copy_inode(int argc, char *argv[])
{
ext2_ino_t src_ino, dest_ino;
struct ext2_inode inode;
unsigned char buf[4096];
int retval;
if (common_args_process(argc, argv, 3, 3, "copy_inode",
"<source file> <dest_name>", CHECK_FS_RW))
return;
src_ino = string_to_inode(argv[1]);
if (!src_ino)
return;
dest_ino = string_to_inode(argv[2]);
if (!dest_ino)
return;
if (debugfs_read_inode_full(src_ino, (struct ext2_inode *) buf,
argv[0], sizeof(buf)))
return;
if (debugfs_write_inode_full(dest_ino, (struct ext2_inode *) buf,
argv[0], sizeof(buf)))
return;
}
#endif /* READ_ONLY */
void do_find_free_block(int argc, char *argv[])