cgroup-util: minor cleanups (#37630)

This commit is contained in:
Yu Watanabe
2025-05-28 02:19:21 +09:00
committed by GitHub
7 changed files with 17 additions and 24 deletions
+7 -10
View File
@@ -592,7 +592,7 @@ int cg_set_xattr(const char *path, const char *name, const void *value, size_t s
return RET_NERRNO(setxattr(fs, name, value, size, flags));
}
int cg_get_xattr_malloc(const char *path, const char *name, char **ret, size_t *ret_size) {
int cg_get_xattr(const char *path, const char *name, char **ret, size_t *ret_size) {
_cleanup_free_ char *fs = NULL;
int r;
@@ -1594,6 +1594,8 @@ int cg_set_attribute(const char *controller, const char *path, const char *attri
_cleanup_free_ char *p = NULL;
int r;
assert(attribute);
r = cg_get_path(controller, path, attribute, &p);
if (r < 0)
return r;
@@ -1605,6 +1607,8 @@ int cg_get_attribute(const char *controller, const char *path, const char *attri
_cleanup_free_ char *p = NULL;
int r;
assert(attribute);
r = cg_get_path(controller, path, attribute, &p);
if (r < 0)
return r;
@@ -1638,24 +1642,17 @@ int cg_get_attribute_as_uint64(const char *controller, const char *path, const c
return 0;
}
int cg_get_attribute_as_bool(const char *controller, const char *path, const char *attribute, bool *ret) {
int cg_get_attribute_as_bool(const char *controller, const char *path, const char *attribute) {
_cleanup_free_ char *value = NULL;
int r;
assert(ret);
r = cg_get_attribute(controller, path, attribute, &value);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
return r;
r = parse_boolean(value);
if (r < 0)
return r;
*ret = r;
return 0;
return parse_boolean(value);
}
int cg_get_owner(const char *path, uid_t *ret_uid) {
+2 -4
View File
@@ -219,14 +219,12 @@ int cg_get_attribute(const char *controller, const char *path, const char *attri
int cg_get_keyed_attribute(const char *controller, const char *path, const char *attribute, char * const *keys, char **values);
int cg_get_attribute_as_uint64(const char *controller, const char *path, const char *attribute, uint64_t *ret);
/* Does a parse_boolean() on the attribute contents and sets ret accordingly */
int cg_get_attribute_as_bool(const char *controller, const char *path, const char *attribute, bool *ret);
int cg_get_attribute_as_bool(const char *controller, const char *path, const char *attribute);
int cg_get_owner(const char *path, uid_t *ret_uid);
int cg_set_xattr(const char *path, const char *name, const void *value, size_t size, int flags);
int cg_get_xattr_malloc(const char *path, const char *name, char **ret, size_t *ret_size);
int cg_get_xattr(const char *path, const char *name, char **ret, size_t *ret_size);
/* Returns negative on error, and 0 or 1 on success for the bool value */
int cg_get_xattr_bool(const char *path, const char *name);
int cg_remove_xattr(const char *path, const char *name);