return 0;
}
+static
+int lttng_abi_session_set_creation_time(struct lttng_session *session,
+ struct lttng_kernel_session_creation_time *time)
+{
+ size_t len;
+
+ len = strnlen(time->iso8601, LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN);
+
+ if (len == LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN) {
+ /* Time is too long/malformed */
+ return -EINVAL;
+ }
+
+ strcpy(session->creation_time, time->iso8601);
+ return 0;
+}
+
/**
* lttng_session_ioctl - lttng session fd ioctl
*
return -EFAULT;
return lttng_abi_session_set_name(session, &name);
}
+ case LTTNG_KERNEL_SESSION_SET_CREATION_TIME:
+ {
+ struct lttng_kernel_session_creation_time time;
+
+ if (copy_from_user(&time,
+ (struct lttng_kernel_session_creation_time __user *) arg,
+ sizeof(struct lttng_kernel_session_creation_time)))
+ return -EFAULT;
+ return lttng_abi_session_set_creation_time(session, &time);
+ }
default:
return -ENOIOCTLCMD;
}
#define LTTNG_KERNEL_SYM_NAME_LEN 256
#define LTTNG_KERNEL_SESSION_NAME_LEN 256
+#define LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN 26
enum lttng_kernel_instrumentation {
LTTNG_KERNEL_TRACEPOINT = 0,
char name[LTTNG_KERNEL_SESSION_NAME_LEN];
} __attribute__((packed));
+struct lttng_kernel_session_creation_time {
+ char iso8601[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN];
+} __attribute__((packed));
+
enum lttng_kernel_calibrate_type {
LTTNG_KERNEL_CALIBRATE_KRETPROBE,
};
#define LTTNG_KERNEL_SESSION_STATEDUMP _IO(0xF6, 0x5C)
#define LTTNG_KERNEL_SESSION_SET_NAME \
_IOR(0xF6, 0x5D, struct lttng_kernel_session_name)
+#define LTTNG_KERNEL_SESSION_SET_CREATION_TIME \
+ _IOR(0xF6, 0x5E, struct lttng_kernel_session_creation_time)
/* Channel FD ioctl */
#define LTTNG_KERNEL_STREAM _IO(0xF6, 0x62)
}
static
-int print_metadata_session_name(struct lttng_session *session)
+int print_metadata_escaped_field(struct lttng_session *session, const char *field,
+ const char *field_value)
{
int ret;
- ret = lttng_metadata_printf(session, " trace_name = \"");
+ ret = lttng_metadata_printf(session, " %s = \"", field);
if (ret)
goto error;
- ret = print_escaped_ctf_string(session, session->name);
+ ret = print_escaped_ctf_string(session, field_value);
if (ret)
goto error;
if (ret)
goto end;
- ret = print_metadata_session_name(session);
+ 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;
/* Hash table of events */
struct lttng_event_ht events_ht;
char name[LTTNG_KERNEL_SESSION_NAME_LEN];
+ char creation_time[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN];
};
struct lttng_metadata_cache {