blob: e9cd9c0bc84f573e4c4976f66667d90ceedda626 [file] [log] [blame]
Mathieu Desnoyers31155bc2007-10-18 23:41:08 -07001/* 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
16struct proc_dir_entry *pentry_example;
17
18static int my_open(struct inode *inode, struct file *file)
19{
20 int i;
21
Mathieu Desnoyerscc9f2f82007-11-14 16:59:50 -080022 trace_mark(subsystem_event, "integer %d string %s", 123,
23 "example string");
Mathieu Desnoyers31155bc2007-10-18 23:41:08 -070024 for (i = 0; i < 10; i++)
25 trace_mark(subsystem_eventb, MARK_NOARGS);
26 return -EPERM;
27}
28
29static struct file_operations mark_ops = {
30 .open = my_open,
31};
32
Qinghuang Feng7ec7fb32009-01-06 14:40:52 -080033static int __init example_init(void)
Mathieu Desnoyers31155bc2007-10-18 23:41:08 -070034{
35 printk(KERN_ALERT "example init\n");
Denis V. Lunev16e70f62008-04-29 01:02:16 -070036 pentry_example = proc_create("marker-example", 0444, NULL, &mark_ops);
37 if (!pentry_example)
Mathieu Desnoyers31155bc2007-10-18 23:41:08 -070038 return -EPERM;
39 return 0;
40}
41
Qinghuang Feng7ec7fb32009-01-06 14:40:52 -080042static void __exit example_exit(void)
Mathieu Desnoyers31155bc2007-10-18 23:41:08 -070043{
44 printk(KERN_ALERT "example exit\n");
45 remove_proc_entry("marker-example", NULL);
46}
47
48module_init(example_init)
49module_exit(example_exit)
50
51MODULE_LICENSE("GPL");
52MODULE_AUTHOR("Mathieu Desnoyers");
53MODULE_DESCRIPTION("Marker example");