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