mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
cgroups: allow statfs on cgroup files
PiperOrigin-RevId: 544179511
This commit is contained in:
@@ -683,6 +683,8 @@ type writableControllerFileImpl interface {
|
||||
// +stateify savable
|
||||
type controllerFile struct {
|
||||
kernfs.DynamicBytesFile
|
||||
implStatFS
|
||||
|
||||
allowBackgroundAccess bool
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user