From: drakenclimber Date: Wed, 16 Mar 2022 14:36:46 +0000 (+0000) Subject: deploy: 7e30070e882f3b0ed1b72421cb6ea0a4e4c0d559 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d60550df7919908ad8d7829e2483cb19b89324ec;p=thirdparty%2Flibcgroup.git deploy: 7e30070e882f3b0ed1b72421cb6ea0a4e4c0d559 --- diff --git a/abstraction-common_8h_source.html b/abstraction-common_8h_source.html index cc456c25..10887f6e 100644 --- a/abstraction-common_8h_source.html +++ b/abstraction-common_8h_source.html @@ -69,103 +69,90 @@ $(function() {
abstraction-common.h
-
1
-
8/*
-
9 * This library is free software; you can redistribute it and/or modify it
-
10 * under the terms of version 2.1 of the GNU Lesser General Public License as
-
11 * published by the Free Software Foundation.
-
12 *
-
13 * This library is distributed in the hope that it will be useful, but WITHOUT
-
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
-
16 * for more details.
-
17 *
-
18 * You should have received a copy of the GNU Lesser General Public License
-
19 * along with this library; if not, see <http://www.gnu.org/licenses>.
-
20 */
-
21#ifndef __ABSTRACTION_COMMON
-
22#define __ABSTRACTION_COMMON
-
23
-
24#ifdef __cplusplus
-
25extern "C" {
-
26#endif
-
27
-
28#include "config.h"
-
29
-
30#include <libcgroup.h>
-
31#include "libcgroup-internal.h"
-
32
-
44int cgroup_strtol(const char * const in_str, int base,
-
45 long * const out_value);
-
46
-
56int cgroup_convert_int(struct cgroup_controller * const dst_cgc,
-
57 const char * const in_value,
-
58 const char * const out_setting,
-
59 void *in_dflt, void *out_dflt);
-
60
-
71int cgroup_convert_name_only(struct cgroup_controller * const dst_cgc,
-
72 const char * const in_value,
-
73 const char * const out_setting,
-
74 void *in_dflt, void *out_dflt);
-
75
-
85int cgroup_convert_passthrough(struct cgroup_controller * const dst_cgc,
-
86 const char * const in_value,
-
87 const char * const out_setting,
-
88 void *in_dflt, void *out_dflt);
-
89
-
100int cgroup_convert_unmappable(struct cgroup_controller * const dst_cgc,
-
101 const char * const in_value,
-
102 const char * const out_setting,
-
103 void *in_dflt, void *out_dflt);
-
104
-
105/* cpu */
-
106int cgroup_convert_cpu_nto1(struct cgroup_controller * const out_cgc,
-
107 struct cgroup_controller * const in_cgc);
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
9#ifndef __ABSTRACTION_COMMON
+
10#define __ABSTRACTION_COMMON
+
11
+
12#ifdef __cplusplus
+
13extern "C" {
+
14#endif
+
15
+
16#include "config.h"
+
17
+
18#include <libcgroup.h>
+
19#include "libcgroup-internal.h"
+
20
+
32int cgroup_strtol(const char * const in_str, int base,
+
33 long * const out_value);
+
34
+
44int cgroup_convert_int(struct cgroup_controller * const dst_cgc,
+
45 const char * const in_value,
+
46 const char * const out_setting,
+
47 void *in_dflt, void *out_dflt);
+
48
+
59int cgroup_convert_name_only(struct cgroup_controller * const dst_cgc,
+
60 const char * const in_value,
+
61 const char * const out_setting,
+
62 void *in_dflt, void *out_dflt);
+
63
+
73int cgroup_convert_passthrough(struct cgroup_controller * const dst_cgc,
+
74 const char * const in_value,
+
75 const char * const out_setting,
+
76 void *in_dflt, void *out_dflt);
+
77
+
88int cgroup_convert_unmappable(struct cgroup_controller * const dst_cgc,
+
89 const char * const in_value,
+
90 const char * const out_setting,
+
91 void *in_dflt, void *out_dflt);
+
92
+
93/* cpu */
+
94int cgroup_convert_cpu_nto1(struct cgroup_controller * const out_cgc,
+
95 struct cgroup_controller * const in_cgc);
+
96
+
97int cgroup_convert_cpu_quota_to_max(
+
98 struct cgroup_controller * const dst_cgc,
+
99 const char * const in_value,
+
100 const char * const out_setting,
+
101 void *in_dflt, void *out_dflt);
+
102
+
103int cgroup_convert_cpu_period_to_max(
+
104 struct cgroup_controller * const dst_cgc,
+
105 const char * const in_value,
+
106 const char * const out_setting,
+
107 void *in_dflt, void *out_dflt);
108
-
109int cgroup_convert_cpu_quota_to_max(
+
109int cgroup_convert_cpu_max_to_quota(
110 struct cgroup_controller * const dst_cgc,
111 const char * const in_value,
112 const char * const out_setting,
113 void *in_dflt, void *out_dflt);
114
-
115int cgroup_convert_cpu_period_to_max(
+
115int cgroup_convert_cpu_max_to_period(
116 struct cgroup_controller * const dst_cgc,
117 const char * const in_value,
118 const char * const out_setting,
119 void *in_dflt, void *out_dflt);
120
-
121int cgroup_convert_cpu_max_to_quota(
-
122 struct cgroup_controller * const dst_cgc,
-
123 const char * const in_value,
-
124 const char * const out_setting,
-
125 void *in_dflt, void *out_dflt);
-
126
-
127int cgroup_convert_cpu_max_to_period(
-
128 struct cgroup_controller * const dst_cgc,
-
129 const char * const in_value,
-
130 const char * const out_setting,
-
131 void *in_dflt, void *out_dflt);
-
132
-
133/* cpuset */
-
134int cgroup_convert_cpuset_to_exclusive(
-
135 struct cgroup_controller * const dst_cgc,
-
136 const char * const in_value,
-
137 const char * const out_setting,
-
138 void *in_dflt, void *out_dflt);
-
139
-
140int cgroup_convert_cpuset_to_partition(
-
141 struct cgroup_controller * const dst_cgc,
-
142 const char * const in_value,
-
143 const char * const out_setting,
-
144 void *in_dflt, void *out_dflt);
-
145
-
146
-
147#ifdef __cplusplus
-
148} /* extern "C" */
-
149#endif
-
150
-
151#endif /* __ABSTRACTION_COMMON */
-
Definition: libcgroup-internal.h:108
+
121/* cpuset */
+
122int cgroup_convert_cpuset_to_exclusive(
+
123 struct cgroup_controller * const dst_cgc,
+
124 const char * const in_value,
+
125 const char * const out_setting,
+
126 void *in_dflt, void *out_dflt);
+
127
+
128int cgroup_convert_cpuset_to_partition(
+
129 struct cgroup_controller * const dst_cgc,
+
130 const char * const in_value,
+
131 const char * const out_setting,
+
132 void *in_dflt, void *out_dflt);
+
133
+
134
+
135#ifdef __cplusplus
+
136} /* extern "C" */
+
137#endif
+
138
+
139#endif /* __ABSTRACTION_COMMON */
+
Definition: libcgroup-internal.h:101
-
1
-
8/*
-
9 * This library is free software; you can redistribute it and/or modify it
-
10 * under the terms of version 2.1 of the GNU Lesser General Public License as
-
11 * published by the Free Software Foundation.
-
12 *
-
13 * This library is distributed in the hope that it will be useful, but WITHOUT
-
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
-
16 * for more details.
-
17 *
-
18 * You should have received a copy of the GNU Lesser General Public License
-
19 * along with this library; if not, see <http://www.gnu.org/licenses>.
-
20 */
-
21#ifndef __ABSTRACTION_MAP
-
22#define __ABSTRACTION_MAP
-
23
-
24#ifdef __cplusplus
-
25extern "C" {
-
26#endif
-
27
- -
29 /* if the conversion isn't a one-to-one mapping or the mathematical
-
30 * conversion is unique, create a custom conversion function.
-
31 */
-
32 int (*cgroup_convert)(struct cgroup_controller * const dst_cgc,
-
33 const char * const in_value,
-
34 const char * const out_setting,
-
35 void *in_dflt, void *out_dflt);
-
36 char *in_setting;
-
37 void *in_dflt;
-
38 char *out_setting;
-
39 void *out_dflt;
-
40};
-
41
-
42extern const struct cgroup_abstraction_map cgroup_v1_to_v2_map[];
-
43extern const int cgroup_v1_to_v2_map_sz;
-
44
-
45extern const struct cgroup_abstraction_map cgroup_v2_to_v1_map[];
-
46extern const int cgroup_v2_to_v1_map_sz;
-
47
-
48#ifdef __cplusplus
-
49} /* extern "C" */
-
50#endif
-
51
-
52#endif /* __ABSTRACTION_MAP */
-
Definition: abstraction-map.h:28
-
Definition: libcgroup-internal.h:108
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
9#ifndef __ABSTRACTION_MAP
+
10#define __ABSTRACTION_MAP
+
11
+
12#ifdef __cplusplus
+
13extern "C" {
+
14#endif
+
15
+ +
17 /* if the conversion isn't a one-to-one mapping or the mathematical
+
18 * conversion is unique, create a custom conversion function.
+
19 */
+
20 int (*cgroup_convert)(struct cgroup_controller * const dst_cgc,
+
21 const char * const in_value,
+
22 const char * const out_setting,
+
23 void *in_dflt, void *out_dflt);
+
24 char *in_setting;
+
25 void *in_dflt;
+
26 char *out_setting;
+
27 void *out_dflt;
+
28};
+
29
+
30extern const struct cgroup_abstraction_map cgroup_v1_to_v2_map[];
+
31extern const int cgroup_v1_to_v2_map_sz;
+
32
+
33extern const struct cgroup_abstraction_map cgroup_v2_to_v1_map[];
+
34extern const int cgroup_v2_to_v1_map_sz;
+
35
+
36#ifdef __cplusplus
+
37} /* extern "C" */
+
38#endif
+
39
+
40#endif /* __ABSTRACTION_MAP */
+
Definition: abstraction-map.h:16
+
Definition: libcgroup-internal.h:101
-
1/*
-
2 * Copyright Red Hat Inc. 2008
-
3 *
-
4 * Author: Steve Olivieri <sjo@redhat.com>
-
5 *
-
6 * This program is free software; you can redistribute it and/or modify it
-
7 * under the terms of version 2.1 of the GNU Lesser General Public License
-
8 * as published by the Free Software Foundation.
-
9 *
-
10 * This program is distributed in the hope that it would be useful, but
-
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
-
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
13 */
-
14
-
15#ifndef _CGRULESENGD_H
-
16#define _CGRULESENGD_H
-
17
-
18#include <features.h>
-
19
-
20#ifdef __cplusplus
-
21extern "C" {
-
22#endif
-
23
-
24#include "config.h"
-
25#include "libcgroup.h"
-
26#include <linux/connector.h>
-
27#include <linux/cn_proc.h>
-
28
-
29#ifndef _GNU_SOURCE
-
30#define _GNU_SOURCE
-
31#endif
-
32
-
33#ifndef __USE_GNU
-
34#define __USE_GNU
-
35#endif
-
36
-
37/* The following ten macros are all for the Netlink code. */
-
38#define SEND_MESSAGE_LEN (NLMSG_LENGTH(sizeof(struct cn_msg) + \
-
39 sizeof(enum proc_cn_mcast_op)))
-
40#define RECV_MESSAGE_LEN (NLMSG_LENGTH(sizeof(struct cn_msg) + \
-
41 sizeof(struct proc_event)))
-
42
-
43#define SEND_MESSAGE_SIZE (NLMSG_SPACE(SEND_MESSAGE_LEN))
-
44#define RECV_MESSAGE_SIZE (NLMSG_SPACE(RECV_MESSAGE_LEN))
-
45
-
46#define BUFF_SIZE (max(max(SEND_MESSAGE_SIZE, RECV_MESSAGE_SIZE), 1024))
-
47#define MIN_RECV_SIZE (min(SEND_MESSAGE_SIZE, RECV_MESSAGE_SIZE))
-
48
-
49#define PROC_CN_MCAST_LISTEN (1)
-
50#define PROC_CN_MCAST_IGNORE (2)
-
51
-
59void cgre_usage(FILE *fd, const char *msg, ...);
-
60
-
69void flog(int level, const char *msg, ...);
-
70
-
79int cgre_process_event(const struct proc_event *ev, const int type);
-
80
-
88int cgre_handle_message(struct cn_msg *cn_hdr);
-
89
-
100int cgre_start_daemon(const char *logp, const int logf,
-
101 const unsigned char daemon, const int logv);
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
8#ifndef _CGRULESENGD_H
+
9#define _CGRULESENGD_H
+
10
+
11#include <features.h>
+
12
+
13#ifdef __cplusplus
+
14extern "C" {
+
15#endif
+
16
+
17#include "config.h"
+
18#include "libcgroup.h"
+
19#include <linux/connector.h>
+
20#include <linux/cn_proc.h>
+
21
+
22#ifndef _GNU_SOURCE
+
23#define _GNU_SOURCE
+
24#endif
+
25
+
26#ifndef __USE_GNU
+
27#define __USE_GNU
+
28#endif
+
29
+
30/* The following ten macros are all for the Netlink code. */
+
31#define SEND_MESSAGE_LEN (NLMSG_LENGTH(sizeof(struct cn_msg) + \
+
32 sizeof(enum proc_cn_mcast_op)))
+
33#define RECV_MESSAGE_LEN (NLMSG_LENGTH(sizeof(struct cn_msg) + \
+
34 sizeof(struct proc_event)))
+
35
+
36#define SEND_MESSAGE_SIZE (NLMSG_SPACE(SEND_MESSAGE_LEN))
+
37#define RECV_MESSAGE_SIZE (NLMSG_SPACE(RECV_MESSAGE_LEN))
+
38
+
39#define BUFF_SIZE (max(max(SEND_MESSAGE_SIZE, RECV_MESSAGE_SIZE), 1024))
+
40#define MIN_RECV_SIZE (min(SEND_MESSAGE_SIZE, RECV_MESSAGE_SIZE))
+
41
+
42#define PROC_CN_MCAST_LISTEN (1)
+
43#define PROC_CN_MCAST_IGNORE (2)
+
44
+
52void cgre_usage(FILE *fd, const char *msg, ...);
+
53
+
62void flog(int level, const char *msg, ...);
+
63
+
72int cgre_process_event(const struct proc_event *ev, const int type);
+
73
+
81int cgre_handle_message(struct cn_msg *cn_hdr);
+
82
+
93int cgre_start_daemon(const char *logp, const int logf,
+
94 const unsigned char daemon, const int logv);
+
95
+
101void cgre_flash_rules(int signum);
102
-
108void cgre_flash_rules(int signum);
+
108void cgre_flash_templates(int signum);
109
-
115void cgre_flash_templates(int signum);
+
115void cgre_catch_term(int signum);
116
-
122void cgre_catch_term(int signum);
-
123
-
124#ifdef __cplusplus
-
125} /* extern "C" */
-
126#endif
-
127
-
128#endif /* _CGRULESENGD_H */
-
129
+
117#ifdef __cplusplus
+
118} /* extern "C" */
+
119#endif
+
120
+
121#endif /* _CGRULESENGD_H */
+
122
-
1#ifndef _LIBCGROUP_CONFIG_H
-
2#define _LIBCGROUP_CONFIG_H
-
3
-
4#ifndef _LIBCGROUP_H_INSIDE
-
5#error "Only <libcgroup.h> should be included directly."
-
6#endif
-
7
-
8#ifndef SWIG
-
9#include <features.h>
-
10#endif
-
11
-
12#ifdef __cplusplus
-
13extern "C" {
-
14#endif
-
15
-
36int cgroup_config_load_config(const char *pathname);
-
37
-
41int cgroup_unload_cgroups(void);
-
42
-
58int cgroup_config_unload_config(const char *pathname, int flags);
-
59
-
76int cgroup_config_set_default(struct cgroup *new_default);
-
77
-
81int cgroup_init_templates_cache(char *pathname);
-
82
-
86int cgroup_reload_cached_templates(char *pathname);
-
87
- -
95
-
101struct cgroup_string_list;
- -
103 struct cgroup_string_list *tmpl_files);
-
104
- -
126 struct cgroup *cgroup, char *template_name,
-
127 int flags);
-
128
-
133#ifdef __cplusplus
-
134} /* extern "C" */
-
135#endif
-
136
-
137#endif /*_LIBCGROUP_CONFIG_H*/
-
int cgroup_config_set_default(struct cgroup *new_default)
Definition: config.c:1486
-
int cgroup_init_templates_cache(char *pathname)
Definition: config.c:1574
-
int cgroup_config_create_template_group(struct cgroup *cgroup, char *template_name, int flags)
Definition: config.c:1799
-
int cgroup_unload_cgroups(void)
Definition: config.c:1396
-
int cgroup_reload_cached_templates(char *pathname)
Definition: config.c:1509
-
int cgroup_config_load_config(const char *pathname)
Definition: config.c:1130
-
int cgroup_load_templates_cache_from_files(int *file_index)
Definition: config.c:1715
-
void cgroup_templates_cache_set_source_files(struct cgroup_string_list *tmpl_files)
Definition: config.c:1642
-
int cgroup_config_unload_config(const char *pathname, int flags)
Definition: config.c:1266
-
Definition: tools-common.h:45
-
Definition: libcgroup-internal.h:116
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
2#ifndef _LIBCGROUP_CONFIG_H
+
3#define _LIBCGROUP_CONFIG_H
+
4
+
5#ifndef _LIBCGROUP_H_INSIDE
+
6#error "Only <libcgroup.h> should be included directly."
+
7#endif
+
8
+
9#ifndef SWIG
+
10#include <features.h>
+
11#endif
+
12
+
13#ifdef __cplusplus
+
14extern "C" {
+
15#endif
+
16
+
37int cgroup_config_load_config(const char *pathname);
+
38
+
42int cgroup_unload_cgroups(void);
+
43
+
59int cgroup_config_unload_config(const char *pathname, int flags);
+
60
+
77int cgroup_config_set_default(struct cgroup *new_default);
+
78
+
82int cgroup_init_templates_cache(char *pathname);
+
83
+
87int cgroup_reload_cached_templates(char *pathname);
+
88
+ +
96
+
102struct cgroup_string_list;
+ +
104 struct cgroup_string_list *tmpl_files);
+
105
+ +
127 struct cgroup *cgroup, char *template_name,
+
128 int flags);
+
129
+
134#ifdef __cplusplus
+
135} /* extern "C" */
+
136#endif
+
137
+
138#endif /*_LIBCGROUP_CONFIG_H*/
+
int cgroup_config_set_default(struct cgroup *new_default)
Definition: config.c:1479
+
int cgroup_init_templates_cache(char *pathname)
Definition: config.c:1567
+
int cgroup_config_create_template_group(struct cgroup *cgroup, char *template_name, int flags)
Definition: config.c:1792
+
int cgroup_unload_cgroups(void)
Definition: config.c:1389
+
int cgroup_reload_cached_templates(char *pathname)
Definition: config.c:1502
+
int cgroup_config_load_config(const char *pathname)
Definition: config.c:1123
+
int cgroup_load_templates_cache_from_files(int *file_index)
Definition: config.c:1708
+
void cgroup_templates_cache_set_source_files(struct cgroup_string_list *tmpl_files)
Definition: config.c:1635
+
int cgroup_config_unload_config(const char *pathname, int flags)
Definition: config.c:1259
+
Definition: tools-common.h:37
+
Definition: libcgroup-internal.h:109
-
1#ifndef _LIBCGROUP_ERROR_H
-
2#define _LIBCGROUP_ERROR_H
-
3
-
4#ifndef _LIBCGROUP_H_INSIDE
-
5#error "Only <libcgroup.h> should be included directly."
-
6#endif
-
7
-
8#ifndef SWIG
-
9#include <features.h>
-
10#endif
-
11
-
12#ifdef __cplusplus
-
13extern "C" {
-
14#endif
-
15
-
31enum {
-
32 ECGROUPNOTCOMPILED = 50000,
-
33 ECGROUPNOTMOUNTED, /* 50001 */
-
34 ECGROUPNOTEXIST, /* 50002 */
-
35 ECGROUPNOTCREATED, /* 50003 */
-
36 ECGROUPSUBSYSNOTMOUNTED, /* 50004 */
-
37 ECGROUPNOTOWNER, /* 50005 */
- -
40 /* This is the stock error. Default error. @todo really? */
-
41 ECGROUPNOTALLOWED, /* 50007 */
-
42 ECGMAXVALUESEXCEEDED, /* 50008 */
-
43 ECGCONTROLLEREXISTS, /* 50009 */
-
44 ECGVALUEEXISTS, /* 50010 */
-
45 ECGINVAL, /* 50011 */
-
46 ECGCONTROLLERCREATEFAILED, /* 50012 */
-
47 ECGFAIL, /* 50013 */
-
48 ECGROUPNOTINITIALIZED, /* 50014 */
-
49 ECGROUPVALUENOTEXIST, /* 50015 */
-
55 ECGOTHER, /* 50016 */
-
56 ECGROUPNOTEQUAL, /* 50017 */
-
57 ECGCONTROLLERNOTEQUAL, /* 50018 */
-
59 ECGROUPPARSEFAIL, /* 50019 */
-
61 ECGROUPNORULES, /* 50020 */
-
62 ECGMOUNTFAIL, /* 50021 */
-
67 ECGEOF = 50023,
-
69 ECGCONFIGPARSEFAIL, /* 50024 */
-
70 ECGNAMESPACEPATHS, /* 50025 */
-
71 ECGNAMESPACECONTROLLER, /* 50026 */
-
72 ECGMOUNTNAMESPACE, /* 50027 */
-
73 ECGROUPUNSUPP, /* 50028 */
-
74 ECGCANTSETVALUE, /* 50029 */
-
76 ECGNONEMPTY, /* 50030 */
- -
79};
-
80
-
84#define ECGRULESPARSEFAIL ECGROUPPARSEFAIL
-
85
-
95const char *cgroup_strerror(int code);
-
96
-
100int cgroup_get_last_errno(void);
-
101
-
106#ifdef __cplusplus
-
107} /* extern "C" */
-
108#endif
-
109
-
110#endif /* _LIBCGROUP_INIT_H */
-
int cgroup_get_last_errno(void)
Definition: api.c:4593
-
const char * cgroup_strerror(int code)
Definition: api.c:4582
-
@ ECGROUPMULTIMOUNTED
Definition: error.h:39
-
@ ECGEOF
Definition: error.h:67
-
@ ECGNOVERSIONCONVERT
Definition: error.h:78
-
@ ECGROUPNORULES
Definition: error.h:61
-
@ ECGOTHER
Definition: error.h:55
-
@ ECGNONEMPTY
Definition: error.h:76
-
@ ECGROUPPARSEFAIL
Definition: error.h:59
-
@ ECGCONFIGPARSEFAIL
Definition: error.h:69
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
2#ifndef _LIBCGROUP_ERROR_H
+
3#define _LIBCGROUP_ERROR_H
+
4
+
5#ifndef _LIBCGROUP_H_INSIDE
+
6#error "Only <libcgroup.h> should be included directly."
+
7#endif
+
8
+
9#ifndef SWIG
+
10#include <features.h>
+
11#endif
+
12
+
13#ifdef __cplusplus
+
14extern "C" {
+
15#endif
+
16
+
32enum {
+
33 ECGROUPNOTCOMPILED = 50000,
+
34 ECGROUPNOTMOUNTED, /* 50001 */
+
35 ECGROUPNOTEXIST, /* 50002 */
+
36 ECGROUPNOTCREATED, /* 50003 */
+
37 ECGROUPSUBSYSNOTMOUNTED, /* 50004 */
+
38 ECGROUPNOTOWNER, /* 50005 */
+ +
41 /* This is the stock error. Default error. @todo really? */
+
42 ECGROUPNOTALLOWED, /* 50007 */
+
43 ECGMAXVALUESEXCEEDED, /* 50008 */
+
44 ECGCONTROLLEREXISTS, /* 50009 */
+
45 ECGVALUEEXISTS, /* 50010 */
+
46 ECGINVAL, /* 50011 */
+
47 ECGCONTROLLERCREATEFAILED, /* 50012 */
+
48 ECGFAIL, /* 50013 */
+
49 ECGROUPNOTINITIALIZED, /* 50014 */
+
50 ECGROUPVALUENOTEXIST, /* 50015 */
+
56 ECGOTHER, /* 50016 */
+
57 ECGROUPNOTEQUAL, /* 50017 */
+
58 ECGCONTROLLERNOTEQUAL, /* 50018 */
+
60 ECGROUPPARSEFAIL, /* 50019 */
+
62 ECGROUPNORULES, /* 50020 */
+
63 ECGMOUNTFAIL, /* 50021 */
+
68 ECGEOF = 50023,
+
70 ECGCONFIGPARSEFAIL, /* 50024 */
+
71 ECGNAMESPACEPATHS, /* 50025 */
+
72 ECGNAMESPACECONTROLLER, /* 50026 */
+
73 ECGMOUNTNAMESPACE, /* 50027 */
+
74 ECGROUPUNSUPP, /* 50028 */
+
75 ECGCANTSETVALUE, /* 50029 */
+
77 ECGNONEMPTY, /* 50030 */
+ +
80};
+
81
+
85#define ECGRULESPARSEFAIL ECGROUPPARSEFAIL
+
86
+
96const char *cgroup_strerror(int code);
+
97
+
101int cgroup_get_last_errno(void);
+
102
+
107#ifdef __cplusplus
+
108} /* extern "C" */
+
109#endif
+
110
+
111#endif /* _LIBCGROUP_INIT_H */
+
int cgroup_get_last_errno(void)
Definition: api.c:4586
+
const char * cgroup_strerror(int code)
Definition: api.c:4575
+
@ ECGROUPMULTIMOUNTED
Definition: error.h:40
+
@ ECGEOF
Definition: error.h:68
+
@ ECGNOVERSIONCONVERT
Definition: error.h:79
+
@ ECGROUPNORULES
Definition: error.h:62
+
@ ECGOTHER
Definition: error.h:56
+
@ ECGNONEMPTY
Definition: error.h:77
+
@ ECGROUPPARSEFAIL
Definition: error.h:60
+
@ ECGCONFIGPARSEFAIL
Definition: error.h:70
I.e. there is cpu and cpuacct controller mounted together in one hierarchy, with foo and bar groups. In addition, freezer is mounted as separate hierarchy, with only one foo group.
Following code creates struct cgroup* structure, which represents one group cpu,cpuacct:/foo:
struct cgroup *foo = cgroup_new_cgroup("foo");
-
struct cgroup_controller * cgroup_add_controller(struct cgroup *cgroup, const char *name)
Definition: wrapper.c:59
-
struct cgroup * cgroup_new_cgroup(const char *name)
Definition: wrapper.c:46
-
Definition: libcgroup-internal.h:116
+
struct cgroup_controller * cgroup_add_controller(struct cgroup *cgroup, const char *name)
Definition: wrapper.c:52
+
struct cgroup * cgroup_new_cgroup(const char *name)
Definition: wrapper.c:39
+
Definition: libcgroup-internal.h:109
Now, you can call e.g. cgroup_delete_cgroup() and the group is deleted from the hierarchy. You can note that it's enough to add only one controller to the group to fully identify a group in cpu,cpuacct hierarchy.
Following code creates struct cgroup* structure, which represents two groups, cpu,cpuacct:/foo and freezer:/foo:
struct cgroup *foo = cgroup_new_cgroup("foo");
@@ -710,7 +710,7 @@ int cgroup_convert_cgroup<

