| Mathieu Desnoyers | 4a08975 | 2008-07-18 12:16:16 -0400 | [diff] [blame] | 1 | /* | 
|  | 2 | * tracepoint-probe-sample.c | 
|  | 3 | * | 
|  | 4 | * sample tracepoint probes. | 
|  | 5 | */ | 
|  | 6 |  | 
|  | 7 | #include <linux/module.h> | 
|  | 8 | #include <linux/file.h> | 
|  | 9 | #include <linux/dcache.h> | 
|  | 10 | #include "tp-samples-trace.h" | 
|  | 11 |  | 
|  | 12 | /* | 
|  | 13 | * Here the caller only guarantees locking for struct file and struct inode. | 
|  | 14 | * Locking must therefore be done in the probe to use the dentry. | 
|  | 15 | */ | 
|  | 16 | static void probe_subsys_event(struct inode *inode, struct file *file) | 
|  | 17 | { | 
|  | 18 | path_get(&file->f_path); | 
|  | 19 | dget(file->f_path.dentry); | 
|  | 20 | printk(KERN_INFO "Event is encountered with filename %s\n", | 
|  | 21 | file->f_path.dentry->d_name.name); | 
|  | 22 | dput(file->f_path.dentry); | 
|  | 23 | path_put(&file->f_path); | 
|  | 24 | } | 
|  | 25 |  | 
|  | 26 | static void probe_subsys_eventb(void) | 
|  | 27 | { | 
|  | 28 | printk(KERN_INFO "Event B is encountered\n"); | 
|  | 29 | } | 
|  | 30 |  | 
| Qinghuang Feng | 7ec7fb3 | 2009-01-06 14:40:52 -0800 | [diff] [blame] | 31 | static int __init tp_sample_trace_init(void) | 
| Mathieu Desnoyers | 4a08975 | 2008-07-18 12:16:16 -0400 | [diff] [blame] | 32 | { | 
|  | 33 | int ret; | 
|  | 34 |  | 
|  | 35 | ret = register_trace_subsys_event(probe_subsys_event); | 
|  | 36 | WARN_ON(ret); | 
|  | 37 | ret = register_trace_subsys_eventb(probe_subsys_eventb); | 
|  | 38 | WARN_ON(ret); | 
|  | 39 |  | 
|  | 40 | return 0; | 
|  | 41 | } | 
|  | 42 |  | 
|  | 43 | module_init(tp_sample_trace_init); | 
|  | 44 |  | 
| Qinghuang Feng | 7ec7fb3 | 2009-01-06 14:40:52 -0800 | [diff] [blame] | 45 | static void __exit tp_sample_trace_exit(void) | 
| Mathieu Desnoyers | 4a08975 | 2008-07-18 12:16:16 -0400 | [diff] [blame] | 46 | { | 
|  | 47 | unregister_trace_subsys_eventb(probe_subsys_eventb); | 
|  | 48 | unregister_trace_subsys_event(probe_subsys_event); | 
| Mathieu Desnoyers | 2504ea5 | 2008-11-14 17:47:41 -0500 | [diff] [blame] | 49 | tracepoint_synchronize_unregister(); | 
| Mathieu Desnoyers | 4a08975 | 2008-07-18 12:16:16 -0400 | [diff] [blame] | 50 | } | 
|  | 51 |  | 
|  | 52 | module_exit(tp_sample_trace_exit); | 
|  | 53 |  | 
|  | 54 | MODULE_LICENSE("GPL"); | 
|  | 55 | MODULE_AUTHOR("Mathieu Desnoyers"); | 
|  | 56 | MODULE_DESCRIPTION("Tracepoint Probes Samples"); |