Annotation of coherent/b/etc/fsck/phase1b.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *     Phase 1b of fsck - Rescan for more Dups
                      3:  */
                      4: 
                      5: #include "fsck.h"
                      6: 
                      7: phase1b()
                      8: {
                      9:        if (!qflag)
                     10:                printf("Phase 1b: Rescan for more Dups\n");
                     11:        buildtable();
                     12:        iscanb();
                     13: }
                     14: 
                     15: buildtable()
                     16: {
                     17:        unsigned cntr=0;
                     18:        daddr_t bn;
                     19: 
                     20:        while (cntr<totdups) {
                     21:                bn = dupblck[cntr++];
                     22:                markdup(bn);
                     23:        }
                     24: }
                     25: 
                     26: iscanb()
                     27: {
                     28:        register daddr_t bn;
                     29:        register struct dinode *dip;
                     30:        register ino_t  ino;
                     31:        int i;
                     32: 
                     33:        ino = 1;
                     34: 
                     35:        for (bn=INODEI; bn<isize; bn++) {
                     36:                if (testblock(bn)) {            /* block is bad via inode 1 */
                     37:                        ino += INOPB;
                     38:                        continue;
                     39:                }
                     40:                bread(bn, databuf);
                     41:                dip = (struct dinode *) databuf;
                     42:                for (i=0; i<INOPB; i++) {
                     43:                        candino(dip);
                     44:                        if (inuse(dip) == TRUE) 
                     45:                                ckblksb(dip, ino);
                     46:                        ino++;
                     47:                        dip++;
                     48:                }
                     49:        }
                     50: }
                     51: 
                     52: /*
                     53:  *     Check the blocks associated with the given inode to find the
                     54:  *     remaining duplicate blocks
                     55:  */
                     56: 
                     57: ckblksb(dip, ino)
                     58: register struct dinode *dip;
                     59: register ino_t ino;
                     60: {
                     61:        daddr_t addrs[NADDR], bn;
                     62:        int i, lev, naddr;
                     63:        int mode;
                     64: 
                     65:        mode = dip->di_mode & IFMT;
                     66: 
                     67:        if ( (mode == IFREG) || (mode == IFDIR) )
                     68:                l3tol(addrs, dip->di_addr, naddr=NADDR);
                     69:        else if ( mode == IFPIPE )
                     70:                l3tol(addrs, dip->di_addr, naddr=ND);
                     71:        else
                     72:                return;
                     73: 
                     74:        for(i=0; i<naddr; i++)
                     75:                for (lev=0; lev<4; lev++) 
                     76:                        if (i < offsets[lev]) {
                     77:                                if ( (bn=addrs[i]) != 0 ) {
                     78:                                        dblocksb(bn, ino, lev);
                     79:                                        break;
                     80:                                }
                     81:                        }
                     82: }
                     83: 
                     84: /*
                     85:  *     Checks recursively the blocks pointed at via
                     86:  *     the inode list of blocks.  'bn' is the block number,
                     87:  *     'ino' is the inode referencing it, and 'lev' is the
                     88:  *     level 0 == direct ... 3 = triple-indirect
                     89:  */
                     90: 
                     91: dblocksb(bn, ino, lev)
                     92: daddr_t        bn;
                     93: ino_t  ino;
                     94: int    lev;
                     95: {
                     96:        char buf[BSIZE];
                     97:        int  i;
                     98:        daddr_t *bnptr;
                     99: 
                    100:        if ( cdupb(bn, ino) == OK ) {
                    101:                if (lev--==0)
                    102:                        return(OK);
                    103:                bread(bn, buf);
                    104:                bnptr = (long *) buf;
                    105:                for (i=0; i<NBN; i++) {
                    106:                        bn = bnptr[i];
                    107:                        candaddr(bn);
                    108:                        if ( bn != 0 )
                    109:                                dblocksb(bn, ino, lev);
                    110:                }
                    111:        }
                    112: }
                    113: 
                    114: /*
                    115:  *     Check the given block number for duplicate reference.
                    116:  */
                    117: 
                    118: cdupb(bn, ino)
                    119: daddr_t        bn;
                    120: ino_t  ino;
                    121: {
                    122:        if ( bn >= fsize )
                    123:                return(STOP);
                    124:        if ( !testdup(bn) ) {
                    125:                if ( ino == 1 )         /* bad block inode, let's mark it */
                    126:                        markdup(bn);    /* so we never read it again      */
                    127:                return(OK);
                    128:        }
                    129: 
                    130:        if (!fflag)
                    131:                orflags(ino, IBAD_IDUP);
                    132:        printf("Dup Block %lu, i-number = %u\n", bn, ino);
                    133: 
                    134:        return(STOP);
                    135: }

unix.superglobalmegacorp.com

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