This is the mail archive of the
cygwin@sources.redhat.com
mailing list for the Cygwin project.
Re: lseek() fails to seek on /dev/fd0 ('\\.\A:')
- To: Jesper Eskilson <jojo at virtutech dot se>
- Subject: Re: lseek() fails to seek on /dev/fd0 ('\\.\A:')
- From: Egor Duda <deo at logos-m dot ru>
- Date: Mon, 26 Feb 2001 13:21:56 +0300
- CC: cygwin at cygwin dot com
- Organization: DEO
- References: <u67ae79bw6v.fsf@rachel.hq.vtech>
- Reply-To: Egor Duda <cygwin at cygwin dot com>
Hi!
Monday, 26 February, 2001 Jesper Eskilson jojo@virtutech.se wrote:
JE> /* lseek_bug.c */
JE> #include <stdio.h>
JE> #include <fcntl.h>
JE> #include <errno.h>
JE> int main(int argc, char *argv[])
JE> {
JE> /* Mount /dev/fd0 as: mount -b '\\.\A:' /dev/fd0 */
JE> char *filename = "/dev/fd0";
JE> int fd, i;
JE> fd = open(filename, O_RDONLY);
JE> if (fd != -1) {
JE> for (i = 0; i < 4; i++) {
JE> printf("\nlseek():ing %d bytes from start of %s.\n", i, filename);
JE> lseek(fd, SEEK_SET, i);
JE> perror("lseek()");
JE> }
JE> }
JE> return 0;
JE> }
the correct prototype of lseek is
off_t lseek(int fildes, off_t offset, int whence);
your program should read like this:
lseek(fd, i, SEEK_SET);
Egor. mailto:deo@logos-m.ru ICQ 5165414 FidoNet 2:5020/496.19
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple