From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 590223857732; Tue, 6 Jun 2023 14:11:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 590223857732 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686060660; bh=bmzd+yA5rhkqLR9uL8vzFUKw0mR1IhCuBSQzCkRr3aU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iyS32VrrvCR9cJbjFghBMTdSC7OMWMcIyBn40o2JMM7y2ipAtFrJ9sTSZ6hMOyuWs Cc/jllXGL6TfOeRAfAcTCAG5MyO2G1CtCi0OfyqQhu2uvmrXz0LJAX5fnAbqHBnGGc oO7FmDC/21ZKfdwq7uRHuzdx+nR4/J/XbJ9MurmY= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/108178] Filesystem::copy_file can't copy from /proc on Linux machines Date: Tue, 06 Jun 2023 14:10:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108178 --- Comment #8 from CVS Commits --- The releases/gcc-13 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:c0a57904308ad0f10833f38cb207c750e5658b6b commit r13-7420-gc0a57904308ad0f10833f38cb207c750e5658b6b Author: Jonathan Wakely 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)=