lttng-context-prio.o lttng-context-nice.o \
lttng-context-vpid.o lttng-context-tid.o \
lttng-context-vtid.o lttng-context-ppid.o \
- lttng-context-vppid.o lttng-calibrate.o
+ lttng-context-vppid.o lttng-calibrate.o \
+ wrapper/random.o
ifneq ($(CONFIG_HAVE_SYSCALL_TRACEPOINTS),)
lttng-tracer-objs += lttng-syscalls.o
#include <linux/jiffies.h>
#include "wrapper/uuid.h"
#include "wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */
+#include "wrapper/random.h"
#include "lttng-events.h"
#include "lttng-tracer.h"
int _lttng_session_metadata_statedump(struct lttng_session *session)
{
unsigned char *uuid_c = session->uuid.b;
- unsigned char uuid_s[37];
+ unsigned char uuid_s[37], clock_uuid_s[BOOT_ID_LEN];
struct lttng_channel *chan;
struct lttng_event *event;
int ret = 0;
ret = lttng_metadata_printf(session,
"clock {\n"
- " name = %s;\n"
- " uuid = %s;\n"
+ " name = %s;\n",
+ "monotonic"
+ );
+ if (ret)
+ goto end;
+
+ if (!trace_clock_uuid(clock_uuid_s)) {
+ ret = lttng_metadata_printf(session,
+ " uuid = %s;\n",
+ clock_uuid_s
+ );
+ if (ret)
+ goto end;
+ }
+
+ ret = lttng_metadata_printf(session,
" description = \"Monotonic Clock\";\n"
" freq = %llu; /* Frequency, in Hz */\n"
" /* clock value offset from Epoch is: offset * (1/freq) */\n"
" offset = %llu;\n"
"};\n\n",
- "monotonic",
- trace_clock_uuid(),
(unsigned long long) trace_clock_freq(),
(unsigned long long) measure_clock_offset()
);
--- /dev/null
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers@efficios.com)
+ *
+ * wrapper around bootid read. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+/* boot_id depends on sysctl */
+#if defined(CONFIG_SYSCTL)
+
+#include <linux/fs.h>
+#include <linux/file.h>
+#include <linux/sched.h>
+#include <linux/uaccess.h>
+#include "random.h"
+
+/*
+ * Returns string boot id.
+ */
+int wrapper_get_bootid(char *bootid)
+{
+ struct file *file;
+ int ret;
+ ssize_t len;
+ mm_segment_t old_fs;
+
+ file = filp_open("/proc/sys/kernel/random/boot_id", O_RDONLY, 0);
+ if (IS_ERR(file))
+ return PTR_ERR(file);
+
+ old_fs = get_fs();
+ set_fs(KERNEL_DS);
+
+ if (!file->f_op || !file->f_op->read) {
+ ret = -EINVAL;
+ goto end;
+ }
+
+ len = file->f_op->read(file, bootid, BOOT_ID_LEN - 1, &file->f_pos);
+ if (len != BOOT_ID_LEN - 1) {
+ ret = -EINVAL;
+ goto end;
+ }
+
+ bootid[BOOT_ID_LEN - 1] = '\0';
+ ret = 0;
+end:
+ set_fs(old_fs);
+ filp_close(file, current->files);
+ return ret;
+}
+
+#else
+
+int wrapper_get_bootid(char *bootid)
+{
+ return -ENOSYS;
+}
+
+#endif
--- /dev/null
+#ifndef _LTTNG_WRAPPER_RANDOM_H
+#define _LTTNG_WRAPPER_RANDOM_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers@efficios.com)
+ *
+ * wrapper around bootid read. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#define BOOT_ID_LEN 37
+
+int wrapper_get_bootid(char *bootid);
+
+#endif /* _LTTNG_WRAPPER_RANDOM_H */
#include <linux/ktime.h>
#include <linux/time.h>
#include <linux/hrtimer.h>
+#include "random.h"
static inline u64 trace_clock_monotonic_wrapper(void)
{
return (u64) NSEC_PER_SEC;
}
-static inline const char *trace_clock_uuid(void)
+static inline int trace_clock_uuid(char *uuid)
{
- return "CLOCK_MONOTONIC";
+ return wrapper_get_bootid(uuid);
}
static inline int get_trace_clock(void)