From patchwork Thu Oct 1 08:59:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Donnefort X-Patchwork-Id: 11811199 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AF6D6CB for ; Thu, 1 Oct 2020 08:59:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A5642137B for ; Thu, 1 Oct 2020 08:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731365AbgJAI7g (ORCPT ); Thu, 1 Oct 2020 04:59:36 -0400 Received: from foss.arm.com ([217.140.110.172]:56428 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725894AbgJAI7g (ORCPT ); Thu, 1 Oct 2020 04:59:36 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 91FE4D6E; Thu, 1 Oct 2020 01:59:35 -0700 (PDT) Received: from e120877-lin.cambridge.arm.com (e120877-lin.cambridge.arm.com [10.1.194.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id ED9F43F70D; Thu, 1 Oct 2020 01:59:34 -0700 (PDT) From: vincent.donnefort@arm.com To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Vincent Donnefort Subject: [PATCH v2] trace-cmd: Fix "trace-cmd extract" temp files path Date: Thu, 1 Oct 2020 09:59:29 +0100 Message-Id: <1601542769-443324-1-git-send-email-vincent.donnefort@arm.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: Vincent Donnefort 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 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);