1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#include <sys/mount.h>
#include <sys/stat.h>
#include "zdtmtst.h"
const char *test_doc = "Check that some cgroup-v2 properties in kernel controllers are preserved";
const char *test_author = "Bui Quang Minh <minhquangbui99@gmail.com>";
char *dirname;
TEST_OPTION(dirname, string, "cgroup-v2 directory name", 1);
const char *cgname = "subcg00";
int main(int argc, char **argv)
{
char path[1024], aux[1024];
int ret = -1;
test_init(argc, argv);
if (mkdir(dirname, 0700) < 0 && errno != EEXIST) {
pr_perror("Can't make dir");
return -1;
}
if (mount("cgroup2", dirname, "cgroup2", 0, NULL)) {
pr_perror("Can't mount cgroup-v2");
return -1;
}
sprintf(path, "%s/%s", dirname, cgname);
if (mkdir(path, 0700) < 0 && errno != EEXIST) {
pr_perror("Can't make dir");
goto out;
}
/* Make cpuset controllers available in children directory */
sprintf(path, "%s/%s", dirname, "cgroup.subtree_control");
sprintf(aux, "%s", "+cpuset");
if (write_value(path, aux))
goto out;
sprintf(path, "%s/%s/%s", dirname, cgname, "cgroup.subtree_control");
sprintf(aux, "%s", "+cpuset");
if (write_value(path, aux))
goto out;
sprintf(path, "%s/%s/%s", dirname, cgname, "cgroup.type");
sprintf(aux, "%s", "threaded");
if (write_value(path, aux))
goto out;
sprintf(path, "%s/%s/%s", dirname, cgname, "cgroup.procs");
sprintf(aux, "%d", getpid());
if (write_value(path, aux))
goto out;
test_daemon();
test_waitsig();
sprintf(path, "%s/%s/%s", dirname, cgname, "cgroup.subtree_control");
if (read_value(path, aux, sizeof(aux)))
goto out;
if (strcmp(aux, "cpuset\n")) {
fail("cgroup.subtree_control mismatches");
goto out;
}
sprintf(path, "%s/%s/%s", dirname, cgname, "cgroup.type");
if (read_value(path, aux, sizeof(aux)))
goto out;
if (strcmp(aux, "threaded\n")) {
fail("cgroup.type mismatches");
goto out;
}
pass();
ret = 0;
out:
sprintf(path, "%s", dirname);
umount(path);
return ret;
}
|