1: #
   2: 
   3: char    *dargv[]
   4: {
   5:     "/dev/rrk2",
   6:     "/dev/rrp0",
   7:     0
   8: };
   9: 
  10: #define NINODE  16*16
  11: #include "/usr/sys/ino.h"
  12: #include "/usr/sys/filsys.h"
  13: 
  14: struct  filsys  sblock;
  15: struct  inode   inode[NINODE];
  16: 
  17: int sflg;
  18: int aflg;
  19: #define NI  20
  20: #define NDIRS   787
  21: 
  22: int ilist[NI] { -1};
  23: int fi;
  24: struct  htab {
  25:     int hino;
  26:     int hpino;
  27:     char    hname[14];
  28: } htab[NDIRS];
  29: int nhent   10;
  30: int (*pass[])() { pass1, pass2, pass3 };
  31: char    *lasts;
  32: int ino;
  33: int nerror;
  34: int nffil;
  35: int fout;
  36: int nfiles;
  37: struct dir {
  38:     int ino;
  39:     char    name[14];
  40: };
  41: 
  42: main(argc, argv)
  43: char **argv;
  44: {
  45:     register char **p;
  46:     register int n, *lp;
  47: 
  48:     nffil = dup(1);
  49:     if (argc == 1) {
  50:         for (p = dargv; *p;)
  51:             check(*p++);
  52:         return(nerror);
  53:     }
  54:     while (--argc) {
  55:         argv++;
  56:         if (**argv=='-') switch ((*argv)[1]) {
  57:         case 's':
  58:             sflg++;
  59:             continue;
  60: 
  61:         case 'a':
  62:             aflg++;
  63:             continue;
  64: 
  65:         case 'i':
  66:             lp = ilist;
  67:             while (lp < &ilist[NI-1] && (n = number(argv[1]))) {
  68:                 *lp++ = n;
  69:                 argv++;
  70:                 argc--;
  71:             }
  72:             *lp++ = -1;
  73:             continue;
  74: 
  75:         default:
  76:             printf2("Bad flag\n");
  77:         }
  78:         check(*argv);
  79:     }
  80:     return(nerror);
  81: }
  82: 
  83: check(file)
  84: char *file;
  85: {
  86:     register i, j, pno;
  87: 
  88:     fi = open(file, 0);
  89:     if (fi < 0) {
  90:         printf2("cannot open %s\n", file);
  91:         return;
  92:     }
  93:     printf2("%s:\n", file);
  94:     sync();
  95:     bread(1, &sblock, 512);
  96:     nfiles = sblock.s_isize*16;
  97:     for (i=0; i<NDIRS; i++)
  98:         htab[i].hino = 0;
  99:     fout = nffil;
 100:     flush();
 101:     for (pno=0; pno<3; pno++) {
 102:         ino = 0;
 103:         for (i=0; ino<nfiles; i =+ NINODE/16) {
 104:             bread(i+2, inode, sizeof inode);
 105:             for (j=0; j<NINODE && ino<nfiles; j++) {
 106:                 ino++;
 107:                 (*pass[pno])(&inode[j]);
 108:             }
 109:         }
 110:     }
 111:     flush();
 112:     fout = 1;
 113: }
 114: 
 115: pass1(ip)
 116: {
 117:     if ((ip->i_mode&IALLOC)==0 || (ip->i_mode&IFMT)!=IFDIR)
 118:         return;
 119:     lookup(ino, 1);
 120: }
 121: 
 122: pass2(ip)
 123: struct inode *ip;
 124: {
 125:     register doff;
 126:     register struct htab *hp;
 127:     register struct dir *dp;
 128:     int i;
 129: 
 130:     if ((ip->i_mode&IALLOC)==0 || (ip->i_mode&IFMT)!=IFDIR)
 131:         return;
 132:     doff = 0;
 133:     while (dp = dread(ip, doff)) {
 134:         doff =+ 16;
 135:         if (dp->ino==0)
 136:             continue;
 137:         if ((hp = lookup(dp->ino, 0)) == 0)
 138:             continue;
 139:         if (dotname(dp))
 140:             continue;
 141:         hp->hpino = ino;
 142:         for (i=0; i<14; i++)
 143:             hp->hname[i] = dp->name[i];
 144:     }
 145: }
 146: 
 147: pass3(ip)
 148: struct inode *ip;
 149: {
 150:     register doff;
 151:     register struct dir *dp;
 152:     register int *ilp;
 153: 
 154:     if ((ip->i_mode&IALLOC)==0 || (ip->i_mode&IFMT)!=IFDIR)
 155:         return;
 156:     doff = 0;
 157:     while (dp = dread(ip, doff)) {
 158:         doff =+ 16;
 159:         if (dp->ino==0)
 160:             continue;
 161:         if (aflg==0 && dotname(dp))
 162:             continue;
 163:         for (ilp=ilist; *ilp >= 0; ilp++)
 164:             if (*ilp == dp->ino)
 165:                 break;
 166:         if (ilp > ilist && *ilp!=dp->ino)
 167:             continue;
 168:         printf("%d	", dp->ino);
 169:         pname(ino, 0);
 170:         printf("/%.14s\n", dp->name);
 171:     }
 172: }
 173: 
 174: dotname(adp)
 175: {
 176:     register struct dir *dp;
 177: 
 178:     dp = adp;
 179:     if (dp->name[0]=='.')
 180:         if (dp->name[1]==0 || dp->name[1]=='.' && dp->name[2]==0)
 181:             return(1);
 182:     return(0);
 183: }
 184: 
 185: pname(i, lev)
 186: {
 187:     register struct htab *hp;
 188: 
 189:     if (i==1)
 190:         return;
 191:     if ((hp = lookup(i, 0)) == 0) {
 192:         printf("???");
 193:         return;
 194:     }
 195:     if (lev > 10) {
 196:         printf("...");
 197:         return;
 198:     }
 199:     pname(hp->hpino, ++lev);
 200:     printf("/%.14s", hp->hname);
 201: }
 202: 
 203: lookup(i, ef)
 204: {
 205:     register struct htab *hp;
 206: 
 207:     for (hp = &htab[i%NDIRS]; hp->hino;) {
 208:         if (hp->hino==i)
 209:             return(hp);
 210:         if (++hp >= &htab[NDIRS])
 211:             hp = htab;
 212:     }
 213:     if (ef==0)
 214:         return(0);
 215:     if (++nhent >= NDIRS) {
 216:         printf2("Out of core-- increase NDIRS\n");
 217:         flush();
 218:         exit(1);
 219:     }
 220:     hp->hino = i;
 221:     return(hp);
 222: }
 223: 
 224: dread(aip, aoff)
 225: {
 226:     register b, off;
 227:     register struct inode *ip;
 228:     static ibuf[256];
 229:     static char buf[512];
 230: 
 231:     off = aoff;
 232:     ip = aip;
 233:     if ((off&0777)==0) {
 234:         if (off==0177000) {
 235:             printf2("Monstrous directory %l\n", ino);
 236:             return(0);
 237:         }
 238:         if ((ip->i_mode&ILARG)==0) {
 239:             if (off>=010000 || (b = ip->i_addr[off>>9])==0)
 240:                 return(0);
 241:             bread(b, buf, 512);
 242:         } else {
 243:             if (off==0) {
 244:                 if (ip->i_addr[0]==0)
 245:                     return(0);
 246:                 bread(ip->i_addr[0], ibuf, 512);
 247:             }
 248:             if ((b = ibuf[(off>>9)&0177])==0)
 249:                 return(0);
 250:             bread(b, buf, 512);
 251:         }
 252:     }
 253:     return(&buf[off&0777]);
 254: }
 255: 
 256: bread(bno, buf, cnt)
 257: {
 258: 
 259:     seek(fi, bno, 3);
 260:     if (read(fi, buf, cnt) != cnt) {
 261:         printf2("read error %d\n", bno);
 262:         exit();
 263:     }
 264: }
 265: 
 266: bwrite(bno, buf)
 267: {
 268: 
 269:     seek(fi, bno, 3);
 270:     if (write(fi, buf, 512) != 512) {
 271:         printf2("write error %d\n", bno);
 272:         exit();
 273:     }
 274: }
 275: 
 276: number(as)
 277: char *as;
 278: {
 279:     register n, c;
 280:     register char *s;
 281: 
 282:     s = as;
 283:     n = 0;
 284:     while ((c = *s++) >= '0' && c <= '9') {
 285:         n = n*10+c-'0';
 286:     }
 287:     return(n);
 288: }
 289: 
 290: printf2(s, a1, a2)
 291: {
 292:     extern fout;
 293: 
 294:     flush();
 295:     fout = 2;
 296:     printf(s, a1, a2);
 297:     fout = nffil;
 298:     flush();
 299: }

