oom_kill bug
[linux-2.6/mini2440.git] / samples / markers / marker-example.c
blobe787c6d16dd77ace5f998a3f8a17e50f57b38fe3
1 /* marker-example.c
3 * Executes a marker when /proc/marker-example is opened.
5 * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
7 * This file is released under the GPLv2.
8 * See the file COPYING for more details.
9 */
11 #include <linux/module.h>
12 #include <linux/marker.h>
13 #include <linux/sched.h>
14 #include <linux/proc_fs.h>
16 struct proc_dir_entry *pentry_example;
18 static int my_open(struct inode *inode, struct file *file)
20 int i;
22 trace_mark(subsystem_event, "%d %s", 123, "example string");
23 for (i = 0; i < 10; i++)
24 trace_mark(subsystem_eventb, MARK_NOARGS);
25 return -EPERM;
28 static struct file_operations mark_ops = {
29 .open = my_open,
32 static int example_init(void)
34 printk(KERN_ALERT "example init\n");
35 pentry_example = create_proc_entry("marker-example", 0444, NULL);
36 if (pentry_example)
37 pentry_example->proc_fops = &mark_ops;
38 else
39 return -EPERM;
40 return 0;
43 static void example_exit(void)
45 printk(KERN_ALERT "example exit\n");
46 remove_proc_entry("marker-example", NULL);
49 module_init(example_init)
50 module_exit(example_exit)
52 MODULE_LICENSE("GPL");
53 MODULE_AUTHOR("Mathieu Desnoyers");
54 MODULE_DESCRIPTION("Marker example");