This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] ftell: seek to end only when there are unflushed bytes (BZ #17647)
- From: Rich Felker <dalias at libc dot org>
- To: libc-alpha at sourceware dot org
- Date: Mon, 1 Dec 2014 10:49:38 -0500
- Subject: Re: [PATCH v2] ftell: seek to end only when there are unflushed bytes (BZ #17647)
- Authentication-results: sourceware.org; auth=none
- References: <20141125155404 dot GO12197 at spoyarek dot pnq dot redhat dot com> <20141125201415 dot GS29621 at brightrain dot aerifal dot cx> <20141126085600 dot GQ12197 at spoyarek dot pnq dot redhat dot com>
On Wed, Nov 26, 2014 at 02:26:01PM +0530, Siddhesh Poyarekar wrote:
> On Tue, Nov 25, 2014 at 03:14:15PM -0500, Rich Felker wrote:
> > I haven't read these patches in detail, but are you sure this matters?
> > I think the "active handle" rules forbid truncating a file while a
> > stdio stream is the active handle, but I may be mistaken.
>
> Apparently, they don't. The active handle rules seem to only forbid
> operations that modify the file offset and ftruncate does not modify
> the file offset. Instead, ftell ends up modifying the file offset by
> explicitly seeking to the end of file when it is not immediately
> required, thus breaking expectations of what the offset returned
> should be.
OK. FWIW, your new condition, unflushed_writes && append_mode, matches
what I've had in musl and I believe it's the correct condition.
Rich