Defined functions

bread defined in line 256; used 5 times
bwrite defined in line 266; never used
check defined in line 83; used 2 times
dotname defined in line 174; used 2 times
dread defined in line 224; used 2 times
lookup defined in line 203; used 3 times
main defined in line 42; never used
number defined in line 276; used 1 times
  • in line 67
pass1 defined in line 115; used 1 times
  • in line 30
pass2 defined in line 122; used 1 times
  • in line 30
pass3 defined in line 147; used 1 times
  • in line 30
pname defined in line 185; used 2 times
printf2 defined in line 290; used 7 times

Defined variables

aflg defined in line 18; used 2 times
dargv defined in line 3; used 1 times
  • in line 50
fi defined in line 23; used 6 times
fout defined in line 35; used 5 times
htab defined in line 28; used 4 times
ilist defined in line 22; used 4 times
ino defined in line 32; used 15 times
inode defined in line 15; used 3 times
lasts defined in line 31; never used
nerror defined in line 33; used 2 times
nffil defined in line 34; used 3 times
nfiles defined in line 36; used 3 times
nhent defined in line 29; used 1 times
sblock defined in line 14; used 2 times
sflg defined in line 17; used 1 times
  • in line 58

Defined struct's

dir defined in line 37; used 6 times
htab defined in line 24; used 6 times

Defined macros

NDIRS defined in line 20; used 5 times
NI defined in line 19; used 2 times
NINODE defined in line 10; used 3 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1254
Valid CSS Valid XHTML 1.0 Strict