summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/statfs.cc
diff options
context:
space:
mode:
authorRahat Mahmood <rahat@google.com>2020-08-28 14:29:16 -0700
committergVisor bot <gvisor-bot@google.com>2020-08-28 14:31:11 -0700
commitb4820e598681c61fbf0e8a7f4d3436d2599ce53c (patch)
tree9e7c5770ba0edba0ae77f35300803c13d6914970 /test/syscalls/linux/statfs.cc
parentbdd5996a73b14d6f6600ab7aa00cdaed459cab16 (diff)
Implement StatFS for various VFS2 filesystems.
This mainly involved enabling kernfs' client filesystems to provide a StatFS implementation. Fixes #3411, #3515. PiperOrigin-RevId: 329009864
Diffstat (limited to 'test/syscalls/linux/statfs.cc')
-rw-r--r--test/syscalls/linux/statfs.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/test/syscalls/linux/statfs.cc b/test/syscalls/linux/statfs.cc
index aca51d30f..49f2f156c 100644
--- a/test/syscalls/linux/statfs.cc
+++ b/test/syscalls/linux/statfs.cc
@@ -13,6 +13,7 @@
// limitations under the License.
#include <fcntl.h>
+#include <linux/magic.h>
#include <sys/statfs.h>
#include <unistd.h>
@@ -26,6 +27,10 @@ namespace testing {
namespace {
+// From linux/magic.h. For some reason, not defined in the headers for some
+// build environments.
+#define OVERLAYFS_SUPER_MAGIC 0x794c7630
+
TEST(StatfsTest, CannotStatBadPath) {
auto temp_file = NewTempAbsPathInDir("/tmp");
@@ -38,19 +43,18 @@ TEST(StatfsTest, InternalTmpfs) {
struct statfs st;
EXPECT_THAT(statfs(temp_file.path().c_str(), &st), SyscallSucceeds());
+ // Note: We could be an overlay or goferfs on some configurations.
+ EXPECT_TRUE(st.f_type == TMPFS_MAGIC || st.f_type == OVERLAYFS_SUPER_MAGIC ||
+ st.f_type == V9FS_MAGIC);
}
TEST(StatfsTest, InternalDevShm) {
struct statfs st;
EXPECT_THAT(statfs("/dev/shm", &st), SyscallSucceeds());
-}
-
-TEST(StatfsTest, NameLen) {
- struct statfs st;
- EXPECT_THAT(statfs("/dev/shm", &st), SyscallSucceeds());
// This assumes that /dev/shm is tmpfs.
- EXPECT_EQ(st.f_namelen, NAME_MAX);
+ // Note: We could be an overlay on some configurations.
+ EXPECT_TRUE(st.f_type == TMPFS_MAGIC || st.f_type == OVERLAYFS_SUPER_MAGIC);
}
TEST(FstatfsTest, CannotStatBadFd) {