This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/2] Fix file offsets when in append update mode (a+) (#16532)
- From: Andreas Schwab <schwab at suse dot de>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 11 Feb 2014 10:22:06 +0100
- Subject: Re: [PATCH 2/2] Fix file offsets when in append update mode (a+) (#16532)
- Authentication-results: sourceware.org; auth=none
- References: <20140211083818 dot GC1424 at spoyarek dot pnq dot redhat dot com>
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."