From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 08/10] trace-cmd library: Use the new flow when creating output handler
Date: Fri, 8 Oct 2021 07:13:19 +0300 [thread overview]
Message-ID: <20211008041321.973755-9-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20211008041321.973755-1-tz.stoyanov@gmail.com>
The trace-cmd library APIs, that create a new output handler to a trace
file, are converted to use the newly introduced APIs. Affected are:
tracecmd_create_file_latency()
tracecmd_create_init_fd()
tracecmd_create_init_file()
tracecmd_copy()
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
lib/trace-cmd/trace-output.c | 54 ++++++++++++++++++++++++++++++++----
1 file changed, 48 insertions(+), 6 deletions(-)
diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
index f8a16d82..9ea85b1c 100644
--- a/lib/trace-cmd/trace-output.c
+++ b/lib/trace-cmd/trace-output.c
@@ -1503,11 +1503,19 @@ struct tracecmd_output *tracecmd_create_file_latency(const char *output_file, in
{
struct tracecmd_output *handle;
char *path;
+ int fd;
- handle = create_file(output_file, NULL, NULL, NULL, &all_event_list);
- if (!handle)
+ fd = open(output_file, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, 0644);
+ if (fd < 0)
return NULL;
+ handle = tracecmd_output_allocate(fd);
+ if (!handle)
+ goto out_free;
+ if (tracecmd_output_write_init(handle))
+ goto out_free;
+ if (tracecmd_output_write_headers(handle, NULL))
+ goto out_free;
/*
* Save the command lines;
*/
@@ -1801,7 +1809,20 @@ struct tracecmd_output *tracecmd_get_output_handle_fd(int fd)
struct tracecmd_output *tracecmd_create_init_fd(int fd)
{
- return create_file_fd(fd, NULL, NULL, NULL, &all_event_list, NULL);
+ struct tracecmd_output *out;
+
+ out = tracecmd_output_allocate(fd);
+ if (!out)
+ return NULL;
+ if (tracecmd_output_write_init(out))
+ goto error;
+ if (tracecmd_output_write_headers(out, NULL))
+ goto error;
+
+ return out;
+error:
+ tracecmd_output_close(out);
+ return NULL;
}
struct tracecmd_output *
@@ -1826,7 +1847,20 @@ tracecmd_create_init_file_glob(const char *output_file,
struct tracecmd_output *tracecmd_create_init_file(const char *output_file)
{
- return create_file(output_file, NULL, NULL, NULL, &all_event_list);
+ struct tracecmd_output *handle;
+ int fd;
+
+ fd = open(output_file, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, 0644);
+ if (fd < 0)
+ return NULL;
+ handle = tracecmd_create_init_fd(fd);
+ if (!handle) {
+ close(fd);
+ unlink(output_file);
+ return NULL;
+ }
+
+ return handle;
}
struct tracecmd_output *tracecmd_create_init_file_override(const char *output_file,
@@ -1849,11 +1883,19 @@ struct tracecmd_output *tracecmd_copy(struct tracecmd_input *ihandle,
const char *file)
{
struct tracecmd_output *handle;
+ int fd;
- handle = create_file(file, ihandle, NULL, NULL, &all_event_list);
- if (!handle)
+ fd = open(file, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, 0644);
+ if (fd < 0)
return NULL;
+ handle = tracecmd_output_allocate(fd);
+ if (!handle)
+ goto out_free;
+ if (tracecmd_output_set_from_input(handle, ihandle))
+ goto out_free;
+ tracecmd_output_write_init(handle);
+
if (tracecmd_copy_headers(ihandle, handle->fd, 0, 0) < 0)
goto out_free;
--
2.31.1
next prev parent reply other threads:[~2021-10-08 4:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-08 4:13 [PATCH 00/10] Refactor APIs for creating output handler Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 01/10] trace-cmd library: New API for allocating an " Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 02/10] trace-cmd library: New API for setting a message context to " Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 03/10] trace-cmd library: New API for setting a custom trace directory " Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 04/10] trace-cmd library: New API for setting a custom kallsyms " Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 05/10] trace-cmd library: New API to inherit parameters from an existing trace file Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 06/10] trace-cmd library: New API tracecmd_output_write_init Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 07/10] trace-cmd library: New API to write headers of a trace file Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` Tzvetomir Stoyanov (VMware) [this message]
2021-10-08 4:13 ` [PATCH 09/10] trace-cmd: Use the new flow when creating output handler Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 10/10] trace-cmd library: Remove deprecated APIs for creating an " 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=20211008041321.973755-9-tz.stoyanov@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).