unit_has_memory_config(u))
mask |= CGROUP_MASK_MEMORY;
- if (c->device_allow ||
- c->device_policy != CGROUP_DEVICE_POLICY_AUTO)
+ if (cgroup_context_has_device_policy(c))
mask |= CGROUP_MASK_DEVICES | CGROUP_MASK_BPF_DEVICES;
if (c->tasks_accounting ||
(c->memory_pressure_watch == CGROUP_PRESSURE_WATCH_AUTO && c->memory_accounting);
}
+static inline bool cgroup_context_has_device_policy(const CGroupContext *c) {
+ assert(c);
+
+ return c->device_policy != CGROUP_DEVICE_POLICY_AUTO ||
+ c->device_allow;
+}
+
int cgroup_context_add_device_allow(CGroupContext *c, const char *dev, CGroupDevicePermissions p);
int cgroup_context_add_or_update_device_allow(CGroupContext *c, const char *dev, CGroupDevicePermissions p);
int cgroup_context_add_bpf_foreign_program(CGroupContext *c, uint32_t attach_type, const char *path);
if (c->private_devices)
return true;
- if (cgroup_context->device_policy != CGROUP_DEVICE_POLICY_AUTO ||
- cgroup_context->device_allow)
+ if (cgroup_context_has_device_policy(cgroup_context))
return true;
return false;
cc->device_policy = CGROUP_DEVICE_POLICY_CLOSED;
/* Only add these if needed, as they imply that everything else is blocked. */
- if (cc->device_policy != CGROUP_DEVICE_POLICY_AUTO || cc->device_allow) {
+ if (cgroup_context_has_device_policy(cc)) {
if (ec->root_image || ec->mount_images) {
/* When RootImage= or MountImages= is specified, the following devices are touched. */