inode.c revision 1.61 1 /* $NetBSD: inode.c,v 1.61 2015/09/01 06:08:37 dholland Exp $ */
2
3 /*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant (at) hhhh.org>.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 * Copyright (c) 1980, 1986, 1993
34 * The Regents of the University of California. All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 */
60
61 #include <sys/types.h>
62 #include <sys/param.h>
63 #include <sys/time.h>
64 #include <sys/buf.h>
65 #include <sys/mount.h>
66
67 #define vnode uvnode
68 #include <ufs/lfs/lfs.h>
69 #include <ufs/lfs/lfs_accessors.h>
70 #include <ufs/lfs/lfs_inode.h>
71 #undef vnode
72
73 #include <err.h>
74 #ifndef SMALL
75 #include <pwd.h>
76 #endif
77 #include <stdio.h>
78 #include <stdlib.h>
79 #include <string.h>
80 #include <util.h>
81
82 #include "bufcache.h"
83 #include "vnode.h"
84 #include "lfs_user.h"
85
86 #include "fsck.h"
87 #include "fsutil.h"
88 #include "extern.h"
89
90 extern SEGUSE *seg_table;
91 extern ulfs_daddr_t *din_table;
92
93 static int iblock(struct inodesc *, long, u_int64_t);
94 int blksreqd(struct lfs *, int);
95 int lfs_maxino(void);
96
97 /*
98 * Get a dinode of a given inum.
99 * XXX combine this function with vget.
100 */
101 union lfs_dinode *
102 ginode(ino_t ino)
103 {
104 struct uvnode *vp;
105 struct ubuf *bp;
106 IFILE *ifp;
107 daddr_t daddr;
108 unsigned segno;
109
110 vp = vget(fs, ino);
111 if (vp == NULL)
112 return NULL;
113
114 if (din_table[ino] == 0x0) {
115 LFS_IENTRY(ifp, fs, ino, bp);
116 daddr = lfs_if_getdaddr(fs, ifp);
117 segno = lfs_dtosn(fs, daddr);
118 din_table[ino] = daddr;
119 seg_table[segno].su_nbytes += DINOSIZE(fs);
120 brelse(bp, 0);
121 }
122 return VTOI(vp)->i_din;
123 }
124
125 /*
126 * Check validity of held blocks in an inode, recursing through all blocks.
127 */
128 int
129 ckinode(union lfs_dinode *dp, struct inodesc *idesc)
130 {
131 ulfs_daddr_t lbn, pbn;
132 long ret, n, ndb, offset;
133 union lfs_dinode dino;
134 u_int64_t remsize, sizepb;
135 mode_t mode;
136 char pathbuf[MAXPATHLEN + 1];
137 struct uvnode *vp, *thisvp;
138
139 if (idesc->id_fix != IGNORE)
140 idesc->id_fix = DONTKNOW;
141 idesc->id_entryno = 0;
142 idesc->id_filesize = lfs_dino_getsize(fs, dp);
143 mode = lfs_dino_getmode(fs, dp) & LFS_IFMT;
144 if (mode == LFS_IFBLK || mode == LFS_IFCHR ||
145 (mode == LFS_IFLNK && (lfs_dino_getsize(fs, dp) < lfs_sb_getmaxsymlinklen(fs) ||
146 (lfs_sb_getmaxsymlinklen(fs) == 0 &&
147 lfs_dino_getblocks(fs, dp) == 0))))
148 return (KEEPON);
149 /* XXX is this safe if we're 32-bit? */
150 dino = *dp;
151 ndb = howmany(lfs_dino_getsize(fs, &dino), lfs_sb_getbsize(fs));
152
153 thisvp = vget(fs, idesc->id_number);
154 for (lbn = 0; lbn < ULFS_NDADDR; lbn++) {
155 pbn = lfs_dino_getdb(fs, &dino, lbn);
156 if (thisvp)
157 idesc->id_numfrags =
158 lfs_numfrags(fs, VTOI(thisvp)->i_lfs_fragsize[lbn]);
159 else {
160 if (--ndb == 0 && (offset = lfs_blkoff(fs, lfs_dino_getsize(fs, &dino))) != 0) {
161 idesc->id_numfrags =
162 lfs_numfrags(fs, lfs_fragroundup(fs, offset));
163 } else
164 idesc->id_numfrags = lfs_sb_getfrag(fs);
165 }
166 if (pbn == 0) {
167 if (idesc->id_type == DATA && ndb >= 0) {
168 /* An empty block in a directory XXX */
169 getpathname(pathbuf, sizeof(pathbuf),
170 idesc->id_number, idesc->id_number);
171 pfatal("DIRECTORY %s INO %lld: CONTAINS EMPTY BLOCKS [1]",
172 pathbuf, (long long)idesc->id_number);
173 if (reply("ADJUST LENGTH") == 1) {
174 vp = vget(fs, idesc->id_number);
175 dp = VTOD(vp);
176 lfs_dino_setsize(fs, dp,
177 lbn * lfs_sb_getbsize(fs));
178 printf(
179 "YOU MUST RERUN FSCK AFTERWARDS\n");
180 rerun = 1;
181 inodirty(VTOI(vp));
182 } else
183 break;
184 }
185 continue;
186 }
187 idesc->id_blkno = pbn;
188 idesc->id_lblkno = lbn;
189 if (idesc->id_type == ADDR) {
190 ret = (*idesc->id_func) (idesc);
191 } else
192 ret = dirscan(idesc);
193 if (ret & STOP)
194 return (ret);
195 }
196 idesc->id_numfrags = lfs_sb_getfrag(fs);
197 remsize = lfs_dino_getsize(fs, &dino) - lfs_sb_getbsize(fs) * ULFS_NDADDR;
198 sizepb = lfs_sb_getbsize(fs);
199 for (n = 1; n <= ULFS_NIADDR; n++) {
200 pbn = lfs_dino_getib(fs, &dino, n-1);
201 if (pbn) {
202 idesc->id_blkno = pbn;
203 ret = iblock(idesc, n, remsize);
204 if (ret & STOP)
205 return (ret);
206 } else {
207 if (idesc->id_type == DATA && remsize > 0) {
208 /* An empty block in a directory XXX */
209 getpathname(pathbuf, sizeof(pathbuf),
210 idesc->id_number, idesc->id_number);
211 pfatal("DIRECTORY %s INO %lld: CONTAINS EMPTY BLOCKS [2]",
212 pathbuf, (long long)idesc->id_number);
213 if (reply("ADJUST LENGTH") == 1) {
214 vp = vget(fs, idesc->id_number);
215 dp = VTOD(vp);
216 lfs_dino_setsize(fs, dp,
217 lfs_dino_getsize(fs, dp) - remsize);
218 remsize = 0;
219 printf(
220 "YOU MUST RERUN FSCK AFTERWARDS\n");
221 rerun = 1;
222 inodirty(VTOI(vp));
223 break;
224 } else
225 break;
226 }
227 }
228 sizepb *= LFS_NINDIR(fs);
229 remsize -= sizepb;
230 }
231 return (KEEPON);
232 }
233
234 static int
235 iblock(struct inodesc *idesc, long ilevel, u_int64_t isize)
236 {
237 ulfs_daddr_t *ap, *aplim;
238 struct ubuf *bp;
239 int i, n, (*func) (struct inodesc *), nif;
240 u_int64_t sizepb;
241 char pathbuf[MAXPATHLEN + 1], buf[BUFSIZ];
242 struct uvnode *devvp, *vp;
243 int diddirty = 0;
244
245 if (idesc->id_type == ADDR) {
246 func = idesc->id_func;
247 n = (*func) (idesc);
248 if ((n & KEEPON) == 0)
249 return (n);
250 } else
251 func = dirscan;
252 if (chkrange(idesc->id_blkno, idesc->id_numfrags))
253 return (SKIP);
254
255 devvp = fs->lfs_devvp;
256 bread(devvp, LFS_FSBTODB(fs, idesc->id_blkno), lfs_sb_getbsize(fs),
257 0, &bp);
258 ilevel--;
259 for (sizepb = lfs_sb_getbsize(fs), i = 0; i < ilevel; i++)
260 sizepb *= LFS_NINDIR(fs);
261 if (isize > sizepb * LFS_NINDIR(fs))
262 nif = LFS_NINDIR(fs);
263 else
264 nif = howmany(isize, sizepb);
265 if (idesc->id_func == pass1check && nif < LFS_NINDIR(fs)) {
266 aplim = ((ulfs_daddr_t *) bp->b_data) + LFS_NINDIR(fs);
267 for (ap = ((ulfs_daddr_t *) bp->b_data) + nif; ap < aplim; ap++) {
268 if (*ap == 0)
269 continue;
270 (void)snprintf(buf, sizeof(buf),
271 "PARTIALLY TRUNCATED INODE I=%llu",
272 (unsigned long long)idesc->id_number);
273 if (dofix(idesc, buf)) {
274 *ap = 0;
275 ++diddirty;
276 }
277 }
278 }
279 aplim = ((ulfs_daddr_t *) bp->b_data) + nif;
280 for (ap = ((ulfs_daddr_t *) bp->b_data); ap < aplim; ap++) {
281 if (*ap) {
282 idesc->id_blkno = *ap;
283 if (ilevel == 0) {
284 /*
285 * dirscan needs lfs_lblkno.
286 */
287 idesc->id_lblkno++;
288 n = (*func) (idesc);
289 } else {
290 n = iblock(idesc, ilevel, isize);
291 }
292 if (n & STOP) {
293 if (diddirty)
294 VOP_BWRITE(bp);
295 else
296 brelse(bp, 0);
297 return (n);
298 }
299 } else {
300 if (idesc->id_type == DATA && isize > 0) {
301 /* An empty block in a directory XXX */
302 getpathname(pathbuf, sizeof(pathbuf),
303 idesc->id_number, idesc->id_number);
304 pfatal("DIRECTORY %s INO %lld: CONTAINS EMPTY BLOCKS [3]",
305 pathbuf, (long long)idesc->id_number);
306 if (reply("ADJUST LENGTH") == 1) {
307 vp = vget(fs, idesc->id_number);
308 lfs_dino_setsize(fs, VTOI(vp)->i_din,
309 lfs_dino_getsize(fs,
310 VTOI(vp)->i_din)
311 - isize);
312 isize = 0;
313 printf(
314 "YOU MUST RERUN FSCK AFTERWARDS\n");
315 rerun = 1;
316 inodirty(VTOI(vp));
317 if (diddirty)
318 VOP_BWRITE(bp);
319 else
320 brelse(bp, 0);
321 return (STOP);
322 }
323 }
324 }
325 isize -= sizepb;
326 }
327 if (diddirty)
328 VOP_BWRITE(bp);
329 else
330 brelse(bp, 0);
331 return (KEEPON);
332 }
333
334 /*
335 * Check that a block in a legal block number.
336 * Return 0 if in range, 1 if out of range.
337 */
338 int
339 chkrange(daddr_t blk, int cnt)
340 {
341 if (blk < lfs_sntod(fs, 0)) {
342 return (1);
343 }
344 if (blk > maxfsblock) {
345 return (1);
346 }
347 if (blk + cnt < lfs_sntod(fs, 0)) {
348 return (1);
349 }
350 if (blk + cnt > maxfsblock) {
351 return (1);
352 }
353 return (0);
354 }
355
356 /*
357 * Routines to maintain information about directory inodes.
358 * This is built during the first pass and used during the
359 * second and third passes.
360 *
361 * Enter inodes into the cache.
362 */
363 void
364 cacheino(union lfs_dinode *dp, ino_t inumber)
365 {
366 struct inoinfo *inp;
367 struct inoinfo **inpp, **ninpsort;
368 unsigned int blks, i;
369
370 blks = howmany(lfs_dino_getsize(fs, dp), lfs_sb_getbsize(fs));
371 if (blks > ULFS_NDADDR)
372 blks = ULFS_NDADDR + ULFS_NIADDR;
373 inp = emalloc(sizeof(*inp) + (blks - 1) * sizeof(ulfs_daddr_t));
374 inpp = &inphead[inumber % numdirs];
375 inp->i_nexthash = *inpp;
376 *inpp = inp;
377 inp->i_child = inp->i_sibling = inp->i_parentp = 0;
378 if (inumber == ULFS_ROOTINO)
379 inp->i_parent = ULFS_ROOTINO;
380 else
381 inp->i_parent = (ino_t) 0;
382 inp->i_dotdot = (ino_t) 0;
383 inp->i_number = inumber;
384 inp->i_isize = lfs_dino_getsize(fs, dp);
385
386 inp->i_numblks = blks * sizeof(ulfs_daddr_t);
387 for (i=0; i<blks && i<ULFS_NDADDR; i++) {
388 inp->i_blks[i] = lfs_dino_getdb(fs, dp, i);
389 }
390 for (; i<blks; i++) {
391 inp->i_blks[i] = lfs_dino_getib(fs, dp, i - ULFS_NDADDR);
392 }
393 if (inplast == listmax) {
394 ninpsort = erealloc(inpsort,
395 (listmax + 100) * sizeof(struct inoinfo *));
396 inpsort = ninpsort;
397 listmax += 100;
398 }
399 inpsort[inplast++] = inp;
400 }
401
402 /*
403 * Look up an inode cache structure.
404 */
405 struct inoinfo *
406 getinoinfo(ino_t inumber)
407 {
408 struct inoinfo *inp;
409
410 for (inp = inphead[inumber % numdirs]; inp; inp = inp->i_nexthash) {
411 if (inp->i_number != inumber)
412 continue;
413 return (inp);
414 }
415 err(EEXIT, "cannot find inode %llu", (unsigned long long)inumber);
416 return ((struct inoinfo *) 0);
417 }
418
419 /*
420 * Clean up all the inode cache structure.
421 */
422 void
423 inocleanup(void)
424 {
425 struct inoinfo **inpp;
426
427 if (inphead == NULL)
428 return;
429 for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--)
430 free((char *) (*inpp));
431 free((char *) inphead);
432 free((char *) inpsort);
433 inphead = inpsort = NULL;
434 }
435
436 void
437 inodirty(struct inode *ip)
438 {
439 ip->i_flag |= IN_MODIFIED;
440 }
441
442 void
443 clri(struct inodesc * idesc, const char *type, int flag)
444 {
445 struct uvnode *vp;
446
447 vp = vget(fs, idesc->id_number);
448 if (flag & 0x1) {
449 pwarn("%s %s", type,
450 (lfs_dino_getmode(fs, VTOI(vp)->i_din) & LFS_IFMT) == LFS_IFDIR ? "DIR" : "FILE");
451 pinode(idesc->id_number);
452 }
453 if ((flag & 0x2) || preen || reply("CLEAR") == 1) {
454 if (preen && flag != 2)
455 printf(" (CLEARED)\n");
456 n_files--;
457 (void) ckinode(VTOD(vp), idesc);
458 clearinode(idesc->id_number);
459 statemap[idesc->id_number] = USTATE;
460 vnode_destroy(vp);
461 return;
462 }
463 return;
464 }
465
466 void
467 clearinode(ino_t inumber)
468 {
469 struct ubuf *bp;
470 IFILE *ifp;
471 daddr_t daddr;
472
473 /* Send cleared inode to the free list */
474
475 LFS_IENTRY(ifp, fs, inumber, bp);
476 daddr = lfs_if_getdaddr(fs, ifp);
477 if (daddr == LFS_UNUSED_DADDR) {
478 brelse(bp, 0);
479 return;
480 }
481 lfs_if_setdaddr(fs, ifp, LFS_UNUSED_DADDR);
482 lfs_if_setnextfree(fs, ifp, lfs_sb_getfreehd(fs));
483 lfs_sb_setfreehd(fs, inumber);
484 sbdirty();
485 VOP_BWRITE(bp);
486
487 /*
488 * update segment usage.
489 */
490 if (daddr != LFS_UNUSED_DADDR) {
491 SEGUSE *sup;
492 u_int32_t oldsn = lfs_dtosn(fs, daddr);
493
494 seg_table[oldsn].su_nbytes -= DINOSIZE(fs);
495 LFS_SEGENTRY(sup, fs, oldsn, bp);
496 sup->su_nbytes -= DINOSIZE(fs);
497 LFS_WRITESEGENTRY(sup, fs, oldsn, bp); /* Ifile */
498 }
499 }
500
501 int
502 findname(struct inodesc * idesc)
503 {
504 struct lfs_direct *dirp = idesc->id_dirp;
505 size_t len;
506 char *buf;
507
508 if (dirp->d_ino != idesc->id_parent)
509 return (KEEPON);
510 if ((len = dirp->d_namlen + 1) > MAXPATHLEN) {
511 /* Truncate it but don't overflow the buffer */
512 len = MAXPATHLEN;
513 }
514 /* this is namebuf with utils.h */
515 buf = __UNCONST(idesc->id_name);
516 (void)memcpy(buf, dirp->d_name, len);
517 return (STOP | FOUND);
518 }
519
520 int
521 findino(struct inodesc * idesc)
522 {
523 struct lfs_direct *dirp = idesc->id_dirp;
524
525 if (dirp->d_ino == 0)
526 return (KEEPON);
527 if (strcmp(dirp->d_name, idesc->id_name) == 0 &&
528 dirp->d_ino >= ULFS_ROOTINO && dirp->d_ino < maxino) {
529 idesc->id_parent = dirp->d_ino;
530 return (STOP | FOUND);
531 }
532 return (KEEPON);
533 }
534
535 void
536 pinode(ino_t ino)
537 {
538 union lfs_dinode *dp;
539 struct passwd *pw;
540
541 printf(" I=%llu ", (unsigned long long)ino);
542 if (ino < ULFS_ROOTINO || ino >= maxino)
543 return;
544 dp = ginode(ino);
545 if (dp) {
546 printf(" OWNER=");
547 #ifndef SMALL
548 if (Uflag && (pw = getpwuid(lfs_dino_getuid(fs, dp))) != 0)
549 printf("%s ", pw->pw_name);
550 else
551 #endif
552 printf("%u ", (unsigned)lfs_dino_getuid(fs, dp));
553 printf("MODE=%o\n", lfs_dino_getmode(fs, dp));
554 if (preen)
555 printf("%s: ", cdevname());
556 printf("SIZE=%ju ", (uintmax_t) lfs_dino_getsize(fs, dp));
557 printf("MTIME=%s ", print_mtime(lfs_dino_getmtime(fs, dp)));
558 }
559 }
560
561 void
562 blkerror(ino_t ino, const char *type, daddr_t blk)
563 {
564
565 pfatal("%lld %s I=%llu", (long long) blk, type,
566 (unsigned long long)ino);
567 printf("\n");
568 if (exitonfail)
569 exit(1);
570 switch (statemap[ino]) {
571
572 case FSTATE:
573 statemap[ino] = FCLEAR;
574 return;
575
576 case DSTATE:
577 statemap[ino] = DCLEAR;
578 return;
579
580 case FCLEAR:
581 case DCLEAR:
582 return;
583
584 default:
585 err(EEXIT, "BAD STATE %d TO BLKERR", statemap[ino]);
586 /* NOTREACHED */
587 }
588 }
589
590 /*
591 * allocate an unused inode
592 */
593 ino_t
594 allocino(ino_t request, int type)
595 {
596 ino_t ino;
597 union lfs_dinode *dp;
598 time_t t;
599 struct uvnode *vp;
600 struct ubuf *bp;
601
602 if (request == 0)
603 request = ULFS_ROOTINO;
604 else if (statemap[request] != USTATE)
605 return (0);
606 for (ino = request; ino < maxino; ino++)
607 if (statemap[ino] == USTATE)
608 break;
609 if (ino == maxino)
610 extend_ifile(fs);
611
612 switch (type & LFS_IFMT) {
613 case LFS_IFDIR:
614 statemap[ino] = DSTATE;
615 break;
616 case LFS_IFREG:
617 case LFS_IFLNK:
618 statemap[ino] = FSTATE;
619 break;
620 default:
621 return (0);
622 }
623 vp = lfs_valloc(fs, ino);
624 if (vp == NULL)
625 return (0);
626 dp = VTOI(vp)->i_din;
627 bp = getblk(vp, 0, lfs_sb_getfsize(fs));
628 VOP_BWRITE(bp);
629 lfs_dino_setmode(fs, dp, type);
630 (void) time(&t);
631 lfs_dino_setatime(fs, dp, t);
632 lfs_dino_setctime(fs, dp, t);
633 lfs_dino_setmtime(fs, dp, t);
634 lfs_dino_setsize(fs, dp, lfs_sb_getfsize(fs));
635 lfs_dino_setblocks(fs, dp, lfs_btofsb(fs, lfs_sb_getfsize(fs)));
636 n_files++;
637 inodirty(VTOI(vp));
638 typemap[ino] = LFS_IFTODT(type);
639 return (ino);
640 }
641
642 /*
643 * deallocate an inode
644 */
645 void
646 freeino(ino_t ino)
647 {
648 struct inodesc idesc;
649 struct uvnode *vp;
650
651 memset(&idesc, 0, sizeof(struct inodesc));
652 idesc.id_type = ADDR;
653 idesc.id_func = pass4check;
654 idesc.id_number = ino;
655 vp = vget(fs, ino);
656 (void) ckinode(VTOD(vp), &idesc);
657 clearinode(ino);
658 statemap[ino] = USTATE;
659 vnode_destroy(vp);
660
661 n_files--;
662 }
663