yet more ongoing ABI implementation
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 25 Nov 2010 01:45:08 +0000 (20:45 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 25 Nov 2010 01:45:08 +0000 (20:45 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ltt-debugfs-abi.c
ltt-events.c
ltt-events.h

index fe70f9a9fd3b9c3ea1ce9f2f66138dee892b68df..d9d93ac4f0dac131f556f99f739e6f8769c06afc 100644 (file)
@@ -40,7 +40,6 @@ static const struct file_operations lttng_channel_fops;
  */
 
 struct lttng_channel {
-       int session;                    /* Session file descriptor */
        int overwrite;                  /* 1: overwrite, 0: discard */
        u64 subbuf_size;
        u64 num_subbuf;
@@ -49,7 +48,6 @@ struct lttng_channel {
 };
 
 struct lttng_event {
-       int channel;                    /* Channel file descriptor */
        enum instrum_type itype;
        char name[];
 };
@@ -61,7 +59,7 @@ int lttng_abi_create_session(void)
        struct file *session_file;
        int session_fd;
 
-       session = ltt_session_create()
+       session = ltt_session_create();
        if (!session)
                return -ENOMEM;
        session_fd = get_unused_fd_flags(O_RDWR);
@@ -140,7 +138,7 @@ int lttng_abi_create_channel(struct file *session_filp,
        int chan_fd;
        int ret = 0;
 
-       if (copy_from_user(&chan_param, ucham_param, sizeof(chan_param)))
+       if (copy_from_user(&chan_param, uchan_param, sizeof(chan_param)))
                return -EFAULT;
        chan = ltt_channel_create(session, chan_param->overwrite, NULL,
                                  chan_param->subbuf_size,
@@ -256,6 +254,55 @@ fd_error:
        return ret;
 }
 
+static
+int lttng_abi_create_event(struct file *channel_filp,
+                          struct lttng_event __user *uevent_param)
+{
+       struct ltt_channel *channel = channel_filp->private_data;
+       struct ltt_event *event;
+       char *event_name;
+       struct lttng_event event_param;
+       int event_fd, ret;
+
+       if (copy_from_user(&event_param, uevent_param, sizeof(event_param)))
+               return -EFAULT;
+       event_name = kmalloc(PATH_MAX, GFP_KERNEL);
+       if (!event_name)
+               return -ENOMEM;
+       if (strncpy_from_user(event_name, &uevent_param->name, PATH_MAX)) {
+               ret = -EFAULT;
+               goto name_error;
+       }
+       event_name[PATH_MAX - 1] = '\0';
+       event = ltt_event_create(channel, event_param->itype, event_name, NULL);
+       if (!event)
+               return -EEXIST;
+
+       event_fd = get_unused_fd_flags(O_RDWR);
+       if (event_fd < 0) {
+               ret = event_fd;
+               goto fd_error;
+       }
+       event_filp = anon_inode_getfile("[lttng_event]",
+                                        &lttng_event_fops,
+                                        event, O_RDWR);
+       if (IS_ERR(event_filp)) {
+               ret = PTR_ERR(event_filp);
+               goto file_error;
+       }
+
+       /* The event holds a reference on the channel */
+       atomic_inc(&channel_filp->f_count);
+       return event_fd;
+
+file_error:
+       put_unused_fd(event_fd);
+fd_error:
+       ltt_event_destroy(event);
+name_error:
+       kfree(event_name);
+       return ret;
+}
 
 /**
  *     lttng_channel_ioctl - lttng syscall through ioctl
@@ -268,10 +315,6 @@ fd_error:
  *      LTTNG_STREAM
  *              Returns an event stream file descriptor or failure.
  *              (typically, one event stream records events from one CPU)
- *      LTTNG_STREAM_NOTIFIER
- *              Returns a file descriptor that can be used to monitor
- *              addition/removal of streams to/from a channel. (e.g. notifier
- *              called on CPU hotplug).
  *     LTTNG_EVENT
  *             Returns an event file descriptor or failure.
  *
@@ -284,8 +327,6 @@ long lttng_channel_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        switch (cmd) {
        case LTTNG_STREAM:
                return lttng_abi_open_stream(filp);
-       case LTTNG_STREAM_NOTIFIER:
-               return lttng_abi_open_stream_notifier(filp);
        case LTTNG_EVENT:
                return lttng_abi_create_event(filp, (struct lttng_event __user *)arg);
        default:
@@ -299,9 +340,7 @@ long lttng_channel_compat_ioctl(struct file *filp, unsigned int cmd, unsigned lo
 {
        switch (cmd) {
        case LTTNG_STREAM:
-               return lttng_abi_get_stream(filp);
-       case LTTNG_STREAM_NOTIFIER:
-               return lttng_abi_get_stream_notifier(filp);
+               return lttng_abi_open_stream(filp);
        case LTTNG_EVENT:
                return lttng_abi_create_event(filp, (struct lttng_event __user *)arg);
        default:
@@ -310,7 +349,33 @@ long lttng_channel_compat_ioctl(struct file *filp, unsigned int cmd, unsigned lo
 }
 #endif
 
+/**
+ *     lttng_channel_poll - lttng stream addition/removal monitoring
+ *
+ *     @filp: the file
+ *     @wait: poll table
+ */
+unsigned int lttng_channel_poll(struct file *filp, poll_table *wait)
+{
+       struct ltt_channel *channel = filp->private_data;
+       unsigned int mask = 0;
+
+       if (filp->f_mode & FMODE_READ) {
+               poll_wait_set_exclusive(wait);
+               poll_wait(filp, &channel->notify_wait, wait);
+
+               /* TODO: identify when the channel is being finalized. */
+               if (finalized)
+                       return POLLHUP;
+               else
+                       return POLLIN | POLLRDNORM;
+       }
+       return mask;
+
+}
+
 static const struct file_operations lttng_channel_fops = {
+       .poll = lttng_channel_poll,
        .unlocked_ioctl = lttng_channel_ioctl,
 #ifdef CONFIG_COMPAT
        .compat_ioctl = lttng_channel_compat_ioctl,
index f22351fcb0f92fc83070f3a0b90009ee3adba7ab..3060c07e05d2386d8d90d0482b3040d3d0f970b9 100644 (file)
@@ -71,6 +71,7 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session,
        if (!chan)
                return NULL;
        chan->session = session;
+       init_waitqueue_head(&chan->notify_wait);
 
        /* TODO: create rb channel */
        list_add(&chan->list, &session->chan);
index 165e616ac8306f20992f4e494da045441bfb97a4..4e1bc058f5ff9cb55f5e570351f99a85472d957f 100644 (file)
@@ -35,7 +35,7 @@ struct ltt_channel {
        struct ltt_session *session;
        unsigned int free_event_id;     /* Next event ID to allocate */
        struct list_head list;          /* Channel list */
-       char name[PATH_MAX];
+       wait_queue_head_t notify_wait;  /* Channel addition notif. waitqueue */
 };
 
 struct ltt_session {
@@ -43,7 +43,6 @@ struct ltt_session {
        struct list_head chan;          /* Channel list head */
        struct list_head events;        /* Event list head */
        struct list_head list;          /* Session list */
-       char name[PATH_MAX];
 };
 
 struct ltt_session *ltt_session_create(void);
@@ -56,6 +55,8 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session,
                                       unsigned int read_timer_interval);
 int _ltt_channel_destroy(struct ltt_channel *chan);
 
-struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name,
+struct ltt_event *ltt_event_create(struct ltt_channel *chan,
+                                  enum instrum_type itype,
+                                  char *name,
                                   void *filter);
 int _ltt_event_destroy(struct ltt_event *event);
This page took 0.028516 seconds and 4 git commands to generate.