|
26 | 26 | #include <vector> |
27 | 27 |
|
28 | 28 | #include <android-base/file.h> |
29 | | -#include "absl/strings/ascii.h" |
30 | | -#include "absl/strings/strip.h" |
31 | | -#include "absl/strings/str_split.h" |
32 | 29 | #include <fmt/core.h> |
33 | 30 | #include "absl/log/log.h" |
| 31 | +#include "absl/strings/ascii.h" |
34 | 32 | #include "absl/strings/match.h" |
35 | 33 | #include "absl/strings/numbers.h" |
| 34 | +#include "absl/strings/str_split.h" |
| 35 | +#include "absl/strings/strip.h" |
36 | 36 |
|
37 | 37 | #include "cuttlefish/common/libs/fs/shared_buf.h" |
38 | 38 | #include "cuttlefish/common/libs/fs/shared_fd.h" |
@@ -62,9 +62,7 @@ static Result<ProcStatusUids> OwnerUids(const pid_t pid) { |
62 | 62 | // parse from /proc/<pid>/status |
63 | 63 | std::regex uid_pattern(R"(Uid:\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+))"); |
64 | 64 | std::string status_path = fmt::format("/proc/{}/status", pid); |
65 | | - std::string status_content; |
66 | | - CF_EXPECT(android::base::ReadFileToString(status_path, &status_content, |
67 | | - /* follow_symlinks */ true)); |
| 65 | + std::string status_content = CF_EXPECT(ReadFileContents(status_path)); |
68 | 66 | std::vector<uid_t> uids; |
69 | 67 | for (std::string_view line : |
70 | 68 | absl::StrSplit(status_content, '\n', absl::SkipEmpty())) { |
@@ -163,9 +161,7 @@ Result<std::string> GetExecutablePath(const pid_t pid) { |
163 | 161 | static Result<void> CheckExecNameFromStatus(const std::string& exec_name, |
164 | 162 | const pid_t pid) { |
165 | 163 | std::string status_path = fmt::format("/proc/{}/status", pid); |
166 | | - std::string status_content; |
167 | | - CF_EXPECT(android::base::ReadFileToString(status_path, &status_content, |
168 | | - /* follow_symlinks */ true)); |
| 164 | + std::string status_content = CF_EXPECT(ReadFileContents(status_path)); |
169 | 165 | bool found = false; |
170 | 166 | for (std::string_view line : |
171 | 167 | absl::StrSplit(status_content, '\n', absl::SkipEmpty())) { |
@@ -275,9 +271,7 @@ Result<pid_t> Ppid(const pid_t pid) { |
275 | 271 | // parse from /proc/<pid>/status |
276 | 272 | std::regex uid_pattern(R"(PPid:\s*([0-9]+))"); |
277 | 273 | std::string status_path = fmt::format("/proc/{}/status", pid); |
278 | | - std::string status_content; |
279 | | - CF_EXPECT(android::base::ReadFileToString(status_path, &status_content, |
280 | | - /* follow_symlinks */ true)); |
| 274 | + std::string status_content = CF_EXPECT(ReadFileContents(status_path)); |
281 | 275 | for (std::string_view line : |
282 | 276 | absl::StrSplit(status_content, '\n', absl::SkipEmpty())) { |
283 | 277 | std::smatch matches; |
|
0 commit comments