Physically create new control group in kernel, with all parameters and values copied from its parent group. The group is created in all hierarchies, where the parent group exists. I.e. following code creates subgroup in all hierarchies, because all of them have root (=parent) group.

struct cgroup *foo = cgroup_new_cgroup("foo");
-
int cgroup_create_cgroup_from_parent(struct cgroup *cgroup, int ignore_ownership)
Definition: api.c:2771
+
int cgroup_create_cgroup_from_parent(struct cgroup *cgroup, int ignore_ownership)
Definition: api.c:2764
Todo:
what is this good for? Why the list of controllers added by cgroup_add_controller() is not used, like in cgroup_create_cgroup()? I can't crate subgroup of root group in just one hierarchy with this function!
Parameters
@@ -872,7 +872,7 @@ int 
cgroup_convert_cgroup<

Read all information regarding the group from kernel. Based on name of the group, list of controllers and all parameters and their values are read from all hierarchies, where a group with given name exists. All existing controllers are replaced. I.e. following code will fill root with controllers from all hierarchies, because the root group is available in all of them.

struct cgroup *root = cgroup_new_cgroup("/");
-
int cgroup_get_cgroup(struct cgroup *cgroup)
Definition: api.c:3321
+
int cgroup_get_cgroup(struct cgroup *cgroup)
Definition: api.c:3314
Todo:
what is this function good for? Why is not considered only the list of controllers attached by cgroup_add_controller()? What owners will return cgroup_get_uid_gid() if the group is in multiple hierarchies, each with different owner of tasks file?
Parameters
diff --git a/group__group__iterators.html b/group__group__iterators.html index 92c5fe9b..373ed1a7 100644 --- a/group__group__iterators.html +++ b/group__group__iterators.html @@ -191,7 +191,7 @@ Data Structures
// process the error here
}
iterator_name_end(&handle);
-
@ ECGEOF
Definition: error.h:67
+
@ ECGEOF
Definition: error.h:68
diff --git a/group__group__log.html b/group__group__log.html index 2b7215e2..87ec0956 100644 --- a/group__group__log.html +++ b/group__group__log.html @@ -85,7 +85,7 @@ $(function() {
...
}
...
-
void cgroup_set_logger(cgroup_logger_callback logger, int loglevel, void *userdata)
Definition: log.c:49
+
void cgroup_set_logger(cgroup_logger_callback logger, int loglevel, void *userdata)
Definition: log.c:42
enum  cgroup_log_level { CGROUP_LOG_ERROR = 1 diff --git a/groups_8h_source.html b/groups_8h_source.html index c3e885c2..edcafe0e 100644 --- a/groups_8h_source.html +++ b/groups_8h_source.html @@ -69,194 +69,195 @@ $(function() {
groups.h
-
1#ifndef _LIBCGROUP_GROUPS_H
-
2#define _LIBCGROUP_GROUPS_H
-
3
-
4#ifndef _LIBCGROUP_H_INSIDE
-
5#error "Only <libcgroup.h> should be included directly."
-
6#endif
-
7
-
8#ifndef SWIG
-
9#include <features.h>
-
10#include <sys/types.h>
-
11#include <stdbool.h>
-
12#endif
-
13
-
14#ifdef __cplusplus
-
15extern "C" {
-
16#endif
-
17
-
18enum cg_version_t {
-
19 CGROUP_UNK = 0,
-
20 CGROUP_V1,
-
21 CGROUP_V2,
-
22 CGROUP_DISK = 0xFF,
-
23};
-
24
-
28enum cgroup_delete_flag {
-
32 CGFLAG_DELETE_IGNORE_MIGRATION = 1,
-
33
-
37 CGFLAG_DELETE_RECURSIVE = 2,
-
38
-
44 CGFLAG_DELETE_EMPTY_ONLY = 4,
-
45};
-
46
-
117struct cgroup;
-
118
-
126struct cgroup_controller;
-
127
-
131#define NO_PERMS (-1U)
-
132
-
136#define NO_UID_GID (-1U)
-
137
-
148struct cgroup *cgroup_new_cgroup(const char *name);
-
149
- -
159 const char *name);
-
160
- -
169
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
2#ifndef _LIBCGROUP_GROUPS_H
+
3#define _LIBCGROUP_GROUPS_H
+
4
+
5#ifndef _LIBCGROUP_H_INSIDE
+
6#error "Only <libcgroup.h> should be included directly."
+
7#endif
+
8
+
9#ifndef SWIG
+
10#include <features.h>
+
11#include <sys/types.h>
+
12#include <stdbool.h>
+
13#endif
+
14
+
15#ifdef __cplusplus
+
16extern "C" {
+
17#endif
+
18
+
19enum cg_version_t {
+
20 CGROUP_UNK = 0,
+
21 CGROUP_V1,
+
22 CGROUP_V2,
+
23 CGROUP_DISK = 0xFF,
+
24};
+
25
+
29enum cgroup_delete_flag {
+
33 CGFLAG_DELETE_IGNORE_MIGRATION = 1,
+
34
+
38 CGFLAG_DELETE_RECURSIVE = 2,
+
39
+
45 CGFLAG_DELETE_EMPTY_ONLY = 4,
+
46};
+
47
+
118struct cgroup;
+
119
+
127struct cgroup_controller;
+
128
+
132#define NO_PERMS (-1U)
+
133
+
137#define NO_UID_GID (-1U)
+
138
+
149struct cgroup *cgroup_new_cgroup(const char *name);
+
150
+ +
160 const char *name);
+
161
+
170
- -
179 const char *name);
-
180
-
186void cgroup_free(struct cgroup **cgroup);
-
187
- -
194
+
171
+ +
180 const char *name);
+
181
+
187void cgroup_free(struct cgroup **cgroup);
+
188
+
195
-
219int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership);
-
220
- -
243 int ignore_ownership);
-
244
- -
253
-
268int cgroup_delete_cgroup(struct cgroup *cgroup, int ignore_migration);
-
269
-
284int cgroup_delete_cgroup_ext(struct cgroup *cgroup, int flags);
-
285
+
196
+
220int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership);
+
221
+ +
244 int ignore_ownership);
+
245
+ +
254
+
269int cgroup_delete_cgroup(struct cgroup *cgroup, int ignore_migration);
+
270
+
285int cgroup_delete_cgroup_ext(struct cgroup *cgroup, int flags);
286
-
314int cgroup_get_cgroup(struct cgroup *cgroup);
-
315
-
324int cgroup_copy_cgroup(struct cgroup *dst, struct cgroup *src);
-
325
-
337int cgroup_compare_cgroup(struct cgroup *cgroup_a, struct cgroup *cgroup_b);
-
338
+
287
+
315int cgroup_get_cgroup(struct cgroup *cgroup);
+
316
+
325int cgroup_copy_cgroup(struct cgroup *dst, struct cgroup *src);
+
326
+
338int cgroup_compare_cgroup(struct cgroup *cgroup_a, struct cgroup *cgroup_b);
339
- -
350 struct cgroup_controller *cgcb);
-
351
-
365int cgroup_set_uid_gid(struct cgroup *cgroup, uid_t tasks_uid, gid_t tasks_gid,
-
366 uid_t control_uid, gid_t control_gid);
-
367
-
373int cgroup_get_uid_gid(struct cgroup *cgroup, uid_t *tasks_uid,
-
374 gid_t *tasks_gid, uid_t *control_uid, gid_t *control_gid);
-
375
- -
389 mode_t control_dperm, mode_t control_fperm,
-
390 mode_t task_fperm);
-
391
-
412int cgroup_add_value_string(struct cgroup_controller *controller,
-
413 const char *name, const char *value);
-
425int cgroup_add_value_int64(struct cgroup_controller *controller,
-
426 const char *name, int64_t value);
-
436int cgroup_add_value_uint64(struct cgroup_controller *controller,
-
437 const char *name, u_int64_t value);
-
447int cgroup_add_value_bool(struct cgroup_controller *controller,
-
448 const char *name, bool value);
-
449
-
465int cgroup_get_value_string(struct cgroup_controller *controller,
-
466 const char *name, char **value);
-
475int cgroup_get_value_int64(struct cgroup_controller *controller,
-
476 const char *name, int64_t *value);
-
485int cgroup_get_value_uint64(struct cgroup_controller *controller,
-
486 const char *name, u_int64_t *value);
-
495int cgroup_get_value_bool(struct cgroup_controller *controller,
-
496 const char *name, bool *value);
-
497
-
506int cgroup_set_value_string(struct cgroup_controller *controller,
-
507 const char *name, const char *value);
-
518int cgroup_set_value_int64(struct cgroup_controller *controller,
-
519 const char *name, int64_t value);
-
528int cgroup_set_value_uint64(struct cgroup_controller *controller,
-
529 const char *name, u_int64_t value);
-
538int cgroup_set_value_bool(struct cgroup_controller *controller,
-
539 const char *name, bool value);
-
549int cgroup_get_value_name_count(struct cgroup_controller *controller);
-
550
-
563char *cgroup_get_value_name(struct cgroup_controller *controller, int index);
-
564
-
574int cgroup_get_procs(char *name, char *controller, pid_t **pids, int *size);
-
575
-
584int cg_chmod_recursive(struct cgroup *cgroup, mode_t dir_mode,
-
585 int dirm_change, mode_t file_mode, int filem_change);
-
586
- -
592
-
593/*
-
594 * Convert from one cgroup version to another version
-
595 *
-
596 * @param out_cgroup Destination cgroup
-
597 * @param out_version Destination cgroup version
-
598 * @param in_cgroup Source cgroup
-
599 * @param in_version Source cgroup version, only used if set to v1 or v2
-
600 *
-
601 * @return 0 on success
-
602 * ECGFAIL conversion failed
-
603 * ECGCONTROLLERNOTEQUAL incorrect controller version provided
-
604 */
-
605int cgroup_convert_cgroup(struct cgroup * const out_cgroup,
-
606 enum cg_version_t out_version,
-
607 const struct cgroup * const in_cgroup,
-
608 enum cg_version_t in_version);
-
609
-
617int cgroup_get_controller_version(const char * const controller,
-
618 enum cg_version_t * const version);
-
619
-
626#ifdef __cplusplus
-
627} /* extern "C" */
-
628#endif
-
629
-
630#endif /* _LIBCGROUP_GROUPS_H */
-
int cgroup_get_uid_gid(struct cgroup *cgroup, uid_t *tasks_uid, gid_t *tasks_gid, uid_t *control_uid, gid_t *control_gid)
Definition: wrapper.c:424
-
int cgroup_get_procs(char *name, char *controller, pid_t **pids, int *size)
Definition: api.c:5631
-
int cgroup_get_value_int64(struct cgroup_controller *controller, const char *name, int64_t *value)
Definition: wrapper.c:504
-
int cgroup_delete_cgroup(struct cgroup *cgroup, int ignore_migration)
Definition: api.c:3026
-
int cgroup_get_value_name_count(struct cgroup_controller *controller)
Definition: wrapper.c:728
-
int cgroup_modify_cgroup(struct cgroup *cgroup)
Definition: api.c:2312
-
struct cgroup_controller * cgroup_add_controller(struct cgroup *cgroup, const char *name)
Definition: wrapper.c:59
-
int cgroup_get_controller_version(const char *const controller, enum cg_version_t *const version)
Definition: api.c:5889
-
int cgroup_add_value_string(struct cgroup_controller *controller, const char *name, const char *value)
Definition: wrapper.c:216
-
int cgroup_add_value_bool(struct cgroup_controller *controller, const char *name, bool value)
Definition: wrapper.c:297
-
int cgroup_set_uid_gid(struct cgroup *cgroup, uid_t tasks_uid, gid_t tasks_gid, uid_t control_uid, gid_t control_gid)
Definition: wrapper.c:410
-
struct cgroup_controller * cgroup_get_controller(struct cgroup *cgroup, const char *name)
Definition: wrapper.c:438
-
int cgroup_add_value_int64(struct cgroup_controller *controller, const char *name, int64_t value)
Definition: wrapper.c:261
-
int cgroup_delete_cgroup_ext(struct cgroup *cgroup, int flags)
Definition: api.c:3033
-
int cgroup_compare_cgroup(struct cgroup *cgroup_a, struct cgroup *cgroup_b)
Definition: wrapper.c:374
-
int cgroup_create_cgroup_from_parent(struct cgroup *cgroup, int ignore_ownership)
Definition: api.c:2771
-
void cgroup_free_controllers(struct cgroup *cgroup)
Definition: wrapper.c:188
-
int cgroup_set_value_string(struct cgroup_controller *controller, const char *name, const char *value)
Definition: wrapper.c:482
-
int cgroup_get_value_uint64(struct cgroup_controller *controller, const char *name, u_int64_t *value)
Definition: wrapper.c:554
-
char * cgroup_get_value_name(struct cgroup_controller *controller, int index)
Definition: wrapper.c:737
-
void cgroup_set_permissions(struct cgroup *cgroup, mode_t control_dperm, mode_t control_fperm, mode_t task_fperm)
Definition: api.c:379
-
int cgroup_set_value_int64(struct cgroup_controller *controller, const char *name, int64_t value)
Definition: wrapper.c:527
-
int cgroup_copy_cgroup(struct cgroup *dst, struct cgroup *src)
Definition: api.c:2424
-
int cgroup_compare_controllers(struct cgroup_controller *cgca, struct cgroup_controller *cgcb)
Definition: wrapper.c:347
-
void cgroup_free(struct cgroup **cgroup)
Definition: wrapper.c:201
-
char * cgroup_get_cgroup_name(struct cgroup *cgroup)
Definition: wrapper.c:749
-
int cgroup_get_value_bool(struct cgroup_controller *controller, const char *name, bool *value)
Definition: wrapper.c:603
-
struct cgroup * cgroup_new_cgroup(const char *name)
Definition: wrapper.c:46
-
int cgroup_get_cgroup(struct cgroup *cgroup)
Definition: api.c:3321
-
int cgroup_add_value_uint64(struct cgroup_controller *controller, const char *name, u_int64_t value)
Definition: wrapper.c:279
-
int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership)
Definition: api.c:2611
-
int cgroup_set_value_uint64(struct cgroup_controller *controller, const char *name, u_int64_t value)
Definition: wrapper.c:576
-
int cgroup_add_all_controllers(struct cgroup *cgroup)
Definition: wrapper.c:115
-
int cg_chmod_recursive(struct cgroup *cgroup, mode_t dir_mode, int dirm_change, mode_t file_mode, int filem_change)
Definition: api.c:350
-
int cgroup_get_value_string(struct cgroup_controller *controller, const char *name, char **value)
Definition: wrapper.c:457
-
int cgroup_set_value_bool(struct cgroup_controller *controller, const char *name, bool value)
Definition: wrapper.c:631
-
Definition: libcgroup-internal.h:108
-
Definition: libcgroup-internal.h:116
+
340
+ +
351 struct cgroup_controller *cgcb);
+
352
+
366int cgroup_set_uid_gid(struct cgroup *cgroup, uid_t tasks_uid, gid_t tasks_gid,
+
367 uid_t control_uid, gid_t control_gid);
+
368
+
374int cgroup_get_uid_gid(struct cgroup *cgroup, uid_t *tasks_uid,
+
375 gid_t *tasks_gid, uid_t *control_uid, gid_t *control_gid);
+
376
+ +
390 mode_t control_dperm, mode_t control_fperm,
+
391 mode_t task_fperm);
+
392
+
413int cgroup_add_value_string(struct cgroup_controller *controller,
+
414 const char *name, const char *value);
+
426int cgroup_add_value_int64(struct cgroup_controller *controller,
+
427 const char *name, int64_t value);
+
437int cgroup_add_value_uint64(struct cgroup_controller *controller,
+
438 const char *name, u_int64_t value);
+
448int cgroup_add_value_bool(struct cgroup_controller *controller,
+
449 const char *name, bool value);
+
450
+
466int cgroup_get_value_string(struct cgroup_controller *controller,
+
467 const char *name, char **value);
+
476int cgroup_get_value_int64(struct cgroup_controller *controller,
+
477 const char *name, int64_t *value);
+
486int cgroup_get_value_uint64(struct cgroup_controller *controller,
+
487 const char *name, u_int64_t *value);
+
496int cgroup_get_value_bool(struct cgroup_controller *controller,
+
497 const char *name, bool *value);
+
498
+
507int cgroup_set_value_string(struct cgroup_controller *controller,
+
508 const char *name, const char *value);
+
519int cgroup_set_value_int64(struct cgroup_controller *controller,
+
520 const char *name, int64_t value);
+
529int cgroup_set_value_uint64(struct cgroup_controller *controller,
+
530 const char *name, u_int64_t value);
+
539int cgroup_set_value_bool(struct cgroup_controller *controller,
+
540 const char *name, bool value);
+
550int cgroup_get_value_name_count(struct cgroup_controller *controller);
+
551
+
564char *cgroup_get_value_name(struct cgroup_controller *controller, int index);
+
565
+
575int cgroup_get_procs(char *name, char *controller, pid_t **pids, int *size);
+
576
+
585int cg_chmod_recursive(struct cgroup *cgroup, mode_t dir_mode,
+
586 int dirm_change, mode_t file_mode, int filem_change);
+
587
+ +
593
+
594/*
+
595 * Convert from one cgroup version to another version
+
596 *
+
597 * @param out_cgroup Destination cgroup
+
598 * @param out_version Destination cgroup version
+
599 * @param in_cgroup Source cgroup
+
600 * @param in_version Source cgroup version, only used if set to v1 or v2
+
601 *
+
602 * @return 0 on success
+
603 * ECGFAIL conversion failed
+
604 * ECGCONTROLLERNOTEQUAL incorrect controller version provided
+
605 */
+
606int cgroup_convert_cgroup(struct cgroup * const out_cgroup,
+
607 enum cg_version_t out_version,
+
608 const struct cgroup * const in_cgroup,
+
609 enum cg_version_t in_version);
+
610
+
618int cgroup_get_controller_version(const char * const controller,
+
619 enum cg_version_t * const version);
+
620
+
627#ifdef __cplusplus
+
628} /* extern "C" */
+
629#endif
+
630
+
631#endif /* _LIBCGROUP_GROUPS_H */
+
int cgroup_get_uid_gid(struct cgroup *cgroup, uid_t *tasks_uid, gid_t *tasks_gid, uid_t *control_uid, gid_t *control_gid)
Definition: wrapper.c:417
+
int cgroup_get_procs(char *name, char *controller, pid_t **pids, int *size)
Definition: api.c:5624
+
int cgroup_get_value_int64(struct cgroup_controller *controller, const char *name, int64_t *value)
Definition: wrapper.c:497
+
int cgroup_delete_cgroup(struct cgroup *cgroup, int ignore_migration)
Definition: api.c:3019
+
int cgroup_get_value_name_count(struct cgroup_controller *controller)
Definition: wrapper.c:721
+
int cgroup_modify_cgroup(struct cgroup *cgroup)
Definition: api.c:2305
+
struct cgroup_controller * cgroup_add_controller(struct cgroup *cgroup, const char *name)
Definition: wrapper.c:52
+
int cgroup_get_controller_version(const char *const controller, enum cg_version_t *const version)
Definition: api.c:5882
+
int cgroup_add_value_string(struct cgroup_controller *controller, const char *name, const char *value)
Definition: wrapper.c:209
+
int cgroup_add_value_bool(struct cgroup_controller *controller, const char *name, bool value)
Definition: wrapper.c:290
+
int cgroup_set_uid_gid(struct cgroup *cgroup, uid_t tasks_uid, gid_t tasks_gid, uid_t control_uid, gid_t control_gid)
Definition: wrapper.c:403
+
struct cgroup_controller * cgroup_get_controller(struct cgroup *cgroup, const char *name)
Definition: wrapper.c:431
+
int cgroup_add_value_int64(struct cgroup_controller *controller, const char *name, int64_t value)
Definition: wrapper.c:254
+
int cgroup_delete_cgroup_ext(struct cgroup *cgroup, int flags)
Definition: api.c:3026
+
int cgroup_compare_cgroup(struct cgroup *cgroup_a, struct cgroup *cgroup_b)
Definition: wrapper.c:367
+
int cgroup_create_cgroup_from_parent(struct cgroup *cgroup, int ignore_ownership)
Definition: api.c:2764
+
void cgroup_free_controllers(struct cgroup *cgroup)
Definition: wrapper.c:181
+
int cgroup_set_value_string(struct cgroup_controller *controller, const char *name, const char *value)
Definition: wrapper.c:475
+
int cgroup_get_value_uint64(struct cgroup_controller *controller, const char *name, u_int64_t *value)
Definition: wrapper.c:547
+
char * cgroup_get_value_name(struct cgroup_controller *controller, int index)
Definition: wrapper.c:730
+
void cgroup_set_permissions(struct cgroup *cgroup, mode_t control_dperm, mode_t control_fperm, mode_t task_fperm)
Definition: api.c:372
+
int cgroup_set_value_int64(struct cgroup_controller *controller, const char *name, int64_t value)
Definition: wrapper.c:520
+
int cgroup_copy_cgroup(struct cgroup *dst, struct cgroup *src)
Definition: api.c:2417
+
int cgroup_compare_controllers(struct cgroup_controller *cgca, struct cgroup_controller *cgcb)
Definition: wrapper.c:340
+
void cgroup_free(struct cgroup **cgroup)
Definition: wrapper.c:194
+
char * cgroup_get_cgroup_name(struct cgroup *cgroup)
Definition: wrapper.c:742
+
int cgroup_get_value_bool(struct cgroup_controller *controller, const char *name, bool *value)
Definition: wrapper.c:596
+
struct cgroup * cgroup_new_cgroup(const char *name)
Definition: wrapper.c:39
+
int cgroup_get_cgroup(struct cgroup *cgroup)
Definition: api.c:3314
+
int cgroup_add_value_uint64(struct cgroup_controller *controller, const char *name, u_int64_t value)
Definition: wrapper.c:272
+
int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership)
Definition: api.c:2604
+
int cgroup_set_value_uint64(struct cgroup_controller *controller, const char *name, u_int64_t value)
Definition: wrapper.c:569
+
int cgroup_add_all_controllers(struct cgroup *cgroup)
Definition: wrapper.c:108
+
int cg_chmod_recursive(struct cgroup *cgroup, mode_t dir_mode, int dirm_change, mode_t file_mode, int filem_change)
Definition: api.c:343
+
int cgroup_get_value_string(struct cgroup_controller *controller, const char *name, char **value)
Definition: wrapper.c:450
+
int cgroup_set_value_bool(struct cgroup_controller *controller, const char *name, bool value)
Definition: wrapper.c:624
+
Definition: libcgroup-internal.h:101
+
Definition: libcgroup-internal.h:109
-
1#ifndef _LIBCGROUP_ITERATORS_H
-
2#define _LIBCGROUP_ITERATORS_H
-
3
-
4#ifndef _LIBCGROUP_H_INSIDE
-
5#error "Only <libcgroup.h> should be included directly."
-
6#endif
-
7
-
8#ifndef SWIG
-
9#include <sys/types.h>
-
10#include <stdio.h>
-
11#include <features.h>
-
12#endif
-
13
-
14#ifdef __cplusplus
-
15extern "C" {
-
16#endif
-
17
- - - -
100};
-
101
- - - - -
109};
-
110
- - -
118 const char *path;
-
120 const char *parent;
-
126 const char *full_path;
-
131 short depth;
-
132};
-
133
-
152int cgroup_walk_tree_begin(const char *controller, const char *base_path, int depth,
-
153 void **handle, struct cgroup_file_info *info,
-
154 int *base_level);
-
164int cgroup_walk_tree_next(int depth, void **handle,
-
165 struct cgroup_file_info *info, int base_level);
-
166
-
170int cgroup_walk_tree_end(void **handle);
-
171
-
178int cgroup_walk_tree_set_flags(void **handle, int flags);
-
179
-
195int cgroup_read_value_begin(const char * const controller, const char *path,
-
196 const char * const name, void **handle, char *buffer, int max);
-
197
-
211int cgroup_read_value_next(void **handle, char *buffer, int max);
-
212
-
216int cgroup_read_value_end(void **handle);
-
217
-
230#define CG_VALUE_MAX 100
- -
235 char name[FILENAME_MAX];
-
236 char value[CG_VALUE_MAX];
-
237};
-
238
-
249int cgroup_read_stats_begin(const char *controller, const char *path, void **handle,
-
250 struct cgroup_stat *stat);
-
251
-
258int cgroup_read_stats_next(void **handle, struct cgroup_stat *stat);
-
259
-
263int cgroup_read_stats_end(void **handle);
-
264
-
281int cgroup_get_task_begin(const char *cgroup, const char *controller, void **handle,
-
282 pid_t *pid);
-
283
-
291int cgroup_get_task_next(void **handle, pid_t *pid);
-
292
-
296int cgroup_get_task_end(void **handle);
-
297
- -
314 char name[FILENAME_MAX];
-
316 char path[FILENAME_MAX];
-
317};
-
318
-
326int cgroup_get_controller_begin(void **handle, struct cgroup_mount_point *info);
-
327
-
337int cgroup_get_controller_next(void **handle, struct cgroup_mount_point *info);
-
338
-
342int cgroup_get_controller_end(void **handle);
-
343
- -
358 char name[FILENAME_MAX];
- - - -
369};
-
370
-
376int cgroup_get_all_controller_begin(void **handle,
-
377 struct controller_data *info);
-
383int cgroup_get_all_controller_next(void **handle, struct controller_data *info);
-
384
-
388int cgroup_get_all_controller_end(void **handle);
-
389
-
407int cgroup_get_subsys_mount_point_begin(const char *controller, void **handle,
-
408 char *path);
-
415int cgroup_get_subsys_mount_point_next(void **handle,
-
416 char *path);
-
417
-
421int cgroup_get_subsys_mount_point_end(void **handle);
-
422
-
428#ifdef __cplusplus
-
429} /* extern "C" */
-
430#endif
-
431
-
432#endif /* _LIBCGROUP_ITERATORS_H */
-
int cgroup_walk_tree_end(void **handle)
Definition: api.c:4670
-
int cgroup_get_all_controller_end(void **handle)
Definition: api.c:5542
-
int cgroup_read_stats_begin(const char *controller, const char *path, void **handle, struct cgroup_stat *stat)
Definition: api.c:4928
-
int cgroup_get_subsys_mount_point_begin(const char *controller, void **handle, char *path)
Definition: api.c:5825
-
cgroup_walk_type
Definition: iterators.h:73
-
int cgroup_get_subsys_mount_point_next(void **handle, char *path)
Definition: api.c:5856
-
int cgroup_get_all_controller_next(void **handle, struct controller_data *info)
Definition: api.c:5556
-
int cgroup_walk_tree_next(int depth, void **handle, struct cgroup_file_info *info, int base_level)
Definition: api.c:4643
-
#define CG_VALUE_MAX
Definition: iterators.h:230
-
int cgroup_get_controller_begin(void **handle, struct cgroup_mount_point *info)
Definition: api.c:5077
-
cgroup_file_type
Definition: iterators.h:105
-
int cgroup_walk_tree_set_flags(void **handle, int flags)
Definition: api.c:4756
-
int cgroup_walk_tree_begin(const char *controller, const char *base_path, int depth, void **handle, struct cgroup_file_info *info, int *base_level)
Definition: api.c:4691
-
int cgroup_get_controller_next(void **handle, struct cgroup_mount_point *info)
Definition: api.c:5044
-
int cgroup_read_value_begin(const char *const controller, const char *path, const char *const name, void **handle, char *buffer, int max)
Definition: api.c:4852
-
int cgroup_get_subsys_mount_point_end(void **handle)
Definition: api.c:5878
-
int cgroup_get_controller_end(void **handle)
Definition: api.c:5028
-
int cgroup_read_stats_end(void **handle)
Definition: api.c:4890
-
int cgroup_read_value_next(void **handle, char *buffer, int max)
Definition: api.c:4832
-
int cgroup_read_value_end(void **handle)
Definition: api.c:4816
-
int cgroup_get_all_controller_begin(void **handle, struct controller_data *info)
Definition: api.c:5585
-
int cgroup_get_task_begin(const char *cgroup, const char *controller, void **handle, pid_t *pid)
Definition: api.c:4995
-
int cgroup_get_task_end(void **handle)
Definition: api.c:4959
-
int cgroup_get_task_next(void **handle, pid_t *pid)
Definition: api.c:4973
-
int cgroup_read_stats_next(void **handle, struct cgroup_stat *stat)
Definition: api.c:4908
-
@ CGROUP_WALK_TYPE_POST_DIR
Definition: iterators.h:99
-
@ CGROUP_WALK_TYPE_PRE_DIR
Definition: iterators.h:86
-
@ CGROUP_FILE_TYPE_OTHER
Definition: iterators.h:108
-
@ CGROUP_FILE_TYPE_DIR
Definition: iterators.h:107
-
@ CGROUP_FILE_TYPE_FILE
Definition: iterators.h:106
-
Definition: iterators.h:114
-
const char * full_path
Definition: iterators.h:126
-
const char * parent
Definition: iterators.h:120
-
const char * path
Definition: iterators.h:118
-
enum cgroup_file_type type
Definition: iterators.h:116
-
short depth
Definition: iterators.h:131
-
Definition: iterators.h:312
-
char name[FILENAME_MAX]
Definition: iterators.h:314
-
char path[FILENAME_MAX]
Definition: iterators.h:316
-
Definition: iterators.h:234
-
Definition: libcgroup-internal.h:116
-
Definition: iterators.h:356
-
int enabled
Definition: iterators.h:368
-
int hierarchy
Definition: iterators.h:364
-
char name[FILENAME_MAX]
Definition: iterators.h:358
-
int num_cgroups
Definition: iterators.h:366
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
2#ifndef _LIBCGROUP_ITERATORS_H
+
3#define _LIBCGROUP_ITERATORS_H
+
4
+
5#ifndef _LIBCGROUP_H_INSIDE
+
6#error "Only <libcgroup.h> should be included directly."
+
7#endif
+
8
+
9#ifndef SWIG
+
10#include <sys/types.h>
+
11#include <stdio.h>
+
12#include <features.h>
+
13#endif
+
14
+
15#ifdef __cplusplus
+
16extern "C" {
+
17#endif
+
18
+ + + +
101};
+
102
+ + + + +
110};
+
111
+ + +
119 const char *path;
+
121 const char *parent;
+
127 const char *full_path;
+
132 short depth;
+
133};
+
134
+
153int cgroup_walk_tree_begin(const char *controller, const char *base_path, int depth,
+
154 void **handle, struct cgroup_file_info *info,
+
155 int *base_level);
+
165int cgroup_walk_tree_next(int depth, void **handle,
+
166 struct cgroup_file_info *info, int base_level);
+
167
+
171int cgroup_walk_tree_end(void **handle);
+
172
+
179int cgroup_walk_tree_set_flags(void **handle, int flags);
+
180
+
196int cgroup_read_value_begin(const char * const controller, const char *path,
+
197 const char * const name, void **handle, char *buffer, int max);
+
198
+
212int cgroup_read_value_next(void **handle, char *buffer, int max);
+
213
+
217int cgroup_read_value_end(void **handle);
+
218
+
231#define CG_VALUE_MAX 100
+ +
236 char name[FILENAME_MAX];
+
237 char value[CG_VALUE_MAX];
+
238};
+
239
+
250int cgroup_read_stats_begin(const char *controller, const char *path, void **handle,
+
251 struct cgroup_stat *stat);
+
252
+
259int cgroup_read_stats_next(void **handle, struct cgroup_stat *stat);
+
260
+
264int cgroup_read_stats_end(void **handle);
+
265
+
282int cgroup_get_task_begin(const char *cgroup, const char *controller, void **handle,
+
283 pid_t *pid);
+
284
+
292int cgroup_get_task_next(void **handle, pid_t *pid);
+
293
+
297int cgroup_get_task_end(void **handle);
+
298
+ +
315 char name[FILENAME_MAX];
+
317 char path[FILENAME_MAX];
+
318};
+
319
+
327int cgroup_get_controller_begin(void **handle, struct cgroup_mount_point *info);
+
328
+
338int cgroup_get_controller_next(void **handle, struct cgroup_mount_point *info);
+
339
+
343int cgroup_get_controller_end(void **handle);
+
344
+ +
359 char name[FILENAME_MAX];
+ + + +
370};
+
371
+
377int cgroup_get_all_controller_begin(void **handle,
+
378 struct controller_data *info);
+
384int cgroup_get_all_controller_next(void **handle, struct controller_data *info);
+
385
+
389int cgroup_get_all_controller_end(void **handle);
+
390
+
408int cgroup_get_subsys_mount_point_begin(const char *controller, void **handle,
+
409 char *path);
+
416int cgroup_get_subsys_mount_point_next(void **handle,
+
417 char *path);
+
418
+
422int cgroup_get_subsys_mount_point_end(void **handle);
+
423
+
429#ifdef __cplusplus
+
430} /* extern "C" */
+
431#endif
+
432
+
433#endif /* _LIBCGROUP_ITERATORS_H */
+
int cgroup_walk_tree_end(void **handle)
Definition: api.c:4663
+
int cgroup_get_all_controller_end(void **handle)
Definition: api.c:5535
+
int cgroup_read_stats_begin(const char *controller, const char *path, void **handle, struct cgroup_stat *stat)
Definition: api.c:4921
+
int cgroup_get_subsys_mount_point_begin(const char *controller, void **handle, char *path)
Definition: api.c:5818
+
cgroup_walk_type
Definition: iterators.h:74
+
int cgroup_get_subsys_mount_point_next(void **handle, char *path)
Definition: api.c:5849
+
int cgroup_get_all_controller_next(void **handle, struct controller_data *info)
Definition: api.c:5549
+
int cgroup_walk_tree_next(int depth, void **handle, struct cgroup_file_info *info, int base_level)
Definition: api.c:4636
+
#define CG_VALUE_MAX
Definition: iterators.h:231
+
int cgroup_get_controller_begin(void **handle, struct cgroup_mount_point *info)
Definition: api.c:5070
+
cgroup_file_type
Definition: iterators.h:106
+
int cgroup_walk_tree_set_flags(void **handle, int flags)
Definition: api.c:4749
+
int cgroup_walk_tree_begin(const char *controller, const char *base_path, int depth, void **handle, struct cgroup_file_info *info, int *base_level)
Definition: api.c:4684
+
int cgroup_get_controller_next(void **handle, struct cgroup_mount_point *info)
Definition: api.c:5037
+
int cgroup_read_value_begin(const char *const controller, const char *path, const char *const name, void **handle, char *buffer, int max)
Definition: api.c:4845
+
int cgroup_get_subsys_mount_point_end(void **handle)
Definition: api.c:5871
+
int cgroup_get_controller_end(void **handle)
Definition: api.c:5021
+
int cgroup_read_stats_end(void **handle)
Definition: api.c:4883
+
int cgroup_read_value_next(void **handle, char *buffer, int max)
Definition: api.c:4825
+
int cgroup_read_value_end(void **handle)
Definition: api.c:4809
+
int cgroup_get_all_controller_begin(void **handle, struct controller_data *info)
Definition: api.c:5578
+
int cgroup_get_task_begin(const char *cgroup, const char *controller, void **handle, pid_t *pid)
Definition: api.c:4988
+
int cgroup_get_task_end(void **handle)
Definition: api.c:4952
+
int cgroup_get_task_next(void **handle, pid_t *pid)
Definition: api.c:4966
+
int cgroup_read_stats_next(void **handle, struct cgroup_stat *stat)
Definition: api.c:4901
+
@ CGROUP_WALK_TYPE_POST_DIR
Definition: iterators.h:100
+
@ CGROUP_WALK_TYPE_PRE_DIR
Definition: iterators.h:87
+
@ CGROUP_FILE_TYPE_OTHER
Definition: iterators.h:109
+
@ CGROUP_FILE_TYPE_DIR
Definition: iterators.h:108
+
@ CGROUP_FILE_TYPE_FILE
Definition: iterators.h:107
+
Definition: iterators.h:115
+
const char * full_path
Definition: iterators.h:127
+
const char * parent
Definition: iterators.h:121
+
const char * path
Definition: iterators.h:119
+
enum cgroup_file_type type
Definition: iterators.h:117
+
short depth
Definition: iterators.h:132
+
Definition: iterators.h:313
+
char name[FILENAME_MAX]
Definition: iterators.h:315
+
char path[FILENAME_MAX]
Definition: iterators.h:317
+
Definition: iterators.h:235
+
Definition: libcgroup-internal.h:109
+
Definition: iterators.h:357
+
int enabled
Definition: iterators.h:369
+
int hierarchy
Definition: iterators.h:365
+
char name[FILENAME_MAX]
Definition: iterators.h:359
+
int num_cgroups
Definition: iterators.h:367
-
1/*
-
2 * Copyright IBM Corporation. 2008
-
3 *
-
4 * Author: Dhaval Giani <dhaval@linux.vnet.ibm.com>
-
5 *
-
6 * This program is free software; you can redistribute it and/or modify it
-
7 * under the terms of version 2.1 of the GNU Lesser General Public License
-
8 * as published by the Free Software Foundation.
-
9 *
-
10 * This program is distributed in the hope that it would be useful, but
-
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
-
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
13 *
-
14 */
-
15#ifndef __LIBCG_INTERNAL
-
16
-
17#define __LIBCG_INTERNAL
-
18
-
19#ifdef __cplusplus
-
20extern "C" {
-
21#endif
-
22
-
23#include "config.h"
-
24
-
25#include <libcgroup.h>
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
8#ifndef __LIBCG_INTERNAL
+
9
+
10#define __LIBCG_INTERNAL
+
11
+
12#ifdef __cplusplus
+
13extern "C" {
+
14#endif
+
15
+
16#include "config.h"
+
17
+
18#include <libcgroup.h>
+
19
+
20#include <pthread.h>
+
21#include <dirent.h>
+
22#include <limits.h>
+
23#include <mntent.h>
+
24#include <setjmp.h>
+
25#include <fts.h>
26
-
27#include <pthread.h>
-
28#include <dirent.h>
-
29#include <limits.h>
-
30#include <mntent.h>
-
31#include <setjmp.h>
-
32#include <fts.h>
-
33
-
34#include <sys/stat.h>
-
35#include <sys/types.h>
-
36
-
37/* Maximum number of mount points/controllers */
-
38#define MAX_MNT_ELEMENTS 16
-
39/* Estimated number of groups created */
-
40#define MAX_GROUP_ELEMENTS 128
-
41
-
42/* Maximum length of a value */
-
43#define CG_CONTROL_VALUE_MAX 4096
-
44
-
45#define CG_NV_MAX 100
-
46#define CG_CONTROLLER_MAX 100
-
47#define CG_OPTIONS_MAX 100
-
48/* Max number of mounted hierarchies. Event if one controller is mounted per
-
49 * hier, it can not exceed CG_CONTROLLER_MAX
-
50 */
-
51#define CG_HIER_MAX CG_CONTROLLER_MAX
-
52
-
53/* Definitions for the uid and gid members of a cgroup_rules */
-
54#define CGRULE_INVALID ((uid_t) -1)
-
55#define CGRULE_WILD ((uid_t) -2)
-
56
-
57#define CGRULE_SUCCESS_STORE_PID "SUCCESS_STORE_PID"
-
58
-
59/* Definitions for the cgrules options field */
-
60#define CGRULE_OPTION_IGNORE "ignore"
-
61
-
62#define CGCONFIG_CONF_FILE "/etc/cgconfig.conf"
-
63/* Minimum number of file in template file list for cgrulesengd */
-
64#define CGCONFIG_CONF_FILES_LIST_MINIMUM_SIZE 4
-
65#define CGCONFIG_CONF_DIR "/etc/cgconfig.d"
-
66
-
67#define CGRULES_CONF_FILE "/etc/cgrules.conf"
-
68#define CGRULES_CONF_DIR "/etc/cgrules.d"
-
69#define CGRULES_MAX_FIELDS_PER_LINE 3
-
70
-
71#define CGROUP_BUFFER_LEN (5 * FILENAME_MAX)
+
27#include <sys/stat.h>
+
28#include <sys/types.h>
+
29
+
30/* Maximum number of mount points/controllers */
+
31#define MAX_MNT_ELEMENTS 16
+
32/* Estimated number of groups created */
+
33#define MAX_GROUP_ELEMENTS 128
+
34
+
35/* Maximum length of a value */
+
36#define CG_CONTROL_VALUE_MAX 4096
+
37
+
38#define CG_NV_MAX 100
+
39#define CG_CONTROLLER_MAX 100
+
40#define CG_OPTIONS_MAX 100
+
41/* Max number of mounted hierarchies. Event if one controller is mounted per
+
42 * hier, it can not exceed CG_CONTROLLER_MAX
+
43 */
+
44#define CG_HIER_MAX CG_CONTROLLER_MAX
+
45
+
46/* Definitions for the uid and gid members of a cgroup_rules */
+
47#define CGRULE_INVALID ((uid_t) -1)
+
48#define CGRULE_WILD ((uid_t) -2)
+
49
+
50#define CGRULE_SUCCESS_STORE_PID "SUCCESS_STORE_PID"
+
51
+
52/* Definitions for the cgrules options field */
+
53#define CGRULE_OPTION_IGNORE "ignore"
+
54
+
55#define CGCONFIG_CONF_FILE "/etc/cgconfig.conf"
+
56/* Minimum number of file in template file list for cgrulesengd */
+
57#define CGCONFIG_CONF_FILES_LIST_MINIMUM_SIZE 4
+
58#define CGCONFIG_CONF_DIR "/etc/cgconfig.d"
+
59
+
60#define CGRULES_CONF_FILE "/etc/cgrules.conf"
+
61#define CGRULES_CONF_DIR "/etc/cgrules.d"
+
62#define CGRULES_MAX_FIELDS_PER_LINE 3
+
63
+
64#define CGROUP_BUFFER_LEN (5 * FILENAME_MAX)
+
65
+
66/* Maximum length of a key(<user>:<process name>) in the daemon config file */
+
67#define CGROUP_RULE_MAXKEY (LOGIN_NAME_MAX + FILENAME_MAX + 1)
+
68
+
69/* Maximum length of a line in the daemon config file */
+
70#define CGROUP_RULE_MAXLINE (FILENAME_MAX + CGROUP_RULE_MAXKEY + \
+
71 CG_CONTROLLER_MAX + 3)
72
-
73/* Maximum length of a key(<user>:<process name>) in the daemon config file */
-
74#define CGROUP_RULE_MAXKEY (LOGIN_NAME_MAX + FILENAME_MAX + 1)
-
75
-
76/* Maximum length of a line in the daemon config file */
-
77#define CGROUP_RULE_MAXLINE (FILENAME_MAX + CGROUP_RULE_MAXKEY + \
-
78 CG_CONTROLLER_MAX + 3)
+
73#define CGROUP_FILE_PREFIX "cgroup"
+
74
+
75#define cgroup_err(x...) cgroup_log(CGROUP_LOG_ERROR, "Error: " x)
+
76#define cgroup_warn(x...) cgroup_log(CGROUP_LOG_WARNING, "Warning: " x)
+
77#define cgroup_info(x...) cgroup_log(CGROUP_LOG_INFO, "Info: " x)
+
78#define cgroup_dbg(x...) cgroup_log(CGROUP_LOG_DEBUG, x)
79
-
80#define CGROUP_FILE_PREFIX "cgroup"
+
80#define CGROUP_DEFAULT_LOGLEVEL CGROUP_LOG_ERROR
81
-
82#define cgroup_err(x...) cgroup_log(CGROUP_LOG_ERROR, "Error: " x)
-
83#define cgroup_warn(x...) cgroup_log(CGROUP_LOG_WARNING, "Warning: " x)
-
84#define cgroup_info(x...) cgroup_log(CGROUP_LOG_INFO, "Info: " x)
-
85#define cgroup_dbg(x...) cgroup_log(CGROUP_LOG_DEBUG, x)
-
86
-
87#define CGROUP_DEFAULT_LOGLEVEL CGROUP_LOG_ERROR
+
82#define max(x, y) ((y) < (x)?(x):(y))
+
83#define min(x, y) ((y) > (x)?(x):(y))
+
84
+ +
86 char name[FILENAME_MAX];
+
87 char value[CG_CONTROL_VALUE_MAX];
88
-
89#define max(x, y) ((y) < (x)?(x):(y))
-
90#define min(x, y) ((y) > (x)?(x):(y))
+
89 /* cgget uses this field for values that span multiple lines */
+
90 char *multiline_value;
91
- -
93 char name[FILENAME_MAX];
-
94 char value[CG_CONTROL_VALUE_MAX];
-
95
-
96 /* cgget uses this field for values that span multiple lines */
-
97 char *multiline_value;
-
98
-
99 /*
-
100 * The abstraction layer uses prev_name when there's an N->1 or
-
101 * 1->N relationship between cgroup v1 and v2 settings.
-
102 */
-
103 char *prev_name;
-
104
-
105 bool dirty;
-
106};
-
107
- -
109 char name[FILENAME_MAX];
-
110 struct control_value *values[CG_NV_MAX];
-
111 struct cgroup *cgroup;
+
92 /*
+
93 * The abstraction layer uses prev_name when there's an N->1 or
+
94 * 1->N relationship between cgroup v1 and v2 settings.
+
95 */
+
96 char *prev_name;
+
97
+
98 bool dirty;
+
99};
+
100
+ +
102 char name[FILENAME_MAX];
+
103 struct control_value *values[CG_NV_MAX];
+
104 struct cgroup *cgroup;
+
105 int index;
+
106 enum cg_version_t version;
+
107};
+
108
+
109struct cgroup {
+
110 char name[FILENAME_MAX];
+
111 struct cgroup_controller *controller[CG_CONTROLLER_MAX];
112 int index;
-
113 enum cg_version_t version;
-
114};
-
115
-
116struct cgroup {
-
117 char name[FILENAME_MAX];
-
118 struct cgroup_controller *controller[CG_CONTROLLER_MAX];
-
119 int index;
-
120 uid_t tasks_uid;
-
121 gid_t tasks_gid;
-
122 mode_t task_fperm;
-
123 uid_t control_uid;
-
124 gid_t control_gid;
-
125 mode_t control_fperm;
-
126 mode_t control_dperm;
-
127};
-
128
- -
130 char path[FILENAME_MAX];
-
131 struct cg_mount_point *next;
-
132};
-
133
- -
136 char name[FILENAME_MAX];
- -
141 int index;
-
142 enum cg_version_t version;
-
143};
-
144
- -
146 pid_t pid; /* pid of the process which needs to change group */
-
147
-
148 /* Details of user under consideration for destination cgroup */
-
149 struct passwd *pw;
-
150 /* Gid of the process */
-
151 gid_t gid;
-
152};
-
153
-
154/* A rule that maps UID/GID to a cgroup */
- -
156 uid_t uid;
-
157 gid_t gid;
-
158 bool is_ignore;
-
159 char *procname;
-
160 char username[LOGIN_NAME_MAX];
-
161 char destination[FILENAME_MAX];
-
162 char *controllers[MAX_MNT_ELEMENTS];
-
163 struct cgroup_rule *next;
+
113 uid_t tasks_uid;
+
114 gid_t tasks_gid;
+
115 mode_t task_fperm;
+
116 uid_t control_uid;
+
117 gid_t control_gid;
+
118 mode_t control_fperm;
+
119 mode_t control_dperm;
+
120};
+
121
+ +
123 char path[FILENAME_MAX];
+
124 struct cg_mount_point *next;
+
125};
+
126
+ +
129 char name[FILENAME_MAX];
+ +
134 int index;
+
135 enum cg_version_t version;
+
136};
+
137
+ +
139 pid_t pid; /* pid of the process which needs to change group */
+
140
+
141 /* Details of user under consideration for destination cgroup */
+
142 struct passwd *pw;
+
143 /* Gid of the process */
+
144 gid_t gid;
+
145};
+
146
+
147/* A rule that maps UID/GID to a cgroup */
+ +
149 uid_t uid;
+
150 gid_t gid;
+
151 bool is_ignore;
+
152 char *procname;
+
153 char username[LOGIN_NAME_MAX];
+
154 char destination[FILENAME_MAX];
+
155 char *controllers[MAX_MNT_ELEMENTS];
+
156 struct cgroup_rule *next;
+
157};
+
158
+
159/* Container for a list of rules */
+ +
161 struct cgroup_rule *head;
+
162 struct cgroup_rule *tail;
+
163 int len;
164};
165
-
166/* Container for a list of rules */
- -
168 struct cgroup_rule *head;
-
169 struct cgroup_rule *tail;
-
170 int len;
-
171};
-
172
-
173/*The walk_tree handle */
- -
175 FTS *fts;
-
176 int flags;
-
177};
-
178
- -
187 const char *name;
-
188 const char *value;
-
189 struct cgroup_dictionary_item *next;
-
190};
-
191
-
192/* Flags for cgroup_dictionary_create */
-
199#define CG_DICT_DONT_FREE_ITEMS 1
-
200
- -
210 struct cgroup_dictionary_item *head;
-
211 struct cgroup_dictionary_item *tail;
-
212 int flags;
-
213};
-
214
- -
217 struct cgroup_dictionary_item *item;
-
218};
-
219
-
223extern __thread int last_errno;
-
224
-
228extern jmp_buf parser_error_env;
-
229
-
230/* Internal API */
-
231char *cg_build_path(const char *name, char *path, const char *type);
-
232int cgroup_get_uid_gid_from_procfs(pid_t pid, uid_t *euid, gid_t *egid);
-
233int cgroup_get_procname_from_procfs(pid_t pid, char **procname);
-
234int cg_mkdir_p(const char *path);
-
235struct cgroup *create_cgroup_from_name_value_pairs(const char *name,
-
236 struct control_value *name_value, int nv_number);
-
237void init_cgroup_table(struct cgroup *cgroups, size_t count);
-
238
-
239/*
-
240 * Main mounting structures
-
241 */
-
242extern struct cg_mount_table_s cg_mount_table[CG_CONTROLLER_MAX];
-
243extern pthread_rwlock_t cg_mount_table_lock;
-
244
-
245/*
-
246 * config related structures
-
247 */
-
248
-
249extern __thread char *cg_namespace_table[CG_CONTROLLER_MAX];
-
250
-
251/*
-
252 * config related API
-
253 */
-
254int cgroup_config_insert_cgroup(char *cg_name);
-
255int cgroup_config_parse_controller_options(char *controller,
-
256 struct cgroup_dictionary *values);
-
257int template_config_insert_cgroup(char *cg_name);
-
258int template_config_parse_controller_options(char *controller,
-
259 struct cgroup_dictionary *values);
-
260int template_config_group_task_perm(char *perm_type, char *value);
-
261int template_config_group_admin_perm(char *perm_type, char *value);
-
262int cgroup_config_group_task_perm(char *perm_type, char *value);
-
263int cgroup_config_group_admin_perm(char *perm_type, char *value);
-
264int cgroup_config_insert_into_mount_table(char *name, char *mount_point);
-
265int cgroup_config_insert_into_namespace_table(char *name, char *mount_point);
-
266void cgroup_config_cleanup_mount_table(void);
-
267void cgroup_config_cleanup_namespace_table(void);
-
268int cgroup_config_define_default(void);
-
269
-
273extern int cgroup_dictionary_create(struct cgroup_dictionary **dict,
-
274 int flags);
-
278extern int cgroup_dictionary_add(struct cgroup_dictionary *dict,
-
279 const char *name, const char *value);
-
284extern int cgroup_dictionary_free(struct cgroup_dictionary *dict);
-
285
-
290extern int cgroup_dictionary_iterator_begin(struct cgroup_dictionary *dict,
-
291 void **handle, const char **name, const char **value);
-
295extern int cgroup_dictionary_iterator_next(void **handle,
-
296 const char **name, const char **value);
-
300extern void cgroup_dictionary_iterator_end(void **handle);
-
301
-
311int cg_chmod_path(const char *path, mode_t mode, int owner_is_umask);
-
312
-
322int cgroup_build_tasks_procs_path(char * const path,
-
323 size_t path_sz, const char * const cg_name,
-
324 const char * const ctrl_name);
-
325
-
337char *cg_build_path_locked(const char *setting, char *path,
-
338 const char *controller);
-
339
-
351int cgroup_fill_cgc(struct dirent *ctrl_dir, struct cgroup *cgroup,
-
352 struct cgroup_controller *cgc, int cg_index);
-
353
-
360int cgroup_test_subsys_mounted(const char *ctrl_name);
-
361
-
370int cgroup_copy_controller_values(struct cgroup_controller * const dst,
-
371 const struct cgroup_controller * const src);
-
372
-
380int cgroup_remove_value(struct cgroup_controller * const controller,
-
381 const char * const name);
-
382
-
389void cgroup_free_controller(struct cgroup_controller *ctrl);
+
166/*The walk_tree handle */
+ +
168 FTS *fts;
+
169 int flags;
+
170};
+
171
+ +
180 const char *name;
+
181 const char *value;
+
182 struct cgroup_dictionary_item *next;
+
183};
+
184
+
185/* Flags for cgroup_dictionary_create */
+
192#define CG_DICT_DONT_FREE_ITEMS 1
+
193
+ +
203 struct cgroup_dictionary_item *head;
+
204 struct cgroup_dictionary_item *tail;
+
205 int flags;
+
206};
+
207
+ +
210 struct cgroup_dictionary_item *item;
+
211};
+
212
+
216extern __thread int last_errno;
+
217
+
221extern jmp_buf parser_error_env;
+
222
+
223/* Internal API */
+
224char *cg_build_path(const char *name, char *path, const char *type);
+
225int cgroup_get_uid_gid_from_procfs(pid_t pid, uid_t *euid, gid_t *egid);
+
226int cgroup_get_procname_from_procfs(pid_t pid, char **procname);
+
227int cg_mkdir_p(const char *path);
+
228struct cgroup *create_cgroup_from_name_value_pairs(const char *name,
+
229 struct control_value *name_value, int nv_number);
+
230void init_cgroup_table(struct cgroup *cgroups, size_t count);
+
231
+
232/*
+
233 * Main mounting structures
+
234 */
+
235extern struct cg_mount_table_s cg_mount_table[CG_CONTROLLER_MAX];
+
236extern pthread_rwlock_t cg_mount_table_lock;
+
237
+
238/*
+
239 * config related structures
+
240 */
+
241
+
242extern __thread char *cg_namespace_table[CG_CONTROLLER_MAX];
+
243
+
244/*
+
245 * config related API
+
246 */
+
247int cgroup_config_insert_cgroup(char *cg_name);
+
248int cgroup_config_parse_controller_options(char *controller,
+
249 struct cgroup_dictionary *values);
+
250int template_config_insert_cgroup(char *cg_name);
+
251int template_config_parse_controller_options(char *controller,
+
252 struct cgroup_dictionary *values);
+
253int template_config_group_task_perm(char *perm_type, char *value);
+
254int template_config_group_admin_perm(char *perm_type, char *value);
+
255int cgroup_config_group_task_perm(char *perm_type, char *value);
+
256int cgroup_config_group_admin_perm(char *perm_type, char *value);
+
257int cgroup_config_insert_into_mount_table(char *name, char *mount_point);
+
258int cgroup_config_insert_into_namespace_table(char *name, char *mount_point);
+
259void cgroup_config_cleanup_mount_table(void);
+
260void cgroup_config_cleanup_namespace_table(void);
+
261int cgroup_config_define_default(void);
+
262
+
266extern int cgroup_dictionary_create(struct cgroup_dictionary **dict,
+
267 int flags);
+
271extern int cgroup_dictionary_add(struct cgroup_dictionary *dict,
+
272 const char *name, const char *value);
+
277extern int cgroup_dictionary_free(struct cgroup_dictionary *dict);
+
278
+
283extern int cgroup_dictionary_iterator_begin(struct cgroup_dictionary *dict,
+
284 void **handle, const char **name, const char **value);
+
288extern int cgroup_dictionary_iterator_next(void **handle,
+
289 const char **name, const char **value);
+
293extern void cgroup_dictionary_iterator_end(void **handle);
+
294
+
304int cg_chmod_path(const char *path, mode_t mode, int owner_is_umask);
+
305
+
315int cgroup_build_tasks_procs_path(char * const path,
+
316 size_t path_sz, const char * const cg_name,
+
317 const char * const ctrl_name);
+
318
+
330char *cg_build_path_locked(const char *setting, char *path,
+
331 const char *controller);
+
332
+
344int cgroup_fill_cgc(struct dirent *ctrl_dir, struct cgroup *cgroup,
+
345 struct cgroup_controller *cgc, int cg_index);
+
346
+
353int cgroup_test_subsys_mounted(const char *ctrl_name);
+
354
+
363int cgroup_copy_controller_values(struct cgroup_controller * const dst,
+
364 const struct cgroup_controller * const src);
+
365
+
373int cgroup_remove_value(struct cgroup_controller * const controller,
+
374 const char * const name);
+
375
+
382void cgroup_free_controller(struct cgroup_controller *ctrl);
+
383
+
389#ifdef UNIT_TEST
390
-
396#ifdef UNIT_TEST
-
397
-
398#define TEST_PROC_PID_CGROUP_FILE "test-procpidcgroup"
+
391#define TEST_PROC_PID_CGROUP_FILE "test-procpidcgroup"
+
392
+
393int cgroup_parse_rules_options(char *options,
+
394 struct cgroup_rule * const rule);
+
395
+
396int cg_get_cgroups_from_proc_cgroups(pid_t pid, char *cgroup_list[],
+
397 char *controller_list[],
+
398 int list_len);
399
-
400int cgroup_parse_rules_options(char *options,
-
401 struct cgroup_rule * const rule);
+
400bool cgroup_compare_ignore_rule(const struct cgroup_rule * const rule,
+
401 pid_t pid, const char * const procname);
402
-
403int cg_get_cgroups_from_proc_cgroups(pid_t pid, char *cgroup_list[],
-
404 char *controller_list[],
-
405 int list_len);
-
406
-
407bool cgroup_compare_ignore_rule(const struct cgroup_rule * const rule,
-
408 pid_t pid, const char * const procname);
-
409
-
410bool cgroup_compare_wildcard_procname(const char * const rule_procname,
-
411 const char * const procname);
-
412
-
413int cgroup_process_v1_mnt(char *controllers[], struct mntent *ent,
-
414 int *mnt_tbl_idx);
-
415
-
416int cgroup_process_v2_mnt(struct mntent *ent, int *mnt_tbl_idx);
+
403bool cgroup_compare_wildcard_procname(const char * const rule_procname,
+
404 const char * const procname);
+
405
+
406int cgroup_process_v1_mnt(char *controllers[], struct mntent *ent,
+
407 int *mnt_tbl_idx);
+
408
+
409int cgroup_process_v2_mnt(struct mntent *ent, int *mnt_tbl_idx);
+
410
+
411int cgroup_set_values_recursive(const char * const base,
+
412 const struct cgroup_controller * const controller,
+
413 bool ignore_non_dirty_failures);
+
414
+
415int cgroup_chown_chmod_tasks(const char * const cg_path,
+
416 uid_t uid, gid_t gid, mode_t fperm);
417
-
418int cgroup_set_values_recursive(const char * const base,
-
419 const struct cgroup_controller * const controller,
-
420 bool ignore_non_dirty_failures);
-
421
-
422int cgroup_chown_chmod_tasks(const char * const cg_path,
-
423 uid_t uid, gid_t gid, mode_t fperm);
+
418int cgroupv2_subtree_control(const char *path, const char *ctrl_name,
+
419 bool enable);
+
420
+
421int cgroupv2_get_subtree_control(const char *path,
+
422 const char *ctrl_name,
+
423 bool * const enabled);
424
-
425int cgroupv2_subtree_control(const char *path, const char *ctrl_name,
-
426 bool enable);
+
425int cgroupv2_controller_enabled(const char * const cg_name,
+
426 const char * const ctrl_name);
427
-
428int cgroupv2_get_subtree_control(const char *path,
-
429 const char *ctrl_name,
-
430 bool * const enabled);
-
431
-
432int cgroupv2_controller_enabled(const char * const cg_name,
-
433 const char * const ctrl_name);
-
434
-
435#endif /* UNIT_TEST */
-
436
-
437#ifdef __cplusplus
-
438} /* extern "C" */
-
439#endif
-
440
-
441#endif
-
Definition: libcgroup-internal.h:129
-
Definition: libcgroup-internal.h:134
-
struct cg_mount_point mount
Definition: libcgroup-internal.h:140
-
char name[FILENAME_MAX]
Definition: libcgroup-internal.h:136
-
Definition: libcgroup-internal.h:108
-
Definition: libcgroup-internal.h:186
-
Definition: libcgroup-internal.h:216
-
Definition: libcgroup-internal.h:209
-
Definition: libcgroup-internal.h:167
-
Definition: libcgroup-internal.h:155
-
Definition: libcgroup-internal.h:145
-
Definition: libcgroup-internal.h:174
-
Definition: libcgroup-internal.h:116
-
Definition: libcgroup-internal.h:92
+
428#endif /* UNIT_TEST */
+
429
+
430#ifdef __cplusplus
+
431} /* extern "C" */
+
432#endif
+
433
+
434#endif
+
Definition: libcgroup-internal.h:122
+
Definition: libcgroup-internal.h:127
+
struct cg_mount_point mount
Definition: libcgroup-internal.h:133
+
char name[FILENAME_MAX]
Definition: libcgroup-internal.h:129
+
Definition: libcgroup-internal.h:101
+
Definition: libcgroup-internal.h:179
+
Definition: libcgroup-internal.h:209
+
Definition: libcgroup-internal.h:202
+
Definition: libcgroup-internal.h:160
+
Definition: libcgroup-internal.h:148
+
Definition: libcgroup-internal.h:138
+
Definition: libcgroup-internal.h:167
+
Definition: libcgroup-internal.h:109
+
Definition: libcgroup-internal.h:85
-
1/*
-
2 * Copyright IBM Corporation. 2007
-
3 *
-
4 * Author: Balbir Singh <balbir@linux.vnet.ibm.com>
-
5 *
-
6 * This program is free software; you can redistribute it and/or modify it
-
7 * under the terms of version 2.1 of the GNU Lesser General Public License
-
8 * as published by the Free Software Foundation.
-
9 *
-
10 * This program is distributed in the hope that it would be useful, but
-
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
-
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
13 *
-
14 */
-
15
-
16#ifndef _LIBCGROUP_H
-
17#define _LIBCGROUP_H
-
18
-
19#define _LIBCGROUP_H_INSIDE
-
20
-
21#include <libcgroup/error.h>
-
22#include <libcgroup/init.h>
-
23#include <libcgroup/iterators.h>
-
24#include <libcgroup/groups.h>
-
25#include <libcgroup/tasks.h>
-
26#include <libcgroup/config.h>
-
27#include <libcgroup/log.h>
-
28#include <libcgroup/tools.h>
-
29
-
30#undef _LIBCGROUP_H_INSIDE
-
31
-
50#endif /* _LIBCGROUP_H */
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
8#ifndef _LIBCGROUP_H
+
9#define _LIBCGROUP_H
+
10
+
11#define _LIBCGROUP_H_INSIDE
+
12
+
13#include <libcgroup/error.h>
+
14#include <libcgroup/init.h>
+
15#include <libcgroup/iterators.h>
+
16#include <libcgroup/groups.h>
+
17#include <libcgroup/tasks.h>
+
18#include <libcgroup/config.h>
+
19#include <libcgroup/log.h>
+
20#include <libcgroup/tools.h>
+
21
+
22#undef _LIBCGROUP_H_INSIDE
+
23
+
42#endif /* _LIBCGROUP_H */
-
1#ifndef _LIBCGROUP_LOG_H
-
2#define _LIBCGROUP_LOG_H
-
3
-
4#ifndef _LIBCGROUP_H_INSIDE
-
5#error "Only <libcgroup.h> should be included directly."
-
6#endif
-
7
-
8#ifndef SWIG
-
9#include <features.h>
-
10#endif
-
11
-
12#include <stdarg.h>
-
13
-
14#ifdef __cplusplus
-
15extern "C" {
-
16#endif
-
17
- - - - - -
91};
-
92
-
93typedef void (*cgroup_logger_callback)(void *userdata, int level,
-
94 const char *fmt, va_list ap);
-
95
-
109extern void cgroup_set_logger(cgroup_logger_callback logger, int loglevel,
-
110 void *userdata);
-
111
-
120extern void cgroup_set_default_logger(int loglevel);
-
121
-
127extern void cgroup_set_loglevel(int loglevel);
-
128
-
135extern void cgroup_log(int loglevel, const char *fmt, ...);
-
136
-
142extern int cgroup_parse_log_level_str(const char *levelstr);
-
147#ifdef __cplusplus
-
148} /* extern "C" */
-
149#endif
-
150
-
151#endif /* _LIBCGROUP_LOG_H */
-
void cgroup_set_logger(cgroup_logger_callback logger, int loglevel, void *userdata)
Definition: log.c:49
-
cgroup_log_level
Definition: log.h:72
-
int cgroup_parse_log_level_str(const char *levelstr)
Definition: log.c:63
-
void cgroup_set_loglevel(int loglevel)
Definition: log.c:87
-
void cgroup_set_default_logger(int loglevel)
Definition: log.c:57
-
void cgroup_log(int loglevel, const char *fmt,...)
Definition: log.c:34
-
@ CGROUP_LOG_ERROR
Definition: log.h:77
-
@ CGROUP_LOG_DEBUG
Definition: log.h:90
-
@ CGROUP_LOG_WARNING
Definition: log.h:81
-
@ CGROUP_LOG_INFO
Definition: log.h:86
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
2#ifndef _LIBCGROUP_LOG_H
+
3#define _LIBCGROUP_LOG_H
+
4
+
5#ifndef _LIBCGROUP_H_INSIDE
+
6#error "Only <libcgroup.h> should be included directly."
+
7#endif
+
8
+
9#ifndef SWIG
+
10#include <features.h>
+
11#endif
+
12
+
13#include <stdarg.h>
+
14
+
15#ifdef __cplusplus
+
16extern "C" {
+
17#endif
+
18
+ + + + + +
92};
+
93
+
94typedef void (*cgroup_logger_callback)(void *userdata, int level,
+
95 const char *fmt, va_list ap);
+
96
+
110extern void cgroup_set_logger(cgroup_logger_callback logger, int loglevel,
+
111 void *userdata);
+
112
+
121extern void cgroup_set_default_logger(int loglevel);
+
122
+
128extern void cgroup_set_loglevel(int loglevel);
+
129
+
136extern void cgroup_log(int loglevel, const char *fmt, ...);
+
137
+
143extern int cgroup_parse_log_level_str(const char *levelstr);
+
148#ifdef __cplusplus
+
149} /* extern "C" */
+
150#endif
+
151
+
152#endif /* _LIBCGROUP_LOG_H */
+
void cgroup_set_logger(cgroup_logger_callback logger, int loglevel, void *userdata)
Definition: log.c:42
+
cgroup_log_level
Definition: log.h:73
+
int cgroup_parse_log_level_str(const char *levelstr)
Definition: log.c:56
+
void cgroup_set_loglevel(int loglevel)
Definition: log.c:80
+
void cgroup_set_default_logger(int loglevel)
Definition: log.c:50
+
void cgroup_log(int loglevel, const char *fmt,...)
Definition: log.c:27
+
@ CGROUP_LOG_ERROR
Definition: log.h:78
+
@ CGROUP_LOG_DEBUG
Definition: log.h:91
+
@ CGROUP_LOG_WARNING
Definition: log.h:82
+
@ CGROUP_LOG_INFO
Definition: log.h:87
-
1#ifndef _LIBCGROUP_TASKS_H
-
2#define _LIBCGROUP_TASKS_H
-
3
-
4#ifndef _LIBCGROUP_H_INSIDE
-
5#error "Only <libcgroup.h> should be included directly."
-
6#endif
-
7
-
8#include <libcgroup/groups.h>
-
9
-
10#ifndef SWIG
-
11#include <features.h>
-
12#include <stdbool.h>
-
13#endif
-
14
-
15#ifdef __cplusplus
-
16extern "C" {
-
17#endif
-
18
-
20enum cgflags {
-
22 CGFLAG_USECACHE = 0x01,
-
24 CGFLAG_USE_TEMPLATE_CACHE = 0x02,
-
25};
-
26
-
28enum cgroup_daemon_type {
-
33 CGROUP_DAEMON_UNCHANGE_CHILDREN = 0x1,
-
34 CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS = 0x2,
-
35};
-
36
- -
52
-
58int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid);
-
59
-
71int cgroup_change_cgroup_path(const char *path, pid_t pid,
-
72 const char * const controllers[]);
-
73
-
82int cgroup_get_current_controller_path(pid_t pid, const char *controller,
-
83 char **current_path);
-
84
- -
100
- -
106
-
113void cgroup_print_rules_config(FILE *fp);
-
114
- -
135
-
155int cgroup_change_cgroup_flags(uid_t uid, gid_t gid,
-
156 const char *procname, pid_t pid, int flags);
-
157
-
171int cgroup_change_cgroup_uid_gid_flags(uid_t uid, gid_t gid,
-
172 pid_t pid, int flags);
-
173
-
183int cgroup_change_cgroup_uid_gid(uid_t uid, gid_t gid, pid_t pid);
-
184
-
203int cgroup_register_unchanged_process(pid_t pid, int flags);
-
204
-
209#ifdef __cplusplus
-
210} /* extern "C" */
-
211#endif
-
212
-
213#endif /* _LIBCGROUP_TASKS_H */
-
int cgroup_change_cgroup_path(const char *path, pid_t pid, const char *const controllers[])
Definition: api.c:4277
-
int cgroup_change_cgroup_flags(uid_t uid, gid_t gid, const char *procname, pid_t pid, int flags)
Definition: api.c:4043
-
int cgroup_attach_task(struct cgroup *cgroup)
Definition: api.c:1870
-
int cgroup_change_cgroup_uid_gid(uid_t uid, gid_t gid, pid_t pid)
Definition: api.c:4265
-
int cgroup_register_unchanged_process(pid_t pid, int flags)
Definition: api.c:5467
-
int cgroup_get_current_controller_path(pid_t pid, const char *controller, char **current_path)
Definition: api.c:4499
-
int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid)
Definition: api.c:1802
-
void cgroup_print_rules_config(FILE *fp)
Definition: api.c:4391
-
int cgroup_init_rules_cache(void)
Definition: api.c:4477
-
int cgroup_change_cgroup_uid_gid_flags(uid_t uid, gid_t gid, pid_t pid, int flags)
Definition: api.c:4248
-
int cgroup_reload_cached_rules(void)
Definition: api.c:4451
-
int cgroup_change_all_cgroups(void)
Definition: api.c:4345
-
Definition: libcgroup-internal.h:116
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
2#ifndef _LIBCGROUP_TASKS_H
+
3#define _LIBCGROUP_TASKS_H
+
4
+
5#ifndef _LIBCGROUP_H_INSIDE
+
6#error "Only <libcgroup.h> should be included directly."
+
7#endif
+
8
+
9#include <libcgroup/groups.h>
+
10
+
11#ifndef SWIG
+
12#include <features.h>
+
13#include <stdbool.h>
+
14#endif
+
15
+
16#ifdef __cplusplus
+
17extern "C" {
+
18#endif
+
19
+
21enum cgflags {
+
23 CGFLAG_USECACHE = 0x01,
+
25 CGFLAG_USE_TEMPLATE_CACHE = 0x02,
+
26};
+
27
+
29enum cgroup_daemon_type {
+
34 CGROUP_DAEMON_UNCHANGE_CHILDREN = 0x1,
+
35 CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS = 0x2,
+
36};
+
37
+ +
53
+
59int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid);
+
60
+
72int cgroup_change_cgroup_path(const char *path, pid_t pid,
+
73 const char * const controllers[]);
+
74
+
83int cgroup_get_current_controller_path(pid_t pid, const char *controller,
+
84 char **current_path);
+
85
+ +
101
+ +
107
+
114void cgroup_print_rules_config(FILE *fp);
+
115
+ +
136
+
156int cgroup_change_cgroup_flags(uid_t uid, gid_t gid,
+
157 const char *procname, pid_t pid, int flags);
+
158
+
172int cgroup_change_cgroup_uid_gid_flags(uid_t uid, gid_t gid,
+
173 pid_t pid, int flags);
+
174
+
184int cgroup_change_cgroup_uid_gid(uid_t uid, gid_t gid, pid_t pid);
+
185
+
204int cgroup_register_unchanged_process(pid_t pid, int flags);
+
205
+
210#ifdef __cplusplus
+
211} /* extern "C" */
+
212#endif
+
213
+
214#endif /* _LIBCGROUP_TASKS_H */
+
int cgroup_change_cgroup_path(const char *path, pid_t pid, const char *const controllers[])
Definition: api.c:4270
+
int cgroup_change_cgroup_flags(uid_t uid, gid_t gid, const char *procname, pid_t pid, int flags)
Definition: api.c:4036
+
int cgroup_attach_task(struct cgroup *cgroup)
Definition: api.c:1863
+
int cgroup_change_cgroup_uid_gid(uid_t uid, gid_t gid, pid_t pid)
Definition: api.c:4258
+
int cgroup_register_unchanged_process(pid_t pid, int flags)
Definition: api.c:5460
+
int cgroup_get_current_controller_path(pid_t pid, const char *controller, char **current_path)
Definition: api.c:4492
+
int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid)
Definition: api.c:1795
+
void cgroup_print_rules_config(FILE *fp)
Definition: api.c:4384
+
int cgroup_init_rules_cache(void)
Definition: api.c:4470
+
int cgroup_change_cgroup_uid_gid_flags(uid_t uid, gid_t gid, pid_t pid, int flags)
Definition: api.c:4241
+
int cgroup_reload_cached_rules(void)
Definition: api.c:4444
+
int cgroup_change_all_cgroups(void)
Definition: api.c:4338
+
Definition: libcgroup-internal.h:109
-
1/*
-
2 * Copyright Red Hat, Inc. 2009
-
3 *
-
4 * Author: Vivek Goyal <vgoyal@redhat.com>
-
5 * Jan Safranek <jsafrane@redhat.com>
-
6 *
-
7 * This program is free software; you can redistribute it and/or modify it
-
8 * under the terms of version 2.1 of the GNU Lesser General Public License
-
9 * as published by the Free Software Foundation.
-
10 *
-
11 * This program is distributed in the hope that it would be useful, but
-
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
-
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
14 *
-
15 */
-
16
-
17#ifndef __TOOLS_COMMON
-
18
-
19#define __TOOLS_COMMON
-
20
-
21#ifdef __cplusplus
-
22extern "C" {
-
23#endif
-
24#include "config.h"
-
25#include <libcgroup.h>
-
26#include "../libcgroup-internal.h"
-
27
-
28#define cgroup_err(x...) cgroup_log(CGROUP_LOG_ERROR, "Error: " x)
-
29#define cgroup_warn(x...) cgroup_log(CGROUP_LOG_WARNING, "Warning: " x)
-
30#define cgroup_info(x...) cgroup_log(CGROUP_LOG_INFO, "Info: " x)
-
31#define cgroup_dbg(x...) cgroup_log(CGROUP_LOG_DEBUG, x)
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
9#ifndef __TOOLS_COMMON
+
10
+
11#define __TOOLS_COMMON
+
12
+
13#ifdef __cplusplus
+
14extern "C" {
+
15#endif
+
16#include "config.h"
+
17#include <libcgroup.h>
+
18#include "../libcgroup-internal.h"
+
19
+
20#define cgroup_err(x...) cgroup_log(CGROUP_LOG_ERROR, "Error: " x)
+
21#define cgroup_warn(x...) cgroup_log(CGROUP_LOG_WARNING, "Warning: " x)
+
22#define cgroup_info(x...) cgroup_log(CGROUP_LOG_INFO, "Info: " x)
+
23#define cgroup_dbg(x...) cgroup_log(CGROUP_LOG_DEBUG, x)
+
24
+ +
29 char path[FILENAME_MAX];
+
30 char *controllers[CG_CONTROLLER_MAX];
+
31};
32
- -
37 char path[FILENAME_MAX];
-
38 char *controllers[CG_CONTROLLER_MAX];
-
39};
-
40
-
41
- -
46 char **items;
-
47 int size;
-
48 int count;
-
49};
-
50
-
64int parse_cgroup_spec(struct cgroup_group_spec **cdptr, char *optarg,
-
65 int capacity);
-
66
-
71void cgroup_free_group_spec(struct cgroup_group_spec *cl);
-
72
+
33
+ +
38 char **items;
+
39 int size;
+
40 int count;
+
41};
+
42
+
56int parse_cgroup_spec(struct cgroup_group_spec **cdptr, char *optarg,
+
57 int capacity);
+
58
+
63void cgroup_free_group_spec(struct cgroup_group_spec *cl);
+
64
+
65
+
71int cgroup_string_list_init(struct cgroup_string_list *list,
+
72 int initial_size);
73
-
79int cgroup_string_list_init(struct cgroup_string_list *list,
-
80 int initial_size);
-
81
-
86void cgroup_string_list_free(struct cgroup_string_list *list);
-
87
-
94int cgroup_string_list_add_item(struct cgroup_string_list *list,
-
95 const char *item);
-
96
-
106int cgroup_string_list_add_directory(struct cgroup_string_list *list,
-
107 char *dirname, char *program_name);
-
108
+
78void cgroup_string_list_free(struct cgroup_string_list *list);
+
79
+
86int cgroup_string_list_add_item(struct cgroup_string_list *list,
+
87 const char *item);
+
88
+
98int cgroup_string_list_add_directory(struct cgroup_string_list *list,
+
99 char *dirname, char *program_name);
+
100
+
101
+
108int parse_mode(char *string, mode_t *pmode, const char *program_name);
109
-
116int parse_mode(char *string, mode_t *pmode, const char *program_name);
-
117
-
125int parse_uid_gid(char *string, uid_t *uid, gid_t *gid,
-
126 const char *program_name);
-
127
-
133#ifdef UNIT_TEST
-
134
-
135int parse_r_flag(const char * const program_name,
-
136 const char * const name_value_str,
-
137 struct control_value * const name_value);
-
138
-
139#endif /* UNIT_TEST */
-
140
-
141#ifdef __cplusplus
-
142} /* extern "C" */
-
143#endif
-
144
-
145#endif /* TOOLS_COMMON */
-
Definition: tools-common.h:36
-
Definition: tools-common.h:45
-
Definition: libcgroup-internal.h:92
+
117int parse_uid_gid(char *string, uid_t *uid, gid_t *gid,
+
118 const char *program_name);
+
119
+
125#ifdef UNIT_TEST
+
126
+
127int parse_r_flag(const char * const program_name,
+
128 const char * const name_value_str,
+
129 struct control_value * const name_value);
+
130
+
131#endif /* UNIT_TEST */
+
132
+
133#ifdef __cplusplus
+
134} /* extern "C" */
+
135#endif
+
136
+
137#endif /* TOOLS_COMMON */
+
Definition: tools-common.h:28
+
Definition: tools-common.h:37
+
Definition: libcgroup-internal.h:85
-
1
-
8/*
-
9 * This library is free software; you can redistribute it and/or modify it
-
10 * under the terms of version 2.1 of the GNU Lesser General Public License as
-
11 * published by the Free Software Foundation.
-
12 *
-
13 * This library is distributed in the hope that it will be useful, but WITHOUT
-
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
-
16 * for more details.
-
17 *
-
18 * You should have received a copy of the GNU Lesser General Public License
-
19 * along with this library; if not, see <http://www.gnu.org/licenses>.
-
20 */
-
21#ifndef _LIBCGROUP_TOOLS_H
-
22#define _LIBCGROUP_TOOLS_H
-
23
-
24#ifndef _LIBCGROUP_H_INSIDE
-
25#error "Only <libcgroup.h> should be included directly."
-
26#endif
-
27
-
28#ifndef SWIG
-
29#include <features.h>
-
30#include <sys/types.h>
-
31#include <stdbool.h>
-
32#endif
-
33
-
34#ifdef __cplusplus
-
35extern "C" {
-
36#endif
-
37
-
53int cgroup_cgxget(struct cgroup ** cg,
-
54 enum cg_version_t version, bool ignore_unmappable);
-
55
-
66int cgroup_cgxset(const struct cgroup * const cg,
-
67 enum cg_version_t version, bool ignore_unmappable);
-
68
-
69#ifdef __cplusplus
-
70} /* extern "C" */
-
71#endif
-
72
-
73#endif /* _LIBCGROUP_TOOLS_H */
-
Definition: libcgroup-internal.h:116
+
1/* SPDX-License-Identifier: LGPL-2.1-only */
+
9#ifndef _LIBCGROUP_TOOLS_H
+
10#define _LIBCGROUP_TOOLS_H
+
11
+
12#ifndef _LIBCGROUP_H_INSIDE
+
13#error "Only <libcgroup.h> should be included directly."
+
14#endif
+
15
+
16#ifndef SWIG
+
17#include <features.h>
+
18#include <sys/types.h>
+
19#include <stdbool.h>
+
20#endif
+
21
+
22#ifdef __cplusplus
+
23extern "C" {
+
24#endif
+
25
+
41int cgroup_cgxget(struct cgroup ** cg,
+
42 enum cg_version_t version, bool ignore_unmappable);
+
43
+
54int cgroup_cgxset(const struct cgroup * const cg,
+
55 enum cg_version_t version, bool ignore_unmappable);
+
56
+
57#ifdef __cplusplus
+
58} /* extern "C" */
+
59#endif
+
60
+
61#endif /* _LIBCGROUP_TOOLS_H */
+
Definition: libcgroup-internal.h:109