Re: [RFC][PATCH 2/2] [PATCH 2/2] tracing: Make event basedtrace_printk()

From: Steven Rostedt
Date: Wed Nov 17 2010 - 23:19:44 EST


On Wed, 2010-11-17 at 22:58 -0500, Steven Rostedt wrote:

> +static __init int event_printk_init(void)
> +{
> + struct event_printk_struct *print;
> + struct dentry *d_events;
> + char *topdir;
> + char *p;
> + int len;
> + int ret = -1;
> +
> + /*
> + * Do nothing if we have no trace printks.
> + * May change in the future when we support modules.
> + */
> + if (__start_trace_printk == __stop_trace_printk)
> + return 0;
> +
> + /*
> + * Use this file to find the path for other
> + * files. That is, __FILE__ returns the full path,
> + * but we don't want the top dir path, so we must
> + * chop it off. We know the path of this file as it
> + * is (kernel/trace/event_printk.c), so we simply
> + * cut that off and then we have the path to cut
> + * off of other files.
> + */
> + topdir = kstrdup(__FILE__, GFP_KERNEL);
> + if (WARN(!topdir, "failed to allocate printk info"))
> + return -1;
> +
> + p = strstr(topdir, "kernel/trace/event_printk.c");
> + if (WARN(!p, "event_printk.c not found. Did the file move?"))
> + goto out;
> + *p = '\0';
> +
> + d_events = event_trace_events_dir();
> +
> + printk_root = debugfs_create_dir("printk", d_events);
> + if (WARN(!printk_root, "Could not create printk entry"))
> + goto out;
> +
> + trace_create_file("enable", 0644, printk_root,
> + NULL, &trace_printk_enable_fops);
> +
> + len = strlen(topdir);
> + for_each_printk(print, __start_trace_printk, __stop_trace_printk)
> + add_event_printk(topdir, len, print);

Oops, I'm missing a:

ret = 0;

here.

-- Steve

> +
> + out:
> + kfree(topdir);
> + return ret;
> +}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/