From 49938fb6a42264963829418b06238dd6aa529a32 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Wed, 17 Apr 2019 17:58:04 -0400 Subject: [PATCH] Support LTTNG_KERNEL_SESSION_SET_NAME of lttng-modules Signed-off-by: Jonathan Rajotte --- src/bin/lttng-sessiond/kernel.c | 5 +++++ src/common/kernel-ctl/kernel-ctl.c | 10 ++++++++++ src/common/kernel-ctl/kernel-ctl.h | 1 + src/common/kernel-ctl/kernel-ioctl.h | 2 ++ src/common/lttng-kernel.h | 9 +++++++++ 5 files changed, 27 insertions(+) diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index b4fc995ce..75b76db2e 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -125,6 +125,11 @@ int kernel_create_session(struct ltt_session *session, int tracer_fd) DBG("Kernel session created (fd: %d)", lks->fd); + ret = kernctl_session_set_name(lks->fd, session->name); + if (ret) { + WARN("Could not set kernel session name"); + } + return 0; error: diff --git a/src/common/kernel-ctl/kernel-ctl.c b/src/common/kernel-ctl/kernel-ctl.c index 047d40a34..6a37015ae 100644 --- a/src/common/kernel-ctl/kernel-ctl.c +++ b/src/common/kernel-ctl/kernel-ctl.c @@ -238,6 +238,16 @@ int kernctl_session_regenerate_statedump(int fd) return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_STATEDUMP); } +int kernctl_session_set_name(int fd, const char *name) +{ + struct lttng_kernel_session_name session_name; + + strncpy(session_name.name, name, LTTNG_KERNEL_SESSION_NAME_LEN); + + return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_SET_NAME, + &session_name); +} + 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 841c31da0..884929ac1 100644 --- a/src/common/kernel-ctl/kernel-ctl.h +++ b/src/common/kernel-ctl/kernel-ctl.h @@ -67,6 +67,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); /* Buffer operations */ diff --git a/src/common/kernel-ctl/kernel-ioctl.h b/src/common/kernel-ctl/kernel-ioctl.h index e7ff50b24..ce910e96f 100644 --- a/src/common/kernel-ctl/kernel-ioctl.h +++ b/src/common/kernel-ctl/kernel-ioctl.h @@ -145,6 +145,8 @@ #define LTTNG_KERNEL_SESSION_METADATA_REGEN _IO(0xF6, 0x59) /* 0x5A and 0x5B are reserved for a future ABI-breaking cleanup. */ #define LTTNG_KERNEL_SESSION_STATEDUMP _IO(0xF6, 0x5C) +#define LTTNG_KERNEL_SESSION_SET_NAME \ + _IOR(0xF6, 0x5D, struct lttng_kernel_session_name) /* 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 9d777ee77..66cc99681 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -27,6 +27,7 @@ #define LTTNG_KERNEL_SYM_NAME_LEN 256 #define LTTNG_KERNEL_MAX_UPROBE_NUM 32 +#define LTTNG_KERNEL_SESSION_NAME_LEN 256 /* * LTTng DebugFS ABI structures. @@ -197,4 +198,12 @@ struct lttng_kernel_filter_bytecode { char data[0]; } LTTNG_PACKED; +/* + * kernel session + */ +struct lttng_kernel_session_name { + char name[LTTNG_KERNEL_SESSION_NAME_LEN]; +} LTTNG_PACKED; + + #endif /* _LTTNG_KERNEL_H */ -- 2.34.1