fixed logic bug
[tridge/junkcode.git] / tfloppy.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <fcntl.h>
4
5 main(int argc,char *argv[])
6 {
7   int count = 1024*1024;
8   char *fname = argv[1];
9   int fd1,fd2;
10
11   fd1 = open("/dev/fd0",O_WRONLY,0);
12   fd2 = open(fname,O_WRONLY|O_CREAT|O_TRUNC,0666);
13
14   while (count--)
15     {
16       char val = random();
17       int pos = (unsigned)random() % (1440*1024);
18       int doit = (random() % 1000 == 0);
19       lseek(fd1,pos,SEEK_SET);
20       lseek(fd2,pos,SEEK_SET);
21       write(fd1,&val,sizeof(val));
22       write(fd2,&val,sizeof(val));
23       if (doit)
24         sync();
25     }
26 }
27