Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 177342
b: refs/heads/master
c: fdb372e
h: refs/heads/master
v: v3
  • Loading branch information
Li Zefan authored and Frederic Weisbecker committed Dec 13, 2009
1 parent c8a5f39 commit 174840b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 44 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 91baf6285be7282cfa487de92f836c50749dffb9
refs/heads/master: fdb372ed4cadbfe9dbba0e932a77d0523682e690
60 changes: 17 additions & 43 deletions trunk/kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2316,67 +2316,32 @@ static const struct file_operations tracing_cpumask_fops = {
.write = tracing_cpumask_write,
};

static ssize_t
tracing_trace_options_read(struct file *filp, char __user *ubuf,
size_t cnt, loff_t *ppos)
static int tracing_trace_options_show(struct seq_file *m, void *v)
{
struct tracer_opt *trace_opts;
u32 tracer_flags;
int len = 0;
char *buf;
int r = 0;
int i;


/* calculate max size */
for (i = 0; trace_options[i]; i++) {
len += strlen(trace_options[i]);
len += 3; /* "no" and newline */
}

mutex_lock(&trace_types_lock);
tracer_flags = current_trace->flags->val;
trace_opts = current_trace->flags->opts;

/*
* Increase the size with names of options specific
* of the current tracer.
*/
for (i = 0; trace_opts[i].name; i++) {
len += strlen(trace_opts[i].name);
len += 3; /* "no" and newline */
}

/* +1 for \0 */
buf = kmalloc(len + 1, GFP_KERNEL);
if (!buf) {
mutex_unlock(&trace_types_lock);
return -ENOMEM;
}

for (i = 0; trace_options[i]; i++) {
if (trace_flags & (1 << i))
r += sprintf(buf + r, "%s\n", trace_options[i]);
seq_printf(m, "%s\n", trace_options[i]);
else
r += sprintf(buf + r, "no%s\n", trace_options[i]);
seq_printf(m, "no%s\n", trace_options[i]);
}

for (i = 0; trace_opts[i].name; i++) {
if (tracer_flags & trace_opts[i].bit)
r += sprintf(buf + r, "%s\n",
trace_opts[i].name);
seq_printf(m, "%s\n", trace_opts[i].name);
else
r += sprintf(buf + r, "no%s\n",
trace_opts[i].name);
seq_printf(m, "no%s\n", trace_opts[i].name);
}
mutex_unlock(&trace_types_lock);

WARN_ON(r >= len + 1);

r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);

kfree(buf);
return r;
return 0;
}

/* Try to assign a tracer specific option */
Expand Down Expand Up @@ -2471,9 +2436,18 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
return cnt;
}

static int tracing_trace_options_open(struct inode *inode, struct file *file)
{
if (tracing_disabled)
return -ENODEV;
return single_open(file, tracing_trace_options_show, NULL);
}

static const struct file_operations tracing_iter_fops = {
.open = tracing_open_generic,
.read = tracing_trace_options_read,
.open = tracing_trace_options_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = tracing_trace_options_write,
};

Expand Down

0 comments on commit 174840b

Please sign in to comment.