Mail Archives: cygwin/2001/02/26/05:03:20
Hi!
I'm having trouble with getting lseek() to seek on a raw device. The device
in question is A:, and it is mounted on /dev/fd0. The mount list looks like:
Device Directory Type Flags
C:\cygwin\bin /usr/bin system binmode
C:\cygwin\lib /usr/lib system binmode
C:\cygwin / system binmode
\\.\A: /dev/fd0 system binmode
e: /ackbar system binmode
k: /rachel system binmode
The following small program demonstrates the problem:
/* lseek_bug.c */
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
int main(int argc, char *argv[])
{
/* Mount /dev/fd0 as: mount -b '\\.\A:' /dev/fd0 */
char *filename = "/dev/fd0";
int fd, i;
fd = open(filename, O_RDONLY);
if (fd != -1) {
for (i = 0; i < 4; i++) {
printf("\nlseek():ing %d bytes from start of %s.\n", i, filename);
lseek(fd, SEEK_SET, i);
perror("lseek()");
}
}
return 0;
}
/* end */
The program tries to do lseek(fd, SEEK_SET, i), where i == 0, 1, 2, 3, 4,
etc. The output I get is:
bash$ gcc lseek_bug.c -o lseek_bug
bash$ ./lseek_bug.exe
lseek():ing 0 bytes from start of /dev/fd0.
lseek(): error 0
lseek():ing 1 bytes from start of /dev/fd0.
lseek(): error 0
lseek():ing 2 bytes from start of /dev/fd0.
lseek(): Invalid request code
lseek():ing 3 bytes from start of /dev/fd0.
lseek(): Invalid request code
bash$
Why is it ok to seek to 0 bytes and 1 byte, but not 2?
I tracked down the somewhat cryptical error "Invalid request code" to the
Cygwin sources and found out the it maps to Win32 error INVALID_FUNCTION,
but the Win32 documentation isn't exactly clear as to what this exacly
means, but surely it must be supported to seek on a raw device?
The Cygwin version is 1.1.8, if it matters.
/Jesper
--
-------------------------------------------------------------------------
Jesper Eskilson jojo AT virtutech DOT se
Virtutech http://www.virtutech.se
-------------------------------------------------------------------------
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -