From b88cafd198e23bab1c41013fbfa4e87b13d7e72f Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Mon, 8 Feb 2021 15:48:54 -0700 Subject: [PATCH] api: Expose cg_build_path_locked() to users of libcgroup.la Remove the static qualifier from cg_build_path_locked(). As part of the cgget refactor, cgget will utilize this function. Signed-off-by: Tom Hromatka --- src/api.c | 4 ++-- src/libcgroup-internal.h | 14 ++++++++++++++ src/libcgroup.map | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/api.c b/src/api.c index 51f9075f..ac500861 100644 --- a/src/api.c +++ b/src/api.c @@ -1460,8 +1460,8 @@ static char *cg_concat_path(const char *pref, const char *suf, char *path) /* Call with cg_mount_table_lock taken */ /* path value have to have size at least FILENAME_MAX */ -static char *cg_build_path_locked(const char *name, char *path, - const char *type) +char *cg_build_path_locked(const char *name, char *path, + const char *type) { int i; for (i = 0; cg_mount_table[i].name[0] != '\0'; i++) { diff --git a/src/libcgroup-internal.h b/src/libcgroup-internal.h index 800227c0..c152b687 100644 --- a/src/libcgroup-internal.h +++ b/src/libcgroup-internal.h @@ -321,6 +321,20 @@ int cgroup_build_tasks_procs_path(char * const path, size_t path_sz, const char * const cg_name, const char * const ctrl_name); +/** + * Build the full path to the controller/setting + * + * @param setting Cgroup virtual filename/setting (optional) + * @param path Output variable to contain the concatenated path + * @param controller Cgroup controller name + * + * @return If successful, a valid pointer to the concatenated path + * + * @note The cg_mount_table_lock must be held prior to calling this function + */ +char *cg_build_path_locked(const char *setting, char *path, + const char *controller); + /** * Functions that are defined as STATIC can be placed within the UNIT_TEST * ifdef. This will allow them to be included in the unit tests while diff --git a/src/libcgroup.map b/src/libcgroup.map index 8b7fd6ad..fbb4530a 100644 --- a/src/libcgroup.map +++ b/src/libcgroup.map @@ -132,4 +132,5 @@ CGROUP_0.42 { CGROUP_0.43 { cgroup_build_tasks_procs_path; + cg_build_path_locked; } CGROUP_0.42; -- 2.47.2