home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / C-FDC / CHECKD.C next >
Text File  |  1986-06-19  |  2KB  |  70 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include <memory.h>
  5. #include "fdc.h"
  6.  
  7. int main()
  8. {
  9.  
  10.     int i, j, drive, head, track, start_sect, max_sect, type;
  11.     int times;
  12.     long size;
  13.     int sector;
  14.     char buf[BUFSIZ * 9 + 1];
  15.     char buf1[BUFSIZ * 9 + 1];
  16.     int fd;
  17.  
  18.     size = (long)(360l * 1024l);
  19.  
  20.     if((fd = mopen(size)) != -1) {
  21.         fprintf(stderr, "Can't open the output file!\n");
  22.         exit(1);
  23.     }
  24.     for(times = 0; times < 1; ++times) {
  25.         if(!times) {
  26.             printf("insert the first diskette into the drive & hit enter ");
  27.             gets(buf);
  28.         } else {
  29.             lseek(fd, 0l, 0);
  30.             printf("insert the second diskette into the drive & hit enter ");
  31.             gets(buf);
  32.         }
  33.         drive = 0;                /* set drive to A */
  34.         type = 2;                /* set 320/360K disk in 1.2 M drive */
  35.         start_sect = 1;
  36.         max_sect = 9;
  37.         if(setdasd(drive, type)) {
  38.             fprintf(stderr, "Can't set the dasd for drive A!\n");
  39.             close(fd);
  40.             exit(1);
  41.         }
  42.         
  43.         for(track = 0; track < 40; track++) 
  44.             for(head = 0; head < 2; head++)
  45.                 for(sector = 1; sector < 10; sector++)
  46.                 for(i = 0; i < 3; i++) {
  47.                     if(rdtrack(drive, head, track, sector, 1, buf) == 0) {
  48.                         if(!times) {
  49.                             write(fd, buf, BUFSIZ);
  50.                         } else {
  51.                             read(fd, buf1, BUFSIZ);
  52.                             for(j = 0; j < BUFSIZ; j++)
  53.                                 if(buf1[i] != buf[i]) {
  54.                                     printf("difference at head %2d, track %2d, byte %5d \
  55. %x %x\n", head, track, i, buf1[i], buf[i]);
  56.                                 }
  57.                         }
  58.                     } else {
  59.                         fprintf(stderr, "failure %d on head %d, track %d, sector %d\n", i, head,
  60.                         track, sector);
  61.                     }
  62.                 }
  63.     }
  64.     close(fd);
  65.     printf("done\n");
  66.     exit(0);
  67.     
  68. }
  69.                     
  70.