home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / research / 1972_stuff / dmr_plugin / text0000.txt < prev   
Encoding:
Text File  |  2000-01-04  |  2.3 KB  |  124 lines

  1. Attached below is  the "plugin" for tapfs (part of the plan 9 things that
  2. mount things as file systems).  It's the only part that's tap-specific.
  3.  
  4. Just got your latest mail--as I said, I don't recognize the format of s1
  5. either.  My headers for s2 are consistent with yours, I think, modulo
  6. date understanding.  (And mapping of permissions etc into Plan 9).
  7. For example: 
  8.  
  9. --r---wxrw- M 10745 79524 28 1912 Jan  3  1973 bin/form
  10.  
  11. The M 10745 79524 28 part is just Plan 9; there's a possible year
  12. ambiguity; the day difference is probably US vs AU.
  13.  
  14.     ---
  15.  
  16. #include <u.h>
  17. #include <libc.h>
  18. #include "tapefs.h"
  19.  
  20. /*
  21.  * File system for old tap tapes.
  22.  */
  23.  
  24. struct tap {
  25.     unsigned char    name[32];
  26.     unsigned char    mode[1];
  27.     unsigned char    uid[1];
  28.     unsigned char    size[2];
  29.     unsigned char    tmod[4];
  30.     unsigned char    taddress[2];
  31.     unsigned char    unused[20];
  32.     unsigned char    checksum[2];
  33. } dir[192];
  34.  
  35. int    tapefile;
  36. char    buffer[8192];
  37. long    cvtime(unsigned char *);
  38.  
  39. void
  40. populate(char *name)
  41. {
  42.     int i, isabs;
  43.     struct tap *tpp;
  44.     Fileinf f;
  45.  
  46.     replete = 1;
  47.     tapefile = open(name, OREAD);
  48.     if (tapefile<0)
  49.         error("Can't open argument file");
  50.     read(tapefile, dir, sizeof dir);
  51.     for (i=0, tpp=&dir[8]; i<192; i++, tpp++) {
  52.         unsigned char *sp = (unsigned char *)tpp;
  53.         int j, cksum = 0;
  54.         for (j=0; j<32; j++, sp+=2)
  55.             cksum += sp[0] + (sp[1]<<8);
  56.         cksum &= 0xFFFF;
  57.         if (cksum!=0) {
  58.             print("cksum failure\n");
  59.             continue;
  60.         }
  61.         if (tpp->name[0]=='\0')
  62.             continue;
  63.         f.addr = (void *)(tpp->taddress[0] + (tpp->taddress[1]<<8));
  64.         if (f.addr==0)
  65.             continue;
  66.         f.size = tpp->size[0] + (tpp->size[1]<<8);
  67.         f.mdate = cvtime(tpp->tmod);
  68.         f.mode = tpp->mode[0]&0777;
  69.         isabs = tpp->name[0]=='/';
  70.         f.name = (char *)tpp->name+isabs;
  71.         poppath(f, 1);
  72.     }
  73. }
  74.  
  75. long
  76. cvtime(unsigned char *tp)
  77. {
  78.     unsigned long t = (tp[1]<<24)+(tp[0]<<16)+(tp[3]<<8)+(tp[2]<<0);
  79.     t /= 60;
  80.     t += 3*365*24*3600;
  81.     return t;
  82. }
  83.  
  84. void
  85. popdir(Ram *r)
  86. {
  87.     USED(r);
  88. }
  89.  
  90. void
  91. dotrunc(Ram *r)
  92. {
  93.     USED(r);
  94. }
  95.  
  96. void
  97. docreate(Ram *r)
  98. {
  99.     USED(r);
  100. }
  101.  
  102. char *
  103. doread(Ram *r, long off, long cnt)
  104. {
  105.     if (cnt>sizeof(buffer))
  106.         print("count too big\n");
  107.     seek(tapefile, 512*(int)r->data+off, 0);
  108.     read(tapefile, buffer, cnt);
  109.     return buffer;
  110. }
  111.  
  112. void
  113. dowrite(Ram *r, char *buf, long off, long cnt)
  114. {
  115.     USED(r); USED(buf); USED(off); USED(cnt);
  116. }
  117.  
  118. int
  119. dopermw(Ram *r)
  120. {
  121.     USED(r);
  122.     return 0;
  123. }
  124.