public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/99533] "operation not permitted" error on recursive_directory_iterator despite skip_permission_denied Date: Thu, 11 Mar 2021 15:06:36 +0000 [thread overview] Message-ID: <bug-99533-4-0o3L6yUF5U@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-99533-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99533 --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- The standard says that skip_permission_denied means to ignore "an error indicating that permission to access p is denied" and it's pretty clearly intended to correspond to std::errc::permission_denied errors, not std::errc::operation_not_permitted. But this should solve the issue for MacOS: --- a/libstdc++-v3/src/c++17/fs_dir.cc +++ b/libstdc++-v3/src/c++17/fs_dir.cc @@ -207,7 +207,7 @@ recursive_directory_iterator(const path& p, directory_options options, else { const int err = errno; - if (err == EACCES + if (fs::is_permission_denied_error(err) && is_set(options, fs::directory_options::skip_permission_denied)) { if (ecptr) diff --git a/libstdc++-v3/src/filesystem/dir-common.h b/libstdc++-v3/src/filesystem/dir-common.h index 56e279230f4..a49b8304a29 100644 --- a/libstdc++-v3/src/filesystem/dir-common.h +++ b/libstdc++-v3/src/filesystem/dir-common.h @@ -141,6 +141,18 @@ struct _Dir_base posix::DIR* dirp; }; +inline bool +is_permission_denied_error(int e) +{ + if (e == EACCES) + return true; +#ifdef __APPLE__ + if (e == EPERM) // See PR 99533 + return true; +#endif + return false; +} + } // namespace filesystem // BEGIN/END macros must be defined before including this file. diff --git a/libstdc++-v3/src/filesystem/dir.cc b/libstdc++-v3/src/filesystem/dir.cc index acc62986c68..215a9533f1b 100644 --- a/libstdc++-v3/src/filesystem/dir.cc +++ b/libstdc++-v3/src/filesystem/dir.cc @@ -202,7 +202,7 @@ recursive_directory_iterator(const path& p, directory_options options, else { const int err = errno; - if (err == EACCES + if (std::filesystem::is_permission_denied_error(err) && is_set(options, fs::directory_options::skip_permission_denied)) {
next prev parent reply other threads:[~2021-03-11 15:06 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-10 23:04 [Bug libstdc++/99533] New: " ssh at pobox dot com 2021-03-11 13:12 ` [Bug libstdc++/99533] " redi at gcc dot gnu.org 2021-03-11 13:15 ` redi at gcc dot gnu.org 2021-03-11 15:06 ` redi at gcc dot gnu.org [this message] 2021-03-11 18:21 ` redi at gcc dot gnu.org 2021-03-14 7:05 ` ssh at pobox dot com 2021-03-29 20:03 ` cvs-commit at gcc dot gnu.org 2021-03-29 21:37 ` redi at gcc dot gnu.org 2021-04-20 18:52 ` cvs-commit at gcc dot gnu.org 2021-04-20 18:53 ` redi at gcc dot gnu.org 2022-12-19 21:55 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-99533-4-0o3L6yUF5U@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).