pass2.c revision 1.9 1 1.9 itojun /* $NetBSD: pass2.c,v 1.9 2003/07/13 08:13:19 itojun Exp $ */
2 1.1 perseant
3 1.1 perseant /*
4 1.1 perseant * Copyright (c) 1980, 1986, 1993
5 1.1 perseant * The Regents of the University of California. All rights reserved.
6 1.1 perseant *
7 1.1 perseant * Redistribution and use in source and binary forms, with or without
8 1.1 perseant * modification, are permitted provided that the following conditions
9 1.1 perseant * are met:
10 1.1 perseant * 1. Redistributions of source code must retain the above copyright
11 1.1 perseant * notice, this list of conditions and the following disclaimer.
12 1.1 perseant * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 perseant * notice, this list of conditions and the following disclaimer in the
14 1.1 perseant * documentation and/or other materials provided with the distribution.
15 1.1 perseant * 3. All advertising materials mentioning features or use of this software
16 1.1 perseant * must display the following acknowledgement:
17 1.1 perseant * This product includes software developed by the University of
18 1.1 perseant * California, Berkeley and its contributors.
19 1.1 perseant * 4. Neither the name of the University nor the names of its contributors
20 1.1 perseant * may be used to endorse or promote products derived from this software
21 1.1 perseant * without specific prior written permission.
22 1.1 perseant *
23 1.1 perseant * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 perseant * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 perseant * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 perseant * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 perseant * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 perseant * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 perseant * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 perseant * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 perseant * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 perseant * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 perseant * SUCH DAMAGE.
34 1.1 perseant */
35 1.1 perseant
36 1.7 perseant #include <sys/types.h>
37 1.1 perseant #include <sys/param.h>
38 1.1 perseant #include <sys/time.h>
39 1.7 perseant #include <sys/mount.h>
40 1.7 perseant #include <sys/buf.h>
41 1.7 perseant
42 1.7 perseant #include <ufs/ufs/inode.h>
43 1.1 perseant #include <ufs/ufs/dir.h>
44 1.1 perseant #include <ufs/lfs/lfs.h>
45 1.1 perseant
46 1.7 perseant #include <err.h>
47 1.1 perseant #include <stdio.h>
48 1.1 perseant #include <stdlib.h>
49 1.1 perseant #include <string.h>
50 1.1 perseant
51 1.7 perseant #include "bufcache.h"
52 1.7 perseant #include "vnode.h"
53 1.7 perseant #include "lfs.h"
54 1.7 perseant
55 1.1 perseant #include "fsck.h"
56 1.1 perseant #include "fsutil.h"
57 1.1 perseant #include "extern.h"
58 1.1 perseant
59 1.1 perseant #define MINDIRSIZE (sizeof (struct dirtemplate))
60 1.1 perseant
61 1.7 perseant static int pass2check(struct inodesc *);
62 1.7 perseant static int blksort(const void *, const void *);
63 1.1 perseant
64 1.1 perseant void
65 1.1 perseant pass2()
66 1.1 perseant {
67 1.8 fvdl struct ufs1_dinode *dp;
68 1.7 perseant struct uvnode *vp;
69 1.7 perseant struct inoinfo **inpp, *inp;
70 1.1 perseant struct inoinfo **inpend;
71 1.7 perseant struct inodesc curino;
72 1.8 fvdl struct ufs1_dinode dino;
73 1.7 perseant char pathbuf[MAXPATHLEN + 1];
74 1.1 perseant
75 1.1 perseant switch (statemap[ROOTINO]) {
76 1.1 perseant
77 1.1 perseant case USTATE:
78 1.1 perseant pfatal("ROOT INODE UNALLOCATED");
79 1.1 perseant if (reply("ALLOCATE") == 0)
80 1.7 perseant err(8, "%s", "");
81 1.1 perseant if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
82 1.7 perseant err(8, "CANNOT ALLOCATE ROOT INODE\n");
83 1.1 perseant break;
84 1.1 perseant
85 1.1 perseant case DCLEAR:
86 1.1 perseant pfatal("DUPS/BAD IN ROOT INODE");
87 1.1 perseant if (reply("REALLOCATE")) {
88 1.1 perseant freeino(ROOTINO);
89 1.1 perseant if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
90 1.7 perseant err(8, "CANNOT ALLOCATE ROOT INODE\n");
91 1.1 perseant break;
92 1.1 perseant }
93 1.1 perseant if (reply("CONTINUE") == 0)
94 1.7 perseant err(8, "%s", "");
95 1.1 perseant break;
96 1.1 perseant
97 1.1 perseant case FSTATE:
98 1.1 perseant case FCLEAR:
99 1.1 perseant pfatal("ROOT INODE NOT DIRECTORY");
100 1.1 perseant if (reply("REALLOCATE")) {
101 1.1 perseant freeino(ROOTINO);
102 1.1 perseant if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
103 1.7 perseant err(8, "CANNOT ALLOCATE ROOT INODE\n");
104 1.1 perseant break;
105 1.1 perseant }
106 1.1 perseant if (reply("FIX") == 0)
107 1.7 perseant err(8, "%s", "");
108 1.7 perseant vp = vget(fs, ROOTINO);
109 1.7 perseant dp = VTOD(vp);
110 1.1 perseant dp->di_mode &= ~IFMT;
111 1.1 perseant dp->di_mode |= IFDIR;
112 1.7 perseant inodirty(VTOI(vp));
113 1.1 perseant break;
114 1.1 perseant
115 1.1 perseant case DSTATE:
116 1.1 perseant break;
117 1.1 perseant
118 1.1 perseant default:
119 1.7 perseant err(8, "BAD STATE %d FOR ROOT INODE\n", statemap[ROOTINO]);
120 1.1 perseant }
121 1.7 perseant statemap[WINO] = FSTATE;
122 1.7 perseant typemap[WINO] = DT_WHT;
123 1.1 perseant /*
124 1.1 perseant * Sort the directory list into disk block order.
125 1.1 perseant */
126 1.7 perseant qsort((char *) inpsort, (size_t) inplast, sizeof *inpsort, blksort);
127 1.1 perseant /*
128 1.1 perseant * Check the integrity of each directory.
129 1.1 perseant */
130 1.1 perseant memset(&curino, 0, sizeof(struct inodesc));
131 1.1 perseant curino.id_type = DATA;
132 1.1 perseant curino.id_func = pass2check;
133 1.1 perseant inpend = &inpsort[inplast];
134 1.1 perseant for (inpp = inpsort; inpp < inpend; inpp++) {
135 1.1 perseant inp = *inpp;
136 1.1 perseant if (inp->i_isize == 0)
137 1.1 perseant continue;
138 1.1 perseant if (inp->i_isize < MINDIRSIZE) {
139 1.1 perseant direrror(inp->i_number, "DIRECTORY TOO SHORT");
140 1.1 perseant inp->i_isize = roundup(MINDIRSIZE, DIRBLKSIZ);
141 1.1 perseant if (reply("FIX") == 1) {
142 1.7 perseant vp = vget(fs, inp->i_number);
143 1.7 perseant dp = VTOD(vp);
144 1.1 perseant dp->di_size = inp->i_isize;
145 1.7 perseant inodirty(VTOI(vp));
146 1.1 perseant }
147 1.1 perseant } else if ((inp->i_isize & (DIRBLKSIZ - 1)) != 0) {
148 1.9 itojun getpathname(pathbuf, sizeof(pathbuf), inp->i_number,
149 1.9 itojun inp->i_number);
150 1.2 nathanw pwarn("DIRECTORY %s: LENGTH %lu NOT MULTIPLE OF %d",
151 1.7 perseant pathbuf, (unsigned long) inp->i_isize, DIRBLKSIZ);
152 1.1 perseant if (preen)
153 1.1 perseant printf(" (ADJUSTED)\n");
154 1.1 perseant inp->i_isize = roundup(inp->i_isize, DIRBLKSIZ);
155 1.1 perseant if (preen || reply("ADJUST") == 1) {
156 1.7 perseant vp = vget(fs, inp->i_number);
157 1.7 perseant dp = VTOD(vp);
158 1.1 perseant dp->di_size = inp->i_isize;
159 1.7 perseant inodirty(VTOI(vp));
160 1.1 perseant }
161 1.1 perseant }
162 1.8 fvdl memset(&dino, 0, sizeof(struct ufs1_dinode));
163 1.1 perseant dino.di_mode = IFDIR;
164 1.1 perseant dino.di_size = inp->i_isize;
165 1.7 perseant memcpy(&dino.di_db[0], &inp->i_blks[0], (size_t) inp->i_numblks);
166 1.1 perseant curino.id_number = inp->i_number;
167 1.1 perseant curino.id_parent = inp->i_parent;
168 1.7 perseant (void) ckinode(&dino, &curino);
169 1.1 perseant }
170 1.1 perseant /*
171 1.1 perseant * Now that the parents of all directories have been found,
172 1.1 perseant * make another pass to verify the value of `..'
173 1.1 perseant */
174 1.1 perseant for (inpp = inpsort; inpp < inpend; inpp++) {
175 1.1 perseant inp = *inpp;
176 1.1 perseant if (inp->i_parent == 0 || inp->i_isize == 0)
177 1.1 perseant continue;
178 1.1 perseant if (inp->i_dotdot == inp->i_parent ||
179 1.7 perseant inp->i_dotdot == (ino_t) - 1)
180 1.1 perseant continue;
181 1.1 perseant if (inp->i_dotdot == 0) {
182 1.1 perseant inp->i_dotdot = inp->i_parent;
183 1.1 perseant fileerror(inp->i_parent, inp->i_number, "MISSING '..'");
184 1.1 perseant if (reply("FIX") == 0)
185 1.1 perseant continue;
186 1.7 perseant (void) makeentry(inp->i_number, inp->i_parent, "..");
187 1.1 perseant lncntp[inp->i_parent]--;
188 1.1 perseant continue;
189 1.1 perseant }
190 1.1 perseant fileerror(inp->i_parent, inp->i_number,
191 1.7 perseant "BAD INODE NUMBER FOR '..'");
192 1.1 perseant if (reply("FIX") == 0)
193 1.1 perseant continue;
194 1.1 perseant lncntp[inp->i_dotdot]++;
195 1.1 perseant lncntp[inp->i_parent]--;
196 1.1 perseant inp->i_dotdot = inp->i_parent;
197 1.7 perseant (void) changeino(inp->i_number, "..", inp->i_parent);
198 1.1 perseant }
199 1.1 perseant /*
200 1.1 perseant * Mark all the directories that can be found from the root.
201 1.1 perseant */
202 1.1 perseant propagate();
203 1.1 perseant }
204 1.1 perseant
205 1.1 perseant static int
206 1.4 perseant pass2check(struct inodesc * idesc)
207 1.1 perseant {
208 1.1 perseant register struct direct *dirp = idesc->id_dirp;
209 1.1 perseant register struct inoinfo *inp;
210 1.7 perseant int n, entrysize, ret = 0;
211 1.8 fvdl struct ufs1_dinode *dp;
212 1.7 perseant char *errmsg;
213 1.7 perseant struct direct proto;
214 1.7 perseant char namebuf[MAXPATHLEN + 1];
215 1.7 perseant char pathbuf[MAXPATHLEN + 1];
216 1.1 perseant
217 1.1 perseant /*
218 1.1 perseant * check for "."
219 1.1 perseant */
220 1.1 perseant if (idesc->id_entryno != 0)
221 1.1 perseant goto chk1;
222 1.1 perseant if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") == 0) {
223 1.1 perseant if (dirp->d_ino != idesc->id_number) {
224 1.1 perseant direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'");
225 1.1 perseant dirp->d_ino = idesc->id_number;
226 1.1 perseant if (reply("FIX") == 1)
227 1.1 perseant ret |= ALTERED;
228 1.1 perseant }
229 1.7 perseant if (dirp->d_type != DT_DIR) {
230 1.1 perseant direrror(idesc->id_number, "BAD TYPE VALUE FOR '.'");
231 1.1 perseant dirp->d_type = DT_DIR;
232 1.1 perseant if (reply("FIX") == 1)
233 1.1 perseant ret |= ALTERED;
234 1.1 perseant }
235 1.1 perseant goto chk1;
236 1.1 perseant }
237 1.1 perseant direrror(idesc->id_number, "MISSING '.'");
238 1.1 perseant proto.d_ino = idesc->id_number;
239 1.7 perseant proto.d_type = DT_DIR;
240 1.1 perseant proto.d_namlen = 1;
241 1.9 itojun (void) strlcpy(proto.d_name, ".", sizeof(proto.d_name));
242 1.1 perseant entrysize = DIRSIZ(0, &proto, 0);
243 1.1 perseant if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) {
244 1.1 perseant pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
245 1.7 perseant dirp->d_name);
246 1.1 perseant } else if (dirp->d_reclen < entrysize) {
247 1.1 perseant pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n");
248 1.1 perseant } else if (dirp->d_reclen < 2 * entrysize) {
249 1.1 perseant proto.d_reclen = dirp->d_reclen;
250 1.7 perseant memcpy(dirp, &proto, (size_t) entrysize);
251 1.1 perseant if (reply("FIX") == 1)
252 1.1 perseant ret |= ALTERED;
253 1.1 perseant } else {
254 1.1 perseant n = dirp->d_reclen - entrysize;
255 1.1 perseant proto.d_reclen = entrysize;
256 1.7 perseant memcpy(dirp, &proto, (size_t) entrysize);
257 1.1 perseant idesc->id_entryno++;
258 1.1 perseant lncntp[dirp->d_ino]--;
259 1.7 perseant dirp = (struct direct *) ((char *) (dirp) + entrysize);
260 1.7 perseant memset(dirp, 0, (size_t) n);
261 1.1 perseant dirp->d_reclen = n;
262 1.1 perseant if (reply("FIX") == 1)
263 1.1 perseant ret |= ALTERED;
264 1.1 perseant }
265 1.1 perseant chk1:
266 1.1 perseant if (idesc->id_entryno > 1)
267 1.1 perseant goto chk2;
268 1.1 perseant inp = getinoinfo(idesc->id_number);
269 1.1 perseant proto.d_ino = inp->i_parent;
270 1.7 perseant proto.d_type = DT_DIR;
271 1.1 perseant proto.d_namlen = 2;
272 1.9 itojun (void) strlcpy(proto.d_name, "..", sizeof(proto.d_name));
273 1.1 perseant entrysize = DIRSIZ(0, &proto, 0);
274 1.1 perseant if (idesc->id_entryno == 0) {
275 1.1 perseant n = DIRSIZ(0, dirp, 0);
276 1.1 perseant if (dirp->d_reclen < n + entrysize)
277 1.1 perseant goto chk2;
278 1.1 perseant proto.d_reclen = dirp->d_reclen - n;
279 1.1 perseant dirp->d_reclen = n;
280 1.1 perseant idesc->id_entryno++;
281 1.1 perseant lncntp[dirp->d_ino]--;
282 1.7 perseant dirp = (struct direct *) ((char *) (dirp) + n);
283 1.7 perseant memset(dirp, 0, (size_t) proto.d_reclen);
284 1.1 perseant dirp->d_reclen = proto.d_reclen;
285 1.1 perseant }
286 1.1 perseant if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") == 0) {
287 1.1 perseant inp->i_dotdot = dirp->d_ino;
288 1.7 perseant if (dirp->d_type != DT_DIR) {
289 1.1 perseant direrror(idesc->id_number, "BAD TYPE VALUE FOR '..'");
290 1.1 perseant dirp->d_type = DT_DIR;
291 1.1 perseant if (reply("FIX") == 1)
292 1.1 perseant ret |= ALTERED;
293 1.1 perseant }
294 1.1 perseant goto chk2;
295 1.1 perseant }
296 1.1 perseant if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") != 0) {
297 1.1 perseant fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
298 1.1 perseant pfatal("CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS %s\n",
299 1.7 perseant dirp->d_name);
300 1.7 perseant inp->i_dotdot = (ino_t) - 1;
301 1.1 perseant } else if (dirp->d_reclen < entrysize) {
302 1.1 perseant fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
303 1.1 perseant pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '..'\n");
304 1.7 perseant inp->i_dotdot = (ino_t) - 1;
305 1.1 perseant } else if (inp->i_parent != 0) {
306 1.1 perseant /*
307 1.1 perseant * We know the parent, so fix now.
308 1.1 perseant */
309 1.1 perseant inp->i_dotdot = inp->i_parent;
310 1.1 perseant fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
311 1.1 perseant proto.d_reclen = dirp->d_reclen;
312 1.7 perseant memcpy(dirp, &proto, (size_t) entrysize);
313 1.1 perseant if (reply("FIX") == 1)
314 1.1 perseant ret |= ALTERED;
315 1.1 perseant }
316 1.1 perseant idesc->id_entryno++;
317 1.1 perseant if (dirp->d_ino != 0)
318 1.1 perseant lncntp[dirp->d_ino]--;
319 1.4 perseant return (ret | KEEPON);
320 1.1 perseant chk2:
321 1.1 perseant if (dirp->d_ino == 0)
322 1.4 perseant return (ret | KEEPON);
323 1.1 perseant if (dirp->d_namlen <= 2 &&
324 1.1 perseant dirp->d_name[0] == '.' &&
325 1.1 perseant idesc->id_entryno >= 2) {
326 1.1 perseant if (dirp->d_namlen == 1) {
327 1.1 perseant direrror(idesc->id_number, "EXTRA '.' ENTRY");
328 1.1 perseant dirp->d_ino = 0;
329 1.1 perseant if (reply("FIX") == 1)
330 1.1 perseant ret |= ALTERED;
331 1.1 perseant return (KEEPON | ret);
332 1.1 perseant }
333 1.1 perseant if (dirp->d_name[1] == '.') {
334 1.1 perseant direrror(idesc->id_number, "EXTRA '..' ENTRY");
335 1.1 perseant dirp->d_ino = 0;
336 1.1 perseant if (reply("FIX") == 1)
337 1.1 perseant ret |= ALTERED;
338 1.1 perseant return (KEEPON | ret);
339 1.1 perseant }
340 1.1 perseant }
341 1.1 perseant idesc->id_entryno++;
342 1.1 perseant n = 0;
343 1.5 perseant if (dirp->d_ino >= maxino) {
344 1.1 perseant fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE");
345 1.1 perseant n = reply("REMOVE");
346 1.4 perseant } else if (dirp->d_ino == LFS_IFILE_INUM &&
347 1.7 perseant idesc->id_number == ROOTINO) {
348 1.4 perseant if (dirp->d_type != DT_REG) {
349 1.4 perseant fileerror(idesc->id_number, dirp->d_ino,
350 1.7 perseant "BAD TYPE FOR IFILE");
351 1.4 perseant dirp->d_type = DT_REG;
352 1.4 perseant if (reply("FIX") == 1)
353 1.4 perseant ret |= ALTERED;
354 1.4 perseant }
355 1.7 perseant } else if (((dirp->d_ino == WINO && (dirp->d_type != DT_WHT)) ||
356 1.7 perseant (dirp->d_ino != WINO && dirp->d_type == DT_WHT))) {
357 1.1 perseant fileerror(idesc->id_number, dirp->d_ino, "BAD WHITEOUT ENTRY");
358 1.1 perseant dirp->d_ino = WINO;
359 1.1 perseant dirp->d_type = DT_WHT;
360 1.1 perseant if (reply("FIX") == 1)
361 1.1 perseant ret |= ALTERED;
362 1.1 perseant } else {
363 1.1 perseant again:
364 1.1 perseant switch (statemap[dirp->d_ino]) {
365 1.1 perseant case USTATE:
366 1.1 perseant if (idesc->id_entryno <= 2)
367 1.1 perseant break;
368 1.1 perseant fileerror(idesc->id_number, dirp->d_ino, "UNALLOCATED");
369 1.1 perseant n = reply("REMOVE");
370 1.1 perseant break;
371 1.1 perseant
372 1.1 perseant case DCLEAR:
373 1.1 perseant case FCLEAR:
374 1.1 perseant if (idesc->id_entryno <= 2)
375 1.1 perseant break;
376 1.1 perseant if (statemap[dirp->d_ino] == FCLEAR)
377 1.1 perseant errmsg = "DUP/BAD";
378 1.1 perseant else if (!preen)
379 1.1 perseant errmsg = "ZERO LENGTH DIRECTORY";
380 1.1 perseant else {
381 1.1 perseant n = 1;
382 1.1 perseant break;
383 1.1 perseant }
384 1.1 perseant fileerror(idesc->id_number, dirp->d_ino, errmsg);
385 1.1 perseant if ((n = reply("REMOVE")) == 1)
386 1.1 perseant break;
387 1.1 perseant dp = ginode(dirp->d_ino);
388 1.1 perseant statemap[dirp->d_ino] =
389 1.7 perseant (dp->di_mode & IFMT) == IFDIR ? DSTATE : FSTATE;
390 1.1 perseant lncntp[dirp->d_ino] = dp->di_nlink;
391 1.1 perseant goto again;
392 1.1 perseant
393 1.1 perseant case DSTATE:
394 1.1 perseant case DFOUND:
395 1.1 perseant inp = getinoinfo(dirp->d_ino);
396 1.1 perseant if (inp->i_parent != 0 && idesc->id_entryno > 2) {
397 1.9 itojun getpathname(pathbuf, sizeof(pathbuf),
398 1.9 itojun idesc->id_number, idesc->id_number);
399 1.9 itojun getpathname(namebuf, sizeof(namebuf),
400 1.9 itojun dirp->d_ino, dirp->d_ino);
401 1.1 perseant pwarn("%s %s %s\n", pathbuf,
402 1.7 perseant "IS AN EXTRANEOUS HARD LINK TO DIRECTORY",
403 1.7 perseant namebuf);
404 1.1 perseant if (preen)
405 1.1 perseant printf(" (IGNORED)\n");
406 1.1 perseant else if ((n = reply("REMOVE")) == 1)
407 1.1 perseant break;
408 1.1 perseant }
409 1.1 perseant if (idesc->id_entryno > 2)
410 1.1 perseant inp->i_parent = idesc->id_number;
411 1.1 perseant /* fall through */
412 1.1 perseant
413 1.1 perseant case FSTATE:
414 1.7 perseant if (dirp->d_type != typemap[dirp->d_ino]) {
415 1.1 perseant fileerror(idesc->id_number, dirp->d_ino,
416 1.7 perseant "BAD TYPE VALUE");
417 1.1 perseant dirp->d_type = typemap[dirp->d_ino];
418 1.1 perseant if (reply("FIX") == 1)
419 1.1 perseant ret |= ALTERED;
420 1.1 perseant }
421 1.1 perseant lncntp[dirp->d_ino]--;
422 1.1 perseant break;
423 1.1 perseant
424 1.1 perseant default:
425 1.7 perseant err(8, "BAD STATE %d FOR INODE I=%d",
426 1.7 perseant statemap[dirp->d_ino], dirp->d_ino);
427 1.1 perseant }
428 1.1 perseant }
429 1.1 perseant if (n == 0)
430 1.4 perseant return (ret | KEEPON);
431 1.1 perseant dirp->d_ino = 0;
432 1.4 perseant return (ret | KEEPON | ALTERED);
433 1.1 perseant }
434 1.1 perseant /*
435 1.1 perseant * Routine to sort disk blocks.
436 1.1 perseant */
437 1.1 perseant static int
438 1.4 perseant blksort(const void *inpp1, const void *inpp2)
439 1.1 perseant {
440 1.7 perseant return ((*(struct inoinfo **) inpp1)->i_blks[0] -
441 1.7 perseant (*(struct inoinfo **) inpp2)->i_blks[0]);
442 1.1 perseant }
443