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 / hdtoms.c < prev    next >
C/C++ Source or Header  |  1991-08-04  |  1KB  |  62 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 = open(argv[ 1 ], S_IREAD )) < 0)
  27.         exit( errno );
  28.     system("ex diskcache -d /d0");
  29.     if ((p0 = open("/d0@", S_IWRITE )) < 0)
  30.         exit( errno );
  31.     if (_gs_opt(p0, &d0opts) >= 0) {
  32.         d0opts.sg_verify = 1;
  33.         _ss_opt(p0, &d0opts);
  34.     }        
  35.     s = 0;
  36.     c = '1';
  37.     while (s < 80 * 2 * 9) {
  38.         putchar(c);
  39.         fflush(stdout);
  40.         c++;
  41.         if (c > '9')
  42.             c = '0';
  43.         if (read(p1, puffer, 72*512 ) == 0)
  44.             break;
  45.         for(j = 0; j < 36; ++j) {
  46.             lseek(p0, convadress(s + j*2), 0);
  47.             if (write(p0, puffer+j*1024, 256) < 256)
  48.                 fprintf(stderr, "Fehler: sector %04x\n",
  49.                     (s + j*2) * 2);
  50.         } 
  51.         for(j = 0; j < 36; ++j) {
  52.             lseek(p0, convadress(s + j*2 + 1), 0);
  53.             if (write(p0, puffer+j*1024 + 512, 256) < 256)
  54.                 fprintf(stderr, "Fehler: sector %04x\n",
  55.                     (s + j*2 + 1) * 2);
  56.         }
  57.         s += 72;
  58.     }
  59.     putchar('\n');
  60. }
  61.