From e04b2181d2d91179ab11f461d481830fd88afaa1 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 5 Sep 2019 18:23:54 -0400 Subject: [PATCH] Support LTTNG_KERNEL_SESSION_SET_CREATION_DATETIME of lttng-modules MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/kernel.c | 6 ++++++ src/common/kernel-ctl/kernel-ctl.c | 18 ++++++++++++++++++ src/common/kernel-ctl/kernel-ctl.h | 1 + src/common/kernel-ctl/kernel-ioctl.h | 2 ++ src/common/lttng-kernel.h | 8 ++++++++ 5 files changed, 35 insertions(+) diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index daf14b339..76162e08c 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -148,6 +148,12 @@ int kernel_create_session(struct ltt_session *session) session->id, session->name); } + ret = kernctl_session_set_creation_time(lks->fd, session->creation_time); + if (ret) { + WARN("Could not set kernel session creation time for session %" PRIu64 " name: %s", + session->id, session->name); + } + return 0; error: diff --git a/src/common/kernel-ctl/kernel-ctl.c b/src/common/kernel-ctl/kernel-ctl.c index c9c52b528..14d96b577 100644 --- a/src/common/kernel-ctl/kernel-ctl.c +++ b/src/common/kernel-ctl/kernel-ctl.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "kernel-ctl.h" #include "kernel-ioctl.h" @@ -255,6 +256,23 @@ end: return ret; } +int kernctl_session_set_creation_time(int fd, time_t time) +{ + int ret; + struct lttng_kernel_session_creation_time creation_time; + + ret = time_to_iso8601_str(time, creation_time.iso8601, + sizeof(creation_time.iso8601)); + if (ret) { + goto end; + } + + ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_SET_CREATION_TIME, + &creation_time); +end: + return ret; +} + int kernctl_create_stream(int fd) { return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_STREAM, diff --git a/src/common/kernel-ctl/kernel-ctl.h b/src/common/kernel-ctl/kernel-ctl.h index 884929ac1..053e7df63 100644 --- a/src/common/kernel-ctl/kernel-ctl.h +++ b/src/common/kernel-ctl/kernel-ctl.h @@ -68,6 +68,7 @@ int kernctl_list_tracker_pids(int fd); int kernctl_session_regenerate_metadata(int fd); int kernctl_session_regenerate_statedump(int fd); int kernctl_session_set_name(int fd, const char *name); +int kernctl_session_set_creation_time(int fd, time_t time); /* Buffer operations */ diff --git a/src/common/kernel-ctl/kernel-ioctl.h b/src/common/kernel-ctl/kernel-ioctl.h index ce910e96f..8d39abbe3 100644 --- a/src/common/kernel-ctl/kernel-ioctl.h +++ b/src/common/kernel-ctl/kernel-ioctl.h @@ -147,6 +147,8 @@ #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) diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h index 001a16e2d..2fd14dc1e 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -28,6 +28,7 @@ #define LTTNG_KERNEL_SYM_NAME_LEN 256 #define LTTNG_KERNEL_MAX_UPROBE_NUM 32 #define LTTNG_KERNEL_SESSION_NAME_LEN 256 +#define LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN 26 /* * LTTng DebugFS ABI structures. @@ -186,4 +187,11 @@ struct lttng_kernel_session_name { char name[LTTNG_KERNEL_SESSION_NAME_LEN]; } LTTNG_PACKED; +/* + * kernel session creation datetime + */ +struct lttng_kernel_session_creation_time { + char iso8601[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN]; +} LTTNG_PACKED; + #endif /* _LTTNG_KERNEL_H */ -- 2.34.1