[PATCH 2/2] Fix file offsets when in append update mode (a+) (#16532)
Andreas Schwab
schwab@suse.de
Tue Feb 11 09:22:00 GMT 2014
Siddhesh Poyarekar <siddhesh@redhat.com> writes:
> adb26fae introduced an optimization in ftell that allowed it to skip a
> flush when it would compute the file offset based on the position in
> the buffer and the offset in the file. This breaks for files opened
> in "a+" mode because these streams have the special requirement of
> being able to read from the beginning, but append at the end. So if
> we were reading and then writing without flushing the buffer, the
> offsets recorded in the stream would be incorrect. Other update modes
> (r+ or w+) don't have this caveat since they explicitly need to have a
> flush or fseek between the read/write switch.
I don't see how a+ is to be treated differently from r+/w+
wrt. switching between read and write.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
More information about the Libc-alpha
mailing list