X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=f253e797fae641e31ef98abcf4e829655feb8dfc;hp=3e659a1c81079d74b52aab9993c555fcaba6b62d;hb=feb0f3e5900ff58202ea0c3f227de3c1b8291952;hpb=0c7bcad5eaa11b368460759fc87f949e8c56b98f diff --git a/src/common/utils.c b/src/common/utils.c index 3e659a1c8..f253e797f 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -32,6 +32,7 @@ #include #include "utils.h" +#include "defaults.h" /* * Return the realpath(3) of the path even if the last directory token does not @@ -580,3 +581,17 @@ int utils_get_count_order_u32(uint32_t x) return fls_u32(x - 1); } + +/** + * Obtain the value of LTTNG_HOME environment variable, if exists. + * Otherwise returns the value of HOME. + */ +char *utils_get_home_dir(void) +{ + char *val = NULL; + val = getenv(DEFAULT_LTTNG_HOME_ENV_VAR); + if (val != NULL) { + return val; + } + return getenv(DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR); +}