return offset;
}
+static
+int print_escaped_ctf_string(struct lttng_session *session, const char *string)
+{
+ int ret;
+ size_t i;
+ char cur;
+
+ i = 0;
+ cur = string[i];
+ while (cur != '\0') {
+ switch (cur) {
+ case '\n':
+ ret = lttng_metadata_printf(session, "%s", "\\n");
+ break;
+ case '\\':
+ case '"':
+ ret = lttng_metadata_printf(session, "%c", '\\');
+ if (ret)
+ goto error;
+ /* We still print the current char */
+ /* Fallthrough */
+ default:
+ ret = lttng_metadata_printf(session, "%c", cur);
+ break;
+ }
+
+ if (ret)
+ goto error;
+
+ cur = string[++i];
+ }
+error:
+ return ret;
+}
+
+static
+int print_metadata_session_name(struct lttng_session *session)
+{
+ int ret;
+
+ ret = lttng_metadata_printf(session, " trace_name = \"");
+ if (ret)
+ goto error;
+
+ ret = print_escaped_ctf_string(session, session->name);
+ if (ret)
+ goto error;
+
+ ret = lttng_metadata_printf(session, "\";\n");
+
+error:
+ return ret;
+}
+
/*
* Output metadata into this session's metadata buffers.
* Must be called with sessions_mutex held.
" tracer_major = %d;\n"
" tracer_minor = %d;\n"
" tracer_patchlevel = %d;\n"
- "};\n\n",
+ " trace_buffering_scheme = \"global\";\n",
current->nsproxy->uts_ns->name.nodename,
utsname()->sysname,
utsname()->release,
if (ret)
goto end;
+ ret = print_metadata_session_name(session);
+ if (ret)
+ goto end;
+
+ /* Close env */
+ ret = lttng_metadata_printf(session, "};\n\n");
+ if (ret)
+ goto end;
+
ret = lttng_metadata_printf(session,
"clock {\n"
" name = \"%s\";\n",