Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com To: cygwin AT cygwin DOT com Subject: lseek() fails to seek on /dev/fd0 ('\\.\A:') From: Jesper Eskilson Organization: Virtutech AB Date: 26 Feb 2001 11:00:40 +0100 Message-ID: Lines: 75 User-Agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.2 (Thalia) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 #include #include 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