marker-example.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* marker-example.c
  2. *
  3. * Executes a marker when /proc/marker-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/marker.h>
  12. #include <linux/sched.h>
  13. #include <linux/proc_fs.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_mark(subsystem_event, "%d %s", 123, "example string");
  19. for (i = 0; i < 10; i++)
  20. trace_mark(subsystem_eventb, MARK_NOARGS);
  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 = create_proc_entry("marker-example", 0444, NULL);
  30. if (pentry_example)
  31. pentry_example->proc_fops = &mark_ops;
  32. else
  33. return -EPERM;
  34. return 0;
  35. }
  36. static void example_exit(void)
  37. {
  38. printk(KERN_ALERT "example exit\n");
  39. remove_proc_entry("marker-example", NULL);
  40. }
  41. module_init(example_init)
  42. module_exit(example_exit)
  43. MODULE_LICENSE("GPL");
  44. MODULE_AUTHOR("Mathieu Desnoyers");
  45. MODULE_DESCRIPTION("Marker example");