lkml.org 
[lkml]   [2008]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 3/3] TEST PATCH - ftrace example patch for use of trace pipe headers
DO NOT APPLY THIS PATCH!!!!!

This is an example of implementing a plugin for header for the trace_pipe
file.

DO NOT APPLY THIS PATCH!!!!!

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/trace_functions.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)

Index: linux-sched-devel.git/kernel/trace/trace_functions.c
===================================================================
--- linux-sched-devel.git.orig/kernel/trace/trace_functions.c 2008-04-21 16:50:49.000000000 -0400
+++ linux-sched-devel.git/kernel/trace/trace_functions.c 2008-04-21 16:54:55.000000000 -0400
@@ -16,6 +16,45 @@

#include "trace.h"

+static void function_pipe_open(struct trace_iterator *iter)
+{
+ int *traceme;
+
+ traceme = kzalloc(sizeof(int), GFP_KERNEL);
+ if (!traceme)
+ return;
+
+ iter->private = traceme;
+}
+
+static ssize_t function_read(struct trace_iterator *iter,
+ struct file *filp, char __user *ubuf,
+ size_t cnt, loff_t *ppos)
+{
+ unsigned char head[] = "Test header\n";
+ int *traced;
+ int ret;
+
+ if (!iter->private)
+ return 0;
+
+ traced = iter->private;
+ if (*traced >= sizeof(head)-1)
+ return 0;
+
+ if (cnt > sizeof(head)-1)
+ cnt = sizeof(head)-1;
+
+ ret = copy_to_user(ubuf, head + *traced, cnt);
+
+ *traced += cnt;
+
+ if (ret)
+ cnt = -EFAULT;
+
+ return cnt;
+}
+
static void function_reset(struct trace_array *tr)
{
int cpu;
@@ -68,6 +107,8 @@ static struct tracer function_trace __re
#ifdef CONFIG_FTRACE_SELFTEST
.selftest = trace_selftest_startup_function,
#endif
+ .pipe_open = function_pipe_open,
+ .read = function_read,
};

static __init int init_function_trace(void)
--


\
 
 \ /
  Last update: 2008-04-21 23:23    [W:3.586 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site