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