linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH v4.1 - 5.1/8] libtracefs: Use the permissions of the instances directory for instances
Date: Thu, 19 Nov 2020 17:07:38 +0200	[thread overview]
Message-ID: <CAPpZLN6=TvMukE67QK_3UK-3eU8t3QqDG0y26DnzT=wpsivxDw@mail.gmail.com> (raw)
In-Reply-To: <20201118164611.007c6900@oasis.local.home>

On Wed, Nov 18, 2020 at 11:46 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
>
> Use the same permissions of the instances directory for the permissions of
> creating a new instance.
>
> Link: https://lore.kernel.org/linux-trace-devel/20201117074557.180602-6-tz.stoyanov@gmail.com
>
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
>  lib/tracefs/tracefs-instance.c | 28 +++++++++++++++++++++++++---
>  1 file changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/lib/tracefs/tracefs-instance.c b/lib/tracefs/tracefs-instance.c
> index 06f33c35..13ec4f5f 100644
> --- a/lib/tracefs/tracefs-instance.c
> +++ b/lib/tracefs/tracefs-instance.c
> @@ -57,6 +57,25 @@ void tracefs_instance_free(struct tracefs_instance *instance)
>         free(instance);
>  }
>
> +static mode_t get_trace_file_permissions(char *name)
> +{
> +       mode_t rmode = 0;
> +       struct stat st;
> +       char *path;
> +       int ret;
> +
> +       path = tracefs_get_tracing_file(name);
> +       if (!path)
> +               return 0;
> +       ret = stat(path, &st);
> +       if (ret)
> +               goto out;
> +       rmode = st.st_mode & ACCESSPERMS;
> +out:
> +       tracefs_put_tracing_file(path);
> +       return rmode;
> +}
> +
>  /**
>   * tracefs_instance_create - Create a new ftrace instance
>   * @instance: Pointer to the instance to be created
> @@ -67,15 +86,18 @@ void tracefs_instance_free(struct tracefs_instance *instance)
>  int tracefs_instance_create(struct tracefs_instance *instance)
>  {
>         struct stat st;
> +       mode_t mode;
>         char *path;
>         int ret;
>
>         path = tracefs_instance_get_dir(instance);
>         ret = stat(path, &st);
> -       if (ret < 0)
> -               ret = mkdir(path, 0777);
> -       else
> +       if (ret < 0) {
> +               mode = get_trace_file_permissions("instances");
> +               ret = mkdir(path, mode);
> +       } else {
>                 ret = 1;
> +       }
>         tracefs_put_tracing_file(path);
>         return ret;
>  }
> --
> 2.25.4
>
I'm OK with that split.
Thanks, Steven!

Acked-by: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>

-- 
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center

  reply	other threads:[~2020-11-19 15:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17  7:45 [PATCH v4 0/8] libtracefs fixes and improvements Tzvetomir Stoyanov (VMware)
2020-11-17  7:45 ` [PATCH v4 1/8] trace-cmd: Change tracefs.h include path Tzvetomir Stoyanov (VMware)
2020-11-17  7:45 ` [PATCH v4 2/8] libtracefs: Change get name API to return constant string Tzvetomir Stoyanov (VMware)
2020-11-17  7:45 ` [PATCH v4 3/8] libtracefs: Use tracefs_list_free() API Tzvetomir Stoyanov (VMware)
2020-11-17  7:45 ` [PATCH v4 4/8] libtracefs: Add new API to check if instance exists Tzvetomir Stoyanov (VMware)
2020-11-17  7:45 ` [PATCH v4 5/8] libtracefs: Combine allocate and create APIs into one Tzvetomir Stoyanov (VMware)
2020-11-18 21:44   ` Steven Rostedt
2020-11-18 21:46     ` [PATCH v4.1 - 5.1/8] libtracefs: Use the permissions of the instances directory for instances Steven Rostedt
2020-11-19 15:07       ` Tzvetomir Stoyanov [this message]
2020-11-18 21:46     ` [PATCH v4.1 5.2/8] libtracefs: Combine allocate and create APIs into one Steven Rostedt
2020-11-17  7:45 ` [PATCH v4 6/8] libtracefs: Add new tracefs API tracefs_instances_walk() Tzvetomir Stoyanov (VMware)
2020-11-17  7:45 ` [PATCH v4 7/8] trace-cmd: Add new libtrasefs API to get the current trace clock Tzvetomir Stoyanov (VMware)
2020-11-17  7:45 ` [PATCH v4 8/8] libtracefs: Hide non API functions Tzvetomir Stoyanov (VMware)

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='CAPpZLN6=TvMukE67QK_3UK-3eU8t3QqDG0y26DnzT=wpsivxDw@mail.gmail.com' \
    --to=tz.stoyanov@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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).