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.tos.c < prev    next >
C/C++ Source or Header  |  1991-08-04  |  969b  |  48 lines

  1. #include <stdio.h>
  2. #include <modes.h>
  3. #include <errno.h>
  4. #include <sgstat.h>
  5.  
  6. struct sgbuf optbuf;
  7.  
  8. unsigned char puffer[ 512 * 9 * 4 ];
  9.  
  10. main(argc, argv)
  11. int argc;
  12. char *argv[];
  13. {
  14.     int p0, p1, i, s, j;
  15.     
  16.     if (argc < 2)
  17.         exit( 1 );
  18.     if ((p1 = open(argv[ 1 ], S_IREAD )) < 0)
  19.         exit( errno );
  20.     if ((p0 = open("/tos0@", S_IWRITE )) < 0)
  21.         exit( errno );
  22.     if (_gs_opt(p0, &optbuf) >= 0) {
  23.         optbuf.sg_verify = 1;
  24.         _ss_opt(p0, &optbuf);
  25.     }        
  26.     s = 0;
  27.     while (s < 80 * 2 * 9 * 512) {
  28.         putchar('#');
  29.         fflush(stdout);
  30.         if (read(p1, puffer, 36*512 ) == 0)
  31.             break;
  32.         for(j = 0; j < 18; ++j) {
  33.             lseek(p0, s + j*1024, 0);
  34.             if (write(p0, puffer+j*1024, 512) < 512)
  35.                 fprintf(stderr, "Fehler: sector %04x\n",
  36.                     (s + j*1024) / 256);
  37.         } 
  38.         for(j = 0; j < 18; ++j) {
  39.             lseek(p0, s + j*1024 + 512, 0);
  40.             if (write(p0, puffer+j*1024 + 512, 512) < 512)
  41.                 fprintf(stderr, "Fehler: sector %04x\n",
  42.                     (s + j*1024 + 512) / 256);
  43.         }
  44.         s += 36*512;
  45.     }
  46.     putchar('\n');
  47. }
  48.