From: Steven Rostedt <rostedt@goodmis.org>
To: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v3 4/6] libtracefs: Combine allocate and create APIs into one
Date: Thu, 12 Nov 2020 14:14:30 -0500 [thread overview]
Message-ID: <20201112141430.3e8d03e8@gandalf.local.home> (raw)
In-Reply-To: <20201112091109.1239169-5-tz.stoyanov@gmail.com>
On Thu, 12 Nov 2020 11:11:07 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:
> +struct tracefs_instance *tracefs_instance_create(const char *name)
> {
> + struct tracefs_instance *inst = NULL;
> struct stat st;
> char *path;
> int ret;
>
> - path = tracefs_instance_get_dir(instance);
> + inst = instance_alloc(name);
> + if (!inst)
> + return NULL;
> +
> + path = tracefs_instance_get_dir(inst);
> ret = stat(path, &st);
> - if (ret < 0)
> - ret = mkdir(path, 0777);
> - else
> - ret = 1;
> + if (ret < 0) {
> + /* Cannot create the top instance, if it does not exist! */
> + if (!name)
> + goto error;
> + if (mkdir(path, 0777))
Not something you have to address now (but perhaps add a new patch?).
This should not be 0777, but instead be a macro, and define it as 0770, or
possibly even look at the permissions of the top level and use whatever
that is set as?
Again, this doesn't affect this series, but something we should change in
the near future.
-- Steve
> + goto error;
> + inst->flags |= FLAG_INSTANCE_NEWLY_CREATED;
> + }
> tracefs_put_tracing_file(path);
> - return ret;
> + return inst;
> +
> +error:
> + tracefs_instance_free(inst);
> + return NULL;
> }
>
next prev parent reply other threads:[~2020-11-12 19:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-12 9:11 [PATCH v3 0/6] libtracefs fixes and improvements Tzvetomir Stoyanov (VMware)
2020-11-12 9:11 ` [PATCH v3 1/6] trace-cmd: Change tracefs.h include path Tzvetomir Stoyanov (VMware)
2020-11-12 9:11 ` [PATCH v3 2/6] libtracefs: Change get name API to return constant string Tzvetomir Stoyanov (VMware)
2020-11-12 19:10 ` Steven Rostedt
2020-11-12 9:11 ` [PATCH v3 3/6] libtracefs: Add new API to check if instance exists Tzvetomir Stoyanov (VMware)
2020-11-12 9:11 ` [PATCH v3 4/6] libtracefs: Combine allocate and create APIs into one Tzvetomir Stoyanov (VMware)
2020-11-12 19:14 ` Steven Rostedt [this message]
2020-11-12 9:11 ` [PATCH v3 5/6] libtracefs: Add new tracefs API tracefs_instances_walk() Tzvetomir Stoyanov (VMware)
2020-11-12 19:17 ` Steven Rostedt
2020-11-12 9:11 ` [PATCH v3 6/6] trace-cmd: Add new libtrasefs API to get the current trace clock Tzvetomir Stoyanov (VMware)
2020-11-12 19:23 ` Steven Rostedt
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=20201112141430.3e8d03e8@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).