gcc/libstdc++-v3
Jonathan Wakely 5750952bec libstdc++: Fix filesystem::remove_all for Windows [PR104161]
The recursive_directory_iterator::__erase member was failing for
Windows, because the entry._M_type value is always file_type::none
(because _Dir_base::advance doesn't populate it for Windows) and
top.unlink uses fs::remove which sets an error using the
system_category. That meant that ec.value() was a Windows error code and
not an errno value, so the comparisons to EPERM and EISDIR failed.
Instead of depending on a specific Windows error code for attempting to
remove a directory, just use directory_entry::refresh() to query the
type first. This doesn't avoid the TOCTTOU races with directory
symlinks, but we can't avoid them on Windows without openat and
unlinkat, and creating symlinks requires admin privs on Windows anyway.

This also fixes the fs::remove_all(const path&) overload, which was
supposed to use the same logic as the other overload, but I forgot to
change it before my previous commit.

libstdc++-v3/ChangeLog:

	PR libstdc++/104161
	* src/c++17/fs_dir.cc (fs::recursive_directory_iterator::__erase):
	[i_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Refresh entry._M_type member,
	instead of checking for errno values indicating a directory.
	* src/c++17/fs_ops.cc (fs::remove_all(const path&)): Use similar
	logic to non-throwing overload.
	(fs::remove_all(const path&, error_code&)): Add comments.
	* src/filesystem/ops-common.h: Likewise.
2022-02-08 13:31:05 +00:00
..
config libstdc++: Add %j, %U, %w, %W time_get support, fix %y, %Y, %C, %p [PR77760] 2022-01-10 15:38:47 +01:00
doc libstdc++: Update documentation for C++17 deprecations 2022-01-19 00:58:26 +00:00
include libstdc++: Allow Clang to use <stdatomic.h> before C++23 2022-02-04 19:51:26 +00:00
libsupc++ libstdc++: Add suggestion to std::uncaught_exception() warning 2022-02-04 15:26:59 +00:00
po libstdc++: Define <stacktrace> header for C++23 2022-01-17 12:13:02 +00:00
python libstdc++: Define <stacktrace> header for C++23 2022-01-17 12:13:02 +00:00
scripts libstdc++: Only add valid -L paths to testsuite linker options 2022-01-20 12:29:29 +00:00
src libstdc++: Fix filesystem::remove_all for Windows [PR104161] 2022-02-08 13:31:05 +00:00
testsuite libstdc++: Fix invalid instantiations in tests 2022-02-02 17:08:54 +00:00
acinclude.m4 libstdc++: Fix filesystem::remove_all races [PR104161] 2022-02-04 19:51:26 +00:00
aclocal.m4
ChangeLog Daily bump. 2022-02-05 00:16:31 +00:00
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog-2017
ChangeLog-2018
ChangeLog-2019
ChangeLog-2020 libstdc++: Fix typo in ChangeLog-2020 2021-01-13 11:02:13 +00:00
ChangeLog-2021 Rotate ChangeLog files - part 1 - add ChangeLog-2021. 2022-01-03 10:18:16 +01:00
config.h.in libstdc++: Fix filesystem::remove_all races [PR104161] 2022-02-04 19:51:26 +00:00
configure libstdc++: Fix filesystem::remove_all races [PR104161] 2022-02-04 19:51:26 +00:00
configure.ac libstdc++: Remove -gdwarf-4 from flags for debug library 2022-01-19 19:31:00 +00:00
configure.host Scope libstdc++ configuration for vxworks to all versions 2020-10-22 16:40:57 +00:00
crossconfig.m4 libstdc++: Check for TLS support on mingw cross-compilers 2021-09-15 09:49:33 +01:00
fragment.am libstdc++: Add C++ runtime support for new 128-bit long double format 2020-12-16 23:25:01 +00:00
linkage.m4
Makefile.am Update copyright years. 2022-01-03 10:42:10 +01:00
Makefile.in libstdc++: Define <stacktrace> header for C++23 2022-01-17 12:13:02 +00:00
README

file: libstdc++-v3/README

New users may wish to point their web browsers to the file
index.html in the 'doc/html' subdirectory.  It contains brief
building instructions and notes on how to configure the library in
interesting ways.