X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=b640b950e7e3d88ac95a966d60e76acaa1a88121;hb=70190e1c2ba092cd35a9e0b53c0ce8a6bf260d50;hp=815965bc4ba25256de830f0794cf357f2150db70;hpb=5983a922b5e591a0fd90800e482e1ab8b89a4281;p=lttng-tools.git diff --git a/src/common/utils.c b/src/common/utils.c index 815965bc4..b640b950e 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -822,11 +822,28 @@ LTTNG_HIDDEN char *utils_get_home_dir(void) { char *val = NULL; + struct passwd *pwd; + val = getenv(DEFAULT_LTTNG_HOME_ENV_VAR); if (val != NULL) { - return val; + goto end; + } + val = getenv(DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR); + if (val != NULL) { + goto end; } - return getenv(DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR); + + /* Fallback on the password file entry. */ + pwd = getpwuid(getuid()); + if (!pwd) { + goto end; + } + val = pwd->pw_dir; + + DBG3("Home directory is '%s'", val); + +end: + return val; } /** @@ -869,6 +886,16 @@ end: return home_dir; } +/* + * Obtain the value of LTTNG_KMOD_PROBES environment variable, if exists. + * Otherwise returns an empty string. + */ +LTTNG_HIDDEN +char *utils_get_kmod_probes_list(void) +{ + return getenv(DEFAULT_LTTNG_KMOD_PROBES); +} + /* * With the given format, fill dst with the time of len maximum siz. * @@ -889,7 +916,7 @@ size_t utils_get_current_time_str(const char *format, char *dst, size_t len) timeinfo = localtime(&rawtime); ret = strftime(dst, len, format, timeinfo); if (ret == 0) { - ERR("Unable to strftime with format %s at dst %p of len %lu", format, + ERR("Unable to strftime with format %s at dst %p of len %zu", format, dst, len); }