]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blame - e2fsck/e2fsck.h
Many files:
[thirdparty/e2fsprogs.git] / e2fsck / e2fsck.h
CommitLineData
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 */
1e3472c5 45#define E2FSCK_CURRENT_REV 1
f3db3566 46
3839e657
TT
47/*
48 * Inode count arrays
49 */
21c84b71
TT
50extern ext2_icount_t inode_count;
51extern ext2_icount_t inode_link_info;
3839e657
TT
52
53/*
54 * The directory information structure; stores directory information
55 * collected in earlier passes, to avoid disk i/o in fetching the
21c84b71 56 * directory information.
3839e657
TT
57 */
58struct 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
3839e657
TT
64/*
65 * This structure is used for keeping track of how much resources have
66 * been used for a particular pass of e2fsck.
67 */
68struct resource_track {
69 struct timeval time_start;
70 struct timeval user_start;
71 struct timeval system_start;
72 void *brk_start;
73};
74
75/*
76 * Variables
77 */
78extern const char * program_name;
79extern const char * device_name;
80
f3db3566
TT
81extern ext2fs_inode_bitmap inode_used_map; /* Inodes which are in use */
82extern ext2fs_inode_bitmap inode_bad_map; /* Inodes which are bad somehow */
83extern ext2fs_inode_bitmap inode_dir_map; /* Inodes which are directories */
21c84b71 84extern ext2fs_inode_bitmap inode_bb_map; /* Inodes which are in bad blocks */
3839e657 85
f3db3566
TT
86extern ext2fs_block_bitmap block_found_map; /* Blocks which are in use */
87extern ext2fs_block_bitmap block_dup_map; /* Blocks which are used by more than once */
521e3685 88extern ext2fs_block_bitmap block_illegal_map; /* Meta-data blocks */
3839e657
TT
89
90extern const char *fix_msg[2]; /* Fixed or ignored! */
91extern const char *clear_msg[2]; /* Cleared or ignored! */
92
f3db3566
TT
93extern int *invalid_inode_bitmap;
94extern int *invalid_block_bitmap;
95extern int *invalid_inode_table;
96extern int restart_e2fsck;
97
3839e657
TT
98/* Command line options */
99extern int nflag;
100extern int yflag;
101extern int tflag;
102extern int preen;
103extern int verbose;
104extern int list;
105extern int debug;
106extern int force;
107
108extern int rwflag;
109
110extern int inode_buffer_blocks;
111extern int process_inode_size;
112extern int directory_blocks;
113
114extern int no_bad_inode;
115extern int no_lpf;
116extern int lpf_corrupted;
117
118/* Files counts */
119extern int fs_directory_count;
120extern int fs_regular_count;
121extern int fs_blockdev_count;
122extern int fs_chardev_count;
123extern int fs_links_count;
124extern int fs_symlinks_count;
125extern int fs_fast_symlinks_count;
126extern int fs_fifo_count;
127extern int fs_total_count;
128extern int fs_badblocks_count;
129extern int fs_sockets_count;
50e1e10f
TT
130extern int fs_ind_count;
131extern int fs_dind_count;
132extern int fs_tind_count;
74becf3c 133extern int fs_fragmented;
3839e657
TT
134
135extern struct resource_track global_rtrack;
136
f3db3566
TT
137extern int invalid_bitmaps;
138
1e3472c5
TT
139/*
140 * For pass1_check_directory and pass1_get_blocks
141 */
142extern ino_t stashed_ino;
143extern struct ext2_inode *stashed_inode;
144
3839e657
TT
145/*
146 * Procedure declarations
147 */
148
149extern void pass1(ext2_filsys fs);
150extern void pass1_dupblocks(ext2_filsys fs, char *block_buf);
151extern void pass2(ext2_filsys fs);
152extern void pass3(ext2_filsys fs);
153extern void pass4(ext2_filsys fs);
154extern void pass5(ext2_filsys fs);
155
1e3472c5
TT
156/* pass1.c */
157extern errcode_t pass1_check_directory(ext2_filsys fs, ino_t ino);
158extern errcode_t pass1_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks);
159extern errcode_t pass1_read_inode(ext2_filsys fs, ino_t ino,
160 struct ext2_inode *inode);
161extern errcode_t pass1_write_inode(ext2_filsys fs, ino_t ino,
162 struct ext2_inode *inode);
163
3839e657
TT
164/* badblock.c */
165extern void read_bad_blocks_file(ext2_filsys fs, const char *bad_blocks_file,
166 int replace_bad_blocks);
167extern void test_disk(ext2_filsys fs);
168
169/* dirinfo.c */
21c84b71 170extern void add_dir_info(ext2_filsys fs, ino_t ino, ino_t parent);
3839e657
TT
171extern struct dir_info *get_dir_info(ino_t ino);
172extern void free_dir_info(ext2_filsys fs);
173extern int get_num_dirs(ext2_filsys fs);
21c84b71 174extern struct dir_info *dir_info_iter(int *control);
3839e657
TT
175
176/* ehandler.c */
177extern const char *ehandler_operation(const char *op);
178extern void ehandler_init(io_channel channel);
179
1e3472c5
TT
180/* swapfs.c */
181void swap_filesys(ext2_filsys fs);
182
3839e657
TT
183/* util.c */
184extern void *allocate_memory(int size, const char *description);
185extern int ask(const char * string, int def);
186extern int ask_yn(const char * string, int def);
187extern void fatal_error (const char * fmt_string);
188extern void read_bitmaps(ext2_filsys fs);
189extern void write_bitmaps(ext2_filsys fs);
50e1e10f 190extern void preenhalt(ext2_filsys fs);
3839e657
TT
191extern void print_resource_track(struct resource_track *track);
192extern void init_resource_track(struct resource_track *track);
193extern int inode_has_valid_blocks(struct ext2_inode *inode);
f3db3566
TT
194extern void e2fsck_read_inode(ext2_filsys fs, unsigned long ino,
195 struct ext2_inode * inode, const char * proc);
196extern void e2fsck_write_inode(ext2_filsys fs, unsigned long ino,
197 struct ext2_inode * inode, const char * proc);
3839e657
TT
198#ifdef MTRACE
199extern void mtrace_print(char *mesg);
200#endif
201
202#define die(str) fatal_error(str)
203
204/*
205 * pass3.c
206 */
207extern int reconnect_file(ext2_filsys fs, ino_t inode);