add examples
[lttv.git] / tests / kernel / marker-example.c
1 /* marker-example.c
2 *
3 * Executes a marker when /proc/marker-example is opened.
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/marker.h>
13 #include <linux/sched.h>
14 #include <linux/proc_fs.h>
15
16 struct proc_dir_entry *pentry_example = NULL;
17
18 static int my_open(struct inode *inode, struct file *file)
19 {
20 int i;
21
22 MARK(subsystem_event, "%d %s %*.*r", 123, "example string",
23 sizeof(current), __alignof__(current), current);
24 for (i=0; i<10; i++) {
25 MARK(subsystem_eventb, MARK_NOARGS);
26 }
27 return -EPERM;
28 }
29
30 static struct file_operations mark_ops = {
31 .open = my_open,
32 };
33
34 static int example_init(void)
35 {
36 printk(KERN_ALERT "example init\n");
37 pentry_example = create_proc_entry("marker-example", 0444, NULL);
38 if (pentry_example)
39 pentry_example->proc_fops = &mark_ops;
40 else
41 return -EPERM;
42 return 0;
43 }
44
45 static void example_exit(void)
46 {
47 printk(KERN_ALERT "example exit\n");
48 remove_proc_entry("marker-example", NULL);
49 }
50
51 module_init(example_init)
52 module_exit(example_exit)
53
54 MODULE_LICENSE("GPL");
55 MODULE_AUTHOR("Mathieu Desnoyers");
56 MODULE_DESCRIPTION("Linux Trace Toolkit example");
This page took 0.031066 seconds and 5 git commands to generate.