Re: [PATCH 2/2] trace-cmd: Check if ftrace file exists, before writing in it.

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

 



On Fri, 18 Oct 2019 17:57:59 +0300
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote:

> ---
>  tracecmd/trace-record.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
> index 81aca1f..c65731f 100644
> --- a/tracecmd/trace-record.c
> +++ b/tracecmd/trace-record.c
> @@ -813,11 +813,14 @@ static int
>  write_instance_file(struct buffer_instance *instance,
>  		    const char *file, const char *str, const char *type)
>  {
> +	struct stat st;
>  	char *path;
>  	int ret;
>  
>  	path = get_instance_file(instance, file);
> -	ret = write_file(path, str, type);
> +	ret = stat(path, &st);

This is fine for now, but perhaps in the future we should check if it
is writable by the user. Hmm, we could move that check to the
write_file() itself. But that will require changing other locations
that expect write_file() to die. Which in the long run, we want to
remove that assumption.

Thanks for the patch, I just applied it.

-- Steve

> +	if (ret == 0)
> +		ret = write_file(path, str, type);
>  	tracecmd_put_tracing_file(path);
>  
>  	return ret;




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux