]> bbs.cooldavid.org Git - net-next-2.6.git/blame - samples/tracepoints/tracepoint-sample.c
llseek: automatically add .llseek fop
[net-next-2.6.git] / samples / tracepoints / tracepoint-sample.c
CommitLineData
4a089752
MD
1/* tracepoint-sample.c
2 *
0a5d6490 3 * Executes a tracepoint when /proc/tracepoint-sample is opened.
4a089752
MD
4 *
5 * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
6 *
7 * This file is released under the GPLv2.
8 * See the file COPYING for more details.
9 */
10
11#include <linux/module.h>
12#include <linux/sched.h>
13#include <linux/proc_fs.h>
14#include "tp-samples-trace.h"
15
7e066fb8
MD
16DEFINE_TRACE(subsys_event);
17DEFINE_TRACE(subsys_eventb);
18
0a5d6490 19struct proc_dir_entry *pentry_sample;
4a089752
MD
20
21static int my_open(struct inode *inode, struct file *file)
22{
23 int i;
24
25 trace_subsys_event(inode, file);
26 for (i = 0; i < 10; i++)
27 trace_subsys_eventb();
28 return -EPERM;
29}
30
828c0950 31static const struct file_operations mark_ops = {
4a089752 32 .open = my_open,
6038f373 33 .llseek = noop_llseek,
4a089752
MD
34};
35
0a5d6490 36static int __init sample_init(void)
4a089752 37{
0a5d6490
JM
38 printk(KERN_ALERT "sample init\n");
39 pentry_sample = proc_create("tracepoint-sample", 0444, NULL,
4a089752 40 &mark_ops);
0a5d6490 41 if (!pentry_sample)
4a089752
MD
42 return -EPERM;
43 return 0;
44}
45
0a5d6490 46static void __exit sample_exit(void)
4a089752 47{
0a5d6490
JM
48 printk(KERN_ALERT "sample exit\n");
49 remove_proc_entry("tracepoint-sample", NULL);
4a089752
MD
50}
51
0a5d6490
JM
52module_init(sample_init)
53module_exit(sample_exit)
4a089752
MD
54
55MODULE_LICENSE("GPL");
56MODULE_AUTHOR("Mathieu Desnoyers");
0a5d6490 57MODULE_DESCRIPTION("Tracepoint sample");