Contexts for RT debugging
[lttng-tools.git] / src / bin / lttng-sessiond / kernel.c
index 381b83e6366c120128d9e6a639a081a24c54b684..7bc713a35be7935250a0f96a63c480419c840706 100644 (file)
@@ -15,7 +15,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
 #define _LGPL_SOURCE
 #include <errno.h>
 #include <fcntl.h>
@@ -50,17 +49,24 @@ int kernel_add_channel_context(struct ltt_kernel_channel *chan,
        DBG("Adding context to channel %s", chan->channel->name);
        ret = kernctl_add_context(chan->fd, &ctx->ctx);
        if (ret < 0) {
-               if (errno != EEXIST) {
-                       PERROR("add context ioctl");
-               } else {
+               switch (errno) {
+               case ENOSYS:
+                       /* Exists but not available for this kernel */
+                       ret = LTTNG_ERR_KERN_CONTEXT_UNAVAILABLE;
+                       goto error;
+               case EEXIST:
                        /* If EEXIST, we just ignore the error */
                        ret = 0;
+                       goto end;
+               default:
+                       PERROR("add context ioctl");
+                       ret = LTTNG_ERR_KERN_CONTEXT_FAIL;
+                       goto error;
                }
-               goto error;
        }
 
+end:
        cds_list_add_tail(&ctx->list, &chan->ctx_list);
-
        return 0;
 
 error:
This page took 0.022852 seconds and 4 git commands to generate.