X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fconf.c;h=50af2289d11f0d83fd636cb136e504b3887c9be3;hp=6f290b7e5f1df78b34f4d88cf87d500a1c72b1fa;hb=d6a07e7da56c327a0c22c9113a0a9fa7bf8197c6;hpb=6775595e33fcf411716849374390e5f8179c8735 diff --git a/src/bin/lttng/conf.c b/src/bin/lttng/conf.c index 6f290b7e5..50af2289d 100644 --- a/src/bin/lttng/conf.c +++ b/src/bin/lttng/conf.c @@ -154,14 +154,51 @@ void config_destroy(char *path) return; } + if (!config_exists(config_path)) { + goto end; + } + + DBG("Removing %s\n", config_path); ret = remove(config_path); if (ret < 0) { perror("remove config file"); } - +end: free(config_path); } +/* + * config_destroy_default + * + * Destroys the default config + */ + +void config_destroy_default(void) +{ + char *path = config_get_default_path(); + if (path == NULL) { + return; + } + config_destroy(path); +} + +/* + * config_exists + * + * Returns 1 if config exists, 0 otherwise + */ +int config_exists(const char *path) +{ + int ret; + struct stat info; + + ret = stat(path, &info); + if (ret < 0) { + return 0; + } + return S_ISREG(info.st_mode) || S_ISDIR(info.st_mode); +} + /* * config_read_session_name *