2008-07-18 20:16:16 +04:00
/* tracepoint-sample.c
*
2009-03-24 23:00:28 +03:00
* Executes a tracepoint when / proc / tracepoint - sample is opened .
2008-07-18 20:16:16 +04: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-15 01:47:47 +03:00
DEFINE_TRACE ( subsys_event ) ;
DEFINE_TRACE ( subsys_eventb ) ;
2009-03-24 23:00:28 +03:00
struct proc_dir_entry * pentry_sample ;
2008-07-18 20:16:16 +04: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 ;
}
2009-10-02 02:43:56 +04:00
static const struct file_operations mark_ops = {
2008-07-18 20:16:16 +04:00
. open = my_open ,
} ;
2009-03-24 23:00:28 +03:00
static int __init sample_init ( void )
2008-07-18 20:16:16 +04:00
{
2009-03-24 23:00:28 +03:00
printk ( KERN_ALERT " sample init \n " ) ;
pentry_sample = proc_create ( " tracepoint-sample " , 0444 , NULL ,
2008-07-18 20:16:16 +04:00
& mark_ops ) ;
2009-03-24 23:00:28 +03:00
if ( ! pentry_sample )
2008-07-18 20:16:16 +04:00
return - EPERM ;
return 0 ;
}
2009-03-24 23:00:28 +03:00
static void __exit sample_exit ( void )
2008-07-18 20:16:16 +04:00
{
2009-03-24 23:00:28 +03:00
printk ( KERN_ALERT " sample exit \n " ) ;
remove_proc_entry ( " tracepoint-sample " , NULL ) ;
2008-07-18 20:16:16 +04:00
}
2009-03-24 23:00:28 +03:00
module_init ( sample_init )
module_exit ( sample_exit )
2008-07-18 20:16:16 +04:00
MODULE_LICENSE ( " GPL " ) ;
MODULE_AUTHOR ( " Mathieu Desnoyers " ) ;
2009-03-24 23:00:28 +03:00
MODULE_DESCRIPTION ( " Tracepoint sample " ) ;