[libcxx-commits] [libcxx] [libc++] Fix filesystem::remove_all() on FreeBSD (PR #79540)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 25 18:34:59 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Mark Johnston (markjdb)
<details>
<summary>Changes</summary>
See the commit message for an explanation.
I'm not sure if this bug is the reason for the `XFAIL: LIBCXX-FREEBSD-FIXME` annotation in test/std/input.output/filesystems/fs.op.funcs/fs.op.remove_all/remove_all.pass.cpp. @<!-- -->emaste do you have any idea?
---
Full diff: https://github.com/llvm/llvm-project/pull/79540.diff
1 Files Affected:
- (modified) libcxx/src/filesystem/operations.cpp (+4-2)
``````````diff
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index 6253d1551b062e..c39a3ee53db439 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -815,8 +815,10 @@ uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) {
// If opening `p` failed because it wasn't a directory, remove it as
// a normal file instead. Note that `openat()` can return either ENOTDIR
- // or ELOOP depending on the exact reason of the failure.
- if (ec == errc::not_a_directory || ec == errc::too_many_symbolic_link_levels) {
+ // or ELOOP depending on the exact reason of the failure. On FreeBSD it
+ // may return EMLINK instead of ELOOP, contradicting POSIX.
+ if (ec == errc::not_a_directory || ec == errc::too_many_symbolic_link_levels ||
+ ec == errc::too_many_links) {
ec.clear();
if (::unlinkat(parent_directory, p.c_str(), /* flags = */ 0) == -1) {
ec = detail::capture_errno();
``````````
</details>
https://github.com/llvm/llvm-project/pull/79540
More information about the libcxx-commits
mailing list