X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt-probes.c;h=45d2dabdef22e977fe8122deeb9a5417aa07fc21;hb=96ba7208aa8009345a525148e32f78cd8d4693ab;hp=0efc23c5c61b749c996783f604c26a537d822416;hpb=dc7f600a24e263bba4a69d7c94ab9c0bda9bca02;p=lttng-modules.git diff --git a/ltt-probes.c b/ltt-probes.c index 0efc23c5..45d2dabd 100644 --- a/ltt-probes.c +++ b/ltt-probes.c @@ -4,11 +4,14 @@ * Copyright 2010 (c) - Mathieu Desnoyers * * Holds LTTng probes registry. + * + * Dual LGPL v2.1/GPL v2 license. */ #include #include #include +#include #include "ltt-events.h" @@ -82,3 +85,79 @@ void ltt_event_put(const struct lttng_event_desc *event) 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; + + mutex_lock(&probe_mutex); + 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) +{ + mutex_unlock(&probe_mutex); +} + +static +int tp_list_show(struct seq_file *m, void *p) +{ + const struct lttng_event_desc *probe_desc = p; + + /* + * Don't export lttng internal events (metadata). + */ + if (!strncmp(probe_desc->name, "lttng_", sizeof("lttng_") - 1)) + return 0; + 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, +};