4 * Copyright (C) 1993, 1994 Theodore Ts'o. This file may be
5 * redistributed under the terms of the GNU Public License.
13 #include <sys/types.h>
16 #ifdef HAVE_LINUX_FS_H
19 #include <linux/ext2_fs.h>
21 #include "ext2fs/ext2fs.h"
31 * Exit codes used by fsck-type programs
33 #define FSCK_OK 0 /* No errors */
34 #define FSCK_NONDESTRUCT 1 /* File system errors corrected */
35 #define FSCK_REBOOT 2 /* System should be rebooted */
36 #define FSCK_UNCORRECTED 4 /* File system errors left uncorrected */
37 #define FSCK_ERROR 8 /* Operational error */
38 #define FSCK_USAGE 16 /* Usage or syntax error */
39 #define FSCK_LIBRARY 128 /* Shared library error */
42 * The last ext2fs revision level that this version of e2fsck is able to
45 #define E2FSCK_CURRENT_REV 1
50 extern ext2_icount_t inode_count;
51 extern ext2_icount_t inode_link_info;
54 * The directory information structure; stores directory information
55 * collected in earlier passes, to avoid disk i/o in fetching the
56 * directory information.
59 ino_t ino; /* Inode number */
60 ino_t dotdot; /* Parent according to '..' */
61 ino_t parent; /* Parent according to treewalk */
65 * This structure is used for keeping track of how much resources have
66 * been used for a particular pass of e2fsck.
68 struct resource_track {
69 struct timeval time_start;
70 struct timeval user_start;
71 struct timeval system_start;
78 extern const char * program_name;
79 extern const char * device_name;
81 extern ext2fs_inode_bitmap inode_used_map; /* Inodes which are in use */
82 extern ext2fs_inode_bitmap inode_bad_map; /* Inodes which are bad somehow */
83 extern ext2fs_inode_bitmap inode_dir_map; /* Inodes which are directories */
84 extern ext2fs_inode_bitmap inode_bb_map; /* Inodes which are in bad blocks */
86 extern ext2fs_block_bitmap block_found_map; /* Blocks which are in use */
87 extern ext2fs_block_bitmap block_dup_map; /* Blocks which are used by more than once */
88 extern ext2fs_block_bitmap block_illegal_map; /* Meta-data blocks */
90 extern const char *fix_msg[2]; /* Fixed or ignored! */
91 extern const char *clear_msg[2]; /* Cleared or ignored! */
93 extern int *invalid_inode_bitmap;
94 extern int *invalid_block_bitmap;
95 extern int *invalid_inode_table;
96 extern int restart_e2fsck;
98 /* Command line options */
110 extern int inode_buffer_blocks;
111 extern int process_inode_size;
112 extern int directory_blocks;
114 extern int no_bad_inode;
116 extern int lpf_corrupted;
119 extern int fs_directory_count;
120 extern int fs_regular_count;
121 extern int fs_blockdev_count;
122 extern int fs_chardev_count;
123 extern int fs_links_count;
124 extern int fs_symlinks_count;
125 extern int fs_fast_symlinks_count;
126 extern int fs_fifo_count;
127 extern int fs_total_count;
128 extern int fs_badblocks_count;
129 extern int fs_sockets_count;
130 extern int fs_ind_count;
131 extern int fs_dind_count;
132 extern int fs_tind_count;
133 extern int fs_fragmented;
135 extern struct resource_track global_rtrack;
137 extern int invalid_bitmaps;
140 * For pass1_check_directory and pass1_get_blocks
142 extern ino_t stashed_ino;
143 extern struct ext2_inode *stashed_inode;
146 * Procedure declarations
149 extern void pass1(ext2_filsys fs);
150 extern void pass1_dupblocks(ext2_filsys fs, char *block_buf);
151 extern void pass2(ext2_filsys fs);
152 extern void pass3(ext2_filsys fs);
153 extern void pass4(ext2_filsys fs);
154 extern void pass5(ext2_filsys fs);
157 extern errcode_t pass1_check_directory(ext2_filsys fs, ino_t ino);
158 extern errcode_t pass1_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks);
159 extern errcode_t pass1_read_inode(ext2_filsys fs, ino_t ino,
160 struct ext2_inode *inode);
161 extern errcode_t pass1_write_inode(ext2_filsys fs, ino_t ino,
162 struct ext2_inode *inode);
163 extern int e2fsck_pass1_check_device_inode(struct ext2_inode *inode);
166 extern void read_bad_blocks_file(ext2_filsys fs, const char *bad_blocks_file,
167 int replace_bad_blocks);
168 extern void test_disk(ext2_filsys fs);
171 extern void add_dir_info(ext2_filsys fs, ino_t ino, ino_t parent);
172 extern struct dir_info *get_dir_info(ino_t ino);
173 extern void free_dir_info(ext2_filsys fs);
174 extern int get_num_dirs(ext2_filsys fs);
175 extern struct dir_info *dir_info_iter(int *control);
178 extern const char *ehandler_operation(const char *op);
179 extern void ehandler_init(io_channel channel);
182 void swap_filesys(ext2_filsys fs);
185 extern void *allocate_memory(int size, const char *description);
186 extern int ask(const char * string, int def);
187 extern int ask_yn(const char * string, int def);
188 extern void fatal_error (const char * fmt_string);
189 extern void read_bitmaps(ext2_filsys fs);
190 extern void write_bitmaps(ext2_filsys fs);
191 extern void preenhalt(ext2_filsys fs);
192 extern void print_resource_track(struct resource_track *track);
193 extern void init_resource_track(struct resource_track *track);
194 extern int inode_has_valid_blocks(struct ext2_inode *inode);
195 extern void e2fsck_read_inode(ext2_filsys fs, unsigned long ino,
196 struct ext2_inode * inode, const char * proc);
197 extern void e2fsck_write_inode(ext2_filsys fs, unsigned long ino,
198 struct ext2_inode * inode, const char * proc);
200 extern void mtrace_print(char *mesg);
203 #define die(str) fatal_error(str)
208 extern int reconnect_file(ext2_filsys fs, ino_t inode);