Commit | Line | Data |
---|---|---|
76797561 DF |
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 | * | |
adc5a10c | 6 | * @(#)fsck.h 5.7 (Berkeley) %G% |
76797561 | 7 | */ |
e12c24e6 | 8 | |
adc5a10c KM |
9 | #define MAXDUP 10 /* limit on dup blks (per inode) */ |
10 | #define MAXBAD 10 /* limit on bad blks (per inode) */ | |
11 | #define MAXBUFSPACE 128*1024 /* maximum space to allocate to buffers */ | |
e12c24e6 KM |
12 | |
13 | typedef int (*SIG_TYP)(); | |
14 | ||
15 | #ifndef BUFSIZ | |
16 | #define BUFSIZ 1024 | |
17 | #endif | |
18 | ||
993a756c KM |
19 | #define USTATE 01 /* inode not allocated */ |
20 | #define FSTATE 02 /* inode is file */ | |
21 | #define DSTATE 03 /* inode is directory */ | |
22 | #define DFOUND 04 /* directory found during descent */ | |
23 | #define DCLEAR 05 /* directory is to be cleared */ | |
24 | #define FCLEAR 06 /* file is to be cleared */ | |
e12c24e6 KM |
25 | |
26 | typedef struct dinode DINODE; | |
27 | typedef struct direct DIRECT; | |
28 | ||
7718c0e6 KM |
29 | #define ALLOC(dip) (((dip)->di_mode & IFMT) != 0) |
30 | #define DIRCT(dip) (((dip)->di_mode & IFMT) == IFDIR) | |
31 | #define SPECIAL(dip) \ | |
32 | (((dip)->di_mode & IFMT) == IFBLK || ((dip)->di_mode & IFMT) == IFCHR) | |
33 | ||
adc5a10c KM |
34 | /* |
35 | * buffer cache structure. | |
36 | */ | |
e12c24e6 | 37 | struct bufarea { |
adc5a10c KM |
38 | struct bufarea *b_next; /* free list queue */ |
39 | struct bufarea *b_prev; /* free list queue */ | |
e12c24e6 KM |
40 | daddr_t b_bno; |
41 | int b_size; | |
49505034 | 42 | int b_errs; |
adc5a10c | 43 | int b_flags; |
e12c24e6 | 44 | union { |
adc5a10c KM |
45 | char *b_buf; /* buffer space */ |
46 | daddr_t *b_indir; /* indirect block */ | |
47 | struct fs *b_fs; /* super block */ | |
48 | struct cg *b_cg; /* cylinder group */ | |
49 | struct dinode *b_dinode; /* inode block */ | |
e12c24e6 KM |
50 | } b_un; |
51 | char b_dirty; | |
52 | }; | |
53 | ||
adc5a10c | 54 | #define B_INUSE 1 |
e12c24e6 KM |
55 | typedef struct bufarea BUFAREA; |
56 | ||
adc5a10c KM |
57 | #define MINBUFS 5 /* minimum number of buffers required */ |
58 | BUFAREA bufhead; /* head of list of other blks in filesys */ | |
e12c24e6 KM |
59 | BUFAREA sblk; /* file system superblock */ |
60 | BUFAREA cgblk; /* cylinder group blocks */ | |
adc5a10c | 61 | BUFAREA *getdatablk(); |
e12c24e6 | 62 | |
e12c24e6 | 63 | #define dirty(x) (x)->b_dirty = 1 |
adc5a10c KM |
64 | #define initbarea(x) \ |
65 | (x)->b_dirty = 0; \ | |
66 | (x)->b_bno = (daddr_t)-1; \ | |
67 | (x)->b_flags = 0; | |
68 | ||
e12c24e6 KM |
69 | #define sbdirty() sblk.b_dirty = 1 |
70 | #define cgdirty() cgblk.b_dirty = 1 | |
adc5a10c KM |
71 | #define sblock (*sblk.b_un.b_fs) |
72 | #define cgrp (*cgblk.b_un.b_cg) | |
e12c24e6 KM |
73 | |
74 | struct filecntl { | |
75 | int rfdes; | |
76 | int wfdes; | |
77 | int mod; | |
78 | } dfile; /* file descriptors for filesys */ | |
79 | ||
7718c0e6 KM |
80 | enum fixstate {DONTKNOW, NOFIX, FIX}; |
81 | ||
e12c24e6 | 82 | struct inodesc { |
7718c0e6 | 83 | enum fixstate id_fix; /* policy on fixing errors */ |
e12c24e6 KM |
84 | int (*id_func)(); /* function to be applied to blocks of inode */ |
85 | ino_t id_number; /* inode number described */ | |
86 | ino_t id_parent; /* for DATA nodes, their parent */ | |
87 | daddr_t id_blkno; /* current block number being examined */ | |
88 | int id_numfrags; /* number of frags contained in block */ | |
89 | long id_filesize; /* for DATA nodes, the size of the directory */ | |
90 | int id_loc; /* for DATA nodes, current location in dir */ | |
91 | int id_entryno; /* for DATA nodes, current entry number */ | |
7718c0e6 KM |
92 | DIRECT *id_dirp; /* for DATA nodes, ptr to current entry */ |
93 | char *id_name; /* for DATA nodes, name to find or enter */ | |
94 | char id_type; /* type of descriptor, DATA or ADDR */ | |
e12c24e6 KM |
95 | }; |
96 | /* file types */ | |
97 | #define DATA 1 | |
98 | #define ADDR 2 | |
99 | ||
62e6c152 | 100 | /* |
82dc9a9e KM |
101 | * Linked list of duplicate blocks. |
102 | * | |
103 | * The list is composed of two parts. The first part of the | |
104 | * list (from duplist through the node pointed to by muldup) | |
105 | * contains a single copy of each duplicate block that has been | |
106 | * found. The second part of the list (from muldup to the end) | |
107 | * contains duplicate blocks that have been found more than once. | |
108 | * To check if a block has been found as a duplicate it is only | |
109 | * necessary to search from duplist through muldup. To find the | |
110 | * total number of times that a block has been found as a duplicate | |
111 | * the entire list must be searched for occurences of the block | |
112 | * in question. The following diagram shows a sample list where | |
113 | * w (found twice), x (found once), y (found three times), and z | |
114 | * (found once) are duplicate block numbers: | |
115 | * | |
116 | * w -> y -> x -> z -> y -> w -> y | |
117 | * ^ ^ | |
118 | * | | | |
119 | * duplist muldup | |
62e6c152 KM |
120 | */ |
121 | struct dups { | |
122 | struct dups *next; | |
123 | daddr_t dup; | |
124 | }; | |
125 | struct dups *duplist; /* head of dup list */ | |
126 | struct dups *muldup; /* end of unique duplicate dup block numbers */ | |
e12c24e6 | 127 | |
82dc9a9e KM |
128 | /* |
129 | * Linked list of inodes with zero link counts. | |
130 | */ | |
131 | struct zlncnt { | |
132 | struct zlncnt *next; | |
133 | ino_t zlncnt; | |
134 | }; | |
135 | struct zlncnt *zlnhead; /* head of zero link count list */ | |
e12c24e6 KM |
136 | |
137 | char rawflg; | |
138 | char *devname; | |
6eb81197 | 139 | long dev_bsize; /* computed value of DEV_BSIZE */ |
919c85da | 140 | long secsize; /* actual disk sector size */ |
e12c24e6 KM |
141 | char nflag; /* assume a no response */ |
142 | char yflag; /* assume a yes response */ | |
143 | int bflag; /* location of alternate super block */ | |
144 | int debug; /* output debugging info */ | |
d3e80ec3 | 145 | int cvtflag; /* convert to old file system format */ |
e12c24e6 | 146 | char preen; /* just fix normal inconsistencies */ |
e12c24e6 | 147 | char hotroot; /* checking root device */ |
55f8bbd7 | 148 | char havesb; /* superblock has been read */ |
e12c24e6 KM |
149 | |
150 | char *blockmap; /* ptr to primary blk allocation map */ | |
e12c24e6 KM |
151 | char *statemap; /* ptr to inode state table */ |
152 | short *lncntp; /* ptr to link count table */ | |
153 | ||
e12c24e6 KM |
154 | char pathname[BUFSIZ]; /* current pathname */ |
155 | char *pathp; /* pointer to pathname position */ | |
156 | char *endpathname; | |
157 | ||
7718c0e6 | 158 | daddr_t fmax; /* number of blocks in the volume */ |
e12c24e6 KM |
159 | ino_t imax; /* number of inodes */ |
160 | ino_t lastino; /* hiwater mark of inodes */ | |
7718c0e6 KM |
161 | ino_t lfdir; /* lost & found directory inode number */ |
162 | char *lfname; /* lost & found directory name */ | |
e12c24e6 KM |
163 | |
164 | off_t maxblk; /* largest logical blk in file */ | |
165 | off_t bmapsz; /* num chars in blockmap */ | |
166 | ||
e12c24e6 KM |
167 | daddr_t n_blks; /* number of blocks used */ |
168 | daddr_t n_files; /* number of files seen */ | |
e12c24e6 KM |
169 | |
170 | #define zapino(x) (*(x) = zino) | |
171 | struct dinode zino; | |
172 | ||
173 | #define setbmap(x) setbit(blockmap, x) | |
174 | #define getbmap(x) isset(blockmap, x) | |
175 | #define clrbmap(x) clrbit(blockmap, x) | |
176 | ||
315f1422 | 177 | #define FOUND 020 |
e12c24e6 KM |
178 | #define ALTERED 010 |
179 | #define KEEPON 04 | |
180 | #define SKIP 02 | |
181 | #define STOP 01 | |
182 | ||
183 | time_t time(); | |
184 | DINODE *ginode(); | |
185 | BUFAREA *getblk(); | |
186 | int findino(); |