代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-os/systemd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From d8024b3de8ce376cdea48ffa59a44b050f215470 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <[email protected]>
Date: Mon, 6 Aug 2018 13:42:14 +0900
Subject: [PATCH] core: introduce cgroup_add_device_allow()
(cherry picked from commit fd870bac25c2dd36affaed0251b5a7023f635306)
Related: #1763435
---
src/core/cgroup.c | 29 +++++++++++++++++++++++++++++
src/core/cgroup.h | 2 ++
src/core/load-fragment.c | 13 +------------
3 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 9d09c65453..a17b38f914 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -341,6 +341,35 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
}
}
+int cgroup_add_device_allow(CGroupContext *c, const char *dev, const char *mode) {
+ _cleanup_free_ CGroupDeviceAllow *a = NULL;
+ _cleanup_free_ char *d = NULL;
+
+ assert(c);
+ assert(dev);
+ assert(isempty(mode) || in_charset(mode, "rwm"));
+
+ a = new(CGroupDeviceAllow, 1);
+ if (!a)
+ return -ENOMEM;
+
+ d = strdup(dev);
+ if (!d)
+ return -ENOMEM;
+
+ *a = (CGroupDeviceAllow) {
+ .path = TAKE_PTR(d),
+ .r = isempty(mode) || !!strchr(mode, 'r'),
+ .w = isempty(mode) || !!strchr(mode, 'w'),
+ .m = isempty(mode) || !!strchr(mode, 'm'),
+ };
+
+ LIST_PREPEND(device_allow, c->device_allow, a);
+ TAKE_PTR(a);
+
+ return 0;
+}
+
static int lookup_block_device(const char *p, dev_t *ret) {
struct stat st;
int r;
diff --git a/src/core/cgroup.h b/src/core/cgroup.h
index 5e1be87b20..8102b442b8 100644
--- a/src/core/cgroup.h
+++ b/src/core/cgroup.h
@@ -153,6 +153,8 @@ void cgroup_context_free_io_device_latency(CGroupContext *c, CGroupIODeviceLaten
void cgroup_context_free_blockio_device_weight(CGroupContext *c, CGroupBlockIODeviceWeight *w);
void cgroup_context_free_blockio_device_bandwidth(CGroupContext *c, CGroupBlockIODeviceBandwidth *b);
+int cgroup_add_device_allow(CGroupContext *c, const char *dev, const char *mode);
+
CGroupMask unit_get_own_mask(Unit *u);
CGroupMask unit_get_delegate_mask(Unit *u);
CGroupMask unit_get_members_mask(Unit *u);
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index d43b0f08f9..89a3457acc 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -3250,7 +3250,6 @@ int config_parse_device_allow(
_cleanup_free_ char *path = NULL, *resolved = NULL;
CGroupContext *c = data;
- CGroupDeviceAllow *a;
const char *p = rvalue;
int r;
@@ -3299,17 +3298,7 @@ int config_parse_device_allow(
return 0;
}
- a = new0(CGroupDeviceAllow, 1);
- if (!a)
- return log_oom();
-
- a->path = TAKE_PTR(resolved);
- a->r = isempty(p) || !!strchr(p, 'r');
- a->w = isempty(p) || !!strchr(p, 'w');
- a->m = isempty(p) || !!strchr(p, 'm');
-
- LIST_PREPEND(device_allow, c->device_allow, a);
- return 0;
+ return cgroup_add_device_allow(c, resolved, p);
}
int config_parse_io_device_weight(
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。