return RET_NERRNO(open_by_handle_at(cgroupfs_fd, &fh.file_handle, O_DIRECTORY|O_CLOEXEC));
}
+int cg_path_from_cgroupid(int cgroupfs_fd, uint64_t id, char **ret) {
+ _cleanup_close_ int cgfd = -EBADF;
+ int r;
+
+ cgfd = cg_cgroupid_open(cgroupfs_fd, id);
+ if (cgfd < 0)
+ return cgfd;
+
+ _cleanup_free_ char *path = NULL;
+ r = fd_get_path(cgfd, &path);
+ if (r < 0)
+ return r;
+
+ if (!path_startswith(path, "/sys/fs/cgroup/"))
+ return -EXDEV; /* recognizable error */
+
+ if (ret)
+ *ret = TAKE_PTR(path);
+ return 0;
+}
+
int cg_get_cgroupid_at(int dfd, const char *path, uint64_t *ret) {
cg_file_handle fh = CG_FILE_HANDLE_INIT;
int mnt_id;
int cg_path_open(const char *controller, const char *path);
int cg_cgroupid_open(int fsfd, uint64_t id);
+int cg_path_from_cgroupid(int cgroupfs_fd, uint64_t id, char **ret);
int cg_get_cgroupid_at(int dfd, const char *path, uint64_t *ret);
static inline int cg_path_get_cgroupid(const char *path, uint64_t *ret) {
return cg_get_cgroupid_at(AT_FDCWD, path, ret);