/* Create session directory .lttng */
ret = mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP);
if (ret < 0) {
- if (errno == EEXIST) {
- ERR("Session already exist at %s", path);
- } else {
+ if (errno != EEXIST) {
perror("mkdir config");
ERR("Couldn't init config directory at %s", path);
+ ret = -errno;
+ goto error;
+ } else {
+ ret = 0;
}
- ret = -errno;
- goto error;
}
error:
/*
* config_get_default_path
*
- * Return the default path to config directory which is the current working
- * directory. User must free() the returned allocated string.
+ * Return the HOME directory path. The output is dup so the user MUST
+ * free(3) the returned string.
*/
char *config_get_default_path(void)
{
- char *alloc_path;
-
- alloc_path = getcwd(NULL, 0);
- if (alloc_path == NULL) {
- perror("getcwd");
- }
-
- return alloc_path;
+ return strdup(getenv("HOME"));
}
/*
perror("remove config file");
}
- ret = rmdir(path);
- if (ret < 0) {
- perror("rmdir config dir");
- }
-
free(config_path);
}