Re: [PATCH v4 01/11] tracing: Add tracing error log

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Tom,

On Fri, 22 Mar 2019 10:34:27 -0500
Tom Zanussi <zanussi@xxxxxxxxxx> wrote:

> +static int tracing_err_log_open(struct inode *inode, struct file *file)
> +{
> +	if (file->f_mode & FMODE_WRITE) {
> +		if (file->f_flags & O_TRUNC)
> +			return 0;
> +		else
> +			return -EINVAL;
> +	}
> +
> +	return seq_open(file, &tracing_err_log_seq_ops);
> +}
> +
> +static ssize_t tracing_err_log_write(struct file *file,
> +				     const char __user *buffer,
> +				     size_t count, loff_t *ppos)
> +{
> +	if (count == 1)
> +		clear_tracing_err_log();
> +	else
> +		return -EINVAL;
> +
> +	*ppos += count;
> +
> +	return count;
> +}

Hmm, could you make this as same as "tracing/trace"?
- It clears buffer at open with WRITE & TRUNC flag
- It just ignore how much user wrote (works as /dev/null)

See tracing_open() and tracing_write_stub() in
kernel/trace/trace.c.

Thank you,


> +
> +static const struct file_operations tracing_err_log_fops = {
> +	.open           = tracing_err_log_open,
> +	.write		= tracing_err_log_write,
> +	.read           = seq_read,
> +	.llseek         = seq_lseek,
> +};
> +
>  static int tracing_buffers_open(struct inode *inode, struct file *filp)
>  {
>  	struct trace_array *tr = inode->i_private;
> @@ -8258,6 +8478,9 @@ init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)
>  			  tr, &snapshot_fops);
>  #endif
>  
> +	trace_create_file("error_log", 0644, d_tracer,
> +			  tr, &tracing_err_log_fops);
> +
>  	for_each_tracing_cpu(cpu)
>  		tracing_init_tracefs_percpu(tr, cpu);
>  
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index d80cee49e0eb..b711edbef7e7 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -1884,6 +1884,10 @@ extern ssize_t trace_parse_run_command(struct file *file,
>  		const char __user *buffer, size_t count, loff_t *ppos,
>  		int (*createfn)(int, char**));
>  
> +extern unsigned int err_pos(char *cmd, const char *str);
> +extern void tracing_log_err(const char *loc, const char *cmd,
> +			    const char **errs, u8 type, u8 pos);
> +
>  /*
>   * Normal trace_printk() and friends allocates special buffers
>   * to do the manipulation, as well as saves the print formats
> -- 
> 2.14.1
> 


-- 
Masami Hiramatsu <mhiramat@xxxxxxxxxx>



[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux