Path: blob/master/samples/tracepoints/tracepoint-sample.c
10818 views
/* tracepoint-sample.c1*2* Executes a tracepoint when /proc/tracepoint-sample is opened.3*4* (C) Copyright 2007 Mathieu Desnoyers <[email protected]>5*6* This file is released under the GPLv2.7* See the file COPYING for more details.8*/910#include <linux/module.h>11#include <linux/sched.h>12#include <linux/proc_fs.h>13#include "tp-samples-trace.h"1415DEFINE_TRACE(subsys_event);16DEFINE_TRACE(subsys_eventb);1718struct proc_dir_entry *pentry_sample;1920static int my_open(struct inode *inode, struct file *file)21{22int i;2324trace_subsys_event(inode, file);25for (i = 0; i < 10; i++)26trace_subsys_eventb();27return -EPERM;28}2930static const struct file_operations mark_ops = {31.open = my_open,32.llseek = noop_llseek,33};3435static int __init sample_init(void)36{37printk(KERN_ALERT "sample init\n");38pentry_sample = proc_create("tracepoint-sample", 0444, NULL,39&mark_ops);40if (!pentry_sample)41return -EPERM;42return 0;43}4445static void __exit sample_exit(void)46{47printk(KERN_ALERT "sample exit\n");48remove_proc_entry("tracepoint-sample", NULL);49}5051module_init(sample_init)52module_exit(sample_exit)5354MODULE_LICENSE("GPL");55MODULE_AUTHOR("Mathieu Desnoyers");56MODULE_DESCRIPTION("Tracepoint sample");575859