Linux-Trace-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] trace-cmd: Fix "trace-cmd extract" temp files path
@ 2020-10-01  8:59 vincent.donnefort
  2020-10-01 16:30 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: vincent.donnefort @ 2020-10-01  8:59 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, Vincent Donnefort

From: Vincent Donnefort <vincent.donnefort@arm.com>

During the introduction of instance's output_file copy:

  3a206ca ("trace-cmd: Have instances include a copy of its output file")

The extract path has been omitted, causing the temp files created to be
written in the same directory using the null "output_file" of the
instance, to create "(null).cpuX" files. If this is executed in a
directory that is not writable (like /sys/kernel/tracing) or does not
have enough space to hold the temp files, then it will fail to write.

Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>

diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index bd00457..72a5c8c 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -6622,6 +6622,9 @@ void trace_extract(int argc, char **argv)
 
 	/* Save the state of tracing_on before starting */
 	for_all_instances(instance) {
+		instance->output_file = strdup(ctx.output);
+		if (!instance->output_file)
+			die("Failed to allocate output file name for instance");
 
 		if (!ctx.manual && instance->flags & BUFFER_FL_PROFILE)
 			enable_profile(ctx.instance);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] trace-cmd: Fix "trace-cmd extract" temp files path
  2020-10-01  8:59 [PATCH v2] trace-cmd: Fix "trace-cmd extract" temp files path vincent.donnefort
@ 2020-10-01 16:30 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2020-10-01 16:30 UTC (permalink / raw)
  To: vincent.donnefort; +Cc: linux-trace-devel

On Thu,  1 Oct 2020 09:59:29 +0100
vincent.donnefort@arm.com wrote:

> From: Vincent Donnefort <vincent.donnefort@arm.com>
> 
> During the introduction of instance's output_file copy:
> 
>   3a206ca ("trace-cmd: Have instances include a copy of its output file")
> 
> The extract path has been omitted, causing the temp files created to be
> written in the same directory using the null "output_file" of the
> instance, to create "(null).cpuX" files. If this is executed in a
> directory that is not writable (like /sys/kernel/tracing) or does not
> have enough space to hold the temp files, then it will fail to write.
> 
> Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
> 
> diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
> index bd00457..72a5c8c 100644
> --- a/tracecmd/trace-record.c
> +++ b/tracecmd/trace-record.c
> @@ -6622,6 +6622,9 @@ void trace_extract(int argc, char **argv)
>  
>  	/* Save the state of tracing_on before starting */
>  	for_all_instances(instance) {
> +		instance->output_file = strdup(ctx.output);
> +		if (!instance->output_file)
> +			die("Failed to allocate output file name for instance");
>  
>  		if (!ctx.manual && instance->flags & BUFFER_FL_PROFILE)
>  			enable_profile(ctx.instance);

Applied. Thanks Vincent!

-- Steve

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01  8:59 [PATCH v2] trace-cmd: Fix "trace-cmd extract" temp files path vincent.donnefort
2020-10-01 16:30 ` Steven Rostedt

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org
	public-inbox-index linux-trace-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git