mirror of
https://github.com/systemd/systemd.git
synced 2025-03-19 22:50:17 +03:00
cgroup-util: drop is_cgroup_fs()
No need to bother with any cgroup v1 stuff anymore.
This commit is contained in:
parent
6e7f8644a5
commit
0b11ad3836
@ -2316,20 +2316,6 @@ static const char* const cgroup_io_limit_type_table[_CGROUP_IO_LIMIT_TYPE_MAX] =
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(cgroup_io_limit_type, CGroupIOLimitType);
|
||||
|
||||
bool is_cgroup_fs(const struct statfs *s) {
|
||||
return is_fs_type(s, CGROUP_SUPER_MAGIC) ||
|
||||
is_fs_type(s, CGROUP2_SUPER_MAGIC);
|
||||
}
|
||||
|
||||
bool fd_is_cgroup_fs(int fd) {
|
||||
struct statfs s;
|
||||
|
||||
if (fstatfs(fd, &s) < 0)
|
||||
return -errno;
|
||||
|
||||
return is_cgroup_fs(&s);
|
||||
}
|
||||
|
||||
static const char *const cgroup_controller_table[_CGROUP_CONTROLLER_MAX] = {
|
||||
[CGROUP_CONTROLLER_CPU] = "cpu",
|
||||
[CGROUP_CONTROLLER_CPUACCT] = "cpuacct",
|
||||
|
@ -329,9 +329,6 @@ static inline int cg_unified(void) {
|
||||
const char* cgroup_controller_to_string(CGroupController c) _const_;
|
||||
CGroupController cgroup_controller_from_string(const char *s) _pure_;
|
||||
|
||||
bool is_cgroup_fs(const struct statfs *s);
|
||||
bool fd_is_cgroup_fs(int fd);
|
||||
|
||||
typedef enum ManagedOOMMode {
|
||||
MANAGED_OOM_AUTO,
|
||||
MANAGED_OOM_KILL,
|
||||
|
@ -8,12 +8,12 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "btrfs-util.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "missing_magic.h"
|
||||
#include "mountpoint-util.h"
|
||||
#include "path-util.h"
|
||||
#include "rm-rf.h"
|
||||
@ -24,7 +24,7 @@
|
||||
* after all: we can create arbitrary directory hierarchies in it, and hence can also use rm_rf() on it
|
||||
* to remove those again. */
|
||||
static bool is_physical_fs(const struct statfs *sfs) {
|
||||
return !is_temporary_fs(sfs) && !is_cgroup_fs(sfs);
|
||||
return !is_temporary_fs(sfs) && !is_fs_type(sfs, CGROUP2_SUPER_MAGIC);
|
||||
}
|
||||
|
||||
static int patch_dirfd_mode(
|
||||
|
@ -362,28 +362,6 @@ TEST(mask_supported, .sd_booted = true) {
|
||||
yes_no(m & CGROUP_CONTROLLER_TO_MASK(c)));
|
||||
}
|
||||
|
||||
TEST(is_cgroup_fs, .sd_booted = true) {
|
||||
struct statfs sfs;
|
||||
assert_se(statfs("/sys/fs/cgroup", &sfs) == 0);
|
||||
if (is_temporary_fs(&sfs))
|
||||
assert_se(statfs("/sys/fs/cgroup/systemd", &sfs) == 0);
|
||||
assert_se(is_cgroup_fs(&sfs));
|
||||
}
|
||||
|
||||
TEST(fd_is_cgroup_fs, .sd_booted = true) {
|
||||
int fd;
|
||||
|
||||
fd = open("/sys/fs/cgroup", O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
|
||||
assert_se(fd >= 0);
|
||||
if (fd_is_temporary_fs(fd)) {
|
||||
fd = safe_close(fd);
|
||||
fd = open("/sys/fs/cgroup/systemd", O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
|
||||
assert_se(fd >= 0);
|
||||
}
|
||||
assert_se(fd_is_cgroup_fs(fd));
|
||||
fd = safe_close(fd);
|
||||
}
|
||||
|
||||
TEST(cg_tests) {
|
||||
int all, hybrid, systemd, r;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user