linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH 2/2] trace-cmd: Check if ftrace file exists, before writing in it.
Date: Fri, 18 Oct 2019 11:18:42 -0400	[thread overview]
Message-ID: <20191018111842.6217f8f8@gandalf.local.home> (raw)
In-Reply-To: <20191018145759.15335-2-tz.stoyanov@gmail.com>

On Fri, 18 Oct 2019 17:57:59 +0300
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> 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;


  reply	other threads:[~2019-10-18 15:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18 14:57 [PATCH 1/2] trace-cmd: Fix a crash on "trace-cmd reset" command Tzvetomir Stoyanov (VMware)
2019-10-18 14:57 ` [PATCH 2/2] trace-cmd: Check if ftrace file exists, before writing in it Tzvetomir Stoyanov (VMware)
2019-10-18 15:18   ` Steven Rostedt [this message]
2019-10-18 15:20   ` Valentin Schneider

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191018111842.6217f8f8@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=tz.stoyanov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).