Path: blob/master/samples/tracepoints/tracepoint-probe-sample.c
10818 views
/*1* tracepoint-probe-sample.c2*3* sample tracepoint probes.4*/56#include <linux/module.h>7#include <linux/file.h>8#include <linux/dcache.h>9#include "tp-samples-trace.h"1011/*12* Here the caller only guarantees locking for struct file and struct inode.13* Locking must therefore be done in the probe to use the dentry.14*/15static void probe_subsys_event(void *ignore,16struct inode *inode, struct file *file)17{18path_get(&file->f_path);19dget(file->f_path.dentry);20printk(KERN_INFO "Event is encountered with filename %s\n",21file->f_path.dentry->d_name.name);22dput(file->f_path.dentry);23path_put(&file->f_path);24}2526static void probe_subsys_eventb(void *ignore)27{28printk(KERN_INFO "Event B is encountered\n");29}3031static int __init tp_sample_trace_init(void)32{33int ret;3435ret = register_trace_subsys_event(probe_subsys_event, NULL);36WARN_ON(ret);37ret = register_trace_subsys_eventb(probe_subsys_eventb, NULL);38WARN_ON(ret);3940return 0;41}4243module_init(tp_sample_trace_init);4445static void __exit tp_sample_trace_exit(void)46{47unregister_trace_subsys_eventb(probe_subsys_eventb, NULL);48unregister_trace_subsys_event(probe_subsys_event, NULL);49tracepoint_synchronize_unregister();50}5152module_exit(tp_sample_trace_exit);5354MODULE_LICENSE("GPL");55MODULE_AUTHOR("Mathieu Desnoyers");56MODULE_DESCRIPTION("Tracepoint Probes Samples");575859