aboutsummaryrefslogtreecommitdiffstats
path: root/linux/CGroupUtils.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/CGroupUtils.c')
-rw-r--r--linux/CGroupUtils.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/linux/CGroupUtils.c b/linux/CGroupUtils.c
index 6f3b6fe..22cce91 100644
--- a/linux/CGroupUtils.c
+++ b/linux/CGroupUtils.c
@@ -33,7 +33,7 @@ static bool StrBuf_putc_write(StrBuf_state* p, char c) {
}
static bool StrBuf_putsn(StrBuf_state* p, StrBuf_putc_t w, const char* s, size_t count) {
- while (count--)
+ for (; count; count--)
if (!w(p, *s++))
return false;
@@ -66,6 +66,7 @@ static bool CGroup_filterName_internal(const char *cgroup, StrBuf_state* s, StrB
const char* str_user_slice = "user.slice";
const char* str_machine_slice = "machine.slice";
const char* str_user_slice_prefix = "/user-";
+ const char* str_system_slice_prefix = "/system-";
const char* str_lxc_monitor_legacy = "lxc.monitor";
const char* str_lxc_payload_legacy = "lxc.payload";
@@ -76,6 +77,8 @@ static bool CGroup_filterName_internal(const char *cgroup, StrBuf_state* s, StrB
const char* str_nspawn_monitor_label = "/supervisor";
const char* str_nspawn_payload_label = "/payload";
+ const char* str_snap_scope_prefix = "snap.";
+
const char* str_service_suffix = ".service";
const char* str_scope_suffix = ".scope";
@@ -100,6 +103,11 @@ static bool CGroup_filterName_internal(const char *cgroup, StrBuf_state* s, StrB
if (!StrBuf_putsz(s, w, "[S]"))
return false;
+ if (String_startsWith(cgroup, str_system_slice_prefix)) {
+ cgroup = strchrnul(cgroup + 1, '/');
+ continue;
+ }
+
continue;
}
@@ -267,6 +275,22 @@ static bool CGroup_filterName_internal(const char *cgroup, StrBuf_state* s, StrB
cgroup += strlen(str_nspawn_payload_label);
continue;
+ } else if(Label_checkPrefix(labelStart, scopeNameLen, str_snap_scope_prefix)) {
+ const char* nextDot = strchrnul(labelStart + strlen(str_snap_scope_prefix), '.');
+
+ if (!StrBuf_putsz(s, w, "!snap:"))
+ return false;
+
+ if (nextDot >= labelStart + scopeNameLen) {
+ nextDot = labelStart + scopeNameLen;
+ }
+
+ if (!StrBuf_putsn(s, w, labelStart + strlen(str_snap_scope_prefix), nextDot - (labelStart + strlen(str_snap_scope_prefix))))
+ return false;
+
+ cgroup = nextSlash;
+
+ continue;
}
if (!w(s, '!'))

© 2014-2024 Faster IT GmbH | imprint | privacy policy