marker-example.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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, "integer %d string %s", 123,
  19. "example string");
  20. for (i = 0; i < 10; i++)
  21. trace_mark(subsystem_eventb, MARK_NOARGS);
  22. return -EPERM;
  23. }
  24. static struct file_operations mark_ops = {
  25. .open = my_open,
  26. };
  27. static int __init example_init(void)
  28. {
  29. printk(KERN_ALERT "example init\n");
  30. pentry_example = proc_create("marker-example", 0444, NULL, &mark_ops);
  31. if (!pentry_example)
  32. return -EPERM;
  33. return 0;
  34. }
  35. static void __exit example_exit(void)
  36. {
  37. printk(KERN_ALERT "example exit\n");
  38. remove_proc_entry("marker-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("Marker example");