This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] Fix ftell with fdopen for all cases and fopen with a+ mode (#16532)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]