#include <linux/jhash.h>
#include <linux/uaccess.h>
#include <linux/vmalloc.h>
+#include <linux/uuid.h>
+#include <linux/dmi.h>
-#include <wrapper/uuid.h>
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
#include <wrapper/random.h>
#include <wrapper/tracepoint.h>
void synchronize_trace(void)
{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,1,0))
+ synchronize_rcu();
+#else
synchronize_sched();
+#endif
+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
#ifdef CONFIG_PREEMPT_RT_FULL
synchronize_rcu();
ret = PTR_ERR(tracker_pids_list_file);
goto file_error;
}
- if (atomic_long_add_unless(&session->file->f_count,
- 1, INT_MAX) == INT_MAX) {
+ if (!atomic_long_add_unless(&session->file->f_count, 1, LONG_MAX)) {
+ ret = -EOVERFLOW;
goto refcount_error;
}
ret = lttng_tracker_pids_list_fops.open(NULL, tracker_pids_list_file);
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_escaped_field(struct lttng_session *session, const char *field,
+ const char *field_value)
+{
+ int ret;
+
+ ret = lttng_metadata_printf(session, " %s = \"", field);
+ if (ret)
+ goto error;
+
+ ret = print_escaped_ctf_string(session, field_value);
+ 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.
{
unsigned char *uuid_c = session->uuid.b;
unsigned char uuid_s[37], clock_uuid_s[BOOT_ID_LEN];
+ const char *product_uuid;
struct lttng_channel *chan;
struct lttng_event *event;
int ret = 0;
" 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_escaped_field(session, "trace_name", session->name);
+ if (ret)
+ goto end;
+ ret = print_metadata_escaped_field(session, "trace_creation_datetime",
+ session->creation_time);
+ if (ret)
+ goto end;
+
+ /* Add the product UUID to the 'env' section */
+ product_uuid = dmi_get_system_info(DMI_PRODUCT_UUID);
+ if (product_uuid) {
+ ret = lttng_metadata_printf(session,
+ " product_uuid = \"%s\";\n",
+ product_uuid
+ );
+ if (ret)
+ goto end;
+ }
+
+ /* Close the 'env' section */
+ ret = lttng_metadata_printf(session, "};\n\n");
+ if (ret)
+ goto end;
+
ret = lttng_metadata_printf(session,
"clock {\n"
" name = \"%s\";\n",