mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-27 10:25:06 +03:00
cgroup-util: cg_get_xattr_malloc helper
`cg_get_xattr_malloc` to read a cgroup xattr value and allocate space to hold said value (simple helper combining existing functions).
This commit is contained in:
parent
613328c3e2
commit
baa358df32
@ -37,6 +37,7 @@
|
||||
#include "strv.h"
|
||||
#include "unit-name.h"
|
||||
#include "user-util.h"
|
||||
#include "xattr-util.h"
|
||||
|
||||
static int cg_enumerate_items(const char *controller, const char *path, FILE **_f, const char *item) {
|
||||
_cleanup_free_ char *fs = NULL;
|
||||
@ -605,6 +606,24 @@ int cg_get_xattr(const char *controller, const char *path, const char *name, voi
|
||||
return (int) n;
|
||||
}
|
||||
|
||||
int cg_get_xattr_malloc(const char *controller, const char *path, const char *name, char **ret) {
|
||||
_cleanup_free_ char *fs = NULL;
|
||||
int r;
|
||||
|
||||
assert(path);
|
||||
assert(name);
|
||||
|
||||
r = cg_get_path(controller, path, NULL, &fs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = getxattr_malloc(fs, name, ret, false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int cg_remove_xattr(const char *controller, const char *path, const char *name) {
|
||||
_cleanup_free_ char *fs = NULL;
|
||||
int r;
|
||||
|
@ -190,6 +190,7 @@ int cg_set_access(const char *controller, const char *path, uid_t uid, gid_t gid
|
||||
|
||||
int cg_set_xattr(const char *controller, const char *path, const char *name, const void *value, size_t size, int flags);
|
||||
int cg_get_xattr(const char *controller, const char *path, const char *name, void *value, size_t size);
|
||||
int cg_get_xattr_malloc(const char *controller, const char *path, const char *name, char **ret);
|
||||
int cg_remove_xattr(const char *controller, const char *path, const char *name);
|
||||
|
||||
int cg_install_release_agent(const char *controller, const char *agent);
|
||||
|
Loading…
Reference in New Issue
Block a user