This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] Fix ftell with fdopen for all cases and fopen with a+ mode (#16532)
- From: Rich Felker <dalias at aerifal dot cx>
- To: 20140211162501 dot GK1424 at redhat dot com
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 18 Feb 2014 11:27:35 -0500
- Subject: Re: [PATCH v2] Fix ftell with fdopen for all cases and fopen with a+ mode (#16532)
- Authentication-results: sourceware.org; auth=none
- References: <20140218160649 dot GA20628 at spoyarek dot pnq dot redhat dot com>
On Tue, Feb 18, 2014 at 09:36:50PM +0530, Siddhesh Poyarekar wrote:
> open/attached and the buffer not yet flushed. Subsequent queries
> should always be correct since applications are required to flush or
> seek to the desired position when switching between reading or
> writing, both of which sync up the offset.
Having the flush/seek sync the offset is not valid, since it's
permissible to switch to using a different active handle (e.g. the
underlying fd or a copy of the FILE in a forked child) at this point
and adjust the offset before switching back to this FILE. Instead,
explicit flush/seek operations need to reset the offset status to
"unknown" so that future ftell operations will query it again like
they did the first time. Implicit flush from the buffer filling up
does not need to do this.
Rich