]>
Commit | Line | Data |
---|---|---|
3839e657 TT |
1 | /* |
2 | * e2fsck.h | |
3 | * | |
4 | * Copyright (C) 1993, 1994 Theodore Ts'o. This file may be | |
5 | * redistributed under the terms of the GNU Public License. | |
6 | * | |
7 | */ | |
8 | ||
9 | #include <stdio.h> | |
10 | #include <string.h> | |
11 | #include <unistd.h> | |
12 | #include <stdlib.h> | |
3839e657 TT |
13 | #include <sys/types.h> |
14 | #include <sys/time.h> | |
15 | ||
50e1e10f | 16 | #ifdef HAVE_LINUX_FS_H |
3839e657 | 17 | #include <linux/fs.h> |
50e1e10f | 18 | #endif |
3839e657 TT |
19 | #include <linux/ext2_fs.h> |
20 | ||
21 | #include "ext2fs/ext2fs.h" | |
22 | ||
23 | #ifdef __STDC__ | |
24 | #define NOARGS void | |
25 | #else | |
26 | #define NOARGS | |
27 | #define const | |
28 | #endif | |
29 | ||
30 | /* | |
31 | * Exit codes used by fsck-type programs | |
32 | */ | |
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 */ | |
40 | ||
f3db3566 TT |
41 | /* |
42 | * The last ext2fs revision level that this version of e2fsck is able to | |
43 | * support | |
44 | */ | |
45 | #define E2FSCK_CURRENT_REV 0 | |
46 | ||
3839e657 TT |
47 | /* |
48 | * Inode count arrays | |
49 | */ | |
50 | extern unsigned short * inode_count; | |
51 | extern unsigned short * inode_link_info; | |
52 | ||
53 | /* | |
54 | * The directory information structure; stores directory information | |
55 | * collected in earlier passes, to avoid disk i/o in fetching the | |
56 | * directoryt information. | |
57 | */ | |
58 | struct dir_info { | |
59 | ino_t ino; /* Inode number */ | |
60 | ino_t dotdot; /* Parent according to '..' */ | |
61 | ino_t parent; /* Parent according to treewalk */ | |
62 | }; | |
63 | ||
64 | struct dir_block_struct { | |
65 | ino_t ino; | |
66 | blk_t blk; | |
67 | int blockcnt; | |
68 | }; | |
69 | ||
70 | struct dir_block_struct *dir_blocks; | |
71 | int dir_block_count; | |
72 | int dir_block_size; | |
73 | ||
74 | /* | |
75 | * This structure is used for keeping track of how much resources have | |
76 | * been used for a particular pass of e2fsck. | |
77 | */ | |
78 | struct resource_track { | |
79 | struct timeval time_start; | |
80 | struct timeval user_start; | |
81 | struct timeval system_start; | |
82 | void *brk_start; | |
83 | }; | |
84 | ||
85 | /* | |
86 | * Variables | |
87 | */ | |
88 | extern const char * program_name; | |
89 | extern const char * device_name; | |
90 | ||
f3db3566 TT |
91 | extern ext2fs_inode_bitmap inode_used_map; /* Inodes which are in use */ |
92 | extern ext2fs_inode_bitmap inode_bad_map; /* Inodes which are bad somehow */ | |
93 | extern ext2fs_inode_bitmap inode_dir_map; /* Inodes which are directories */ | |
3839e657 | 94 | |
f3db3566 TT |
95 | extern ext2fs_block_bitmap block_found_map; /* Blocks which are in use */ |
96 | extern ext2fs_block_bitmap block_dup_map; /* Blocks which are used by more than once */ | |
3839e657 TT |
97 | |
98 | extern const char *fix_msg[2]; /* Fixed or ignored! */ | |
99 | extern const char *clear_msg[2]; /* Cleared or ignored! */ | |
100 | ||
f3db3566 TT |
101 | extern int *invalid_inode_bitmap; |
102 | extern int *invalid_block_bitmap; | |
103 | extern int *invalid_inode_table; | |
104 | extern int restart_e2fsck; | |
105 | ||
3839e657 TT |
106 | /* Command line options */ |
107 | extern int nflag; | |
108 | extern int yflag; | |
109 | extern int tflag; | |
110 | extern int preen; | |
111 | extern int verbose; | |
112 | extern int list; | |
113 | extern int debug; | |
114 | extern int force; | |
115 | ||
116 | extern int rwflag; | |
117 | ||
118 | extern int inode_buffer_blocks; | |
119 | extern int process_inode_size; | |
120 | extern int directory_blocks; | |
121 | ||
122 | extern int no_bad_inode; | |
123 | extern int no_lpf; | |
124 | extern int lpf_corrupted; | |
125 | ||
126 | /* Files counts */ | |
127 | extern int fs_directory_count; | |
128 | extern int fs_regular_count; | |
129 | extern int fs_blockdev_count; | |
130 | extern int fs_chardev_count; | |
131 | extern int fs_links_count; | |
132 | extern int fs_symlinks_count; | |
133 | extern int fs_fast_symlinks_count; | |
134 | extern int fs_fifo_count; | |
135 | extern int fs_total_count; | |
136 | extern int fs_badblocks_count; | |
137 | extern int fs_sockets_count; | |
50e1e10f TT |
138 | extern int fs_ind_count; |
139 | extern int fs_dind_count; | |
140 | extern int fs_tind_count; | |
74becf3c | 141 | extern int fs_fragmented; |
3839e657 TT |
142 | |
143 | extern struct resource_track global_rtrack; | |
144 | ||
f3db3566 TT |
145 | extern int invalid_bitmaps; |
146 | ||
3839e657 TT |
147 | /* |
148 | * Procedure declarations | |
149 | */ | |
150 | ||
151 | extern void pass1(ext2_filsys fs); | |
152 | extern void pass1_dupblocks(ext2_filsys fs, char *block_buf); | |
153 | extern void pass2(ext2_filsys fs); | |
154 | extern void pass3(ext2_filsys fs); | |
155 | extern void pass4(ext2_filsys fs); | |
156 | extern void pass5(ext2_filsys fs); | |
157 | ||
158 | /* badblock.c */ | |
159 | extern void read_bad_blocks_file(ext2_filsys fs, const char *bad_blocks_file, | |
160 | int replace_bad_blocks); | |
161 | extern void test_disk(ext2_filsys fs); | |
162 | ||
163 | /* dirinfo.c */ | |
164 | extern void add_dir_info(ext2_filsys fs, ino_t ino, ino_t parent, | |
165 | struct ext2_inode *inode); | |
166 | extern struct dir_info *get_dir_info(ino_t ino); | |
167 | extern void free_dir_info(ext2_filsys fs); | |
168 | extern int get_num_dirs(ext2_filsys fs); | |
169 | ||
170 | /* ehandler.c */ | |
171 | extern const char *ehandler_operation(const char *op); | |
172 | extern void ehandler_init(io_channel channel); | |
173 | ||
174 | /* util.c */ | |
175 | extern void *allocate_memory(int size, const char *description); | |
176 | extern int ask(const char * string, int def); | |
177 | extern int ask_yn(const char * string, int def); | |
178 | extern void fatal_error (const char * fmt_string); | |
179 | extern void read_bitmaps(ext2_filsys fs); | |
180 | extern void write_bitmaps(ext2_filsys fs); | |
50e1e10f | 181 | extern void preenhalt(ext2_filsys fs); |
3839e657 TT |
182 | extern void print_resource_track(struct resource_track *track); |
183 | extern void init_resource_track(struct resource_track *track); | |
184 | extern int inode_has_valid_blocks(struct ext2_inode *inode); | |
f3db3566 TT |
185 | extern void e2fsck_read_inode(ext2_filsys fs, unsigned long ino, |
186 | struct ext2_inode * inode, const char * proc); | |
187 | extern void e2fsck_write_inode(ext2_filsys fs, unsigned long ino, | |
188 | struct ext2_inode * inode, const char * proc); | |
3839e657 TT |
189 | #ifdef MTRACE |
190 | extern void mtrace_print(char *mesg); | |
191 | #endif | |
192 | ||
193 | #define die(str) fatal_error(str) | |
194 | ||
195 | /* | |
196 | * pass3.c | |
197 | */ | |
198 | extern int reconnect_file(ext2_filsys fs, ino_t inode); |