cgroup-util: add cg_get_attribute_as_bool() helper

This commit is contained in:
Anita Zhang
2020-10-07 17:12:24 -07:00
parent 61ff7397d0
commit b41dcc51eb
2 changed files with 23 additions and 0 deletions
+20
View File
@@ -1685,6 +1685,26 @@ 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) {
_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;
}
int cg_get_keyed_attribute_full(
const char *controller,
const char *path,