Mercurial > minori
diff dep/animone/src/fd/proc.cc @ 270:0718f538c5f9
dep/animone: filter open files by access mode
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Fri, 12 Apr 2024 19:13:50 -0400 |
parents | 862d0d8619f6 |
children | b1f625b0227c |
line wrap: on
line diff
--- a/dep/animone/src/fd/proc.cc Fri Apr 12 05:23:45 2024 -0400 +++ b/dep/animone/src/fd/proc.cc Fri Apr 12 19:13:50 2024 -0400 @@ -36,7 +36,9 @@ if (line.find("flags:", 0) == 0) flags = util::StringToInt(line.substr(line.find_last_not_of("0123456789") + 1)); - if (flags & O_WRONLY || flags & O_RDWR) + /* check if the file was opened in a write mode */ + int accflags = flags & O_ACCMODE; + if (accflags == O_WRONLY || accflags == O_RDWR) return false; return true; @@ -65,11 +67,9 @@ static constexpr std::array<std::string_view, 9> invalid_paths = {"/boot", "/dev", "/bin", "/usr", "/opt", "/proc", "/var", "/etc", "/dev"}; - for (const auto& invalid_path : invalid_paths) { - if (!path.rfind(invalid_path, 0)) { + for (const auto& invalid_path : invalid_paths) + if (!path.rfind(invalid_path, 0)) return true; - } - } return false; }