xref: /illumos-gate/usr/src/cmd/fs.d/ufs/fsck/fsck.h (revision 16b76d3cb933ff92018a2a75594449010192eacb)
1 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
2 /*	  All Rights Reserved	*/
3 
4 /*
5  * Copyright (c) 1980, 1986, 1990 The Regents of the University of California.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms are permitted
9  * provided that: (1) source distributions retain this entire copyright
10  * notice and comment, and (2) distributions including binaries display
11  * the following acknowledgement:  ``This product includes software
12  * developed by the University of California, Berkeley and its contributors''
13  * in the documentation or other materials provided with the distribution
14  * and in all advertising materials mentioning features or use of this
15  * software. Neither the name of the University nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21  */
22 
23 /*
24  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef	_FSCK_FSCK_H
29 #define	_FSCK_FSCK_H
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <stdio.h>
36 #include <stdarg.h>
37 #include <search.h>
38 #include <sys/param.h>
39 #include <sys/types.h>
40 #include <sys/mnttab.h>
41 #include <sys/vfstab.h>
42 #include <sys/fs/ufs_fs.h>
43 #include <sys/fs/ufs_inode.h>
44 
45 #define	MAXDUP		10	/* limit on dup blks (per inode) */
46 #define	MAXBAD		10	/* limit on bad blks (per inode) */
47 #define	MAXBUFSPACE	40*1024 /* initial space to allocate to buffers */
48 #define	INOBUFSIZE	56*1024	/* size of buffer to read inodes in pass1 */
49 
50 #ifndef BUFSIZ
51 #define	BUFSIZ MAXPATHLEN
52 #endif
53 
54 /*
55  * Inode states in statemap[].
56  */
57 #define	USTATE	0x01		/* inode not allocated */
58 #define	FSTATE	0x02		/* inode is file */
59 #define	DSTATE	0x04		/* inode is directory */
60 #define	SSTATE	0x08		/* inode is a shadow/acl */
61 #define	STMASK	0x0f		/* pick off the basic state/type */
62 
63 /* flags OR'd into the above */
64 #define	INZLINK  0x0010		/* inode has zero links */
65 #define	INFOUND  0x0020		/* inode was found during descent */
66 #define	INCLEAR  0x0040		/* inode is to be cleared */
67 #define	INORPHAN 0x0080		/* inode is a known orphan (pass3 only) */
68 #define	INDELAYD 0x0200		/* link count update delayed */
69 #define	INMASK   0xfff0		/* pick off the modifiers */
70 
71 #define	FZLINK	(FSTATE | INZLINK)
72 #define	DZLINK	(DSTATE | INZLINK)
73 #define	SZLINK	(SSTATE | INZLINK)
74 
75 #define	DFOUND	(DSTATE | INFOUND)
76 
77 #define	DCLEAR	(DSTATE | INCLEAR)
78 #define	FCLEAR	(FSTATE | INCLEAR)
79 #define	SCLEAR	(SSTATE | INCLEAR)
80 
81 /*
82  * These tests depend on the state/type defines above not overlapping bits.
83  *
84  *	DUNFOUND === (state == DSTATE || state == DZLINK)
85  *          INCLEAR is irrelevant to the determination of
86  *          connectedness, so it's not included in this test.
87  *
88  *	DVALID   === (state == DSTATE || state == DZLINK || state == DFOUND)
89  */
90 #define	S_IS_DUNFOUND(state)	(((state) & (DSTATE | INZLINK)) \
91 				== (state))
92 #define	S_IS_DVALID(state)	(((state) & (DSTATE | INZLINK | INFOUND | \
93 				INORPHAN)) == (state))
94 #define	S_IS_ZLINK(state)	(((state) & INZLINK) != 0)
95 #define	INO_IS_DUNFOUND(ino)	S_IS_DUNFOUND(statemap[ino])
96 #define	INO_IS_DVALID(ino)	S_IS_DVALID(statemap[ino])
97 
98 /*
99  * buffer cache structure.
100  */
101 struct bufarea {
102 	struct bufarea	*b_next;		/* free list queue */
103 	struct bufarea	*b_prev;		/* free list queue */
104 	diskaddr_t	b_bno;			/* physical sector number */
105 	int	b_size;
106 	int	b_errs;
107 	int	b_flags;
108 	int	b_cnt;				/* reference cnt */
109 	union {
110 		char	*b_buf;			/* buffer space */
111 		daddr32_t	*b_indir;	/* indirect block */
112 		struct	fs *b_fs;		/* super block */
113 		struct	cg *b_cg;		/* cylinder group */
114 		struct	dinode *b_dinode;	/* inode block */
115 	} b_un;
116 	char	b_dirty;
117 };
118 
119 #define	B_INUSE 1
120 
121 #define	MINBUFS		5	/* minimum number of buffers required */
122 extern struct bufarea sblk;	/* file system superblock */
123 extern struct bufarea cgblk;	/* cylinder group blocks */
124 extern struct bufarea *pbp;	/* pointer to inode data in buffer pool */
125 extern struct bufarea *pdirbp;	/* pointer to directory data in buffer pool */
126 
127 #define	sbdirty()	dirty(&sblk)
128 #define	cgdirty()	dirty(&cgblk)
129 #define	sblock		(*sblk.b_un.b_fs)
130 #define	cgrp		(*cgblk.b_un.b_cg)
131 
132 /*
133  * inodesc.id_fix values.  See inode.c for a description of their usage.
134  */
135 enum fixstate {
136 	DONTKNOW, NOFIX, FIX, IGNORE
137 };
138 
139 /*
140  * Tells truncino() whether or not to attempt to update the parent
141  * directory's link count.  Also, TI_NODUP flags when we're discarding
142  * fragments that are beyond the original end of the file, and so
143  * should not be considered duplicate-claim candidates.
144  */
145 #define	TI_NOPARENT	0x0001	/* leave parent's di_nlink alone */
146 #define	TI_PARENT	0x0002	/* update parent's di_nlink */
147 #define	TI_NODUP	0x0004	/* not a dup candidate */
148 
149 /*
150  * Modes for ckinode() and ckinode_common().
151  *
152  * CKI_TRAVERSE is the common case, and requests a traditional
153  * traversal of blocks or directory entries.
154  *
155  * CKI_TRUNCATE indicates that we're truncating the file, and that any
156  * block indices beyond the end of the target length should be cleared
157  * after the callback has returned (i.e., this is a superset of
158  * CKI_TRAVERSE).  idesc->id_truncto is the first logical block number
159  * to clear.  If it is less than zero, then the traversal will be
160  * equivalent to a simple CKI_TRAVERSE.
161  */
162 enum cki_action { CKI_TRAVERSE, CKI_TRUNCATE };
163 
164 /*
165  * The general definition of an ino_t is an unsigned quantity.
166  * However, the on-disk version is an int32_t, which is signed.
167  * Since we really want to be able to detect wrapped-around
168  * inode numbers and such, we'll use something that's compatible
169  * with what's on disk since that's the only context that really
170  * matters.  If an int32_t is found not to be sufficiently large,
171  * this will make it much easier to change later.
172  *
173  * Note that there is one unsigned inode field in the on-disk
174  * inode, ic_oeftflag.  Since all other inode fields are signed,
175  * no legitimate inode number can be put into ic_oeftflag that
176  * would overflow into the high bit.  Essentially, it should
177  * actually be declared as int32_t just like all the others, and
178  * we're going to pretend that it was.
179  *
180  * None of the routines that we use in ufs_subr.c do anything with
181  * inode numbers.  If that changes, then great care will be needed
182  * to deal with the differences in definition of ino_t and fsck_ino_t.
183  * Lint is your friend.
184  */
185 typedef int32_t		fsck_ino_t;
186 
187 /*
188  * See the full discussion of the interactions between struct inodesc
189  * and ckinode() in inode.c
190  */
191 struct inodesc {
192 	enum fixstate id_fix;	/* policy on fixing errors */
193 	int (*id_func)(struct inodesc *);
194 				/* function to be applied to blocks of inode */
195 	fsck_ino_t id_number;	/* inode number described */
196 	fsck_ino_t id_parent;	/* for DATA nodes, their parent */
197 				/* also used for extra (*id_func) parameter */
198 				/* and return values */
199 	daddr32_t id_lbn;	/* logical fragment number of current block */
200 	daddr32_t id_blkno;	/* physical fragment number being examined */
201 	int id_numfrags;	/* number of frags contained in block */
202 	daddr32_t id_truncto;	/* # blocks to truncate to, -1 for no trunc. */
203 	offset_t id_filesize;	/* for DATA nodes, the size of the directory */
204 	uint_t id_loc;		/* for DATA nodes, current location in dir */
205 	daddr32_t id_entryno;	/* for DATA nodes, current dir entry number */
206 	daddr32_t id_firsthole;	/* for DATA inode, logical block that is */
207 				/* zero but shouldn't be, -1 for no holes */
208 	struct direct *id_dirp;	/* for DATA nodes, ptr to current entry */
209 	caddr_t id_name;	/* for DATA nodes, name to find or enter */
210 	char id_type;		/* type of descriptor, DATA or ADDR */
211 };
212 
213 /* file types (0 is reserved for catching bugs) */
214 #define	DATA	1	/* a directory */
215 #define	ACL	2	/* an acl/shadow */
216 #define	ADDR	3	/* anything but a directory or an acl/shadow */
217 
218 /*
219  * OR'd flags for find_dup_ref()'s mode argument
220  */
221 #define	DB_CREATE	0x01	/* if dup record found, make one */
222 #define	DB_INCR		0x02	/* increment block's reference count */
223 #define	DB_DECR		0x04	/* decrement block's reference count */
224 
225 /*
226  * Cache data structures
227  */
228 struct inoinfo {
229 	struct inoinfo	*i_nextlist;	/* next inode/acl cache entry */
230 	fsck_ino_t	i_number;	/* inode number of this entry */
231 	fsck_ino_t	i_parent;	/* inode number of parent */
232 	fsck_ino_t	i_dotdot;	/* inode number of .. */
233 	fsck_ino_t	i_extattr;	/* inode of hidden attr dir */
234 	offset_t	i_isize;	/* size of inode */
235 	size_t		i_blkssize;	/* size of block array in bytes */
236 	daddr32_t	i_blks[1];	/* actually longer */
237 };
238 
239 /*
240  * Inode cache
241  */
242 extern struct inoinfo **inphead, **inpsort;
243 extern int64_t numdirs, listmax, inplast;
244 
245 /*
246  * ACL cache
247  */
248 extern struct inoinfo **aclphead, **aclpsort;
249 extern int64_t numacls, aclmax, aclplast;
250 
251 /*
252  * Tree of directories we haven't reconnected or cleared.  Any
253  * dir inode that linkup() fails on gets added, any that clri()
254  * succeeds on gets removed.  If there are any left at the end of
255  * pass four, then we have a user-forced corrupt filesystem, and
256  * need to set iscorrupt.
257  *
258  * Elements are fsck_ino_t instances (not pointers).
259  */
260 extern void *limbo_dirs;
261 
262 /*
263  * Number of directories we actually found in the filesystem,
264  * as opposed to how many the superblock claims there are.
265  */
266 extern fsck_ino_t countdirs;
267 
268 /*
269  * shadowclients and shadowclientinfo are structures for keeping track of
270  * shadow inodes that exist, and which regular inodes use them (i.e. are
271  * their clients).
272  */
273 
274 struct shadowclients {
275 	fsck_ino_t *client;	/* an array of inode numbers */
276 	int nclients; /* how many inodes in the array are in use (valid) */
277 	struct shadowclients *next; /* link to more client inode numbers */
278 };
279 struct shadowclientinfo {
280 	fsck_ino_t shadow;	/* the shadow inode that this info is for */
281 	int totalClients;	/* how many inodes total refer to this */
282 	struct shadowclients *clients; /* a linked list of wads of clients */
283 	struct shadowclientinfo *next; /* link to the next shadow inode */
284 };
285 /* global pointer to this shadow/client information */
286 extern struct shadowclientinfo *shadowclientinfo;
287 extern struct shadowclientinfo *attrclientinfo;
288 
289 /*
290  * In ufs_inode.h ifdef _KERNEL, this is defined as `/@/'.  However,
291  * to avoid all sorts of potential confusion (you can't actually use
292  * `foo/@/bar' to get to an attribute), we use something that doesn't
293  * look quite so much like a simple pathname.
294  */
295 #define	XATTR_DIR_NAME	" <xattr> "
296 
297 /*
298  * granularity -- how many client inodes do we make space for at a time
299  * initialized in setup.c;
300  */
301 extern int maxshadowclients;
302 
303 /*
304  * Initialized global variables.
305  */
306 extern caddr_t lfname;
307 
308 /*
309  * Unitialized globals.
310  */
311 extern char	*devname;	/* name of device being checked */
312 extern size_t	dev_bsize;	/* computed value of DEV_BSIZE */
313 extern int	secsize;	/* actual disk sector size */
314 extern char	nflag;		/* assume a no response */
315 extern char	yflag;		/* assume a yes response */
316 extern daddr32_t	bflag;	/* location of alternate super block */
317 extern int	debug;		/* output debugging info */
318 extern int	rflag;		/* check raw file systems */
319 extern int	fflag;		/* check regardless of clean flag (force) */
320 extern int	mflag;		/* sanity check only */
321 extern int	verbose;	/* be chatty */
322 extern char	preen;		/* just fix normal inconsistencies */
323 extern char	mountedfs;	/* checking mounted device */
324 extern int	exitstat;	/* exit status (see EX* defines below) */
325 extern char	hotroot;	/* checking root device */
326 extern char	rerun;		/* rerun fsck. Only used in non-preen mode */
327 extern int	interrupted;	/* 1 => exit EXSIGNAL on exit */
328 extern char	havesb;		/* superblock has been read */
329 extern int	fsmodified;	/* 1 => write done to file system */
330 extern int	fsreadfd;	/* file descriptor for reading file system */
331 extern int	fswritefd;	/* file descriptor for writing file system */
332 extern int	iscorrupt;	/* known to be corrupt/inconsistent */
333 				/* -1 means mark clean so user can mount+fix */
334 extern int	isdirty;	/* 1 => write pending to file system */
335 
336 extern int	islog;		/* logging file system */
337 extern int	islogok;	/* log is okay */
338 
339 extern int	errorlocked;	/* set => mounted fs has been error-locked */
340 				/* implies fflag "force check flag" */
341 extern char	*elock_combuf;	/* error lock comment buffer */
342 extern char	*elock_mountp;	/* mount point; used to unlock error-lock */
343 extern int	pid;		/* fsck's process id (put in lockfs comment) */
344 extern int	mountfd;	/* fd of mount point */
345 
346 extern daddr32_t maxfsblock;	/* number of blocks in the file system */
347 extern uint_t	largefile_count; /* global largefile counter */
348 extern char	*mount_point;	/* if mounted, this is where */
349 extern char	*blockmap;	/* ptr to primary blk allocation map */
350 extern fsck_ino_t	maxino;	/* number of inodes in file system */
351 extern fsck_ino_t	lastino; /* last inode in use */
352 extern ushort_t *statemap;	/* ptr to inode state table */
353 extern short	*lncntp;	/* ptr to link count table */
354 
355 extern fsck_ino_t	lfdir;	/* lost & found directory inode number */
356 extern int	overflowed_lf;	/* tried to wrap lost & found's link count */
357 extern int	reattached_dir;	/* reconnected at least one directory */
358 extern int	broke_dir_link;	/* broke at least one directory hardlink */
359 
360 extern daddr32_t	n_blks;		/* number of blocks in use */
361 extern fsck_ino_t	n_files;	/* number of files in use */
362 
363 #define	clearinode(dp)	{ \
364 	*(dp) = zino; \
365 }
366 extern struct	dinode zino;
367 
368 #define	testbmap(blkno)	isset(blockmap, blkno)
369 #define	setbmap(blkno)	setbit(blockmap, blkno)
370 #define	clrbmap(blkno)	clrbit(blockmap, blkno)
371 
372 #define	STOP	0x01
373 #define	SKIP	0x02
374 #define	KEEPON	0x04
375 #define	ALTERED	0x08
376 #define	FOUND	0x10
377 
378 /*
379  * Support relatively easy debugging of lncntp[] updates.  This can't
380  * be a function, because of the (_op) step.  Normally, we just do that.
381  */
382 #define	TRACK_LNCNTP(_ino, _op) (_op)
383 
384 /*
385  * See if the net link count for an inode has gone outside
386  * what can be represented on disk.  Returning text as NULL
387  * indicates no.
388  *
389  * Remember that link counts are effectively inverted, so
390  * underflow and overflow are reversed as well.
391  *
392  * This check should be done before modifying the actual link
393  * count.
394  */
395 #define	LINK_RANGE(text, current, offset) { \
396 	int net = ((int)(current)) + ((int)(offset)); \
397 	text = NULL; \
398 	if (net > (MAXLINK)) \
399 		text = "UNDERFLOW"; \
400 	else if (net < -(MAXLINK)) \
401 		text = "OVERFLOW"; \
402 }
403 
404 /*
405  * If LINK_RANGE() indicated a problem, this is the boiler-plate
406  * for dealing with it.  Usage is:
407  *
408  *     LINK_RANGE(text, current, offset);
409  *     if (text != NULL) {
410  *         LINK_CLEAR(text, ino, mode, idp);
411  *         if (statemap[ino] == USTATE)
412  *             ...inode was cleared...
413  *     }
414  *
415  * Note that clri() will set iscorrupt if the user elects not to
416  * clear the problem inode, so the filesystem won't get reported
417  * as clean when it shouldn't be.
418  */
419 #define	LINK_CLEAR(text, ino, mode, idp) { \
420 	pwarn("%s LINK COUNT %s", file_id((ino), (mode)), (text)); \
421 	pinode((ino)); \
422 	pfatal(""); \
423 	init_inodesc((idp)); \
424 	(idp)->id_type = ADDR; \
425 	(idp)->id_func = pass4check; \
426 	(idp)->id_number = ino; \
427 	(idp)->id_fix = DONTKNOW; \
428 	clri((idp), (text), CLRI_QUIET, CLRI_NOP_CORRUPT); \
429 }
430 
431 /*
432  * Used for checking link count under/overflow specifically on
433  * the lost+found directory.  If the user decides not to do the
434  * clri(), then flag that we've hit this problem and refuse to do
435  * the reconnect.
436  */
437 #define	LFDIR_LINK_RANGE_RVAL(text, current, offset, idp, rval) { \
438 	LINK_RANGE(text, current, offset); \
439 	if (text != NULL) { \
440 		LINK_CLEAR(text, lfdir, IFDIR, idp); \
441 		if (statemap[lfdir] == USTATE) { \
442 			lfdir = 0; \
443 			return (rval); \
444 		} else { \
445 			overflowed_lf++; \
446 		} \
447 	} \
448 }
449 
450 #define	LFDIR_LINK_RANGE_NORVAL(text, current, offset, idp) { \
451 	LINK_RANGE(text, current, offset); \
452 	if (text != NULL) { \
453 		LINK_CLEAR(text, lfdir, IFDIR, idp); \
454 		if (statemap[lfdir] == USTATE) { \
455 			lfdir = 0; \
456 			return; \
457 		} else { \
458 			overflowed_lf++; \
459 		} \
460 	} \
461 }
462 
463 /*
464  * Values for mounted() and mountedfs.
465  */
466 #define	M_NOMNT		0	/* filesystem is not mounted */
467 #define	M_RO		1	/* filesystem is mounted read-only */
468 #define	M_RW		2	/* filesystem is mounted read-write */
469 
470 #define	EXOKAY		0	/* file system is unmounted and ok */
471 #define	EXBADPARM	1	/* bad parameter(s) given */
472 #define	EXUMNTCHK	32	/* fsck -m: unmounted, needs checking */
473 #define	EXMOUNTED	33	/* file system already mounted, not magic, */
474 				/* or it is magic and mounted read/write */
475 #define	EXNOSTAT	34	/* cannot stat device */
476 #define	EXREBOOTNOW	35	/* modified root or something equally scary */
477 #define	EXFNDERRS	36	/* uncorrectable errors, terminate normally */
478 #define	EXSIGNAL	37	/* a signal was caught during processing */
479 #define	EXERRFATAL	39	/* uncorrectable errors, exit immediately */
480 #define	EXROOTOKAY	40	/* for root, same as 0 */
481 
482 /*
483  * Values for clri()'s `verbose' and `corrupting' arguments (third
484  * and fourth, respectively).
485  */
486 #define	CLRI_QUIET		1
487 #define	CLRI_VERBOSE		2
488 
489 #define	CLRI_NOP_OK		1
490 #define	CLRI_NOP_CORRUPT	2
491 
492 /*
493  * Filesystems that are `magical' - if they exist in vfstab,
494  * then they have to be mounted for the system to have gotten
495  * far enough to be able to run fsck.  Thus, don't get all
496  * bent out of shape if we're asked to check it and it is mounted.
497  * Actual initialization of the array is in main.c
498  */
499 enum magic {
500 	MAGIC_NONE = 0,
501 	MAGIC_ROOT = 1,
502 	MAGIC_USR = 2,
503 	MAGIC_LIMIT = 3
504 };
505 extern char *magic_fs[];
506 
507 /*
508  * Paths needed by calcsb().
509  */
510 #define	MKFS_PATH	"/usr/lib/fs/ufs/mkfs"
511 #define	NEWFS_PATH	"/usr/lib/fs/ufs/newfs"
512 
513 int		acltypeok(struct dinode *);
514 void		add_orphan_dir(fsck_ino_t);
515 void		adjust(struct inodesc *, int);
516 daddr32_t	allocblk(int);
517 fsck_ino_t	allocdir(fsck_ino_t, fsck_ino_t, int, int);
518 fsck_ino_t	allocino(fsck_ino_t, int);
519 void		blkerror(fsck_ino_t, caddr_t, daddr32_t, daddr32_t);
520 void		brelse(struct bufarea *);
521 void		bufinit(void);
522 void		bwrite(int, caddr_t, diskaddr_t, int64_t);
523 void		cacheacl(struct dinode *, fsck_ino_t);
524 void		cacheino(struct dinode *, fsck_ino_t);
525 void		catch(int);
526 void		catchquit(int);
527 caddr_t		cg_sanity(struct cg *, int);
528 void		cgflush(void);
529 int		cgisdirty(void);
530 int		changeino(fsck_ino_t, caddr_t, fsck_ino_t);
531 int		check_mnttab(caddr_t, caddr_t, size_t);
532 int		check_vfstab(caddr_t, caddr_t, size_t);
533 int		chkrange(daddr32_t, int);
534 void		ckfini(void);
535 int		ckinode(struct dinode *, struct inodesc *, enum cki_action);
536 void		clearattrref(fsck_ino_t);
537 int		cleardirentry(fsck_ino_t, fsck_ino_t);
538 void		clearshadow(fsck_ino_t, struct shadowclientinfo **);
539 void		clri(struct inodesc *, caddr_t, int, int);
540 void		deshadow(struct shadowclientinfo *, void (*)(fsck_ino_t));
541 void		direrror(fsck_ino_t, caddr_t, ...);
542 int		dirscan(struct inodesc *);
543 void		dirty(struct bufarea *);
544 int		do_errorlock(int);
545 int		dofix(struct inodesc *, caddr_t, ...);
546 void		examinelog(void (*)(daddr32_t));
547 void		errexit(caddr_t, ...);
548 void		fileerror(fsck_ino_t, fsck_ino_t, caddr_t, ...);
549 caddr_t		file_id(fsck_ino_t, mode_t);
550 int		find_dup_ref(daddr32_t, fsck_ino_t, daddr32_t, int);
551 int		findino(struct inodesc *);
552 int		findname(struct inodesc *);
553 void		fix_cg(struct cg *, int);
554 void		flush(int, struct bufarea *);
555 void		free_dup_state(void);
556 void		freeblk(fsck_ino_t, daddr32_t, int);
557 void		freeino(fsck_ino_t, int);
558 void		freeinodebuf(void);
559 int		fsck_asprintf(caddr_t *, caddr_t, ...);
560 int		fsck_bread(int, caddr_t, diskaddr_t, size_t);
561 int		ftypeok(struct dinode *);
562 struct bufarea	*getblk(struct bufarea *, daddr32_t, size_t);
563 struct bufarea	*getdatablk(daddr32_t, size_t size);
564 diskaddr_t	getdisksize(caddr_t, int);
565 struct inoinfo	*getinoinfo(fsck_ino_t);
566 struct dinode	*getnextinode(fsck_ino_t);
567 struct dinode	*getnextrefresh(void);
568 void		getpathname(caddr_t, fsck_ino_t, fsck_ino_t);
569 struct dinode	*ginode(fsck_ino_t);
570 caddr_t		hasvfsopt(struct vfstab *, caddr_t);
571 int		have_dups(void);
572 void		init_inodesc(struct inodesc *);
573 void		init_inoinfo(struct inoinfo *, struct dinode *, fsck_ino_t);
574 void		initbarea(struct bufarea *);
575 int		ino_t_cmp(const void *, const void *);
576 int		inocached(fsck_ino_t);
577 void		inocleanup(void);
578 void		inodirty(void);
579 int		is_errorlocked(caddr_t);
580 int		linkup(fsck_ino_t, fsck_ino_t, caddr_t);
581 int		lookup_named_ino(fsck_ino_t, caddr_t);
582 int		makeentry(fsck_ino_t, fsck_ino_t, caddr_t);
583 void		maybe_convert_attrdir_to_dir(fsck_ino_t);
584 int		mounted(caddr_t, caddr_t, size_t);
585 void		pass1(void);
586 void		pass1b(void);
587 int		pass1check(struct inodesc *);
588 void		pass2(void);
589 void		pass3a(void);
590 void		pass3b(void);
591 int		pass3bcheck(struct inodesc *);
592 void		pass4(void);
593 int		pass4check(struct inodesc *);
594 void		pass5(void);
595 void		pfatal(caddr_t, ...);
596 void		pinode(fsck_ino_t);
597 void		printclean(void);
598 void		propagate(void);
599 void		pwarn(caddr_t, ...);
600 caddr_t		rawname(caddr_t);
601 void		registershadowclient(fsck_ino_t, fsck_ino_t,
602 		    struct shadowclientinfo **);
603 void		remove_orphan_dir(fsck_ino_t);
604 int		reply(caddr_t, ...);
605 int		report_dups(int);
606 void		resetinodebuf(void);
607 char		*setup(caddr_t);
608 void		truncino(fsck_ino_t, offset_t, int);
609 void		unbufinit(void);
610 caddr_t		unrawname(caddr_t);
611 void		unregistershadow(fsck_ino_t, struct shadowclientinfo **);
612 int		updateclean(void);
613 int		writable(caddr_t);
614 void		write_altsb(int);
615 
616 /*
617  * Functions from the kernel sources (ufs_subr.c, etc).
618  */
619 extern void	fragacct(struct fs *, int, int32_t *, int);
620 
621 #ifdef	__cplusplus
622 }
623 #endif
624 
625 #endif	/* _FSCK_FSCK_H */
626