From 3e7e2251fa36dd243b6ebf976e89090e4a5a3218 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 25 Jan 2024 10:12:37 -0800 Subject: 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) --- tests/sys_vfs_test.cpp | 15 +++++++++++++-- 1 file 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 void Check(StatFsT& sb) { EXPECT_EQ(4096, static_cast(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(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(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; -- cgit v1.2.3