1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __CGROUP_HELPERS_H
3 #define __CGROUP_HELPERS_H
8 #define clean_errno() (errno == 0 ? "None" : strerror(errno))
9 #define log_err(MSG, ...) fprintf(stderr, "(%s:%d: errno: %s) " MSG "\n", \
10 __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
12 /* cgroupv2 related */
13 int cgroup_setup_and_join(const char *path);
14 int create_and_get_cgroup(const char *path);
15 unsigned long long get_cgroup_id(const char *path);
17 int join_cgroup(const char *path);
19 int setup_cgroup_environment(void);
20 void cleanup_cgroup_environment(void);
22 /* cgroupv1 related */
23 int set_classid(unsigned int id);
24 int join_classid(void);
26 int setup_classid_environment(void);
27 void cleanup_classid_environment(void);
29 #endif /* __CGROUP_HELPERS_H */