cgroups: allow statfs on cgroup files

PiperOrigin-RevId: 544179511
This commit is contained in:
Andrei Vagin
2023-06-28 15:39:34 -07:00
committed by gVisor bot
parent f52a0f6272
commit 9f3b219e70
2 changed files with 19 additions and 0 deletions
+2
View File
@@ -683,6 +683,8 @@ type writableControllerFileImpl interface {
// +stateify savable
type controllerFile struct {
kernfs.DynamicBytesFile
implStatFS
allowBackgroundAccess bool
}
+17
View File
@@ -16,7 +16,9 @@
// which isn't expected to work, or be safe on a general linux system.
#include <limits.h>
#include <linux/magic.h>
#include <sys/mount.h>
#include <sys/statfs.h>
#include <unistd.h>
#include <cstdint>
@@ -157,6 +159,21 @@ TEST(Cgroup, ProcsAndTasks) {
}
}
TEST(Cgroup, Statfs) {
SKIP_IF(!CgroupsAvailable());
Mounter m(ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir()));
Cgroup c = ASSERT_NO_ERRNO_AND_VALUE(m.MountCgroupfs(""));
struct statfs st;
EXPECT_THAT(statfs(c.Relpath("cgroup.procs").c_str(), &st),
SyscallSucceeds());
EXPECT_EQ(st.f_type, CGROUP_SUPER_MAGIC);
EXPECT_THAT(statfs(c.Relpath(".").c_str(), &st), SyscallSucceeds());
EXPECT_EQ(st.f_type, CGROUP_SUPER_MAGIC);
}
TEST(Cgroup, ControllersMustBeInUniqueHierarchy) {
SKIP_IF(!CgroupsAvailable());