[ping][PATCH v2] ftell: seek to end only when there are unflushed bytes (BZ #17647)

Siddhesh Poyarekar siddhesh@redhat.com
Mon Dec 1 09:35:00 GMT 2014


Ping!

On Tue, Nov 25, 2014 at 09:24:04PM +0530, Siddhesh Poyarekar wrote:
> Upon re-reading the standard, it seems like the intervening
> fseek/fflush should not be required since ftruncate does not change
> the file offset.  So this is a bug and here's an updated patch:
> 
> Currently we seek to end of file if there are unflushed writes or the
> stream is in write mode, to get the current offset for writing in
> append mode, which is the end of file.  The latter case (i.e. stream
> is in write mode, but no unflushed writes) is unnecessary since it
> will only happen when the stream has just been flushed, in which case
> the recorded offset ought to be reliable.
> 
> Removing that case lets ftell give the correct offset when it follows
> an ftruncate.  The latter truncates the file, but does not change the
> file position, due to which it is permissible to call ftell without an
> intervening fseek call.
> 
> Tested on x86_64 to verify that the added test case fails without the
> patch and succeeds with it, and that there are no additional
> regressions due to it.
> 
> 	[BZ #17647]
> 	* libio/fileops.c (do_ftell): Seek only when there are
> 	unflushed writes.
> 	* libio/wfileops.c (do_ftell_wide): Likewise.
> 	* libio/tst-ftell-active-handler.c (do_ftruncate_test): New
> 	test case.
> 	(do_one_test): Call it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20141201/7f020c8d/attachment.sig>


More information about the Libc-alpha mailing list