aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debugfs/debug_cmds.ct4
-rw-r--r--debugfs/debugfs.c6
-rw-r--r--debugfs/debugfs.h30
-rw-r--r--debugfs/extent_inode.c47
-rw-r--r--debugfs/zap.c11
5 files changed, 66 insertions, 32 deletions
diff --git a/debugfs/debug_cmds.ct b/debugfs/debug_cmds.ct
index 9a05ef73..4e50ab52 100644
--- a/debugfs/debug_cmds.ct
+++ b/debugfs/debug_cmds.ct
@@ -184,8 +184,8 @@ request do_extent_open, "Open inode for extent manipulation",
request do_zap_block, "Zap block: fill with 0, pattern, flip bits etc.",
zap_block, zap;
-request do_dump_block, "Dump contents of a block",
- block_dump, bp;
+request do_block_dump, "Dump contents of a block",
+ block_dump, bd;
end;
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 9bcfd520..b4eb805b 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -2237,7 +2237,7 @@ void do_dump_mmp(int argc EXT2FS_ATTR((unused)), char *argv[])
fprintf(stdout, "magic: 0x%x\n", mmp_s->mmp_magic);
}
-static int source_file(const char *cmd_file, int sci_idx)
+static int source_file(const char *cmd_file, int ss_idx)
{
FILE *f;
char buf[256];
@@ -2268,9 +2268,9 @@ static int source_file(const char *cmd_file, int sci_idx)
if (cp)
*cp = 0;
printf("debugfs: %s\n", buf);
- retval = ss_execute_line(sci_idx, buf);
+ retval = ss_execute_line(ss_idx, buf);
if (retval) {
- ss_perror(sci_idx, retval, buf);
+ ss_perror(ss_idx, retval, buf);
exit_status++;
}
}
diff --git a/debugfs/debugfs.h b/debugfs/debugfs.h
index efd8d129..ea09e539 100644
--- a/debugfs/debugfs.h
+++ b/debugfs/debugfs.h
@@ -66,6 +66,32 @@ extern void do_dump(int argc, char **argv);
extern void do_cat(int argc, char **argv);
extern void do_rdump(int argc, char **argv);
+/* extent_inode.c */
+extern void do_extent_open(int argc, char **argv);
+extern void do_extent_close(int argc, char **argv);
+extern void do_current_node(int argc, char **argv);
+extern void do_root_node(int argc, char **argv);
+extern void do_last_leaf(int argc, char **argv);
+extern void do_first_sib(int argc, char **argv);
+extern void do_last_sib(int argc, char **argv);
+extern void do_next_sib(int argc, char **argv);
+extern void do_prev_sib(int argc, char **argv);
+extern void do_next_leaf(int argc, char **argv);
+extern void do_prev_leaf(int argc, char **argv);
+extern void do_next(int argc, char **argv);
+extern void do_prev(int argc, char **argv);
+extern void do_up(int argc, char **argv);
+extern void do_down(int argc, char **argv);
+extern void do_delete_node(int argc, char **argv);
+extern void do_replace_node(int argc, char **argv);
+extern void do_split_node(int argc, char **argv);
+extern void do_insert_node(int argc, char **argv);
+extern void do_set_bmap(int argc, char **argv);
+extern void do_print_all(int argc, char **argv);
+extern void do_fix_parents(int argc, char **argv);
+extern void do_info(int argc, char **argv);
+extern void do_goto_block(int argc, char **argv);
+
/* htree.c */
extern void do_htree_dump(int argc, char **argv);
extern void do_dx_hash(int argc, char **argv);
@@ -142,3 +168,7 @@ extern void do_set_mmp_value(int argc, char **argv);
extern void do_freefrag(int argc, char **argv);
extern void do_filefrag(int argc, char *argv[]);
+
+/* zap.c */
+extern void do_zap_block(int argc, char **argv);
+extern void do_block_dump(int argc, char **argv);
diff --git a/debugfs/extent_inode.c b/debugfs/extent_inode.c
index d726b2b6..11c4b4f9 100644
--- a/debugfs/extent_inode.c
+++ b/debugfs/extent_inode.c
@@ -47,9 +47,9 @@ static void dbg_print_extent(char *desc, struct ext2fs_extent *extent)
}
-int common_extent_args_process(int argc, char *argv[], int min_argc,
- int max_argc, const char *cmd,
- const char *usage, int flags)
+static int common_extent_args_process(int argc, char *argv[], int min_argc,
+ int max_argc, const char *cmd,
+ const char *usage, int flags)
{
if (common_args_process(argc, argv, min_argc, max_argc, cmd,
usage, flags))
@@ -112,7 +112,8 @@ void do_extent_close(int argc, char *argv[])
{
int ret;
- if (check_fs_open(argv[0]))
+ if (common_args_process(argc, argv, 1, 1,
+ "extent_close", "", 0))
return;
if (!current_handle) {
@@ -129,22 +130,24 @@ void do_extent_close(int argc, char *argv[])
extent_prompt = NULL;
}
-void generic_goto_node(char *cmd_name, int op)
+static void generic_goto_node(const char *my_name, int argc,
+ char **argv, int op)
{
struct ext2fs_extent extent;
errcode_t retval;
- if (check_fs_open(cmd_name))
+ if (my_name && common_args_process(argc, argv, 1, 1,
+ my_name, "", 0))
return;
if (!current_handle) {
- com_err(cmd_name, 0, "Extent handle not open");
+ com_err(argv[0], 0, "Extent handle not open");
return;
}
retval = ext2fs_extent_get(current_handle, op, &extent);
if (retval) {
- com_err(cmd_name, retval, 0);
+ com_err(argv[0], retval, 0);
return;
}
dbg_print_extent(0, &extent);
@@ -152,67 +155,67 @@ void generic_goto_node(char *cmd_name, int op)
void do_current_node(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_CURRENT);
+ generic_goto_node("current_node", argc, argv, EXT2_EXTENT_CURRENT);
}
void do_root_node(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_ROOT);
+ generic_goto_node("root_node", argc, argv, EXT2_EXTENT_ROOT);
}
void do_last_leaf(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_LAST_LEAF);
+ generic_goto_node("last_leaf", argc, argv, EXT2_EXTENT_LAST_LEAF);
}
void do_first_sib(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_FIRST_SIB);
+ generic_goto_node("first_sib", argc, argv, EXT2_EXTENT_FIRST_SIB);
}
void do_last_sib(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_LAST_SIB);
+ generic_goto_node("next_sib", argc, argv, EXT2_EXTENT_LAST_SIB);
}
void do_next_sib(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_NEXT_SIB);
+ generic_goto_node("next_sib", argc, argv, EXT2_EXTENT_NEXT_SIB);
}
void do_prev_sib(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_PREV_SIB);
+ generic_goto_node("prev_sib", argc, argv, EXT2_EXTENT_PREV_SIB);
}
void do_next_leaf(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_NEXT_LEAF);
+ generic_goto_node("next_leaf", argc, argv, EXT2_EXTENT_NEXT_LEAF);
}
void do_prev_leaf(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_PREV_LEAF);
+ generic_goto_node("prev_leaf", argc, argv, EXT2_EXTENT_PREV_LEAF);
}
void do_next(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_NEXT);
+ generic_goto_node("next", argc, argv, EXT2_EXTENT_NEXT);
}
void do_prev(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_PREV);
+ generic_goto_node("prev", argc, argv, EXT2_EXTENT_PREV);
}
void do_up(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_UP);
+ generic_goto_node("up", argc, argv, EXT2_EXTENT_UP);
}
void do_down(int argc, char *argv[])
{
- generic_goto_node(argv[0], EXT2_EXTENT_DOWN);
+ generic_goto_node("down", argc, argv, EXT2_EXTENT_DOWN);
}
void do_delete_node(int argc, char *argv[])
@@ -535,5 +538,5 @@ void do_goto_block(int argc, char **argv)
return;
}
- generic_goto_node(argv[0], EXT2_EXTENT_CURRENT);
+ generic_goto_node(NULL, argc, argv, EXT2_EXTENT_CURRENT);
}
diff --git a/debugfs/zap.c b/debugfs/zap.c
index 4a1afbe0..ba205a11 100644
--- a/debugfs/zap.c
+++ b/debugfs/zap.c
@@ -54,7 +54,7 @@ void do_zap_block(int argc, char *argv[])
"bit", &err);
if (err)
return;
- if (bit >= current_fs->blocksize * 8) {
+ if (bit >= (int) current_fs->blocksize * 8) {
com_err(argv[0], 0, "The bit to flip "
"must be within a %d block\n",
current_fs->blocksize);
@@ -77,7 +77,7 @@ void do_zap_block(int argc, char *argv[])
"offset", &err);
if (err)
return;
- if (offset >= current_fs->blocksize) {
+ if (offset >= (int) current_fs->blocksize) {
com_err(argv[0], 0, "The offset must be "
"within a %d block\n",
current_fs->blocksize);
@@ -106,7 +106,7 @@ void do_zap_block(int argc, char *argv[])
offset = 0;
if (length < 0)
length = current_fs->blocksize - offset;
- if ((offset + length) > current_fs->blocksize) {
+ if ((offset + length) > (int) current_fs->blocksize) {
com_err(argv[0], 0, "The specified length is too bug\n");
return;
}
@@ -167,14 +167,15 @@ errout:
return;
}
-void do_dump_block(int argc, char *argv[])
+void do_block_dump(int argc, char *argv[])
{
unsigned char *buf;
ext2_ino_t inode;
errcode_t errcode;
blk64_t block;
char *file = NULL;
- int c, err, i, j;
+ unsigned int i, j;
+ int c, err;
int suppress = -1;
if (check_fs_open(argv[0]))