2008-07-18 10:16:16 -06:00
|
|
|
/* tracepoint-sample.c
|
|
|
|
*
|
2009-03-24 14:00:28 -06:00
|
|
|
* Executes a tracepoint when /proc/tracepoint-sample is opened.
|
2008-07-18 10:16:16 -06:00
|
|
|
*
|
|
|
|
* (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
|
|
|
|
*
|
|
|
|
* This file is released under the GPLv2.
|
|
|
|
* See the file COPYING for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include "tp-samples-trace.h"
|
|
|
|
|
2008-11-14 15:47:47 -07:00
|
|
|
DEFINE_TRACE(subsys_event);
|
|
|
|
DEFINE_TRACE(subsys_eventb);
|
|
|
|
|
2009-03-24 14:00:28 -06:00
|
|
|
struct proc_dir_entry *pentry_sample;
|
2008-07-18 10:16:16 -06:00
|
|
|
|
|
|
|
static int my_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
trace_subsys_event(inode, file);
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
trace_subsys_eventb();
|
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct file_operations mark_ops = {
|
|
|
|
.open = my_open,
|
|
|
|
};
|
|
|
|
|
2009-03-24 14:00:28 -06:00
|
|
|
static int __init sample_init(void)
|
2008-07-18 10:16:16 -06:00
|
|
|
{
|
2009-03-24 14:00:28 -06:00
|
|
|
printk(KERN_ALERT "sample init\n");
|
|
|
|
pentry_sample = proc_create("tracepoint-sample", 0444, NULL,
|
2008-07-18 10:16:16 -06:00
|
|
|
&mark_ops);
|
2009-03-24 14:00:28 -06:00
|
|
|
if (!pentry_sample)
|
2008-07-18 10:16:16 -06:00
|
|
|
return -EPERM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-24 14:00:28 -06:00
|
|
|
static void __exit sample_exit(void)
|
2008-07-18 10:16:16 -06:00
|
|
|
{
|
2009-03-24 14:00:28 -06:00
|
|
|
printk(KERN_ALERT "sample exit\n");
|
|
|
|
remove_proc_entry("tracepoint-sample", NULL);
|
2008-07-18 10:16:16 -06:00
|
|
|
}
|
|
|
|
|
2009-03-24 14:00:28 -06:00
|
|
|
module_init(sample_init)
|
|
|
|
module_exit(sample_exit)
|
2008-07-18 10:16:16 -06:00
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Mathieu Desnoyers");
|
2009-03-24 14:00:28 -06:00
|
|
|
MODULE_DESCRIPTION("Tracepoint sample");
|