public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug stdio/17647] New: ftell after ftruncate reports incorrect offset
@ 2014-11-25 15:43 siddhesh at redhat dot com
2014-12-04 3:33 ` [Bug stdio/17647] " cvs-commit at gcc dot gnu.org
2014-12-04 4:05 ` siddhesh at redhat dot com
0 siblings, 2 replies; 3+ messages in thread
From: siddhesh at redhat dot com @ 2014-11-25 15:43 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=17647
Bug ID: 17647
Summary: ftell after ftruncate reports incorrect offset
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: stdio
Assignee: siddhesh at redhat dot com
Reporter: siddhesh at redhat dot com
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug stdio/17647] ftell after ftruncate reports incorrect offset
2014-11-25 15:43 [Bug stdio/17647] New: ftell after ftruncate reports incorrect offset siddhesh at redhat dot com
@ 2014-12-04 3:33 ` cvs-commit at gcc dot gnu.org
2014-12-04 4:05 ` siddhesh at redhat dot com
1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2014-12-04 3:33 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=17647
--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 24b9788285effddba3d52f174d483583cf820d19 (commit)
via fe8b4d98e9ac371238388469cb74011cb2120343 (commit)
via 61b4f792e03facb456036b3f631d58d4f53b8075 (commit)
via be349d7042de84c3c5157a5c1fbcad580aed33e1 (commit)
from e3d6dba5dfe2e125b15ea1dd36c8dfa373bb4956 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=24b9788285effddba3d52f174d483583cf820d19
commit 24b9788285effddba3d52f174d483583cf820d19
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date: Thu Dec 4 08:45:55 2014 +0530
Fix up function definition style
Don't use K&R style for function definitions.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fe8b4d98e9ac371238388469cb74011cb2120343
commit fe8b4d98e9ac371238388469cb74011cb2120343
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date: Thu Dec 4 08:13:28 2014 +0530
Reset cached offset when reading to end of stream (BZ #17653)
POSIX allows applications to switch file handles when a read results
in an end of file. Unset the cached offset at this point so that it
is queried again.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=61b4f792e03facb456036b3f631d58d4f53b8075
commit 61b4f792e03facb456036b3f631d58d4f53b8075
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date: Thu Dec 4 08:11:07 2014 +0530
tst-ftell-active-handler: Open file with O_TRUNC for w modes
The test case fails to truncate the file when a file is intended to be
opened in w or w+ mode. Add O_TRUNC to fix this. The test still
succeeds with this change.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=be349d7042de84c3c5157a5c1fbcad580aed33e1
commit be349d7042de84c3c5157a5c1fbcad580aed33e1
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date: Thu Dec 4 08:08:37 2014 +0530
ftell: seek to end only when there are unflushed bytes (BZ #17647)
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.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 30 ++++++++
NEWS | 2 +-
libio/fileops.c | 134 +++++++++------------------------
libio/iofopen.c | 12 +--
libio/tst-ftell-active-handler.c | 152 +++++++++++++++++++++++++++++++++++---
libio/wfileops.c | 40 ++++-------
6 files changed, 225 insertions(+), 145 deletions(-)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug stdio/17647] ftell after ftruncate reports incorrect offset
2014-11-25 15:43 [Bug stdio/17647] New: ftell after ftruncate reports incorrect offset siddhesh at redhat dot com
2014-12-04 3:33 ` [Bug stdio/17647] " cvs-commit at gcc dot gnu.org
@ 2014-12-04 4:05 ` siddhesh at redhat dot com
1 sibling, 0 replies; 3+ messages in thread
From: siddhesh at redhat dot com @ 2014-12-04 4:05 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=17647
Siddhesh Poyarekar <siddhesh at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #2 from Siddhesh Poyarekar <siddhesh at redhat dot com> ---
Fixed in master.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-04 4:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-25 15:43 [Bug stdio/17647] New: ftell after ftruncate reports incorrect offset siddhesh at redhat dot com
2014-12-04 3:33 ` [Bug stdio/17647] " cvs-commit at gcc dot gnu.org
2014-12-04 4:05 ` siddhesh at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).