Re: [committed] libstdc++: Fix filesystem::remove_all races [PR104161]

2022-02-04 Thread Jonathan Wakely via Gcc-patches
On Fri, 4 Feb 2022 at 23:55, Jonathan Wakely wrote: > +// Used to implement filesystem::remove_all. > +fs::recursive_directory_iterator& > +fs::recursive_directory_iterator::__erase(error_code* ecptr) > +{ > + error_code ec; > + if (!_M_dirs) > +{ > + ec = std::make_error_code(errc::inva

[committed] libstdc++: Fix filesystem::remove_all races [PR104161]

2022-02-04 Thread Jonathan Wakely via Gcc-patches
Tested powerpc64le-linux and powerpc-aix, pushed to trunk. This fixes the remaining filesystem::remove_all race condition by using POSIX openat to recurse into sub-directories and using POSIX unlinkat to remove files. This avoids the remaining race where the directory being removed is replaced wi