mirror of
https://github.com/systemd/systemd.git
synced 2024-11-07 01:27:11 +03:00
cgroup: detect cgroup namespaces
- define CLONE_NEWCGROUP - add fun to detect whether cgroup namespaces are supported
This commit is contained in:
parent
d6cdc4cd4b
commit
3228995c53
@ -134,6 +134,20 @@ int cg_read_event(const char *controller, const char *path, const char *event,
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
bool cg_ns_supported(void) {
|
||||
static thread_local int enabled = -1;
|
||||
|
||||
if (enabled >= 0)
|
||||
return enabled;
|
||||
|
||||
if (access("/proc/self/ns/cgroup", F_OK) == 0)
|
||||
enabled = 1;
|
||||
else
|
||||
enabled = 0;
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
int cg_enumerate_subgroups(const char *controller, const char *path, DIR **_d) {
|
||||
_cleanup_free_ char *fs = NULL;
|
||||
int r;
|
||||
|
@ -214,6 +214,8 @@ int cg_mask_supported(CGroupMask *ret);
|
||||
|
||||
int cg_kernel_controllers(Set *controllers);
|
||||
|
||||
bool cg_ns_supported(void);
|
||||
|
||||
int cg_unified(void);
|
||||
void cg_unified_flush(void);
|
||||
|
||||
|
@ -445,6 +445,10 @@ struct btrfs_ioctl_quota_ctl_args {
|
||||
#define CGROUP2_SUPER_MAGIC 0x63677270
|
||||
#endif
|
||||
|
||||
#ifndef CLONE_NEWCGROUP
|
||||
#define CLONE_NEWCGROUP 0x02000000
|
||||
#endif
|
||||
|
||||
#ifndef TMPFS_MAGIC
|
||||
#define TMPFS_MAGIC 0x01021994
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user