xref: /freebsd/sbin/fsck_ffs/fsck.h (revision 3cd3900b690d8296094921cec844da3f72d30cbb)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause and BSD-2-Clause
3  *
4  * Copyright (c) 2002 Networks Associates Technology, Inc.
5  * All rights reserved.
6  *
7  * This software was developed for the FreeBSD Project by Marshall
8  * Kirk McKusick and Network Associates Laboratories, the Security
9  * Research Division of Network Associates, Inc. under DARPA/SPAWAR
10  * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
11  * research program.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  * Copyright (c) 1980, 1986, 1993
35  *	The Regents of the University of California.  All rights reserved.
36  *
37  * Redistribution and use in source and binary forms, with or without
38  * modification, are permitted provided that the following conditions
39  * are met:
40  * 1. Redistributions of source code must retain the above copyright
41  *    notice, this list of conditions and the following disclaimer.
42  * 2. Redistributions in binary form must reproduce the above copyright
43  *    notice, this list of conditions and the following disclaimer in the
44  *    documentation and/or other materials provided with the distribution.
45  * 3. Neither the name of the University nor the names of its contributors
46  *    may be used to endorse or promote products derived from this software
47  *    without specific prior written permission.
48  *
49  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
50  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59  * SUCH DAMAGE.
60  */
61 
62 #ifndef _FSCK_H_
63 #define	_FSCK_H_
64 
65 #include <sys/queue.h>
66 
67 #include <signal.h>
68 #include <stdio.h>
69 #include <stdlib.h>
70 #include <unistd.h>
71 #include <libufs.h>
72 
73 #define	MAXDUP		10	/* limit on dup blks (per inode) */
74 #define	MAXBAD		10	/* limit on bad blks (per inode) */
75 #define	MINBUFS		100	/* minimum number of buffers required */
76 #define	INOBUFSIZE	64*1024	/* size of buffer to read inodes in pass1 */
77 #define	ZEROBUFSIZE	(dev_bsize * 128) /* size of zero buffer used by -Z */
78 
79 #define	DIP(dp, field) \
80 	((sblock.fs_magic == FS_UFS1_MAGIC) ? \
81 	(dp)->dp1.field : (dp)->dp2.field)
82 
83 #define DIP_SET(dp, field, val) do { \
84 	if (sblock.fs_magic == FS_UFS1_MAGIC) \
85 		(dp)->dp1.field = (val); \
86 	else \
87 		(dp)->dp2.field = (val); \
88 	} while (0)
89 
90 /*
91  * Each inode on the file system is described by the following structure.
92  * The linkcnt is initially set to the value in the inode. Each time it
93  * is found during the descent in passes 2, 3, and 4 the count is
94  * decremented. Any inodes whose count is non-zero after pass 4 needs to
95  * have its link count adjusted by the value remaining in ino_linkcnt.
96  */
97 struct inostat {
98 	u_char	ino_state;	/* state of inode, see below */
99 	u_char	ino_type:4;	/* type of inode */
100 	u_char	ino_idtype:4;	/* idesc id_type, SNAP or ADDR */
101 	u_short	ino_linkcnt;	/* number of links not found */
102 };
103 /*
104  * Inode states.
105  */
106 #define	USTATE	0x1		/* inode not allocated */
107 #define	FSTATE	0x2		/* inode is file */
108 #define	FZLINK	0x3		/* inode is file with a link count of zero */
109 #define	DSTATE	0x4		/* inode is directory */
110 #define	DZLINK	0x5		/* inode is directory with a zero link count */
111 #define	DFOUND	0x6		/* directory found during descent */
112 /*     		0x7		   UNUSED - see S_IS_DVALID() definition */
113 #define	DCLEAR	0x8		/* directory is to be cleared */
114 #define	FCLEAR	0x9		/* file is to be cleared */
115 /*     	DUNFOUND === (state == DSTATE || state == DZLINK) */
116 #define	S_IS_DUNFOUND(state)	(((state) & ~0x1) == DSTATE)
117 /*     	DVALID   === (state == DSTATE || state == DZLINK || state == DFOUND) */
118 #define	S_IS_DVALID(state)	(((state) & ~0x3) == DSTATE)
119 #define	INO_IS_DUNFOUND(ino)	S_IS_DUNFOUND(inoinfo(ino)->ino_state)
120 #define	INO_IS_DVALID(ino)	S_IS_DVALID(inoinfo(ino)->ino_state)
121 /*
122  * Inode state information is contained on per cylinder group lists
123  * which are described by the following structure.
124  */
125 extern struct inostatlist {
126 	long	il_numalloced;	/* number of inodes allocated in this cg */
127 	struct inostat *il_stat;/* inostat info for this cylinder group */
128 } *inostathead;
129 
130 /*
131  * Structure to reference a dinode.
132  */
133 struct inode {
134 	struct bufarea *i_bp;	/* buffer containing the dinode */
135 	union dinode *i_dp;	/* pointer to dinode in buffer */
136 	ino_t i_number;		/* inode number */
137 };
138 
139 /*
140  * Size of hash tables
141  */
142 #define	HASHSIZE	2048
143 #define	HASH(x)		((x * 2654435761) & (HASHSIZE - 1))
144 
145 /*
146  * buffer cache structure.
147  */
148 struct bufarea {
149 	TAILQ_ENTRY(bufarea) b_list;		/* LRU buffer queue */
150 	LIST_ENTRY(bufarea) b_hash;		/* hash list */
151 	ufs2_daddr_t b_bno;			/* disk block number */
152 	int b_size;				/* size of I/O */
153 	int b_errs;				/* I/O error */
154 	int b_flags;				/* B_ flags below */
155 	int b_type;				/* BT_ type below */
156 	int b_refcnt;				/* ref count of users */
157 	uint64_t b_index;			/* for BT_LEVEL, ptr index */
158 						/* for BT_INODES, first inum */
159 	union {
160 		char *b_buf;			/* buffer space */
161 		ufs1_daddr_t *b_indir1;		/* UFS1 indirect block */
162 		ufs2_daddr_t *b_indir2;		/* UFS2 indirect block */
163 		struct fs *b_fs;		/* super block */
164 		struct cg *b_cg;		/* cylinder group */
165 		struct ufs1_dinode *b_dinode1;	/* UFS1 inode block */
166 		struct ufs2_dinode *b_dinode2;	/* UFS2 inode block */
167 	} b_un;
168 };
169 
170 #define	IBLK(bp, i) \
171 	((sblock.fs_magic == FS_UFS1_MAGIC) ? \
172 	(bp)->b_un.b_indir1[i] : (bp)->b_un.b_indir2[i])
173 
174 #define IBLK_SET(bp, i, val) do { \
175 	if (sblock.fs_magic == FS_UFS1_MAGIC) \
176 		(bp)->b_un.b_indir1[i] = (val); \
177 	else \
178 		(bp)->b_un.b_indir2[i] = (val); \
179 	} while (0)
180 
181 /*
182  * Buffer flags
183  */
184 #define	B_DIRTY 	0x00000001	/* Buffer is dirty */
185 /*
186  * Type of data in buffer
187  */
188 #define	BT_UNKNOWN 	 0	/* Buffer type is unknown */
189 #define	BT_SUPERBLK 	 1	/* Buffer holds a superblock */
190 #define	BT_CYLGRP 	 2	/* Buffer holds a cylinder group map */
191 #define	BT_LEVEL1 	 3	/* Buffer holds single level indirect */
192 #define	BT_LEVEL2 	 4	/* Buffer holds double level indirect */
193 #define	BT_LEVEL3 	 5	/* Buffer holds triple level indirect */
194 #define	BT_EXTATTR 	 6	/* Buffer holds external attribute data */
195 #define	BT_INODES 	 7	/* Buffer holds inodes */
196 #define	BT_DIRDATA 	 8	/* Buffer holds directory data */
197 #define	BT_DATA	 	 9	/* Buffer holds user data */
198 #define BT_NUMBUFTYPES	10
199 #define BT_NAMES {			\
200 	"unknown",			\
201 	"Superblock",			\
202 	"Cylinder Group",		\
203 	"Single Level Indirect",	\
204 	"Double Level Indirect",	\
205 	"Triple Level Indirect",	\
206 	"External Attribute",		\
207 	"Inode Block",			\
208 	"Directory Contents",		\
209 	"User Data" }
210 extern char *buftype[];
211 #define BT_BUFTYPE(type) \
212 	type < BT_NUMBUFTYPES ? buftype[type] : buftype[BT_UNKNOWN]
213 extern long readcnt[BT_NUMBUFTYPES];
214 extern long totalreadcnt[BT_NUMBUFTYPES];
215 extern struct timespec readtime[BT_NUMBUFTYPES];
216 extern struct timespec totalreadtime[BT_NUMBUFTYPES];
217 extern struct timespec startprog;
218 
219 extern struct bufarea *icachebp;	/* inode cache buffer */
220 extern struct bufarea sblk;		/* file system superblock */
221 extern struct bufarea *pdirbp;		/* current directory contents */
222 
223 #define	dirty(bp) do { \
224 	if (fswritefd < 0) \
225 		pfatal("SETTING DIRTY FLAG IN READ_ONLY MODE\n"); \
226 	else \
227 		(bp)->b_flags |= B_DIRTY; \
228 } while (0)
229 #define	initbarea(bp, type) do { \
230 	(bp)->b_bno = (ufs2_daddr_t)-4; \
231 	(bp)->b_size = 0; \
232 	(bp)->b_errs = 0; \
233 	(bp)->b_flags = 0; \
234 	(bp)->b_type = type; \
235 	(bp)->b_refcnt = 0; \
236 	(bp)->b_index = 0; \
237 } while (0)
238 
239 #define	sbdirty()	dirty(&sblk)
240 #define	sblock		(*sblk.b_un.b_fs)
241 
242 enum fixstate {DONTKNOW, NOFIX, FIX, IGNORE};
243 extern ino_t cursnapshot;
244 
245 struct inodesc {
246 	enum fixstate id_fix;	/* policy on fixing errors */
247 	int (*id_func)(struct inodesc *);
248 				/* function to be applied to blocks of inode */
249 	struct bufarea *id_bp;	/* ckinode: buffer with indirect pointers */
250 	union dinode *id_dp;	/* ckinode: dinode being traversed */
251 	ino_t id_number;	/* inode number described */
252 	ino_t id_parent;	/* for DATA nodes, their parent */
253 	ufs_lbn_t id_lbn;	/* logical block number of current block */
254 	ufs2_daddr_t id_blkno;	/* current block number being examined */
255 	int id_level;		/* level of indirection of this block */
256 	int id_numfrags;	/* number of frags contained in block */
257 	ufs_lbn_t id_lballoc;	/* pass1: last LBN that is allocated */
258 	off_t id_filesize;	/* for DATA nodes, the size of the directory */
259 	ufs2_daddr_t id_entryno;/* for DATA nodes, current entry number */
260 	int id_loc;		/* for DATA nodes, current location in dir */
261 	struct direct *id_dirp;	/* for DATA nodes, ptr to current entry */
262 	char *id_name;		/* for DATA nodes, name to find or enter */
263 	char id_type;		/* type of descriptor, DATA, ADDR, or SNAP */
264 };
265 /* file types */
266 #define	DATA	1	/* a directory */
267 #define	SNAP	2	/* a snapshot */
268 #define	ADDR	3	/* anything but a directory or a snapshot */
269 
270 /*
271  * Linked list of duplicate blocks.
272  *
273  * The list is composed of two parts. The first part of the
274  * list (from duplist through the node pointed to by muldup)
275  * contains a single copy of each duplicate block that has been
276  * found. The second part of the list (from muldup to the end)
277  * contains duplicate blocks that have been found more than once.
278  * To check if a block has been found as a duplicate it is only
279  * necessary to search from duplist through muldup. To find the
280  * total number of times that a block has been found as a duplicate
281  * the entire list must be searched for occurrences of the block
282  * in question. The following diagram shows a sample list where
283  * w (found twice), x (found once), y (found three times), and z
284  * (found once) are duplicate block numbers:
285  *
286  *    w -> y -> x -> z -> y -> w -> y
287  *    ^		     ^
288  *    |		     |
289  * duplist	  muldup
290  */
291 struct dups {
292 	struct dups *next;
293 	ufs2_daddr_t dup;
294 };
295 extern struct dups *duplist;	/* head of dup list */
296 extern struct dups *muldup;	/* end of unique duplicate dup block numbers */
297 
298 /*
299  * Inode cache data structures.
300  */
301 struct inoinfo {
302 	SLIST_ENTRY(inoinfo) i_hash;	/* hash list */
303 	ino_t	i_number;		/* inode number of this entry */
304 	ino_t	i_parent;		/* inode number of parent */
305 	ino_t	i_dotdot;		/* inode number of `..' */
306 	size_t	i_isize;		/* size of inode */
307 	u_int	i_depth;		/* depth of directory from root */
308 	u_int	i_flags;		/* flags, see below */
309 	u_int	i_numblks;		/* size of block array in bytes */
310 	ufs2_daddr_t i_blks[1];		/* actually longer */
311 };
312 extern SLIST_HEAD(inohash, inoinfo) *inphash;
313 extern struct inoinfo **inpsort;
314 /*
315  * flags for struct inoinfo
316  */
317 #define INFO_NEW	0x0000001	/* replaced broken directory */
318 
319 extern long dirhash, inplast;
320 extern unsigned long numdirs, listmax;
321 extern long countdirs;		/* number of directories we actually found */
322 
323 #define MIBSIZE	3		/* size of fsck sysctl MIBs */
324 extern int adjblkcnt[MIBSIZE];	/* MIB cmd to adjust inode block count */
325 extern int adjrefcnt[MIBSIZE];	/* MIB cmd to adjust inode reference count */
326 extern int adjndir[MIBSIZE];	/* MIB cmd to adjust number of directories */
327 extern int adjnbfree[MIBSIZE];	/* MIB cmd to adjust number of free blocks */
328 extern int adjnifree[MIBSIZE];	/* MIB cmd to adjust number of free inodes */
329 extern int adjnffree[MIBSIZE];	/* MIB cmd to adjust number of free frags */
330 extern int adjnumclusters[MIBSIZE]; /* MIB cmd adjust number of free clusters */
331 extern int adjdepth[MIBSIZE];	/* MIB cmd to adjust directory depth count */
332 extern int freefiles[MIBSIZE];	/* MIB cmd to free a set of files */
333 extern int freedirs[MIBSIZE];	/* MIB cmd to free a set of directories */
334 extern int freeblks[MIBSIZE];	/* MIB cmd to free a set of data blocks */
335 extern int setsize[MIBSIZE];	/* MIB cmd to set inode size */
336 extern struct fsck_cmd cmd;	/* sysctl file system update commands */
337 
338 extern int bkgrdcheck;		/* determine if background check is possible */
339 extern int bkgrdsumadj;		/* whether the kernel has the ability to adjust
340 				   the superblock summary fields */
341 extern off_t bflag;		/* location of alternate super block */
342 extern int bkgrdflag;		/* use a snapshot to run on an active system */
343 extern char *blockmap;		/* ptr to primary blk allocation map */
344 extern char *cdevname;		/* name of device being checked */
345 extern int cgheader_corrupt;	/* one or more CG headers are corrupt */
346 extern char ckclean;		/* only do work if not cleanly unmounted */
347 extern int ckhashadd;		/* check hashes to be added */
348 extern char *copybuf;		/* buffer to copy snapshot blocks */
349 extern int cvtlevel;		/* convert to newer file system format */
350 extern long dev_bsize;		/* computed value of DEV_BSIZE */
351 extern u_int real_dev_bsize;	/* actual disk sector size, not overridden */
352 extern int debug;		/* output debugging info */
353 extern int Eflag;		/* delete empty data blocks */
354 extern int fsmodified;		/* 1 => write done to file system */
355 extern int fsreadfd;		/* file descriptor for reading file system */
356 extern int fswritefd;		/* file descriptor for writing file system */
357 extern char havesb;		/* superblock has been read */
358 extern int inoopt;		/* trim out unused inodes */
359 extern ino_t lfdir;		/* lost & found directory inode number */
360 extern int lfmode;		/* lost & found directory creation mode */
361 extern const char *lfname; 	/* lost & found directory name */
362 extern ufs2_daddr_t maxfsblock; /* number of blocks in the file system */
363 extern ino_t maxino;		/* number of inodes in file system */
364 extern ufs2_daddr_t n_blks;	/* number of blocks in use */
365 extern ino_t n_files;		/* number of files in use */
366 extern char nflag;		/* assume a no response */
367 extern char preen;		/* just fix normal inconsistencies */
368 extern char rerun;		/* rerun fsck. Only used in non-preen mode */
369 extern char resolved;		/* cleared if unresolved changes => not clean */
370 extern int returntosingle;	/* 1 => return to single user mode on exit */
371 extern long secsize;		/* actual disk sector size */
372 extern char skipclean;		/* skip clean file systems if preening */
373 extern int snapcnt;		/* number of active snapshots */
374 extern struct inode snaplist[FSMAXSNAP + 1]; /* list of active snapshots */
375 extern int sujrecovery;		/* 1 => doing check using the journal */
376 extern int surrender;		/* Give up if reads fail */
377 extern char usedsoftdep;	/* just fix soft dependency inconsistencies */
378 extern int wantrestart;		/* Restart fsck on early termination */
379 extern char yflag;		/* assume a yes response */
380 extern int zflag;		/* zero unused directory space */
381 extern int Zflag;		/* zero empty data blocks */
382 
383 extern volatile sig_atomic_t	got_siginfo;	/* received a SIGINFO */
384 extern volatile sig_atomic_t	got_sigalarm;	/* received a SIGALRM */
385 
386 #define	clearinode(dp) \
387 	if (sblock.fs_magic == FS_UFS1_MAGIC) { \
388 		(dp)->dp1 = zino.dp1; \
389 	} else { \
390 		(dp)->dp2 = zino.dp2; \
391 	}
392 extern union dinode zino;
393 
394 #define	setbmap(blkno)	setbit(blockmap, blkno)
395 #define	testbmap(blkno)	isset(blockmap, blkno)
396 #define	clrbmap(blkno)	clrbit(blockmap, blkno)
397 
398 #define	STOP	0x01
399 #define	SKIP	0x02
400 #define	KEEPON	0x04
401 #define	ALTERED	0x08
402 #define	FOUND	0x10
403 
404 #define	EEXIT	8		/* Standard error exit. */
405 #define	ERERUN	16		/* fsck needs to be re-run. */
406 #define	ERESTART -1
407 
408 int flushentry(void);
409 /*
410  * Wrapper for malloc() that flushes the cylinder group cache to try
411  * to get space.
412  */
413 static inline void*
Malloc(size_t size)414 Malloc(size_t size)
415 {
416 	void *retval;
417 
418 	while ((retval = malloc(size)) == NULL)
419 		if (flushentry() == 0)
420 			break;
421 	return (retval);
422 }
423 /*
424  * Allocate a block of memory to be used as an I/O buffer.
425  * Ensure that the buffer is aligned to the I/O subsystem requirements.
426  */
427 static inline void*
Balloc(size_t size)428 Balloc(size_t size)
429 {
430 	void *retval;
431 
432 	while ((retval = aligned_alloc(LIBUFS_BUFALIGN, size)) == NULL)
433 		if (flushentry() == 0)
434 			break;
435 	return (retval);
436 }
437 
438 /*
439  * Wrapper for calloc() that flushes the cylinder group cache to try
440  * to get space.
441  */
442 static inline void*
Calloc(size_t cnt,size_t size)443 Calloc(size_t cnt, size_t size)
444 {
445 	void *retval;
446 
447 	while ((retval = calloc(cnt, size)) == NULL)
448 		if (flushentry() == 0)
449 			break;
450 	return (retval);
451 }
452 
453 struct fstab;
454 
455 
456 void		adjust(struct inodesc *, int lcnt);
457 void		alarmhandler(int sig);
458 ufs2_daddr_t	allocblk(long cg, long frags, ufs2_daddr_t (*checkblkavail)
459 		    (ufs2_daddr_t blkno, long frags));
460 ino_t		allocdir(ino_t parent, ino_t request, int mode);
461 ino_t		allocino(ino_t request, int type);
462 void		binval(struct bufarea *);
463 void		blkerror(ino_t ino, const char *type, ufs2_daddr_t blk);
464 char	       *blockcheck(char *name);
465 int		blread(int fd, char *buf, ufs2_daddr_t blk, long size);
466 void		bufinit(void);
467 void		blwrite(int fd, char *buf, ufs2_daddr_t blk, ssize_t size);
468 void		blerase(int fd, ufs2_daddr_t blk, long size);
469 void		blzero(int fd, ufs2_daddr_t blk, long size);
470 void		brelse(struct bufarea *);
471 struct inoinfo *cacheino(union dinode *dp, ino_t inumber);
472 void		catch(int);
473 void		catchquit(int);
474 void		cgdirty(struct bufarea *);
475 struct bufarea *cglookup(int cg);
476 int		changeino(ino_t dir, const char *name, ino_t newnum, int depth);
477 void		check_blkcnt(struct inode *ip);
478 int		check_cgmagic(int cg, struct bufarea *cgbp);
479 void		rebuild_cg(int cg, struct bufarea *cgbp);
480 void		check_dirdepth(struct inoinfo *inp);
481 int		chkfilesize(mode_t mode, u_int64_t filesize);
482 int		chkrange(ufs2_daddr_t blk, int cnt);
483 void		ckfini(int markclean);
484 int		ckinode(union dinode *dp, struct inodesc *);
485 void		clri(struct inodesc *, const char *type, int flag);
486 int		clearentry(struct inodesc *);
487 void		copyonwrite(struct fs *, struct bufarea *,
488 		    ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t, long));
489 void		direrror(ino_t ino, const char *errmesg);
490 int		dirscan(struct inodesc *);
491 int		dofix(struct inodesc *, const char *msg);
492 int		eascan(struct inodesc *, struct ufs2_dinode *dp);
493 void		fileerror(ino_t cwd, ino_t ino, const char *errmesg);
494 void		finalIOstats(void);
495 int		findino(struct inodesc *);
496 int		findname(struct inodesc *);
497 void		flush(int fd, struct bufarea *bp);
498 int		freeblock(struct inodesc *);
499 void		freedirino(ino_t ino, ino_t parent);
500 void		freeino(ino_t ino);
501 void		freeinodebuf(void);
502 void		fsckinit(void);
503 void		fsutilinit(void);
504 int		ftypeok(union dinode *dp);
505 void		getblk(struct bufarea *bp, ufs2_daddr_t blk, long size);
506 struct bufarea *getdatablk(ufs2_daddr_t blkno, long size, int type);
507 struct inoinfo *getinoinfo(ino_t inumber);
508 union dinode   *getnextinode(ino_t inumber, int rebuiltcg);
509 void		getpathname(char *namebuf, ino_t curdir, ino_t ino);
510 void		ginode(ino_t, struct inode *);
511 void		gjournal_check(const char *filesys);
512 void		infohandler(int sig);
513 void		irelse(struct inode *);
514 ufs2_daddr_t	ino_blkatoff(union dinode *, ino_t, ufs_lbn_t, int *,
515 		    struct bufarea **);
516 void		inocleanup(void);
517 void		inodirty(struct inode *);
518 struct inostat *inoinfo(ino_t inum);
519 void		IOstats(char *what);
520 int		linkup(ino_t orphan, ino_t parentdir, char *name);
521 int		makeentry(ino_t parent, ino_t ino, const char *name);
522 int		openfilesys(char *dev);
523 void		panic(const char *fmt, ...) __printflike(1, 2);
524 void		pass1(void);
525 void		pass1b(void);
526 int		pass1check(struct inodesc *);
527 void		pass2(void);
528 void		pass3(void);
529 void		pass4(void);
530 void		pass5(void);
531 void		pfatal(const char *fmt, ...) __printflike(1, 2);
532 void		propagate(void);
533 void		prtbuf(struct bufarea *, const char *, ...) __printflike(2, 3);
534 void		prtinode(struct inode *);
535 void		pwarn(const char *fmt, ...) __printflike(1, 2);
536 int		readsb(void);
537 int		removecachedino(ino_t);
538 int		reply(const char *question);
539 void		rwerror(const char *mesg, ufs2_daddr_t blk);
540 void		sblock_init(void);
541 void		setinodebuf(int, ino_t);
542 int		setup(char *dev);
543 int		snapblkfree(struct fs *, ufs2_daddr_t, long, ino_t,
544 		    ufs2_daddr_t (*)(ufs2_daddr_t, long));
545 void		snapremove(ino_t);
546 void		snapflush(ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t, long));
547 ufs2_daddr_t	std_checkblkavail(ufs2_daddr_t blkno, long frags);
548 ufs2_daddr_t	suj_checkblkavail(ufs2_daddr_t, long);
549 int		suj_check(const char *filesys);
550 void		update_maps(struct cg *, struct cg*, int);
551 
552 #endif	/* !_FSCK_H_ */
553