#include <common/error.h>
#include <common/macros.h>
#include <common/utils.h>
-#include <common/config/config-session-internal.h>
#include <lttng/lttng-error.h>
#include <libxml/parser.h>
#include <libxml/valid.h>
va_start(args, format);
ret = vasprintf(&errMsg, format, args);
+ va_end(args);
if (ret == -1) {
ERR("String allocation failed in xml error handler");
return;
}
- va_end(args);
fprintf(stderr, "XML Error: %s", errMsg);
free(errMsg);
xmlNodePtr consumer_output_node;
assert(name);
- assert(kernel_domain);
- assert(ust_domain);
- assert(jul_domain);
if (output_node) {
consumer_output_node = xmlFirstElementChild(output_node);
goto end;
}
- for (i = 0; i < (sizeof(domains) / sizeof(*domain)); i++) {
+ for (i = 0; i < (sizeof(domains) / sizeof(domains[0])); i++) {
domain = domains[i];
if (!domain) {
continue;
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;
}
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;
}
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;
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;
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);
}
if (!session_found) {
- ret = -LTTNG_ERR_LOAD_SESSION_NOT_FOUND;
+ ret = -LTTNG_ERR_LOAD_SESSION_NOENT;
}
return ret;
goto end;
}
- ret = load_session_from_path(path, NULL,
+ ret = load_session_from_path(path, session_name,
&validation_ctx, 0);
- if (ret && ret != -LTTNG_ERR_LOAD_SESSION_NOENT) {
+ if (!ret || (ret && ret != -LTTNG_ERR_LOAD_SESSION_NOENT)) {
+ /* Session found or an error occured */
free(path);
goto end;
}
}
/* Try system session configuration path */
- ret = load_session_from_path(DEFAULT_SESSION_SYSTEM_CONFIGPATH, NULL,
- &validation_ctx, 0);
- if (ret && ret != -LTTNG_ERR_LOAD_SESSION_NOENT) {
+ ret = load_session_from_path(DEFAULT_SESSION_SYSTEM_CONFIGPATH,
+ session_name, &validation_ctx, 0);
+ if (!ret || (ret && ret != -LTTNG_ERR_LOAD_SESSION_NOENT)) {
+ /* Session found or an error occured */
goto end;
}
} else {