return cg_path_get_session(cgroup, ret_session);
}
+int cg_pidref_get_session(const PidRef *pidref, char **ret) {
+ int r;
+
+ if (!pidref_is_set(pidref))
+ return -ESRCH;
+ if (pidref_is_remote(pidref))
+ return -EREMOTE;
+
+ _cleanup_free_ char *session = NULL;
+ r = cg_pid_get_session(pidref->pid, &session);
+ if (r < 0)
+ return r;
+
+ r = pidref_verify(pidref);
+ if (r < 0)
+ return r;
+
+ if (ret)
+ *ret = TAKE_PTR(session);
+ return 0;
+}
+
int cg_path_get_owner_uid(const char *path, uid_t *ret_uid) {
_cleanup_free_ char *slice = NULL;
char *start, *end;
return cg_path_get_owner_uid(cgroup, ret_uid);
}
+int cg_pidref_get_owner_uid(const PidRef *pidref, uid_t *ret) {
+ int r;
+
+ if (!pidref_is_set(pidref))
+ return -ESRCH;
+ if (pidref_is_remote(pidref))
+ return -EREMOTE;
+
+ uid_t uid;
+ r = cg_pid_get_owner_uid(pidref->pid, &uid);
+ if (r < 0)
+ return r;
+
+ r = pidref_verify(pidref);
+ if (r < 0)
+ return r;
+
+ if (ret)
+ *ret = uid;
+
+ return 0;
+}
+
int cg_path_get_slice(const char *p, char **ret_slice) {
const char *e = NULL;
int cg_pid_get_path_shifted(pid_t pid, const char *cached_root, char **ret_cgroup);
int cg_pid_get_session(pid_t pid, char **ret_session);
+int cg_pidref_get_session(const PidRef *pidref, char **ret);
int cg_pid_get_owner_uid(pid_t pid, uid_t *ret_uid);
+int cg_pidref_get_owner_uid(const PidRef *pidref, uid_t *ret);
int cg_pid_get_unit(pid_t pid, char **ret_unit);
int cg_pidref_get_unit(const PidRef *pidref, char **ret);
int cg_pid_get_user_unit(pid_t pid, char **ret_unit);
cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, pid.pid, &path);
cg_pid_get_path_shifted(pid.pid, NULL, &path_shifted);
- cg_pid_get_owner_uid(pid.pid, &uid);
- cg_pid_get_session(pid.pid, &session);
+ cg_pidref_get_owner_uid(&pid, &uid);
+ cg_pidref_get_session(&pid, &session);
cg_pid_get_unit(pid.pid, &unit);
cg_pid_get_user_unit(pid.pid, &user_unit);
cg_pid_get_machine_name(pid.pid, &machine);