This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: [BUG] open(): Opening with flags O_RDONLY | O_APPEND positions the file pointer at the end of the file
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 10 Jul 2002 18:48:30 +0200
- Subject: Re: [BUG] open(): Opening with flags O_RDONLY | O_APPEND positions the file pointer at the end of the file
- References: <823876622.20020710153943@syntrex.com> <20020710163613.GD10966@redhat.com>
- Reply-to: cygwin at cygwin dot com
On Wed, Jul 10, 2002 at 12:36:13PM -0400, Chris Faylor wrote:
> On Wed, Jul 10, 2002 at 03:39:43PM +0200, Pavel Tsekov wrote:
> >Hello, there :)
> >
> >Attached is a testcase which displays the problem. On Linux it will
> >properly return 13, while on cygwin it returns 0.
> >
> >I found this while trying to understand why MC doesn't extract
> >properly files from say .zip files.
> >
> >I don't know exactly why they call O_RDONLY combined with O_APPEND but
> >I will mail the mc-devel list ASAP.
> >
> >Still according to the Linux man page and SUSv2, O_APPEND should be
> >taken into account only when writing to the file.
> >
> >Having in mind that fhandler_base::write() calls SetFilePointer
> >before each write, I wonder why fhandler_disk_base::open calls
> >SetFilePointer when it detects O_APPEND ?
>
> Good question.
What if
fd = open(O_APPEND);
pos = lseek(fd, 0, SEEK_CUR);
? If open() doesn't move the pointer, `pos' is incorrectly set to 0.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin@cygwin.com
Red Hat, Inc.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/