#include <ftw.h>
#include "cgroup-util.h"
-#include "log.h"
#include "set.h"
#include "macro.h"
#include "util.h"
#include "path-util.h"
-#include "strv.h"
#include "unit-name.h"
#include "fileio.h"
#include "special.h"
return 0;
/* Check if this controller actually really exists */
- cc = strappenda("/sys/fs/cgroup/", p);
+ cc = strjoina("/sys/fs/cgroup/", p);
if (laccess(cc, F_OK) < 0)
return -errno;
/* Skip slices, if there are any */
e = skip_slices(path);
- /* Skip the session scope... */
+ /* Skip the session scope or user manager... */
t = skip_session(e);
- if (t)
- /* ... and skip more slices if there's one */
- e = skip_slices(t);
- else {
- /* ... or require a user manager unit to be there */
- e = skip_user_manager(e);
- if (!e)
- return -ENOENT;
- }
+ if (!t)
+ t = skip_user_manager(e);
+ if (!t)
+ return -ENOENT;
+
+ /* ... and skip more slices if there are any */
+ e = skip_slices(t);
return cg_path_decode_unit(e, unit);
}
return write_string_file_no_create(p, value);
}
+int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret) {
+ _cleanup_free_ char *p = NULL;
+ int r;
+
+ r = cg_get_path(controller, path, attribute, &p);
+ if (r < 0)
+ return r;
+
+ return read_one_line_file(p, ret);
+}
+
static const char mask_names[] =
"cpu\0"
"cpuacct\0"