cgroup: Skip mkdir() and subtree control if group already exists

- No point in doing it twice
 - Don't anger the gods (possible kernel bugs)

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-04-07 11:58:48 +02:00
1 parent e3c424e129
commit 19b18afac9
1 file changed
+4 -2
+4 -2
View File
@@ -86,7 +86,8 @@ static void group_init(char *path, int leaf, const char *cfg)
{ {
char *ptr, *s; char *ptr, *s;
if (mkdir(path, 0755) && EEXIST != errno) { if (!fisdir(path)) {
if (mkdir(path, 0755)) {
_pe("Failed creating cgroup %s", path); _pe("Failed creating cgroup %s", path);
return; return;
} }
@@ -94,8 +95,9 @@ static void group_init(char *path, int leaf, const char *cfg)
/* enable detected controllers on domain groups */ /* enable detected controllers on domain groups */
if (!leaf && fnwrite(controllers, "%s/cgroup.subtree_control", path)) if (!leaf && fnwrite(controllers, "%s/cgroup.subtree_control", path))
_pe("Failed enabling %s for %s", controllers, path); _pe("Failed enabling %s for %s", controllers, path);
}
if (!cfg) if (!cfg || !cfg[0])
return; return;
s = strdupa(cfg); s = strdupa(cfg);