diff options
author | Jamie Liu <jamieliu@google.com> | 2021-10-26 00:19:54 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-10-26 00:22:29 -0700 |
commit | 12480f1c4b49234a3761856e40d4d122695b610f (patch) | |
tree | d8c03d4a5174f397928a4c6d11c25216b3f15b4b /test/syscalls | |
parent | 4d07fc952d6bb5aa70b4bc9ff5e6457987f1721c (diff) |
Ensure statfs::f_namelen is set by VFS2 gofer statfs/fstatfs.
VFS1 discards the value of f_namelen returned by the filesystem and returns
NAME_MAX unconditionally instead, so it doesn't run into this. Also set
f_frsize for completeness.
PiperOrigin-RevId: 405579707
Diffstat (limited to 'test/syscalls')
-rw-r--r-- | test/syscalls/linux/statfs.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/test/syscalls/linux/statfs.cc b/test/syscalls/linux/statfs.cc index d057cdc09..b447b5cce 100644 --- a/test/syscalls/linux/statfs.cc +++ b/test/syscalls/linux/statfs.cc @@ -34,17 +34,19 @@ TEST(StatfsTest, CannotStatBadPath) { EXPECT_THAT(statfs(temp_file.c_str(), &st), SyscallFailsWithErrno(ENOENT)); } -TEST(StatfsTest, InternalTmpfs) { +TEST(StatfsTest, TempPath) { auto temp_file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile()); struct statfs st; EXPECT_THAT(statfs(temp_file.path().c_str(), &st), SyscallSucceeds()); + EXPECT_GT(st.f_namelen, 0); } TEST(StatfsTest, InternalDevShm) { struct statfs st; EXPECT_THAT(statfs("/dev/shm", &st), SyscallSucceeds()); + EXPECT_GT(st.f_namelen, 0); // This assumes that /dev/shm is tmpfs. // Note: We could be an overlay on some configurations. EXPECT_TRUE(st.f_type == TMPFS_MAGIC || st.f_type == OVERLAYFS_SUPER_MAGIC); @@ -55,13 +57,14 @@ TEST(FstatfsTest, CannotStatBadFd) { EXPECT_THAT(fstatfs(-1, &st), SyscallFailsWithErrno(EBADF)); } -TEST(FstatfsTest, InternalTmpfs) { +TEST(FstatfsTest, TempPath) { auto temp_file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile()); const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(Open(temp_file.path(), O_RDONLY)); struct statfs st; EXPECT_THAT(fstatfs(fd.get(), &st), SyscallSucceeds()); + EXPECT_GT(st.f_namelen, 0); } TEST(FstatfsTest, CanStatFileWithOpath) { @@ -81,6 +84,10 @@ TEST(FstatfsTest, InternalDevShm) { struct statfs st; EXPECT_THAT(fstatfs(fd.get(), &st), SyscallSucceeds()); + EXPECT_GT(st.f_namelen, 0); + // This assumes that /dev/shm is tmpfs. + // Note: We could be an overlay on some configurations. + EXPECT_TRUE(st.f_type == TMPFS_MAGIC || st.f_type == OVERLAYFS_SUPER_MAGIC); } } // namespace |