summaryrefslogtreecommitdiffhomepage
path: root/test/util/fs_util.cc
diff options
context:
space:
mode:
authorAyush Ranjan <ayushranjan@google.com>2020-09-10 10:38:19 -0700
committergVisor bot <gvisor-bot@google.com>2020-09-10 10:40:35 -0700
commit50c99a86d1c6807c67cdc52102b1fc570426669f (patch)
tree17a4d2bfde09a6bc03f54e03dd97b92cc8649ce8 /test/util/fs_util.cc
parent9a003835f9750630c8acef2f7453eb7c134863b1 (diff)
[vfs] Disable nlink tests for overlayfs.
Overlayfs intentionally does not compute nlink for directories (because it can be really expensive). Linux returns 1, VFS2 returns 2 and VFS1 actually calculates the correct value. PiperOrigin-RevId: 330967139
Diffstat (limited to 'test/util/fs_util.cc')
-rw-r--r--test/util/fs_util.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/util/fs_util.cc b/test/util/fs_util.cc
index 572675622..b16055dd8 100644
--- a/test/util/fs_util.cc
+++ b/test/util/fs_util.cc
@@ -649,5 +649,19 @@ PosixErrorOr<bool> IsTmpfs(const std::string& path) {
}
#endif // __linux__
+PosixErrorOr<bool> IsOverlayfs(const std::string& path) {
+ struct statfs stat;
+ if (statfs(path.c_str(), &stat)) {
+ if (errno == ENOENT) {
+ // Nothing at path, don't raise this as an error. Instead, just report no
+ // overlayfs at path.
+ return false;
+ }
+ return PosixError(errno,
+ absl::StrFormat("statfs(\"%s\", %#p)", path, &stat));
+ }
+ return stat.f_type == OVERLAYFS_SUPER_MAGIC;
+}
+
} // namespace testing
} // namespace gvisor