diff options
author | Rahat Mahmood <rahat@google.com> | 2019-08-29 14:29:43 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-08-29 14:30:41 -0700 |
commit | 863e11ac4d6a49787cd5e5f6fe1cd771d0ceb100 (patch) | |
tree | 93c781bcce55dec62f4acd0725ff4d0192ca8054 /test/util | |
parent | 0789b9cc08249f8d0d6efcb25029efd271e47a9d (diff) |
Implement /proc/net/udp.
PiperOrigin-RevId: 266229756
Diffstat (limited to 'test/util')
-rw-r--r-- | test/util/fs_util.cc | 9 | ||||
-rw-r--r-- | test/util/fs_util.h | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/test/util/fs_util.cc b/test/util/fs_util.cc index ae49725a0..f7d231b14 100644 --- a/test/util/fs_util.cc +++ b/test/util/fs_util.cc @@ -105,6 +105,15 @@ PosixErrorOr<struct stat> Stat(absl::string_view path) { return stat_buf; } +PosixErrorOr<struct stat> Fstat(int fd) { + struct stat stat_buf; + int res = fstat(fd, &stat_buf); + if (res < 0) { + return PosixError(errno, absl::StrCat("fstat ", fd)); + } + return stat_buf; +} + PosixErrorOr<bool> Exists(absl::string_view path) { struct stat stat_buf; int res = stat(std::string(path).c_str(), &stat_buf); diff --git a/test/util/fs_util.h b/test/util/fs_util.h index 3969f8309..e5b555891 100644 --- a/test/util/fs_util.h +++ b/test/util/fs_util.h @@ -35,6 +35,9 @@ PosixErrorOr<bool> Exists(absl::string_view path); // Returns a stat structure for the given path or an error. PosixErrorOr<struct stat> Stat(absl::string_view path); +// Returns a stat struct for the given fd. +PosixErrorOr<struct stat> Fstat(int fd); + // Deletes the file or directory at path or returns an error. PosixError Delete(absl::string_view path); |