1 /* 2 * debugfs.h --- header file for the debugfs program 3 */ 4 5 #include "ss/ss.h" 6 #include "ext2fs/ext2_fs.h" 7 #include "ext2fs/ext2fs.h" 8 #include "../misc/create_inode.h" 9 #include "support/quotaio.h" 10 11 #ifdef __STDC__ 12 #define NOARGS void 13 #else 14 #define NOARGS 15 #define const 16 #endif 17 18 /* 19 * Flags used by the common argument processing functions 20 */ 21 #define CHECK_FS_RW 0x0001 22 #define CHECK_FS_BITMAPS 0x0002 23 #define CHECK_FS_NOTOPEN 0x0004 24 25 extern ext2_filsys current_fs; 26 extern quota_ctx_t current_qctx; 27 extern ext2_ino_t root, cwd; 28 extern int ss_sci_idx; 29 extern ss_request_table debug_cmds, extent_cmds; 30 31 extern void reset_getopt(void); 32 extern FILE *open_pager(void); 33 extern void close_pager(FILE *stream); 34 extern int check_fs_open(char *name); 35 extern int check_fs_not_open(char *name); 36 extern int check_fs_read_write(char *name); 37 extern int check_fs_bitmaps(char *name); 38 extern ext2_ino_t string_to_inode(char *str); 39 extern char *inode_time_to_string(__u32 xtime, __u32 xtime_extra); 40 extern char *time_to_string(__s64); 41 extern __s64 string_to_time(const char *); 42 extern unsigned long parse_ulong(const char *str, const char *cmd, 43 const char *descr, int *err); 44 extern unsigned long long parse_ulonglong(const char *str, const char *cmd, 45 const char *descr, int *err); 46 extern int strtoblk(const char *cmd, const char *str, const char *errmsg, 47 blk64_t *ret); 48 extern int common_args_process(int argc, char *argv[], int min_argc, 49 int max_argc, const char *cmd, 50 const char *usage, int flags); 51 extern int common_inode_args_process(int argc, char *argv[], 52 ext2_ino_t *inode, int flags); 53 extern int common_block_args_process(int argc, char *argv[], 54 blk64_t *block, blk64_t *count); 55 extern int debugfs_read_inode(ext2_ino_t ino, struct ext2_inode * inode, 56 const char *cmd); 57 extern int debugfs_read_inode2(ext2_ino_t ino, struct ext2_inode * inode, 58 const char *cmd, int bufsize, int flags); 59 extern int debugfs_write_inode(ext2_ino_t ino, struct ext2_inode * inode, 60 const char *cmd); 61 extern int debugfs_write_inode2(ext2_ino_t ino, struct ext2_inode * inode, 62 const char *cmd, int bufsize, int flags); 63 extern int debugfs_write_new_inode(ext2_ino_t ino, struct ext2_inode * inode, 64 const char *cmd); 65 extern int ext2_file_type(unsigned int mode); 66 67 /* ss command functions */ 68 69 /* dump.c */ 70 extern void do_dump(int argc, char **argv, int sci_idx, void *infop); 71 extern void do_cat(int argc, char **argv, int sci_idx, void *infop); 72 extern void do_rdump(int argc, char **argv, int sci_idx, void *infop); 73 74 /* extent_inode.c */ 75 extern void do_extent_open(int argc, char **argv, int sci_idx, void *infop); 76 extern void do_extent_close(int argc, char **argv, int sci_idx, void *infop); 77 extern void do_current_node(int argc, char **argv, int sci_idx, void *infop); 78 extern void do_root_node(int argc, char **argv, int sci_idx, void *infop); 79 extern void do_last_leaf(int argc, char **argv, int sci_idx, void *infop); 80 extern void do_first_sib(int argc, char **argv, int sci_idx, void *infop); 81 extern void do_last_sib(int argc, char **argv, int sci_idx, void *infop); 82 extern void do_next_sib(int argc, char **argv, int sci_idx, void *infop); 83 extern void do_prev_sib(int argc, char **argv, int sci_idx, void *infop); 84 extern void do_next_leaf(int argc, char **argv, int sci_idx, void *infop); 85 extern void do_prev_leaf(int argc, char **argv, int sci_idx, void *infop); 86 extern void do_next(int argc, char **argv, int sci_idx, void *infop); 87 extern void do_prev(int argc, char **argv, int sci_idx, void *infop); 88 extern void do_up(int argc, char **argv, int sci_idx, void *infop); 89 extern void do_down(int argc, char **argv, int sci_idx, void *infop); 90 extern void do_delete_node(int argc, char **argv, int sci_idx, void *infop); 91 extern void do_replace_node(int argc, char **argv, int sci_idx, void *infop); 92 extern void do_split_node(int argc, char **argv, int sci_idx, void *infop); 93 extern void do_insert_node(int argc, char **argv, int sci_idx, void *infop); 94 extern void do_set_bmap(int argc, char **argv, int sci_idx, void *infop); 95 extern void do_print_all(int argc, char **argv, int sci_idx, void *infop); 96 extern void do_fix_parents(int argc, char **argv, int sci_idx, void *infop); 97 extern void do_info(int argc, char **argv, int sci_idx, void *infop); 98 extern void do_goto_block(int argc, char **argv, int sci_idx, void *infop); 99 100 /* htree.c */ 101 extern void do_htree_dump(int argc, char **argv, int sci_idx, void *infop); 102 extern void do_dx_hash(int argc, char **argv, int sci_idx, void *infop); 103 extern void do_dirsearch(int argc, char **argv, int sci_idx, void *infop); 104 105 /* logdump.c */ 106 extern void do_logdump(int argc, char **argv, int sci_idx, void *infop); 107 108 /* lsdel.c */ 109 extern void do_lsdel(int argc, char **argv, int sci_idx, void *infop); 110 111 /* icheck.c */ 112 extern void do_icheck(int argc, char **argv, int sci_idx, void *infop); 113 114 /* ncheck.c */ 115 extern void do_ncheck(int argc, char **argv, int sci_idx, void *infop); 116 117 /* set_fields.c */ 118 extern void do_set_super(int argc, char **, int sci_idx, void *infop); 119 extern void do_set_inode(int argc, char **, int sci_idx, void *infop); 120 extern void do_set_block_group_descriptor(int argc, char **, int sci_idx, void *infop); 121 122 /* unused.c */ 123 extern void do_dump_unused(int argc, char **argv, int sci_idx, void *infop); 124 125 /* debugfs.c */ 126 extern void internal_dump_inode(FILE *, const char *, ext2_ino_t, 127 struct ext2_inode *, int); 128 129 extern void do_dirty_filesys(int argc, char **argv, int sci_idx, void *infop); 130 extern void do_open_filesys(int argc, char **argv, int sci_idx, void *infop); 131 extern void do_close_filesys(int argc, char **argv, int sci_idx, void *infop); 132 extern void do_lcd(int argc, char **argv, int sci_idx, void *infop); 133 extern void do_init_filesys(int argc, char **argv, int sci_idx, void *infop); 134 extern void do_show_super_stats(int argc, char **argv, int sci_idx, void *infop); 135 extern void do_kill_file(int argc, char **argv, int sci_idx, void *infop); 136 extern void do_rm(int argc, char **argv, int sci_idx, void *infop); 137 extern void do_link(int argc, char **argv, int sci_idx, void *infop); 138 extern void do_undel(int argc, char **argv, int sci_idx, void *infop); 139 extern void do_unlink(int argc, char **argv, int sci_idx, void *infop); 140 extern void do_copy_inode(int argc, char *argv[], int sci_idx, void *infop); 141 extern void do_find_free_block(int argc, char **argv, int sci_idx, void *infop); 142 extern void do_find_free_inode(int argc, char **argv, int sci_idx, void *infop); 143 extern void do_stat(int argc, char **argv, int sci_idx, void *infop); 144 extern void do_dump_extents(int argc, char **argv, int sci_idx, void *infop); 145 extern void do_blocks(int argc, char *argv[], int sci_idx, void *infop); 146 147 extern void do_chroot(int argc, char **argv, int sci_idx, void *infop); 148 extern void do_clri(int argc, char **argv, int sci_idx, void *infop); 149 extern void do_freei(int argc, char **argv, int sci_idx, void *infop); 150 extern void do_seti(int argc, char **argv, int sci_idx, void *infop); 151 extern void do_testi(int argc, char **argv, int sci_idx, void *infop); 152 extern void do_freeb(int argc, char **argv, int sci_idx, void *infop); 153 extern void do_setb(int argc, char **argv, int sci_idx, void *infop); 154 extern void do_testb(int argc, char **argv, int sci_idx, void *infop); 155 extern void do_modify_inode(int argc, char **argv, int sci_idx, void *infop); 156 extern void do_list_dir(int argc, char **argv, int sci_idx, void *infop); 157 extern void do_change_working_dir(int argc, char **argv, int sci_idx, void *infop); 158 extern void do_print_working_directory(int argc, char **argv, int sci_idx, void *infop); 159 extern void do_write(int argc, char **argv, int sci_idx, void *infop); 160 extern void do_mknod(int argc, char **argv, int sci_idx, void *infop); 161 extern void do_mkdir(int argc, char **argv, int sci_idx, void *infop); 162 extern void do_rmdir(int argc, char **argv, int sci_idx, void *infop); 163 extern void do_show_debugfs_params(int argc, char **argv, int sci_idx, void *infop); 164 extern void do_expand_dir(int argc, char **argv, int sci_idx, void *infop); 165 extern void do_features(int argc, char **argv, int sci_idx, void *infop); 166 extern void do_bmap(int argc, char **argv, int sci_idx, void *infop); 167 extern void do_imap(int argc, char **argv, int sci_idx, void *infop); 168 extern void do_idump(int argc, char *argv[], int sci_idx, void *infop); 169 extern void do_set_current_time(int argc, char **argv, int sci_idx, void *infop); 170 extern void do_supported_features(int argc, char **argv, int sci_idx, void *infop); 171 extern void do_punch(int argc, char **argv, int sci_idx, void *infop); 172 extern void do_fallocate(int argc, char **argv, int sci_idx, void *infop); 173 extern void do_symlink(int argc, char **argv, int sci_idx, void *infop); 174 175 extern void do_dump_mmp(int argc, char **argv, int sci_idx, void *infop); 176 extern void do_set_mmp_value(int argc, char **argv, int sci_idx, void *infop); 177 178 extern void do_freefrag(int argc, char **argv, int sci_idx, void *infop); 179 extern void do_filefrag(int argc, char *argv[], int sci_idx, void *infop); 180 181 /* do_journal.c */ 182 183 extern void do_journal_write(int argc, char *argv[], int sci_idx, void *infop); 184 extern void do_journal_open(int argc, char *argv[], int sci_idx, void *infop); 185 extern void do_journal_close(int argc, char *argv[], int sci_idx, void *infop); 186 extern void do_journal_run(int argc, char *argv[], int sci_idx, void *infop); 187 188 /* quota.c */ 189 extern void do_list_quota(int argc, char *argv[], int sci_idx, void *infop); 190 extern void do_get_quota(int argc, char *argv[], int sci_idx, void *infop); 191 192 /* util.c */ 193 extern __s64 string_to_time(const char *arg); 194 errcode_t read_list(char *str, blk64_t **list, size_t *len); 195 196 /* xattrs.c */ 197 void dump_inode_attributes(FILE *out, ext2_ino_t ino); 198 void do_get_xattr(int argc, char **argv, int sci_idx, void *infop); 199 void do_set_xattr(int argc, char **argv, int sci_idx, void *infop); 200 void do_rm_xattr(int argc, char **argv, int sci_idx, void *infop); 201 void do_list_xattr(int argc, char **argv, int sci_idx, void *infop); 202 void raw_inode_xattr_dump(FILE *f, unsigned char *buf, unsigned int len); 203 void block_xattr_dump(FILE *f, unsigned char *buf, unsigned int len); 204 205 /* zap.c */ 206 extern void do_zap_block(int argc, char **argv, int sci_idx, void *infop); 207 extern void do_block_dump(int argc, char **argv, int sci_idx, void *infop); 208 extern void do_byte_hexdump(FILE *fp, unsigned char *buf, size_t bufsize); 209