home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / C-FDC / TSTFMT.C < prev    next >
Text File  |  1985-05-27  |  2KB  |  86 lines

  1. /* test format & copy of disk  */
  2. #include <stdio.h>
  3. #include "fdc.h"
  4.  
  5. extern int secsize[];
  6. extern int errno;
  7.  
  8. main()
  9. {
  10.  
  11.     int i;
  12.     char *calloc();
  13.     char *buf;
  14.     struct ati *sp, *getati();
  15.     int drive, head, track;
  16.     int sides, max_sect;
  17.     int sect_type;
  18.  
  19.     sp = getati(1);
  20.     drive = 0;
  21.     track = 20;
  22.     switch(sp->media_type & 0xff) {
  23.         case 0xff:
  24.             sides = 2;
  25.             max_sect = 8;
  26.             break;
  27.         case 0xfe:
  28.             sides = 1;
  29.             max_sect = 8;
  30.             break;
  31.         case 0xfd:
  32.             sides = 2;
  33.             max_sect = 9;
  34.             break;
  35.         case 0xfc:
  36.             sides = 1;
  37.             max_sect = 9;
  38.             break;
  39.         case 0xf9:
  40.             sides = 2;
  41.             max_sect = 15;
  42.             break;
  43.         case 0xf8:
  44.             printf("Trying to fdc the hard disk, eh?\n");
  45.             exit(0);
  46.         default:
  47.             printf("Hummmm. I don't recognize the disk type, %x.\n", 
  48.                 sp->media_type);
  49.             exit(0);
  50.     }
  51.     buf = calloc(sp->sector_size * max_sect, sizeof(char));
  52.     if(buf == NULL) {
  53.         printf("fucked it\n");
  54.         exit(1);
  55.     }
  56.     for(i = 0; i < (sp->sector_size * max_sect); ++i)
  57.         buf[i] = i % 10;
  58.     for(i = 0; secsize[i]; ++i)
  59.         if(sp->sector_size == secsize[i]) {
  60.             sect_type = i;
  61.             break;
  62.     }
  63.  
  64.  
  65.     for(head = 0; head < 2; ++head) {
  66.         printf("format/write/verify drive %d, head %d, track %d, max sect %d, sector type %d\n",
  67.             drive, head, track, max_sect, sect_type);
  68.         if(fmtrack(drive, head, track, max_sect, sect_type)) {
  69.             printf("screwed format! errno = %x\n", errno);
  70.             exit(1);
  71.         }
  72.         if(wrtrack(drive, head, track, 1, max_sect, buf)) {
  73.             printf("screwed write! errno = %x\n", errno);
  74.             exit(1);
  75.         }
  76.         if(vertrack(drive, head, track, 1, max_sect, buf)) {
  77.             printf("screwed verify! errno = %x\n", errno);
  78.             exit(1);
  79.         }
  80.  
  81.     }
  82.     exit(0);
  83.  
  84. }
  85.  
  86.