diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-12-12 10:44:57 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-04-06 16:08:23 +0200 |
commit | 3b2874952fed9b71726ca08e4c888e02ca275ca2 (patch) | |
tree | 9dcfe3e920e1c2058445f6eebc80658ed73147d1 /src/basic/cgroup-util.h | |
parent | lock-util: make global lock return parameter to image_path_lock() optional (diff) | |
download | systemd-3b2874952fed9b71726ca08e4c888e02ca275ca2.tar.xz systemd-3b2874952fed9b71726ca08e4c888e02ca275ca2.zip |
cgroup-util: add helpers for opening cgroup by id
Diffstat (limited to 'src/basic/cgroup-util.h')
-rw-r--r-- | src/basic/cgroup-util.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h index 244f3b657b..9ad6dd8eb6 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -180,6 +180,9 @@ typedef enum CGroupUnified { * generate paths with multiple adjacent / removed. */ +int cg_path_open(const char *controller, const char *path); +int cg_cgroupid_open(int fsfd, uint64_t id); + int cg_enumerate_processes(const char *controller, const char *path, FILE **ret); int cg_read_pid(FILE *f, pid_t *ret); int cg_read_pidref(FILE *f, PidRef *ret); @@ -267,6 +270,7 @@ int cg_is_empty_recursive(const char *controller, const char *path); int cg_get_root_path(char **path); int cg_path_get_cgroupid(const char *path, uint64_t *ret); +int cg_fd_get_cgroupid(int fd, uint64_t *ret); int cg_path_get_session(const char *path, char **ret_session); int cg_path_get_owner_uid(const char *path, uid_t *ret_uid); int cg_path_get_unit(const char *path, char **ret_unit); @@ -352,5 +356,10 @@ typedef union { uint8_t space[offsetof(struct file_handle, f_handle) + sizeof(uint64_t)]; } cg_file_handle; -#define CG_FILE_HANDLE_INIT { .file_handle.handle_bytes = sizeof(uint64_t) } +#define CG_FILE_HANDLE_INIT \ + (cg_file_handle) { \ + .file_handle.handle_bytes = sizeof(uint64_t), \ + .file_handle.handle_type = FILEID_KERNFS, \ + } + #define CG_FILE_HANDLE_CGROUPID(fh) (*(uint64_t*) (fh).file_handle.f_handle) |