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 >
Wrap
Text File
|
1986-06-19
|
2KB
|
70 lines
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <memory.h>
#include "fdc.h"
int main()
{
int i, j, drive, head, track, start_sect, max_sect, type;
int times;
long size;
int sector;
char buf[BUFSIZ * 9 + 1];
char buf1[BUFSIZ * 9 + 1];
int fd;
size = (long)(360l * 1024l);
if((fd = mopen(size)) != -1) {
fprintf(stderr, "Can't open the output file!\n");
exit(1);
}
for(times = 0; times < 1; ++times) {
if(!times) {
printf("insert the first diskette into the drive & hit enter ");
gets(buf);
} else {
lseek(fd, 0l, 0);
printf("insert the second diskette into the drive & hit enter ");
gets(buf);
}
drive = 0; /* set drive to A */
type = 2; /* set 320/360K disk in 1.2 M drive */
start_sect = 1;
max_sect = 9;
if(setdasd(drive, type)) {
fprintf(stderr, "Can't set the dasd for drive A!\n");
close(fd);
exit(1);
}
for(track = 0; track < 40; track++)
for(head = 0; head < 2; head++)
for(sector = 1; sector < 10; sector++)
for(i = 0; i < 3; i++) {
if(rdtrack(drive, head, track, sector, 1, buf) == 0) {
if(!times) {
write(fd, buf, BUFSIZ);
} else {
read(fd, buf1, BUFSIZ);
for(j = 0; j < BUFSIZ; j++)
if(buf1[i] != buf[i]) {
printf("difference at head %2d, track %2d, byte %5d \
%x %x\n", head, track, i, buf1[i], buf[i]);
}
}
} else {
fprintf(stderr, "failure %d on head %d, track %d, sector %d\n", i, head,
track, sector);
}
}
}
close(fd);
printf("done\n");
exit(0);
}