From: Mathieu Desnoyers Date: Mon, 20 Oct 2014 22:46:44 +0000 (-0400) Subject: Expose lttng-modules ABI version ioctl X-Git-Tag: v2.6.0-rc1~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=42cabb802371ac5f22232eb494c0fdbcebd4a693;p=lttng-modules.git Expose lttng-modules ABI version ioctl Check compatibility between lttng-modules and tools using a version numbering specifically for the ABI, rather than relying on the major version of lttng-modules per se. This takes into account that we sometimes depend on lock-step updates of the toolchain, including tools and modules. Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-abi.c b/lttng-abi.c index 8073e988..b83ed3d2 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -188,6 +188,13 @@ void lttng_abi_tracer_version(struct lttng_kernel_tracer_version *v) v->patchlevel = LTTNG_MODULES_PATCHLEVEL_VERSION; } +static +void lttng_abi_tracer_abi_version(struct lttng_kernel_tracer_abi_version *v) +{ + v->major = LTTNG_MODULES_ABI_MAJOR_VERSION; + v->minor = LTTNG_MODULES_ABI_MINOR_VERSION; +} + static long lttng_abi_add_context(struct file *file, struct lttng_kernel_context *context_param, @@ -245,6 +252,8 @@ long lttng_abi_add_context(struct file *file, * Returns a file descriptor listing available tracepoints * LTTNG_KERNEL_WAIT_QUIESCENT * Returns after all previously running probes have completed + * LTTNG_KERNEL_TRACER_ABI_VERSION + * Returns the LTTng kernel tracer ABI version * * The returned session will be deleted when its file descriptor is closed. */ @@ -278,7 +287,19 @@ long lttng_ioctl(struct file *file, unsigned int cmd, unsigned long arg) (struct lttng_kernel_tracer_version __user *) arg; lttng_abi_tracer_version(&version); - + + if (copy_to_user(uversion, &version, sizeof(version))) + return -EFAULT; + return 0; + } + case LTTNG_KERNEL_TRACER_ABI_VERSION: + { + struct lttng_kernel_tracer_abi_version version; + struct lttng_kernel_tracer_abi_version *uversion = + (struct lttng_kernel_tracer_abi_version __user *) arg; + + lttng_abi_tracer_abi_version(&version); + if (copy_to_user(uversion, &version, sizeof(version))) return -EFAULT; return 0; diff --git a/lttng-abi.h b/lttng-abi.h index 8f5c0935..b63ead8d 100644 --- a/lttng-abi.h +++ b/lttng-abi.h @@ -25,6 +25,13 @@ #include +/* + * Major/minor version of ABI exposed to lttng tools. Major number + * should be increased when an incompatible ABI change is done. + */ +#define LTTNG_MODULES_ABI_MAJOR_VERSION 1 +#define LTTNG_MODULES_ABI_MINOR_VERSION 0 + #define LTTNG_KERNEL_SYM_NAME_LEN 256 enum lttng_kernel_instrumentation { @@ -109,6 +116,11 @@ struct lttng_kernel_tracer_version { uint32_t patchlevel; } __attribute__((packed)); +struct lttng_kernel_tracer_abi_version { + uint32_t major; + uint32_t minor; +} __attribute__((packed)); + enum lttng_kernel_calibrate_type { LTTNG_KERNEL_CALIBRATE_KRETPROBE, }; @@ -163,6 +175,8 @@ struct lttng_kernel_context { #define LTTNG_KERNEL_CALIBRATE \ _IOWR(0xF6, 0x49, struct lttng_kernel_calibrate) #define LTTNG_KERNEL_SYSCALL_LIST _IO(0xF6, 0x4A) +#define LTTNG_KERNEL_TRACER_ABI_VERSION \ + _IOR(0xF6, 0x4B, struct lttng_kernel_tracer_abi_version) /* Session FD ioctl */ #define LTTNG_KERNEL_METADATA \