+}
+
+/*
+ * set_opt_session_info
+ *
+ * Setup session_name, current_uuid, short_str_uuid and
+ * long_str_uuid using the command line options.
+ */
+static void set_opt_session_info(void)
+{
+ if (opt_session_name != NULL) {
+ session_name = strndup(opt_session_name, NAME_MAX);
+ DBG("Session name set to %s", session_name);
+ }
+}
+
+/*
+ * set_session_uuid
+ *
+ * Set current session uuid to the current flow of command(s) using the
+ * session_name.
+ */
+static int set_session_uuid(void)
+{
+ int ret, count, i, found = 0;
+ struct lttng_session *sessions;
+
+ if (!uuid_is_null(current_uuid)) {
+ lttng_set_current_session_uuid(¤t_uuid);
+ goto end;
+ }
+
+ count = lttng_list_sessions(&sessions);
+ if (count < 0) {
+ ret = count;
+ goto error;
+ }
+
+ for (i = 0; i < count; i++) {
+ if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) {
+ lttng_set_current_session_uuid(&sessions[i].uuid);
+ uuid_copy(current_uuid, sessions[i].uuid);
+ found = 1;
+ break;
+ }
+ }
+
+ free(sessions);
+
+ if (!found) {
+ return -1;
+ }