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 2/2] Fix file offsets when in append update mode (a+) (#16532)


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."


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