config: fix typo in error message
[lttng-tools.git] / src / common / config / session-config.c
index a8ea68eda42fdb92fc0177d02a6c239d6d281bd4..1b7d965fa8db1c3dc4f696a74df8a03a5cf18a18 100644 (file)
@@ -223,6 +223,7 @@ LTTNG_HIDDEN const char * const config_event_context_ipc_ns = "IPC_NS";
 LTTNG_HIDDEN const char * const config_event_context_mnt_ns = "MNT_NS";
 LTTNG_HIDDEN const char * const config_event_context_net_ns = "NET_NS";
 LTTNG_HIDDEN const char * const config_event_context_pid_ns = "PID_NS";
+LTTNG_HIDDEN const char * const config_event_context_time_ns = "TIME_NS";
 LTTNG_HIDDEN const char * const config_event_context_user_ns = "USER_NS";
 LTTNG_HIDDEN const char * const config_event_context_uts_ns = "UTS_NS";
 LTTNG_HIDDEN const char * const config_event_context_uid = "UID";
@@ -711,7 +712,7 @@ void fini_session_config_validation_ctx(
 }
 
 static
-char *get_session_config_xsd_path()
+char *get_session_config_xsd_path(void)
 {
        char *xsd_path;
        const char *base_path = lttng_secure_getenv(DEFAULT_SESSION_CONFIG_XSD_PATH_ENV);
@@ -847,7 +848,7 @@ int parse_bool(xmlChar *str, int *val)
        } else if (!strcmp((const char *) str, config_xml_false)) {
                *val = 0;
        } else {
-               WARN("Invalid boolean value encoutered (%s).",
+               WARN("Invalid boolean value encountered (%s).",
                        (const char *) str);
                ret = -1;
        }
@@ -1094,6 +1095,9 @@ int get_context_type(xmlChar *context_type)
        } else if (!strcmp((char *) context_type,
                config_event_context_pid_ns)) {
                ret = LTTNG_EVENT_CONTEXT_PID_NS;
+       } else if (!strcmp((char *) context_type,
+               config_event_context_time_ns)) {
+               ret = LTTNG_EVENT_CONTEXT_TIME_NS;
        } else if (!strcmp((char *) context_type,
                config_event_context_user_ns)) {
                ret = LTTNG_EVENT_CONTEXT_USER_NS;
@@ -3767,10 +3771,24 @@ int load_session_from_file(const char *path, const char *session_name,
                        xmlNextElementSibling(session_node)) {
                ret = process_session_node(session_node,
                        session_name, overwrite, overrides);
-               if (session_name && ret == 0) {
-                       /* Target session found and loaded */
-                       session_found = 1;
-                       break;
+               if (!session_name && ret) {
+                       /* Loading error occurred. */
+                       goto end;
+               } else if (session_name) {
+                       if (ret == 0) {
+                               /* Target session found and loaded */
+                               session_found = 1;
+                               break;
+                       } else if (ret == -LTTNG_ERR_NO_SESSION) {
+                               /*
+                                * Ignore this error, we are looking for a
+                                * specific session.
+                                */
+                               ret = 0;
+                       } else {
+                               /* Loading error occurred. */
+                               goto end;
+                       }
                }
        }
 end:
@@ -3778,9 +3796,6 @@ end:
        if (!ret) {
                ret = session_found ? 0 : -LTTNG_ERR_LOAD_SESSION_NOENT;
        }
-       if (ret == -LTTNG_ERR_NO_SESSION) {
-               ret = -LTTNG_ERR_LOAD_SESSION_NOENT;
-       }
        return ret;
 }
 
@@ -4002,16 +4017,17 @@ int config_load_session(const char *path, const char *session_name,
                /* Try home path */
                home_path = utils_get_home_dir();
                if (home_path) {
-                       char path[PATH_MAX];
+                       char path_buf[PATH_MAX];
 
                        /*
                         * Try user session configuration path. Ignore error here so we can
                         * continue loading the system wide sessions.
                         */
                        if (autoload) {
-                               ret = snprintf(path, sizeof(path),
-                                               DEFAULT_SESSION_HOME_CONFIGPATH "/"
-                                               DEFAULT_SESSION_CONFIG_AUTOLOAD, home_path);
+                               ret = snprintf(path_buf, sizeof(path_buf),
+                                               DEFAULT_SESSION_HOME_CONFIGPATH
+                                               "/" DEFAULT_SESSION_CONFIG_AUTOLOAD,
+                                               home_path);
                                if (ret < 0) {
                                        PERROR("snprintf session autoload home config path");
                                        ret = -LTTNG_ERR_INVALID;
@@ -4023,19 +4039,20 @@ int config_load_session(const char *path, const char *session_name,
                                 * avoid any user session daemon to try to load kernel sessions
                                 * automatically and failing all the times.
                                 */
-                               ret = validate_path_creds(path);
+                               ret = validate_path_creds(path_buf);
                                if (ret) {
-                                       path_ptr = path;
+                                       path_ptr = path_buf;
                                }
                        } else {
-                               ret = snprintf(path, sizeof(path),
-                                               DEFAULT_SESSION_HOME_CONFIGPATH, home_path);
+                               ret = snprintf(path_buf, sizeof(path_buf),
+                                               DEFAULT_SESSION_HOME_CONFIGPATH,
+                                               home_path);
                                if (ret < 0) {
                                        PERROR("snprintf session home config path");
                                        ret = -LTTNG_ERR_INVALID;
                                        goto end;
                                }
-                               path_ptr = path;
+                               path_ptr = path_buf;
                        }
                        if (path_ptr) {
                                ret = load_session_from_path(path_ptr, session_name,
This page took 0.024974 seconds and 4 git commands to generate.