tracepoint-sample.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* tracepoint-sample.c
  2. *
  3. * Executes a tracepoint when /proc/tracepoint-example is opened.
  4. *
  5. * (C) Copyright 2007 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
  6. *
  7. * This file is released under the GPLv2.
  8. * See the file COPYING for more details.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/sched.h>
  12. #include <linux/proc_fs.h>
  13. #include "tp-samples-trace.h"
  14. struct proc_dir_entry *pentry_example;
  15. static int my_open(struct inode *inode, struct file *file)
  16. {
  17. int i;
  18. trace_subsys_event(inode, file);
  19. for (i = 0; i < 10; i++)
  20. trace_subsys_eventb();
  21. return -EPERM;
  22. }
  23. static struct file_operations mark_ops = {
  24. .open = my_open,
  25. };
  26. static int example_init(void)
  27. {
  28. printk(KERN_ALERT "example init\n");
  29. pentry_example = proc_create("tracepoint-example", 0444, NULL,
  30. &mark_ops);
  31. if (!pentry_example)
  32. return -EPERM;
  33. return 0;
  34. }
  35. static void example_exit(void)
  36. {
  37. printk(KERN_ALERT "example exit\n");
  38. remove_proc_entry("tracepoint-example", NULL);
  39. }
  40. module_init(example_init)
  41. module_exit(example_exit)
  42. MODULE_LICENSE("GPL");
  43. MODULE_AUTHOR("Mathieu Desnoyers");
  44. MODULE_DESCRIPTION("Tracepoint example");