_public_ int sd_bus_creds_get_slice(sd_bus_creds *c, const char **ret) { int r; assert_return(c, -EINVAL); assert_return(ret, -EINVAL); if (!(c->mask & SD_BUS_CREDS_SLICE)) return -ENODATA; assert(c->cgroup); if (!c->slice) { const char *shifted; r = cg_shift_path(c->cgroup, c->cgroup_root, &shifted); if (r < 0) return r; r = cg_path_get_slice(shifted, (char**) &c->slice); if (r < 0) return r; } *ret = c->slice; return 0; }
static void check_p_g_slice(const char *path, int code, const char *result) { _cleanup_free_ char *s = NULL; assert_se(cg_path_get_slice(path, &s) == code); assert_se(streq_ptr(s, result)); }