aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2024-01-11 20:46:23 +0000
committerElliott Hughes <enh@google.com>2024-01-26 23:45:11 +0000
commit234dc36ac657e7848e9b935e6558d748aa5a7018 (patch)
treeec0d88238188a1b1d397ee4c7254cdc7bf3f332b
parent9c1e170668513788b0731a5869dc1216c743110b (diff)
downloadbionic-234dc36ac657e7848e9b935e6558d748aa5a7018.tar.gz
sys_statvfs_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). Bug: http://b/321880382 (for sys_vfs_test) Bug: http://b/319590754 (for sys_statvfs_test) Test: treehugger Change-Id: I0a63faa8ca359592a29d7bca1a40ecd94fd50044 (cherry picked from commit 7506c37386ad71060dee90cfa001b825b97aff84)
-rw-r--r--tests/sys_statvfs_test.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/sys_statvfs_test.cpp b/tests/sys_statvfs_test.cpp
index 1761e6a51..73b2a9681 100644
--- a/tests/sys_statvfs_test.cpp
+++ b/tests/sys_statvfs_test.cpp
@@ -28,9 +28,19 @@ template <typename StatVfsT> void Check(StatVfsT& sb) {
EXPECT_EQ(4096U, sb.f_bsize);
EXPECT_EQ(0U, sb.f_bfree);
EXPECT_EQ(0U, sb.f_ffree);
- EXPECT_EQ(0U, sb.f_fsid);
EXPECT_EQ(255U, sb.f_namemax);
+ // Linux 6.7 requires that all filesystems have a non-zero fsid.
+ if (sb.f_fsid != 0U) {
+ // fs/libfs.c reuses the filesystem's device number.
+ struct stat proc_sb;
+ ASSERT_EQ(0, stat("/proc", &proc_sb));
+ EXPECT_EQ(proc_sb.st_dev, sb.f_fsid);
+ } else {
+ // Prior to that, the fsid for /proc was just 0.
+ EXPECT_EQ(0U, sb.f_fsid);
+ }
+
// 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;