xref: /OK3568_Linux_fs/kernel/tools/testing/selftests/bpf/cgroup_helpers.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef __CGROUP_HELPERS_H
3*4882a593Smuzhiyun #define __CGROUP_HELPERS_H
4*4882a593Smuzhiyun #include <errno.h>
5*4882a593Smuzhiyun #include <string.h>
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #define clean_errno() (errno == 0 ? "None" : strerror(errno))
8*4882a593Smuzhiyun #define log_err(MSG, ...) fprintf(stderr, "(%s:%d: errno: %s) " MSG "\n", \
9*4882a593Smuzhiyun 	__FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun int cgroup_setup_and_join(const char *path);
13*4882a593Smuzhiyun int create_and_get_cgroup(const char *path);
14*4882a593Smuzhiyun int join_cgroup(const char *path);
15*4882a593Smuzhiyun int setup_cgroup_environment(void);
16*4882a593Smuzhiyun void cleanup_cgroup_environment(void);
17*4882a593Smuzhiyun unsigned long long get_cgroup_id(const char *path);
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #endif
20