I wish to exercise my CD-ROM drive, to keep the dust off the lens. On Linux I run (as root) a C program I wrote which seeks back and forth, reading a single block each time as it goes. On FreeBSD this program doesn't get too far. I can open the device and seek to (say) block 1. But when I try to read the block, I get error 22 (EINVAL). It fails on the first read, at block 1, whether or not the device is mounted (-t cd9660). How do I proceed?
Code:
lo_fd=Open(ar_argv[1],
O_RDONLY,
0
);
lo_high_bit=1;
while(lo_high_bit>0)
{
if(lseek(lo_fd,
lo_high_bit,
SEEK_SET
)
==
(off_t)-1
)
{
lo_high_bit>>=1;
break;
}
if(read(lo_fd,
lo_buffer,
1
)
!=
1
)
{
lo_high_bit>>=1;
break;
}
lo_high_bit<<=1;
}