return ret;
}
+static
+int lttng_abi_tracepoint_list(void)
+{
+ struct file *tracepoint_list_file;
+ int file_fd, ret;
+
+ file_fd = get_unused_fd();
+ if (file_fd < 0) {
+ ret = file_fd;
+ goto fd_error;
+ }
+ tracepoint_list_file = anon_inode_getfile("[lttng_session]",
+ <tng_tracepoint_list_fops,
+ NULL, O_RDWR);
+ if (IS_ERR(tracepoint_list_file)) {
+ ret = PTR_ERR(tracepoint_list_file);
+ goto file_error;
+ }
+ fd_install(file_fd, tracepoint_list_file);
+ return file_fd;
+
+file_error:
+ put_unused_fd(file_fd);
+fd_error:
+ return ret;
+}
+
static
long lttng_abi_tracer_version(struct file *file,
struct lttng_kernel_tracer_version __user *uversion_param)
* This ioctl implements lttng commands:
* LTTNG_KERNEL_SESSION
* Returns a LTTng trace session file descriptor
+ * LTTNG_KERNEL_TRACER_VERSION
+ * Returns the LTTng kernel tracer version
+ * LTTNG_KERNEL_TRACEPOINT_LIST
+ * Returns a file descriptor listing available tracepoints
*
* The returned session will be deleted when its file descriptor is closed.
*/
case LTTNG_KERNEL_TRACER_VERSION:
return lttng_abi_tracer_version(file,
(struct lttng_kernel_tracer_version __user *) arg);
+ case LTTNG_KERNEL_TRACEPOINT_LIST:
+ return lttng_abi_tracepoint_list();
default:
return -ENOIOCTLCMD;
}
*/
event = ltt_event_create(channel, &metadata_params, NULL);
if (!event) {
- goto create_error;
ret = -EINVAL;
+ goto create_error;
}
return;
*/
event = ltt_event_create(channel, &event_param, NULL);
if (!event) {
- ret = -EEXIST;
+ ret = -EINVAL;
goto event_error;
}
event_file->private_data = event;
#define LTTNG_KERNEL_SESSION _IO(0xF6, 0x40)
#define LTTNG_KERNEL_TRACER_VERSION \
_IOR(0xF6, 0x41, struct lttng_kernel_tracer_version)
+#define LTTNG_KERNEL_TRACEPOINT_LIST _IO(0xF6, 0x42)
/* Session FD ioctl */
#define LTTNG_KERNEL_METADATA \
{
}
#endif
+
+extern const struct file_operations lttng_tracepoint_list_fops;
+
#endif /* _LTT_EVENTS_H */
#include <linux/module.h>
#include <linux/list.h>
#include <linux/mutex.h>
+#include <linux/seq_file.h>
#include "ltt-events.h"
module_put(event->owner);
}
EXPORT_SYMBOL_GPL(ltt_event_put);
+
+static
+void *tp_list_start(struct seq_file *m, loff_t *pos)
+{
+ struct lttng_probe_desc *probe_desc;
+ int iter = 0, i;
+
+ list_for_each_entry(probe_desc, &probe_list, head) {
+ for (i = 0; i < probe_desc->nr_events; i++) {
+ if (iter++ >= *pos)
+ return (void *) &probe_desc->event_desc[i];
+ }
+ }
+ /* End of list */
+ return NULL;
+}
+
+static
+void *tp_list_next(struct seq_file *m, void *p, loff_t *ppos)
+{
+ struct lttng_probe_desc *probe_desc;
+ int iter = 0, i;
+
+ (*ppos)++;
+ list_for_each_entry(probe_desc, &probe_list, head) {
+ for (i = 0; i < probe_desc->nr_events; i++) {
+ if (iter++ >= *ppos)
+ return (void *) &probe_desc->event_desc[i];
+ }
+ }
+ /* End of list */
+ return NULL;
+}
+
+static
+void tp_list_stop(struct seq_file *m, void *p)
+{
+}
+
+static
+int tp_list_show(struct seq_file *m, void *p)
+{
+ const struct lttng_event_desc *probe_desc = p;
+
+ seq_printf(m, "event { name = %s; };\n",
+ probe_desc->name);
+ return 0;
+}
+
+static
+const struct seq_operations lttng_tracepoint_list_seq_ops = {
+ .start = tp_list_start,
+ .next = tp_list_next,
+ .stop = tp_list_stop,
+ .show = tp_list_show,
+};
+
+static
+int lttng_tracepoint_list_open(struct inode *inode, struct file *file)
+{
+ return seq_open(file, <tng_tracepoint_list_seq_ops);
+}
+
+const struct file_operations lttng_tracepoint_list_fops = {
+ .open = lttng_tracepoint_list_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release_private,
+};