This is the mail archive of the glibc-bugs@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]

[Bug stdio/17647] ftell after ftruncate reports incorrect offset


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.


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