tracepoint-probe-sample2.c 963 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * tracepoint-probe-sample2.c
  3. *
  4. * 2nd sample tracepoint probes.
  5. */
  6. #include <linux/module.h>
  7. #include <linux/fs.h>
  8. #include "tp-samples-trace.h"
  9. /*
  10. * Here the caller only guarantees locking for struct file and struct inode.
  11. * Locking must therefore be done in the probe to use the dentry.
  12. */
  13. static void probe_subsys_event(void *ignore,
  14. struct inode *inode, struct file *file)
  15. {
  16. printk(KERN_INFO "Event is encountered with inode number %lu\n",
  17. inode->i_ino);
  18. }
  19. static int __init tp_sample_trace_init(void)
  20. {
  21. int ret;
  22. ret = register_trace_subsys_event(probe_subsys_event, NULL);
  23. WARN_ON(ret);
  24. return 0;
  25. }
  26. module_init(tp_sample_trace_init);
  27. static void __exit tp_sample_trace_exit(void)
  28. {
  29. unregister_trace_subsys_event(probe_subsys_event, NULL);
  30. tracepoint_synchronize_unregister();
  31. }
  32. module_exit(tp_sample_trace_exit);
  33. MODULE_LICENSE("GPL");
  34. MODULE_AUTHOR("Mathieu Desnoyers");
  35. MODULE_DESCRIPTION("Tracepoint Probes Samples");