Fix: missing #include for 3.8 kernel
[lttng-modules.git] / src / lttng-abi.c
index 9f06295ffa6981d9de6bf4182f8d57be74c825f9..aa1b0195eff6515ddee759871cc3fd4e25ee2f51 100644 (file)
@@ -91,7 +91,7 @@ static int validate_zeroed_padding(char *p, size_t len)
 static
 int lttng_abi_create_session(void)
 {
-       struct lttng_session *session;
+       struct lttng_kernel_session *session;
        struct file *session_file;
        int session_fd, ret;
 
@@ -110,7 +110,7 @@ int lttng_abi_create_session(void)
                ret = PTR_ERR(session_file);
                goto file_error;
        }
-       session->file = session_file;
+       session->priv->file = session_file;
        fd_install(session_fd, session_file);
        return session_fd;
 
@@ -259,10 +259,10 @@ void lttng_abi_tracer_abi_version(struct lttng_kernel_abi_tracer_abi_version *v)
 static
 long lttng_abi_add_context(struct file *file,
        struct lttng_kernel_abi_context *context_param,
-       struct lttng_kernel_ctx **ctx, struct lttng_session *session)
+       struct lttng_kernel_ctx **ctx, struct lttng_kernel_session *session)
 {
 
-       if (session->been_active)
+       if (session->priv->been_active)
                return -EPERM;
 
        switch (context_param->ctx) {
@@ -488,7 +488,7 @@ int lttng_abi_create_channel(struct file *session_file,
                             struct lttng_kernel_abi_channel *chan_param,
                             enum channel_type channel_type)
 {
-       struct lttng_session *session = session_file->private_data;
+       struct lttng_kernel_session *session = session_file->private_data;
        const struct file_operations *fops = NULL;
        const char *transport_name;
        struct lttng_channel *chan;
@@ -576,7 +576,7 @@ fd_error:
 }
 
 static
-int lttng_abi_session_set_name(struct lttng_session *session,
+int lttng_abi_session_set_name(struct lttng_kernel_session *session,
                struct lttng_kernel_abi_session_name *name)
 {
        size_t len;
@@ -588,12 +588,12 @@ int lttng_abi_session_set_name(struct lttng_session *session,
                return -EINVAL;
        }
 
-       strcpy(session->name, name->name);
+       strcpy(session->priv->name, name->name);
        return 0;
 }
 
 static
-int lttng_abi_session_set_creation_time(struct lttng_session *session,
+int lttng_abi_session_set_creation_time(struct lttng_kernel_session *session,
                struct lttng_kernel_abi_session_creation_time *time)
 {
        size_t len;
@@ -605,7 +605,7 @@ int lttng_abi_session_set_creation_time(struct lttng_session *session,
                return -EINVAL;
        }
 
-       strcpy(session->creation_time, time->iso8601);
+       strcpy(session->priv->creation_time, time->iso8601);
        return 0;
 }
 
@@ -789,10 +789,41 @@ enum tracker_type get_tracker_type(struct lttng_kernel_abi_tracker_args *tracker
 static
 long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct lttng_session *session = file->private_data;
+       struct lttng_kernel_session *session = file->private_data;
        struct lttng_kernel_abi_channel chan_param;
        struct lttng_kernel_abi_old_channel old_chan_param;
 
+       /*
+        * Handle backward compatibility. OLD commands have wrong
+        * directions, replace them by the correct direction.
+        */
+       switch (cmd) {
+       case LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_PID:
+               cmd = LTTNG_KERNEL_ABI_SESSION_TRACK_PID;
+               break;
+       case LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_PID:
+               cmd = LTTNG_KERNEL_ABI_SESSION_UNTRACK_PID;
+               break;
+       case LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_ID:
+               cmd = LTTNG_KERNEL_ABI_SESSION_TRACK_ID;
+               break;
+       case LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_ID:
+               cmd = LTTNG_KERNEL_ABI_SESSION_UNTRACK_ID;
+               break;
+       case LTTNG_KERNEL_ABI_OLD_SESSION_LIST_TRACKER_IDS:
+               cmd = LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_IDS;
+               break;
+       case LTTNG_KERNEL_ABI_OLD_SESSION_SET_NAME:
+               cmd = LTTNG_KERNEL_ABI_SESSION_SET_NAME;
+               break;
+       case LTTNG_KERNEL_ABI_OLD_SESSION_SET_CREATION_TIME:
+               cmd = LTTNG_KERNEL_ABI_SESSION_SET_CREATION_TIME;
+               break;
+       default:
+               /* Nothing to do. */
+               break;
+       }
+
        switch (cmd) {
        case LTTNG_KERNEL_ABI_OLD_CHANNEL:
        {
@@ -943,7 +974,7 @@ long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static
 int lttng_session_release(struct inode *inode, struct file *file)
 {
-       struct lttng_session *session = file->private_data;
+       struct lttng_kernel_session *session = file->private_data;
 
        if (session)
                lttng_session_destroy(session);
@@ -1601,7 +1632,7 @@ int lttng_abi_open_stream(struct file *channel_file)
        int ret;
        void *stream_priv;
 
-       buf = channel->ops->buffer_read_open(channel->chan);
+       buf = channel->ops->priv->buffer_read_open(channel->chan);
        if (!buf)
                return -ENOENT;
 
@@ -1615,7 +1646,7 @@ int lttng_abi_open_stream(struct file *channel_file)
        return ret;
 
 fd_error:
-       channel->ops->buffer_read_close(buf);
+       channel->ops->priv->buffer_read_close(buf);
        return ret;
 }
 
@@ -1623,13 +1654,13 @@ static
 int lttng_abi_open_metadata_stream(struct file *channel_file)
 {
        struct lttng_channel *channel = channel_file->private_data;
-       struct lttng_session *session = channel->session;
+       struct lttng_kernel_session *session = channel->session;
        struct lib_ring_buffer *buf;
        int ret;
        struct lttng_metadata_stream *metadata_stream;
        void *stream_priv;
 
-       buf = channel->ops->buffer_read_open(channel->chan);
+       buf = channel->ops->priv->buffer_read_open(channel->chan);
        if (!buf)
                return -ENOENT;
 
@@ -1639,7 +1670,7 @@ int lttng_abi_open_metadata_stream(struct file *channel_file)
                ret = -ENOMEM;
                goto nomem;
        }
-       metadata_stream->metadata_cache = session->metadata_cache;
+       metadata_stream->metadata_cache = session->priv->metadata_cache;
        init_waitqueue_head(&metadata_stream->read_wait);
        metadata_stream->priv = buf;
        stream_priv = metadata_stream;
@@ -1657,7 +1688,7 @@ int lttng_abi_open_metadata_stream(struct file *channel_file)
                goto notransport;
        }
 
-       if (!lttng_kref_get(&session->metadata_cache->refcount)) {
+       if (!lttng_kref_get(&session->priv->metadata_cache->refcount)) {
                ret = -EOVERFLOW;
                goto kref_error;
        }
@@ -1668,20 +1699,20 @@ int lttng_abi_open_metadata_stream(struct file *channel_file)
        if (ret < 0)
                goto fd_error;
 
-       mutex_lock(&session->metadata_cache->lock);
+       mutex_lock(&session->priv->metadata_cache->lock);
        list_add(&metadata_stream->list,
-               &session->metadata_cache->metadata_stream);
-       mutex_unlock(&session->metadata_cache->lock);
+               &session->priv->metadata_cache->metadata_stream);
+       mutex_unlock(&session->priv->metadata_cache->lock);
        return ret;
 
 fd_error:
-       kref_put(&session->metadata_cache->refcount, metadata_cache_destroy);
+       kref_put(&session->priv->metadata_cache->refcount, metadata_cache_destroy);
 kref_error:
        module_put(metadata_stream->transport->owner);
 notransport:
        kfree(metadata_stream);
 nomem:
-       channel->ops->buffer_read_close(buf);
+       channel->ops->priv->buffer_read_close(buf);
        return ret;
 }
 
@@ -1694,7 +1725,7 @@ int lttng_abi_open_event_notifier_group_stream(struct file *notif_file)
        int ret;
        void *stream_priv;
 
-       buf = event_notifier_group->ops->buffer_read_open(chan);
+       buf = event_notifier_group->ops->priv->buffer_read_open(chan);
        if (!buf)
                return -ENOENT;
 
@@ -1716,7 +1747,7 @@ int lttng_abi_open_event_notifier_group_stream(struct file *notif_file)
 fd_error:
        atomic_long_dec(&notif_file->f_count);
 refcount_error:
-       event_notifier_group->ops->buffer_read_close(buf);
+       event_notifier_group->ops->priv->buffer_read_close(buf);
        return ret;
 }
 
@@ -1860,15 +1891,14 @@ int lttng_abi_create_event(struct file *channel_file,
        case LTTNG_KERNEL_ABI_KRETPROBE:                /* Fall-through */
        case LTTNG_KERNEL_ABI_UPROBE:
        {
-               struct lttng_event *event;
+               struct lttng_kernel_event_recorder *event;
 
                /*
                 * We tolerate no failure path after event creation. It
                 * will stay invariant for the rest of the session.
                 */
-               event = lttng_event_create(channel, event_param,
-                               NULL, NULL,
-                               event_param->instrumentation);
+               event = lttng_kernel_event_recorder_create(channel, event_param,
+                               NULL, event_param->instrumentation);
                WARN_ON_ONCE(!event);
                if (IS_ERR(event)) {
                        ret = PTR_ERR(event);
@@ -1901,19 +1931,19 @@ fd_error:
 static
 long lttng_event_notifier_event_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct lttng_event_notifier *event_notifier = file->private_data;
+       struct lttng_kernel_event_notifier *event_notifier = file->private_data;
 
        switch (cmd) {
        case LTTNG_KERNEL_ABI_ENABLE:
-               return lttng_event_notifier_enable(event_notifier);
+               return lttng_event_enable(&event_notifier->parent);
        case LTTNG_KERNEL_ABI_DISABLE:
-               return lttng_event_notifier_disable(event_notifier);
+               return lttng_event_disable(&event_notifier->parent);
        case LTTNG_KERNEL_ABI_FILTER:
                return -EINVAL;
        case LTTNG_KERNEL_ABI_CAPTURE:
                return -EINVAL;
        case LTTNG_KERNEL_ABI_ADD_CALLSITE:
-               return lttng_event_notifier_add_callsite(event_notifier,
+               return lttng_event_add_callsite(&event_notifier->parent,
                        (struct lttng_kernel_abi_event_callsite __user *) arg);
        default:
                return -ENOIOCTLCMD;
@@ -1948,10 +1978,10 @@ long lttng_event_notifier_enabler_ioctl(struct file *file, unsigned int cmd, uns
 static
 int lttng_event_notifier_event_release(struct inode *inode, struct file *file)
 {
-       struct lttng_event_notifier *event_notifier = file->private_data;
+       struct lttng_kernel_event_notifier *event_notifier = file->private_data;
 
        if (event_notifier)
-               fput(event_notifier->group->file);
+               fput(event_notifier->priv->group->file);
        return 0;
 }
 
@@ -2084,7 +2114,7 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
        case LTTNG_KERNEL_ABI_KRETPROBE:                /* Fall-through */
        case LTTNG_KERNEL_ABI_UPROBE:
        {
-               struct lttng_event_notifier *event_notifier;
+               struct lttng_kernel_event_notifier *event_notifier;
 
                /*
                 * We tolerate no failure path after event notifier creation.
@@ -2094,7 +2124,7 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
                                event_notifier_param->event.token,
                                event_notifier_param->error_counter_index,
                                event_notifier_group,
-                               event_notifier_param, NULL,
+                               event_notifier_param,
                                event_notifier_param->event.instrumentation);
                WARN_ON_ONCE(!event_notifier);
                if (IS_ERR(event_notifier)) {
@@ -2508,14 +2538,14 @@ unsigned int lttng_channel_poll(struct file *file, poll_table *wait)
 
        if (file->f_mode & FMODE_READ) {
                poll_wait_set_exclusive(wait);
-               poll_wait(file, channel->ops->get_hp_wait_queue(channel->chan),
+               poll_wait(file, channel->ops->priv->get_hp_wait_queue(channel->chan),
                          wait);
 
-               if (channel->ops->is_disabled(channel->chan))
+               if (channel->ops->priv->is_disabled(channel->chan))
                        return POLLERR;
-               if (channel->ops->is_finalized(channel->chan))
+               if (channel->ops->priv->is_finalized(channel->chan))
                        return POLLHUP;
-               if (channel->ops->buffer_has_read_closed_stream(channel->chan))
+               if (channel->ops->priv->buffer_has_read_closed_stream(channel->chan))
                        return POLLIN | POLLRDNORM;
                return 0;
        }
@@ -2529,7 +2559,7 @@ int lttng_channel_release(struct inode *inode, struct file *file)
        struct lttng_channel *channel = file->private_data;
 
        if (channel)
-               fput(channel->session->file);
+               fput(channel->session->priv->file);
        return 0;
 }
 
@@ -2539,7 +2569,7 @@ int lttng_metadata_channel_release(struct inode *inode, struct file *file)
        struct lttng_channel *channel = file->private_data;
 
        if (channel) {
-               fput(channel->session->file);
+               fput(channel->session->priv->file);
                lttng_metadata_channel_destroy(channel);
        }
 
@@ -2583,7 +2613,7 @@ static const struct file_operations lttng_metadata_fops = {
 static
 long lttng_event_recorder_event_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct lttng_event *event = file->private_data;
+       struct lttng_kernel_event_recorder *event_recorder = file->private_data;
 
        switch (cmd) {
        case LTTNG_KERNEL_ABI_OLD_CONTEXT:
@@ -2598,14 +2628,14 @@ long lttng_event_recorder_event_ioctl(struct file *file, unsigned int cmd, unsig
        }
        case LTTNG_KERNEL_ABI_OLD_ENABLE:
        case LTTNG_KERNEL_ABI_ENABLE:
-               return lttng_event_enable(event);
+               return lttng_event_enable(&event_recorder->parent);
        case LTTNG_KERNEL_ABI_OLD_DISABLE:
        case LTTNG_KERNEL_ABI_DISABLE:
-               return lttng_event_disable(event);
+               return lttng_event_disable(&event_recorder->parent);
        case LTTNG_KERNEL_ABI_FILTER:
                return -EINVAL;
        case LTTNG_KERNEL_ABI_ADD_CALLSITE:
-               return lttng_event_add_callsite(event,
+               return lttng_event_add_callsite(&event_recorder->parent,
                        (struct lttng_kernel_abi_event_callsite __user *) arg);
        default:
                return -ENOIOCTLCMD;
@@ -2663,7 +2693,7 @@ long lttng_event_recorder_enabler_ioctl(struct file *file, unsigned int cmd, uns
 static
 int lttng_event_recorder_event_release(struct inode *inode, struct file *file)
 {
-       struct lttng_event *event = file->private_data;
+       struct lttng_kernel_event_recorder *event = file->private_data;
 
        if (event)
                fput(event->chan->file);
@@ -2714,7 +2744,7 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
        struct lib_ring_buffer *buf = filp->private_data;
        struct channel *chan = buf->backend.chan;
        const struct lib_ring_buffer_config *config = &chan->backend.config;
-       const struct lttng_channel_ops *ops = chan->backend.priv_ops;
+       const struct lttng_kernel_channel_buffer_ops *ops = chan->backend.priv_ops;
        int ret;
 
        if (atomic_read(&chan->record_disabled))
@@ -2725,7 +2755,7 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
        {
                uint64_t ts;
 
-               ret = ops->timestamp_begin(config, buf, &ts);
+               ret = ops->priv->timestamp_begin(config, buf, &ts);
                if (ret < 0)
                        goto error;
                return put_u64(ts, arg);
@@ -2734,7 +2764,7 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
        {
                uint64_t ts;
 
-               ret = ops->timestamp_end(config, buf, &ts);
+               ret = ops->priv->timestamp_end(config, buf, &ts);
                if (ret < 0)
                        goto error;
                return put_u64(ts, arg);
@@ -2743,7 +2773,7 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
        {
                uint64_t ed;
 
-               ret = ops->events_discarded(config, buf, &ed);
+               ret = ops->priv->events_discarded(config, buf, &ed);
                if (ret < 0)
                        goto error;
                return put_u64(ed, arg);
@@ -2752,7 +2782,7 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
        {
                uint64_t cs;
 
-               ret = ops->content_size(config, buf, &cs);
+               ret = ops->priv->content_size(config, buf, &cs);
                if (ret < 0)
                        goto error;
                return put_u64(cs, arg);
@@ -2761,7 +2791,7 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
        {
                uint64_t ps;
 
-               ret = ops->packet_size(config, buf, &ps);
+               ret = ops->priv->packet_size(config, buf, &ps);
                if (ret < 0)
                        goto error;
                return put_u64(ps, arg);
@@ -2770,7 +2800,7 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
        {
                uint64_t si;
 
-               ret = ops->stream_id(config, buf, &si);
+               ret = ops->priv->stream_id(config, buf, &si);
                if (ret < 0)
                        goto error;
                return put_u64(si, arg);
@@ -2779,7 +2809,7 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
        {
                uint64_t ts;
 
-               ret = ops->current_timestamp(config, buf, &ts);
+               ret = ops->priv->current_timestamp(config, buf, &ts);
                if (ret < 0)
                        goto error;
                return put_u64(ts, arg);
@@ -2788,7 +2818,7 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
        {
                uint64_t seq;
 
-               ret = ops->sequence_number(config, buf, &seq);
+               ret = ops->priv->sequence_number(config, buf, &seq);
                if (ret < 0)
                        goto error;
                return put_u64(seq, arg);
@@ -2797,7 +2827,7 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
        {
                uint64_t id;
 
-               ret = ops->instance_id(config, buf, &id);
+               ret = ops->priv->instance_id(config, buf, &id);
                if (ret < 0)
                        goto error;
                return put_u64(id, arg);
@@ -2818,7 +2848,7 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
        struct lib_ring_buffer *buf = filp->private_data;
        struct channel *chan = buf->backend.chan;
        const struct lib_ring_buffer_config *config = &chan->backend.config;
-       const struct lttng_channel_ops *ops = chan->backend.priv_ops;
+       const struct lttng_kernel_channel_buffer_ops *ops = chan->backend.priv_ops;
        int ret;
 
        if (atomic_read(&chan->record_disabled))
@@ -2829,7 +2859,7 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
        {
                uint64_t ts;
 
-               ret = ops->timestamp_begin(config, buf, &ts);
+               ret = ops->priv->timestamp_begin(config, buf, &ts);
                if (ret < 0)
                        goto error;
                return put_u64(ts, arg);
@@ -2838,7 +2868,7 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
        {
                uint64_t ts;
 
-               ret = ops->timestamp_end(config, buf, &ts);
+               ret = ops->priv->timestamp_end(config, buf, &ts);
                if (ret < 0)
                        goto error;
                return put_u64(ts, arg);
@@ -2847,7 +2877,7 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
        {
                uint64_t ed;
 
-               ret = ops->events_discarded(config, buf, &ed);
+               ret = ops->priv->events_discarded(config, buf, &ed);
                if (ret < 0)
                        goto error;
                return put_u64(ed, arg);
@@ -2856,7 +2886,7 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
        {
                uint64_t cs;
 
-               ret = ops->content_size(config, buf, &cs);
+               ret = ops->priv->content_size(config, buf, &cs);
                if (ret < 0)
                        goto error;
                return put_u64(cs, arg);
@@ -2865,7 +2895,7 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
        {
                uint64_t ps;
 
-               ret = ops->packet_size(config, buf, &ps);
+               ret = ops->priv->packet_size(config, buf, &ps);
                if (ret < 0)
                        goto error;
                return put_u64(ps, arg);
@@ -2874,7 +2904,7 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
        {
                uint64_t si;
 
-               ret = ops->stream_id(config, buf, &si);
+               ret = ops->priv->stream_id(config, buf, &si);
                if (ret < 0)
                        goto error;
                return put_u64(si, arg);
@@ -2883,7 +2913,7 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
        {
                uint64_t ts;
 
-               ret = ops->current_timestamp(config, buf, &ts);
+               ret = ops->priv->current_timestamp(config, buf, &ts);
                if (ret < 0)
                        goto error;
                return put_u64(ts, arg);
@@ -2892,7 +2922,7 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
        {
                uint64_t seq;
 
-               ret = ops->sequence_number(config, buf, &seq);
+               ret = ops->priv->sequence_number(config, buf, &seq);
                if (ret < 0)
                        goto error;
                return put_u64(seq, arg);
@@ -2901,7 +2931,7 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
        {
                uint64_t id;
 
-               ret = ops->instance_id(config, buf, &id);
+               ret = ops->priv->instance_id(config, buf, &id);
                if (ret < 0)
                        goto error;
                return put_u64(id, arg);
This page took 0.037954 seconds and 4 git commands to generate.