1: char dot[] ".";
   2: char dotdot[] "..";
   3: char root[] "/";
   4: char name[512];
   5: int file, off -1;
   6: struct statb {int devn, inum, i[18];}x;
   7: struct entry { int jnum; char name[16];}y;
   8: 
   9: main() {
  10:     int n;
  11: 
  12: loop0:
  13:     stat(dot, &x);
  14:     if((file = open(dotdot,0)) < 0) prname();
  15: loop1:
  16:     if((n = read(file,&y,16)) < 16) prname();
  17:     if(y.jnum != x.inum)goto loop1;
  18:     close(file);
  19:     if(y.jnum == 1) ckroot();
  20:     cat();
  21:     chdir(dotdot);
  22:     goto loop0;
  23: }
  24: ckroot() {
  25:     int i, n;
  26: 
  27:     if((n = stat(y.name,&x)) < 0) prname();
  28:     i = x.devn;
  29:     if((n = chdir(root)) < 0) prname();
  30:     if((file = open(root,0)) < 0) prname();
  31: loop:
  32:     if((n = read(file,&y,16)) < 16) prname();
  33:     if(y.jnum == 0) goto loop;
  34:     if((n = stat(y.name,&x)) < 0) prname();
  35:     if(x.devn != i) goto loop;
  36:     x.i[0] =& 060000;
  37:     if(x.i[0] != 040000) goto loop;
  38:     if(y.name[0]=='.')if(((y.name[1]=='.') && (y.name[2]==0)) ||
  39:                 (y.name[1] == 0)) goto pr;
  40:     cat();
  41: pr:
  42:     write(1,root,1);
  43:     prname();
  44: }
  45: prname() {
  46:     if(off<0)off=0;
  47:     name[off] = '\n';
  48:     write(1,name,off+1);
  49:     exit();
  50: }
  51: cat() {
  52:     int i, j;
  53: 
  54:     i = -1;
  55:     while(y.name[++i] != 0);
  56:     if((off+i+2) > 511) prname();
  57:     for(j=off+1; j>=0; --j) name[j+i+1] = name[j];
  58:     off=i+off+1;
  59:     name[i] = root[0];
  60:     for(--i; i>=0; --i) name[i] = y.name[i];
  61: }

Defined functions

cat defined in line 51; used 2 times
ckroot defined in line 24; used 1 times
  • in line 19
main defined in line 9; never used
prname defined in line 45; used 9 times

Defined variables

dot defined in line 1; used 1 times
  • in line 13
dotdot defined in line 2; used 2 times
file defined in line 5; used 5 times
name defined in line 4; used 15 times
off defined in line 5; used 8 times
root defined in line 3; used 4 times
x defined in line 6; used 8 times
y defined in line 7; used 13 times

Defined struct's

entry defined in line 7; never used
statb defined in line 6; never used
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 765
Valid CSS Valid XHTML 1.0 Strict