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