X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fconfig%2Fconfig.c;h=a890c9d872e1778875811c598cd448451a5ff793;hb=54a9842323bdcf75da5f0e31a433191af7f687fd;hp=c952e8ba29180b4164638802b486c22244b0dd95;hpb=6c043b48abd501f7df3e63662fe227e71e00c812;p=lttng-tools.git diff --git a/src/common/config/config.c b/src/common/config/config.c index c952e8ba2..a890c9d87 100644 --- a/src/common/config/config.c +++ b/src/common/config/config.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -2176,7 +2175,7 @@ int process_session_node(xmlNodePtr session_node, const char *session_name, if (session_name && strcmp(name, session_name)) { /* This is not the session we are looking for */ - ret = -LTTNG_ERR_LOAD_SESSION_NOT_FOUND; + ret = -LTTNG_ERR_LOAD_SESSION_NOENT; goto end; } @@ -2328,7 +2327,7 @@ int load_session_from_file(const char *path, const char *session_name, end: xmlFreeDoc(doc); if (!ret) { - ret = session_found ? 0 : -LTTNG_ERR_LOAD_SESSION_NOT_FOUND; + ret = session_found ? 0 : -LTTNG_ERR_LOAD_SESSION_NOENT; } return ret; } @@ -2338,18 +2337,19 @@ int load_session_from_path(const char *path, const char *session_name, struct session_config_validation_ctx *validation_ctx, int override) { int ret, session_found = !session_name; - struct stat sb; DIR *directory = NULL; assert(path); assert(validation_ctx); - ret = stat(path, &sb); - if (ret) { - ret = -LTTNG_ERR_LOAD_SESSION_NOENT; - goto end; + directory = opendir(path); + if (!directory) { + if (errno != ENOTDIR) { + ret = -LTTNG_ERR_LOAD_IO_FAIL; + goto end; + } } - if (S_ISDIR(sb.st_mode)) { + if (directory) { struct dirent *entry; struct dirent *result; char *file_path = NULL; @@ -2366,13 +2366,6 @@ int load_session_from_path(const char *path, const char *session_name, goto end; } - directory = opendir(path); - if (!directory) { - ret = -LTTNG_ERR_LOAD_IO_FAIL; - free(entry); - goto end; - } - file_path = zmalloc(PATH_MAX); if (!file_path) { ret = -LTTNG_ERR_NOMEM; @@ -2385,6 +2378,7 @@ int load_session_from_path(const char *path, const char *session_name, file_path[path_len++] = '/'; } + ret = 0; /* Search for *.lttng files */ while (!readdir_r(directory, entry, &result) && result) { size_t file_name_len = strlen(result->d_name); @@ -2435,7 +2429,7 @@ end: } if (!session_found) { - ret = -LTTNG_ERR_LOAD_SESSION_NOT_FOUND; + ret = -LTTNG_ERR_LOAD_SESSION_NOENT; } return ret;