22 #include <libcgroup.h>
28 debug ( 2,
"cgroup_name == \"%s\"",
ctx_p->cg_groupname );
29 SAFE ( cgroup_init(),
return -1; );
30 SAFE ( (
cgroup = cgroup_new_cgroup (
ctx_p->cg_groupname ) ) == NULL,
return -1; );
41 char control_name_buf[
BUFSIZ +
BUFSIZ] = {[0 ...
BUFSIZ - 1] =
'/',
'd',
'e',
'v',
'i',
'c',
'e',
's',
'.',
'a',
'l',
'l',
'o',
'w'}, *control_name = &control_name_buf[
BUFSIZ];
43 struct cgroup_controller *cgc;
44 SAFE ( ( cgc = cgroup_add_controller (
cgroup,
"devices" ) ) == NULL,
return -1; );
45 debug ( 8,
"Deny device: \"a\"" );
46 SAFE ( cgroup_add_value_string ( cgc,
"devices.deny",
"a" ),
return -1; );
47 allowed_device_i = allowed_devices;
49 while ( *allowed_device_i != NULL ) {
51 debug ( 8,
"Allow device: \"%s\" (\"%s\" = \"%s\")", *allowed_device_i, control_name, *allowed_device_i );
52 SAFE ( cgroup_add_value_string ( cgc, control_name, *allowed_device_i ),
return -1; );
57 if ( ( rc = cgroup_create_cgroup (
cgroup, 1 ) ) ) {
58 error (
"Got error while cgroup_create_cgroup(): %s", cgroup_strerror ( rc ) );
71 error (
"Got error while cgroup_attach_task_pid(): %s", cgroup_strerror ( rc ) );
82 error_on ( cgroup_delete_cgroup_ext (
cgroup, CGFLAG_DELETE_IGNORE_MIGRATION | CGFLAG_DELETE_RECURSIVE ) );