home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / SRC / msdos_diskaccess.lzh / MS_DISK_ACCESS / mstohd.d0.c < prev    next >
C/C++ Source or Header  |  1991-08-04  |  1KB  |  58 lines

  1. #include <stdio.h>
  2. #include <modes.h>
  3. #include <errno.h>
  4. #include <sgstat.h>
  5.  
  6. struct sgbuf d0opts;
  7.  
  8. int
  9. convadress(lsn)
  10. short lsn;
  11. {
  12.     return(((lsn / 9) * 18 + (lsn % 9) + 1) * 256);
  13.  
  14. unsigned char puffer[ 512 * 9 * 8 ];
  15.  
  16. main(argc, argv)
  17. int argc;
  18. char *argv[];
  19. {
  20.     int p0, p1, i;
  21.     short s, j;
  22.     char c;
  23.     
  24.     if (argc < 2)
  25.         exit( 1 );
  26.     if ((p1 = create(argv[ 1 ], S_IWRITE+S_ISIZE,
  27.                       S_IREAD+S_IWRITE, 512*9*80*2 )) < 0)
  28.         exit( errno );
  29.     system("ex diskcache -d /d0");
  30.     if ((p0 = open("/d0@", S_IREAD )) < 0)
  31.         exit( errno );
  32.     s = 0;
  33.     c = '1';
  34.     while (s < 80 * 2 * 9) {
  35.         putchar(c);
  36.         fflush(stdout);
  37.         c++;
  38.         if (c > '9')
  39.             c = '0';
  40.         for(j = 0; j < 36; ++j) {
  41.             lseek(p0, convadress(s + j*2), 0);
  42.             if (read(p0, puffer+j*1024, 256) < 256)
  43.                 fprintf(stderr, "Fehler: sector %04x\n",
  44.                     (s + j*2) * 2);
  45.         } 
  46.         for(j = 0; j < 36; ++j) {
  47.             lseek(p0, convadress(s + j*2 + 1), 0);
  48.             if (read(p0, puffer+j*1024 + 512, 256) < 256)
  49.                 fprintf(stderr, "Fehler: sector %04x\n",
  50.                     (s + j*2 + 1) * 2);
  51.         }
  52.         write(p1, puffer, 72*512 );
  53.         s += 72;
  54.     }
  55.     putchar('\n');
  56. }
  57.