]>
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> | |
13 | #include <sys/stat.h> | |
14 | #include <sys/types.h> | |
15 | #include <sys/time.h> | |
16 | ||
17 | #include <linux/fs.h> | |
18 | #include <linux/ext2_fs.h> | |
19 | ||
20 | #include "ext2fs/ext2fs.h" | |
21 | ||
22 | #ifdef __STDC__ | |
23 | #define NOARGS void | |
24 | #else | |
25 | #define NOARGS | |
26 | #define const | |
27 | #endif | |
28 | ||
29 | /* | |
30 | * Exit codes used by fsck-type programs | |
31 | */ | |
32 | #define FSCK_OK 0 /* No errors */ | |
33 | #define FSCK_NONDESTRUCT 1 /* File system errors corrected */ | |
34 | #define FSCK_REBOOT 2 /* System should be rebooted */ | |
35 | #define FSCK_UNCORRECTED 4 /* File system errors left uncorrected */ | |
36 | #define FSCK_ERROR 8 /* Operational error */ | |
37 | #define FSCK_USAGE 16 /* Usage or syntax error */ | |
38 | #define FSCK_LIBRARY 128 /* Shared library error */ | |
39 | ||
40 | /* | |
41 | * Inode count arrays | |
42 | */ | |
43 | extern unsigned short * inode_count; | |
44 | extern unsigned short * inode_link_info; | |
45 | ||
46 | /* | |
47 | * The directory information structure; stores directory information | |
48 | * collected in earlier passes, to avoid disk i/o in fetching the | |
49 | * directoryt information. | |
50 | */ | |
51 | struct dir_info { | |
52 | ino_t ino; /* Inode number */ | |
53 | ino_t dotdot; /* Parent according to '..' */ | |
54 | ino_t parent; /* Parent according to treewalk */ | |
55 | }; | |
56 | ||
57 | struct dir_block_struct { | |
58 | ino_t ino; | |
59 | blk_t blk; | |
60 | int blockcnt; | |
61 | }; | |
62 | ||
63 | struct dir_block_struct *dir_blocks; | |
64 | int dir_block_count; | |
65 | int dir_block_size; | |
66 | ||
67 | /* | |
68 | * This structure is used for keeping track of how much resources have | |
69 | * been used for a particular pass of e2fsck. | |
70 | */ | |
71 | struct resource_track { | |
72 | struct timeval time_start; | |
73 | struct timeval user_start; | |
74 | struct timeval system_start; | |
75 | void *brk_start; | |
76 | }; | |
77 | ||
78 | /* | |
79 | * Variables | |
80 | */ | |
81 | extern const char * program_name; | |
82 | extern const char * device_name; | |
83 | ||
84 | extern char * inode_used_map; /* Inodes which are in use */ | |
85 | extern char * inode_bad_map; /* Inodes which are bad in some way */ | |
86 | extern char * inode_dir_map; /* Inodes which are directories */ | |
87 | ||
88 | extern char * block_found_map; /* Blocks which are used by an inode */ | |
89 | extern char * block_dup_map; /* Blocks which are used by more than once */ | |
90 | ||
91 | extern const char *fix_msg[2]; /* Fixed or ignored! */ | |
92 | extern const char *clear_msg[2]; /* Cleared or ignored! */ | |
93 | ||
94 | /* Command line options */ | |
95 | extern int nflag; | |
96 | extern int yflag; | |
97 | extern int tflag; | |
98 | extern int preen; | |
99 | extern int verbose; | |
100 | extern int list; | |
101 | extern int debug; | |
102 | extern int force; | |
103 | ||
104 | extern int rwflag; | |
105 | ||
106 | extern int inode_buffer_blocks; | |
107 | extern int process_inode_size; | |
108 | extern int directory_blocks; | |
109 | ||
110 | extern int no_bad_inode; | |
111 | extern int no_lpf; | |
112 | extern int lpf_corrupted; | |
113 | ||
114 | /* Files counts */ | |
115 | extern int fs_directory_count; | |
116 | extern int fs_regular_count; | |
117 | extern int fs_blockdev_count; | |
118 | extern int fs_chardev_count; | |
119 | extern int fs_links_count; | |
120 | extern int fs_symlinks_count; | |
121 | extern int fs_fast_symlinks_count; | |
122 | extern int fs_fifo_count; | |
123 | extern int fs_total_count; | |
124 | extern int fs_badblocks_count; | |
125 | extern int fs_sockets_count; | |
126 | ||
127 | extern struct resource_track global_rtrack; | |
128 | ||
129 | /* | |
130 | * Procedure declarations | |
131 | */ | |
132 | ||
133 | extern void pass1(ext2_filsys fs); | |
134 | extern void pass1_dupblocks(ext2_filsys fs, char *block_buf); | |
135 | extern void pass2(ext2_filsys fs); | |
136 | extern void pass3(ext2_filsys fs); | |
137 | extern void pass4(ext2_filsys fs); | |
138 | extern void pass5(ext2_filsys fs); | |
139 | ||
140 | /* badblock.c */ | |
141 | extern void read_bad_blocks_file(ext2_filsys fs, const char *bad_blocks_file, | |
142 | int replace_bad_blocks); | |
143 | extern void test_disk(ext2_filsys fs); | |
144 | ||
145 | /* dirinfo.c */ | |
146 | extern void add_dir_info(ext2_filsys fs, ino_t ino, ino_t parent, | |
147 | struct ext2_inode *inode); | |
148 | extern struct dir_info *get_dir_info(ino_t ino); | |
149 | extern void free_dir_info(ext2_filsys fs); | |
150 | extern int get_num_dirs(ext2_filsys fs); | |
151 | ||
152 | /* ehandler.c */ | |
153 | extern const char *ehandler_operation(const char *op); | |
154 | extern void ehandler_init(io_channel channel); | |
155 | ||
156 | /* util.c */ | |
157 | extern void *allocate_memory(int size, const char *description); | |
158 | extern int ask(const char * string, int def); | |
159 | extern int ask_yn(const char * string, int def); | |
160 | extern void fatal_error (const char * fmt_string); | |
161 | extern void read_bitmaps(ext2_filsys fs); | |
162 | extern void write_bitmaps(ext2_filsys fs); | |
163 | extern void preenhalt(NOARGS); | |
164 | extern void print_resource_track(struct resource_track *track); | |
165 | extern void init_resource_track(struct resource_track *track); | |
166 | extern int inode_has_valid_blocks(struct ext2_inode *inode); | |
167 | #ifdef MTRACE | |
168 | extern void mtrace_print(char *mesg); | |
169 | #endif | |
170 | ||
171 | #define die(str) fatal_error(str) | |
172 | ||
173 | /* | |
174 | * pass3.c | |
175 | */ | |
176 | extern int reconnect_file(ext2_filsys fs, ino_t inode); |