From 2482ae433a4249495859343ae1fba408300f2c2e Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Tue, 27 May 2014 13:54:19 +0530 Subject: Fix offset computation for append+ mode on switching from read (BZ #16724) The offset computation in write mode uses the fact that _IO_read_end is kept in sync with the external file offset. This however is not true when O_APPEND is in effect since switching to write mode ought to send the external file offset to the end of file without making the necessary adjustment to _IO_read_end. Hence in append mode, offset computation when writing should only consider the effect of unflushed writes, i.e. from _IO_write_base to _IO_write_ptr. The wiki has a detailed document that describes the rationale for offsets returned by ftell in various conditions: https://sourceware.org/glibc/wiki/File%20offsets%20in%20a%20stdio%20stream%20and%20ftell --- libio/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libio/Makefile') diff --git a/libio/Makefile b/libio/Makefile index cca03454fc..b324ccc519 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -60,7 +60,8 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \ tst-wmemstream1 tst-wmemstream2 \ bug-memstream1 bug-wmemstream1 \ tst-setvbuf1 tst-popen1 tst-fgetwc bug-wsetpos tst-fseek \ - tst-fwrite-error tst-ftell-partial-wide tst-ftell-active-handler + tst-fwrite-error tst-ftell-partial-wide tst-ftell-active-handler \ + tst-ftell-append ifeq (yes,$(build-shared)) # Add test-fopenloc only if shared library is enabled since it depends on # shared localedata objects. @@ -160,6 +161,7 @@ tst-fgetwc-ENV = LOCPATH=$(common-objpfx)localedata tst-fseek-ENV = LOCPATH=$(common-objpfx)localedata tst-ftell-partial-wide-ENV = LOCPATH=$(common-objpfx)localedata tst-ftell-active-handler-ENV = LOCPATH=$(common-objpfx)localedata +tst-ftell-append-ENV = LOCPATH=$(common-objpfx)localedata generated += tst-fopenloc.mtrace tst-fopenloc.check -- cgit v1.2.3