aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2024-01-25 10:12:37 -0800
committerElliott Hughes <enh@google.com>2024-01-25 22:53:16 +0000
commit3e7e2251fa36dd243b6ebf976e89090e4a5a3218 (patch)
treef95dd9c30f996b1f8800e3d6ca7983a26ef06bf6
parent9c1e170668513788b0731a5869dc1216c743110b (diff)
downloadbionic-3e7e2251fa36dd243b6ebf976e89090e4a5a3218.tar.gz
sys_vfs_test: fix expectation for Linux 6.7.
I'd assumed that it was _deliberate_ that filesystems like procfs reported 0 here, but apparently not. Good news: this makes for a more worthwhile test than we had previously (at least when run on a 6.7+ kernel). (This is the sys_vfs_test equivalent of the earlier change made to sys_statvfs_test.) Bug: http://b/321880382 (for sys_vfs_test) Bug: http://b/319590754 (for sys_statvfs_test) Test: treehugger Change-Id: I3c6f784d1e348bf1be3a102d1dd6336c33d0b2db (cherry picked from commit 1b48afbc66ada52a74e2c0d22ca50e377ced30f2)
-rw-r--r--tests/sys_vfs_test.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/sys_vfs_test.cpp b/tests/sys_vfs_test.cpp
index 242f8d499..363e49bc5 100644
--- a/tests/sys_vfs_test.cpp
+++ b/tests/sys_vfs_test.cpp
@@ -28,10 +28,21 @@ template <typename StatFsT> void Check(StatFsT& sb) {
EXPECT_EQ(4096, static_cast<int>(sb.f_bsize));
EXPECT_EQ(0U, sb.f_bfree);
EXPECT_EQ(0U, sb.f_ffree);
- EXPECT_EQ(0, sb.f_fsid.__val[0]);
- EXPECT_EQ(0, sb.f_fsid.__val[1]);
EXPECT_EQ(255, static_cast<int>(sb.f_namelen));
+ // Linux 6.7 requires that all filesystems have a non-zero fsid.
+ if (sb.f_fsid.__val[0] != 0U) {
+ // fs/libfs.c reuses the filesystem's device number.
+ struct stat proc_sb;
+ ASSERT_EQ(0, stat("/proc", &proc_sb));
+ EXPECT_EQ(static_cast<int>(proc_sb.st_dev), sb.f_fsid.__val[0]);
+ EXPECT_EQ(0, sb.f_fsid.__val[1]);
+ } else {
+ // Prior to that, the fsid for /proc was just 0.
+ EXPECT_EQ(0, sb.f_fsid.__val[0]);
+ EXPECT_EQ(0, sb.f_fsid.__val[1]);
+ }
+
// The kernel sets a private bit to indicate that f_flags is valid.
// This flag is not supposed to be exposed to libc clients.
static const uint32_t ST_VALID = 0x0020;