提交 0588fa30 编写于 作者: S Steven Rostedt 提交者: Steven Rostedt

tracing: Convert trace_printk() formats for module to const char *

The trace_printk() formats for modules do not show up in the
debugfs/tracing/printk_formats file. Only the formats that are
for trace_printk()s that are in the kernel core.

To facilitate the change to add trace_printk() formats from modules
into that file as well, we need to convert the structure that
holds the formats from char fmt[], into const char *fmt,
and allocate them separately.
Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
上级 176fcc5c
...@@ -32,7 +32,7 @@ static DEFINE_MUTEX(btrace_mutex); ...@@ -32,7 +32,7 @@ static DEFINE_MUTEX(btrace_mutex);
struct trace_bprintk_fmt { struct trace_bprintk_fmt {
struct list_head list; struct list_head list;
char fmt[0]; const char *fmt;
}; };
static inline struct trace_bprintk_fmt *lookup_format(const char *fmt) static inline struct trace_bprintk_fmt *lookup_format(const char *fmt)
...@@ -49,6 +49,7 @@ static ...@@ -49,6 +49,7 @@ static
void hold_module_trace_bprintk_format(const char **start, const char **end) void hold_module_trace_bprintk_format(const char **start, const char **end)
{ {
const char **iter; const char **iter;
char *fmt;
mutex_lock(&btrace_mutex); mutex_lock(&btrace_mutex);
for (iter = start; iter < end; iter++) { for (iter = start; iter < end; iter++) {
...@@ -58,15 +59,19 @@ void hold_module_trace_bprintk_format(const char **start, const char **end) ...@@ -58,15 +59,19 @@ void hold_module_trace_bprintk_format(const char **start, const char **end)
continue; continue;
} }
tb_fmt = kmalloc(offsetof(struct trace_bprintk_fmt, fmt) tb_fmt = kmalloc(sizeof(*tb_fmt), GFP_KERNEL);
+ strlen(*iter) + 1, GFP_KERNEL); if (tb_fmt)
if (tb_fmt) { fmt = kmalloc(strlen(*iter) + 1, GFP_KERNEL);
if (tb_fmt && fmt) {
list_add_tail(&tb_fmt->list, &trace_bprintk_fmt_list); list_add_tail(&tb_fmt->list, &trace_bprintk_fmt_list);
strcpy(tb_fmt->fmt, *iter); strcpy(fmt, *iter);
tb_fmt->fmt = fmt;
*iter = tb_fmt->fmt; *iter = tb_fmt->fmt;
} else } else {
kfree(tb_fmt);
*iter = NULL; *iter = NULL;
} }
}
mutex_unlock(&btrace_mutex); mutex_unlock(&btrace_mutex);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册