home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / research / 1972_stuff / dmr_plugin next >
Text File  |  2000-01-04  |  3KB  |  136 lines

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