From: Tom Hromatka Date: Wed, 6 Dec 2023 15:07:15 +0000 (+0000) Subject: systemd: add cgroup_is_systemd_enabled() helper X-Git-Tag: v3.2.0~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=903e278f296fa265b209805bbc95b31e2196341c;p=thirdparty%2Flibcgroup.git systemd: add cgroup_is_systemd_enabled() helper Add a helper function cgroup_is_systemd_enabled(), that would return true, when compiled with --enabled-systemd option or false when disabled. Signed-off-by: Tom Hromatka --- diff --git a/include/libcgroup/systemd.h b/include/libcgroup/systemd.h index 671b92a9..e6c863a8 100644 --- a/include/libcgroup/systemd.h +++ b/include/libcgroup/systemd.h @@ -133,6 +133,11 @@ void cgroup_cleanup_systemd_opts(void); int cgroup_write_systemd_default_cgroup(const char * const slice, const char * const scope); +/* + * Return true if systemd support is compiled into the libcgroup library + */ +bool cgroup_is_systemd_enabled(void); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/systemd.c b/src/systemd.c index d12abc76..1a531df4 100644 --- a/src/systemd.c +++ b/src/systemd.c @@ -424,6 +424,11 @@ err: return ret; } + +bool cgroup_is_systemd_enabled(void) +{ + return true; +} #else int cgroup_set_default_scope_opts(struct cgroup_systemd_scope_opts * const opts) { @@ -444,4 +449,9 @@ int cgroup_create_scope2(struct cgroup *cgroup, int ignore_ownership, cgroup_err("Systemd support not compiled\n"); return 1; } + +bool cgroup_is_systemd_enabled(void) +{ + return false; +} #endif