Annotation of 43BSDReno/sbin/fsck/pass4.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980, 1986 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted provided
                      6:  * that: (1) source distributions retain this entire copyright notice and
                      7:  * comment, and (2) distributions including binaries display the following
                      8:  * acknowledgement:  ``This product includes software developed by the
                      9:  * University of California, Berkeley and its contributors'' in the
                     10:  * documentation or other materials provided with the distribution and in
                     11:  * all advertising materials mentioning features or use of this software.
                     12:  * Neither the name of the University nor the names of its contributors may
                     13:  * be used to endorse or promote products derived from this software without
                     14:  * specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     16:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     17:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  */
                     19: 
                     20: #ifndef lint
                     21: static char sccsid[] = "@(#)pass4.c    5.10 (Berkeley) 7/20/90";
                     22: #endif /* not lint */
                     23: 
                     24: #include <sys/param.h>
                     25: #include <ufs/dinode.h>
                     26: #include <ufs/fs.h>
                     27: #include <stdlib.h>
                     28: #include <string.h>
                     29: #include "fsck.h"
                     30: 
                     31: int    pass4check();
                     32: 
                     33: pass4()
                     34: {
                     35:        register ino_t inumber;
                     36:        register struct zlncnt *zlnp;
                     37:        struct dinode *dp;
                     38:        struct inodesc idesc;
                     39:        int n;
                     40: 
                     41:        bzero((char *)&idesc, sizeof(struct inodesc));
                     42:        idesc.id_type = ADDR;
                     43:        idesc.id_func = pass4check;
                     44:        for (inumber = ROOTINO; inumber <= lastino; inumber++) {
                     45:                idesc.id_number = inumber;
                     46:                switch (statemap[inumber]) {
                     47: 
                     48:                case FSTATE:
                     49:                case DFOUND:
                     50:                        n = lncntp[inumber];
                     51:                        if (n)
                     52:                                adjust(&idesc, (short)n);
                     53:                        else {
                     54:                                for (zlnp = zlnhead; zlnp; zlnp = zlnp->next)
                     55:                                        if (zlnp->zlncnt == inumber) {
                     56:                                                zlnp->zlncnt = zlnhead->zlncnt;
                     57:                                                zlnp = zlnhead;
                     58:                                                zlnhead = zlnhead->next;
                     59:                                                free((char *)zlnp);
                     60:                                                clri(&idesc, "UNREF", 1);
                     61:                                                break;
                     62:                                        }
                     63:                        }
                     64:                        break;
                     65: 
                     66:                case DSTATE:
                     67:                        clri(&idesc, "UNREF", 1);
                     68:                        break;
                     69: 
                     70:                case DCLEAR:
                     71:                        dp = ginode(inumber);
                     72:                        if (dp->di_size == 0) {
                     73:                                clri(&idesc, "ZERO LENGTH", 1);
                     74:                                break;
                     75:                        }
                     76:                        /* fall through */
                     77:                case FCLEAR:
                     78:                        clri(&idesc, "BAD/DUP", 1);
                     79:                        break;
                     80: 
                     81:                case USTATE:
                     82:                        break;
                     83: 
                     84:                default:
                     85:                        errexit("BAD STATE %d FOR INODE I=%d",
                     86:                            statemap[inumber], inumber);
                     87:                }
                     88:        }
                     89: }
                     90: 
                     91: pass4check(idesc)
                     92:        register struct inodesc *idesc;
                     93: {
                     94:        register struct dups *dlp;
                     95:        int nfrags, res = KEEPON;
                     96:        daddr_t blkno = idesc->id_blkno;
                     97: 
                     98:        for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
                     99:                if (chkrange(blkno, 1)) {
                    100:                        res = SKIP;
                    101:                } else if (testbmap(blkno)) {
                    102:                        for (dlp = duplist; dlp; dlp = dlp->next) {
                    103:                                if (dlp->dup != blkno)
                    104:                                        continue;
                    105:                                dlp->dup = duplist->dup;
                    106:                                dlp = duplist;
                    107:                                duplist = duplist->next;
                    108:                                free((char *)dlp);
                    109:                                break;
                    110:                        }
                    111:                        if (dlp == 0) {
                    112:                                clrbmap(blkno);
                    113:                                n_blks--;
                    114:                        }
                    115:                }
                    116:        }
                    117:        return (res);
                    118: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.