Expose lttng-modules ABI version ioctl
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 20 Oct 2014 22:46:44 +0000 (18:46 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 20 Oct 2014 22:46:44 +0000 (18:46 -0400)
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 <mathieu.desnoyers@efficios.com>
lttng-abi.c
lttng-abi.h

index 8073e9880ff109b1efdc27dd835b82b19b8f3c47..b83ed3d211defb747447469fc40bba06d816242b 100644 (file)
@@ -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;
index 8f5c0935cb4037046ca1e1d65ef093396b976761..b63ead8d134c636838bf38baa9b3e2dcdf62879f 100644 (file)
 
 #include <linux/fs.h>
 
+/*
+ * 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                  \
This page took 0.027143 seconds and 4 git commands to generate.