1: /*
2: * Copyright (c) 1980 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)fsck.h 5.1 (Berkeley) 6/5/85
7: */
8:
9: #define MAXDUP 10 /* limit on dup blks (per inode) */
10: #define MAXBAD 10 /* limit on bad blks (per inode) */
11:
12: typedef int (*SIG_TYP)();
13:
14: #ifndef BUFSIZ
15: #define BUFSIZ 1024
16: #endif
17:
18: #define USTATE 01 /* inode not allocated */
19: #define FSTATE 02 /* inode is file */
20: #define DSTATE 03 /* inode is directory */
21: #define DFOUND 04 /* directory found during descent */
22: #define DCLEAR 05 /* directory is to be cleared */
23: #define FCLEAR 06 /* file is to be cleared */
24:
25: typedef struct dinode DINODE;
26: typedef struct direct DIRECT;
27:
28: #define ALLOC(dip) (((dip)->di_mode & IFMT) != 0)
29: #define DIRCT(dip) (((dip)->di_mode & IFMT) == IFDIR)
30: #define SPECIAL(dip) \
31: (((dip)->di_mode & IFMT) == IFBLK || ((dip)->di_mode & IFMT) == IFCHR)
32:
33: #define MAXNINDIR (MAXBSIZE / sizeof (daddr_t))
34: #define MAXINOPB (MAXBSIZE / sizeof (struct dinode))
35: #define SPERB (MAXBSIZE / sizeof(short))
36:
37: struct bufarea {
38: struct bufarea *b_next; /* must be first */
39: daddr_t b_bno;
40: int b_size;
41: int b_errs;
42: union {
43: char b_buf[MAXBSIZE]; /* buffer space */
44: short b_lnks[SPERB]; /* link counts */
45: daddr_t b_indir[MAXNINDIR]; /* indirect block */
46: struct fs b_fs; /* super block */
47: struct cg b_cg; /* cylinder group */
48: struct dinode b_dinode[MAXINOPB]; /* inode block */
49: } b_un;
50: char b_dirty;
51: };
52:
53: typedef struct bufarea BUFAREA;
54:
55: BUFAREA inoblk; /* inode blocks */
56: BUFAREA fileblk; /* other blks in filesys */
57: BUFAREA sblk; /* file system superblock */
58: BUFAREA cgblk; /* cylinder group blocks */
59:
60: #define initbarea(x) (x)->b_dirty = 0;(x)->b_bno = (daddr_t)-1
61: #define dirty(x) (x)->b_dirty = 1
62: #define inodirty() inoblk.b_dirty = 1
63: #define sbdirty() sblk.b_dirty = 1
64: #define cgdirty() cgblk.b_dirty = 1
65:
66: #define dirblk fileblk.b_un
67: #define sblock sblk.b_un.b_fs
68: #define cgrp cgblk.b_un.b_cg
69:
70: struct filecntl {
71: int rfdes;
72: int wfdes;
73: int mod;
74: } dfile; /* file descriptors for filesys */
75:
76: enum fixstate {DONTKNOW, NOFIX, FIX};
77:
78: struct inodesc {
79: enum fixstate id_fix; /* policy on fixing errors */
80: int (*id_func)(); /* function to be applied to blocks of inode */
81: ino_t id_number; /* inode number described */
82: ino_t id_parent; /* for DATA nodes, their parent */
83: daddr_t id_blkno; /* current block number being examined */
84: int id_numfrags; /* number of frags contained in block */
85: long id_filesize; /* for DATA nodes, the size of the directory */
86: int id_loc; /* for DATA nodes, current location in dir */
87: int id_entryno; /* for DATA nodes, current entry number */
88: DIRECT *id_dirp; /* for DATA nodes, ptr to current entry */
89: char *id_name; /* for DATA nodes, name to find or enter */
90: char id_type; /* type of descriptor, DATA or ADDR */
91: };
92: /* file types */
93: #define DATA 1
94: #define ADDR 2
95:
96: /*
97: * Linked list of duplicate blocks.
98: *
99: * The list is composed of two parts. The first part of the
100: * list (from duplist through the node pointed to by muldup)
101: * contains a single copy of each duplicate block that has been
102: * found. The second part of the list (from muldup to the end)
103: * contains duplicate blocks that have been found more than once.
104: * To check if a block has been found as a duplicate it is only
105: * necessary to search from duplist through muldup. To find the
106: * total number of times that a block has been found as a duplicate
107: * the entire list must be searched for occurences of the block
108: * in question. The following diagram shows a sample list where
109: * w (found twice), x (found once), y (found three times), and z
110: * (found once) are duplicate block numbers:
111: *
112: * w -> y -> x -> z -> y -> w -> y
113: * ^ ^
114: * | |
115: * duplist muldup
116: */
117: struct dups {
118: struct dups *next;
119: daddr_t dup;
120: };
121: struct dups *duplist; /* head of dup list */
122: struct dups *muldup; /* end of unique duplicate dup block numbers */
123:
124: /*
125: * Linked list of inodes with zero link counts.
126: */
127: struct zlncnt {
128: struct zlncnt *next;
129: ino_t zlncnt;
130: };
131: struct zlncnt *zlnhead; /* head of zero link count list */
132:
133: char rawflg;
134: char *devname;
135: char nflag; /* assume a no response */
136: char yflag; /* assume a yes response */
137: int bflag; /* location of alternate super block */
138: int debug; /* output debugging info */
139: char preen; /* just fix normal inconsistencies */
140: char hotroot; /* checking root device */
141:
142: char *blockmap; /* ptr to primary blk allocation map */
143: char *statemap; /* ptr to inode state table */
144: short *lncntp; /* ptr to link count table */
145:
146: char pathname[BUFSIZ]; /* current pathname */
147: char *pathp; /* pointer to pathname position */
148: char *endpathname;
149:
150: daddr_t fmax; /* number of blocks in the volume */
151: ino_t imax; /* number of inodes */
152: ino_t lastino; /* hiwater mark of inodes */
153: ino_t lfdir; /* lost & found directory inode number */
154: char *lfname; /* lost & found directory name */
155:
156: off_t maxblk; /* largest logical blk in file */
157: off_t bmapsz; /* num chars in blockmap */
158:
159: daddr_t n_blks; /* number of blocks used */
160: daddr_t n_files; /* number of files seen */
161:
162: #define zapino(x) (*(x) = zino)
163: struct dinode zino;
164:
165: #define setbmap(x) setbit(blockmap, x)
166: #define getbmap(x) isset(blockmap, x)
167: #define clrbmap(x) clrbit(blockmap, x)
168:
169: #define ALTERED 010
170: #define KEEPON 04
171: #define SKIP 02
172: #define STOP 01
173:
174: time_t time();
175: DINODE *ginode();
176: BUFAREA *getblk();
177: int findino();
Defined variables
cgblk
defined in line
58; used 5 times
dfile
defined in line
74; used 20 times
pathp
defined in line
147; used 20 times
preen
defined in line
139; used 41 times
- in /usr/src/etc/fsck/dir.c line
56-58(2),
227,
234,
293-295(2),
314-323(3),
394,
469
- in /usr/src/etc/fsck/inode.c line
183-184(2),
238
- in /usr/src/etc/fsck/main.c line
44,
79,
99-104(2),
124,
148,
155,
167,
176,
183,
190,
197,
244
- in /usr/src/etc/fsck/pass1.c line
77,
126,
160,
178
- in /usr/src/etc/fsck/pass2.c line
232
- in /usr/src/etc/fsck/setup.c line
52-60(3),
186
- in /usr/src/etc/fsck/utilities.c line
46,
133,
357,
398,
418
sblk
defined in line
57; used 10 times
statemap
defined in line
143; used 47 times
- in /usr/src/etc/fsck/dir.c line
36-43(4),
362,
516-521(5)
- in /usr/src/etc/fsck/inode.c line
189,
253-260(3),
268,
286-289(2),
295-299(2),
307,
338
- in /usr/src/etc/fsck/main.c line
240
- in /usr/src/etc/fsck/pass1.c line
68,
118,
136-138(2)
- in /usr/src/etc/fsck/pass1b.c line
39
- in /usr/src/etc/fsck/pass2.c line
30,
52,
72,
80,
211,
223,
245-257(4)
- in /usr/src/etc/fsck/pass3.c line
28,
49
- in /usr/src/etc/fsck/pass4.c line
30,
64
- in /usr/src/etc/fsck/pass5.c line
79,
100
- in /usr/src/etc/fsck/setup.c line
162-163(2)
- in /usr/src/etc/fsck/utilities.c line
269(2)
zino
defined in line
163; used 3 times
Defined struct's
dups
defined in line
117; used 24 times
inodesc
defined in line
78; used 80 times
- in /usr/src/etc/fsck/dir.c line
29-35(6),
69(2),
112(2),
164(2),
212(2),
242(2),
267(2),
284-288(4),
408-412(4)
- in /usr/src/etc/fsck/inode.c line
20(2),
63(2),
172(2),
195(2),
206(2),
326-330(4)
- in /usr/src/etc/fsck/pass1.c line
26(2),
45(2),
147(2)
- in /usr/src/etc/fsck/pass1b.c line
23-26(4),
49(2)
- in /usr/src/etc/fsck/pass2.c line
23-25(4),
85(2)
- in /usr/src/etc/fsck/pass3.c line
21-25(4)
- in /usr/src/etc/fsck/pass4.c line
22-25(4),
70(2)
- in /usr/src/etc/fsck/pass5.c line
24(2),
30(2)
- in /usr/src/etc/fsck/utilities.c line
250(2),
266(2),
273(2),
346(2)
Defined enum's
Defined typedef's
DINODE
defined in line
25; used 22 times
- in line 175
- in /usr/src/etc/fsck/dir.c line
32,
195,
215,
281,
407,
435,
493,
537
- in /usr/src/etc/fsck/inode.c line
19-24(2),
153,
176,
223,
282,
328
- in /usr/src/etc/fsck/pass1.c line
23
- in /usr/src/etc/fsck/pass1b.c line
22
- in /usr/src/etc/fsck/pass2.c line
22,
90
- in /usr/src/etc/fsck/pass3.c line
20
- in /usr/src/etc/fsck/utilities.c line
22
DIRECT
defined in line
26; used 19 times
- in line 88
- in /usr/src/etc/fsck/dir.c line
26,
71,
90,
110-114(2),
125,
141-146(2),
165,
244-245(2),
269
- in /usr/src/etc/fsck/inode.c line
197,
208
- in /usr/src/etc/fsck/pass2.c line
87-91(2),
129,
150
Defined macros
ADDR
defined in line
94; used 9 times
ALLOC
defined in line
28; used 1 times
ALTERED
defined in line
169; used 19 times
- in /usr/src/etc/fsck/dir.c line
91-94(2),
263,
274,
350,
424-428(2)
- in /usr/src/etc/fsck/pass2.c line
104,
122,
133,
159,
173,
185,
192,
249,
265
- in /usr/src/etc/fsck/utilities.c line
360,
367-370(2)
DATA
defined in line
93; used 9 times
DIRCT
defined in line
29; used 7 times
DSTATE
defined in line
20; used 11 times
KEEPON
defined in line
170; used 18 times
- in /usr/src/etc/fsck/dir.c line
104,
255,
272
- in /usr/src/etc/fsck/inode.c line
30,
59,
76,
117,
200,
211,
217
- in /usr/src/etc/fsck/pass1.c line
149
- in /usr/src/etc/fsck/pass1b.c line
52
- in /usr/src/etc/fsck/pass2.c line
177,
186,
193,
263-265(2)
- in /usr/src/etc/fsck/pass4.c line
73
MAXDUP
defined in line
9; used 1 times
SKIP
defined in line
171; used 6 times
SPERB
defined in line
35; used 1 times
STOP
defined in line
172; used 16 times
- in /usr/src/etc/fsck/dir.c line
101-104(2),
263,
274
- in /usr/src/etc/fsck/inode.c line
46,
55,
114,
202,
215
- in /usr/src/etc/fsck/pass1.c line
164,
182,
189
- in /usr/src/etc/fsck/pass1b.c line
40,
69
- in /usr/src/etc/fsck/utilities.c line
285,
292
cgrp
defined in line
68; used 17 times
dirblk
defined in line
66; used 11 times
dirty
defined in line
61; used 7 times
inodirty
defined in line
62; used 18 times
- in /usr/src/etc/fsck/dir.c line
50,
59,
236,
354,
390,
422,
474,
511,
527,
542
- in /usr/src/etc/fsck/inode.c line
190,
316,
337
- in /usr/src/etc/fsck/pass1.c line
65,
81,
131,
140
- in /usr/src/etc/fsck/pass2.c line
71
sblock
defined in line
67; used 182 times
- in /usr/src/etc/fsck/dir.c line
81,
117,
440-464(8),
479-481(3),
499,
506
- in /usr/src/etc/fsck/inode.c line
32-38(5),
49-54(2),
83-93(7),
128-145(8),
163-168(6),
313-314(2)
- in /usr/src/etc/fsck/main.c line
156,
204-217(13),
235
- in /usr/src/etc/fsck/pass1.c line
32-38(6),
50-51(2),
79-83(2),
94,
122
- in /usr/src/etc/fsck/pass1b.c line
31-32(2)
- in /usr/src/etc/fsck/pass3.c line
46
- in /usr/src/etc/fsck/pass5.c line
28,
34-44(8),
50-59(6),
75-78(4),
109-112(4),
118-126(5),
136-137(2),
153(2),
160-164(4)
- in /usr/src/etc/fsck/setup.c line
72,
79-104(18),
115-149(37)
- in /usr/src/etc/fsck/utilities.c line
95,
120-124(10),
221-224(4)
Usage of this include