mirror of
https://github.com/systemd/systemd.git
synced 2026-08-05 07:30:30 +00:00
cgroup-util: add cg_is_delegated helper
Take is_delegated from cgroup-show.c, and make it a generic helper function. This new helper will be used again in a later commit.
This commit is contained in:
@@ -2268,6 +2268,25 @@ int cg_hybrid_unified(void) {
|
||||
return r == CGROUP_UNIFIED_SYSTEMD && !unified_systemd_v232;
|
||||
}
|
||||
|
||||
int cg_is_delegated(const char *path) {
|
||||
int r;
|
||||
|
||||
assert(path);
|
||||
|
||||
r = cg_get_xattr_bool(path, "trusted.delegate");
|
||||
if (ERRNO_IS_NEG_XATTR_ABSENT(r)) {
|
||||
/* If the trusted xattr isn't set (preferred), then check the
|
||||
* untrusted one. Under the assumption that whoever is trusted
|
||||
* enough to own the cgroup, is also trusted enough to decide
|
||||
* if it is delegated or not this should be safe. */
|
||||
r = cg_get_xattr_bool(path, "user.delegate");
|
||||
if (ERRNO_IS_NEG_XATTR_ABSENT(r))
|
||||
return false;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
const uint64_t cgroup_io_limit_defaults[_CGROUP_IO_LIMIT_TYPE_MAX] = {
|
||||
[CGROUP_IO_RBPS_MAX] = CGROUP_LIMIT_MAX,
|
||||
[CGROUP_IO_WBPS_MAX] = CGROUP_LIMIT_MAX,
|
||||
|
||||
@@ -210,6 +210,8 @@ int cg_rmdir(const char *controller, const char *path);
|
||||
|
||||
int cg_is_threaded(const char *path);
|
||||
|
||||
int cg_is_delegated(const char *path);
|
||||
|
||||
typedef enum {
|
||||
CG_KEY_MODE_GRACEFUL = 1 << 0,
|
||||
} CGroupKeyMode;
|
||||
|
||||
Reference in New Issue
Block a user