https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108178

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jonathan Wakely
<r...@gcc.gnu.org>:

https://gcc.gnu.org/g:f85947338197b12b77aa5eb0eb2d1b4ea7dbdd54

commit r12-9908-gf85947338197b12b77aa5eb0eb2d1b4ea7dbdd54
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Tue Mar 21 12:29:08 2023 +0000

    libstdc++: Make std::filesystem::copy_file work for procfs [PR108178]

    The size reported by stat is always zero for some special files such as
    those under /proc, which means the current copy_file implementation
    thinks there is nothing to copy. Instead of trusting the stat value, try
    to read a character from a streambuf and check for EOF.

    For the backport, we also need to avoid trying to use sendfile when stat
    reports a zero size, so that we use streambufs to copy the file.

    libstdc++-v3/ChangeLog:

            PR libstdc++/108178
            * src/filesystem/ops-common.h (do_copy_file): Check for empty
            files by trying to read a character.
            * testsuite/27_io/filesystem/operations/copy_file_108178.cc:
            New test.

    (cherry picked from commit 07a0e108247f23fcb919c61595adae143f1ea02a)

Reply via email to