From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755015AbbISOuT (ORCPT ); Sat, 19 Sep 2015 10:50:19 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:33648 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754822AbbISOuS (ORCPT ); Sat, 19 Sep 2015 10:50:18 -0400 Subject: Re: [PATCH] tools lib api fs: Store tracing mountpoint for better error message To: Jiri Olsa , Arnaldo Carvalho de Melo References: <1442674027-19427-1-git-send-email-jolsa@kernel.org> Cc: lkml , Ingo Molnar , Namhyung Kim , Peter Zijlstra , Matt Fleming , =?UTF-8?Q?Rapha=c3=abl_Beamonte?= From: David Ahern Message-ID: <55FD762B.4080607@gmail.com> Date: Sat, 19 Sep 2015 08:50:19 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442674027-19427-1-git-send-email-jolsa@kernel.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/19/15 8:47 AM, Jiri Olsa wrote: > diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c > index 38aca2dd1946..0406a7d5c891 100644 > --- a/tools/lib/api/fs/tracing_path.c > +++ b/tools/lib/api/fs/tracing_path.c > @@ -12,12 +12,14 @@ > #include "tracing_path.h" > > > +char tracing_mnt[PATH_MAX + 1] = "/sys/kernel/debug"; > char tracing_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing"; > char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events"; why all the +1s? null terminator has to fit within PATH_MAX as well. > > > static void __tracing_path_set(const char *tracing, const char *mountpoint) > { > + snprintf(tracing_mnt, sizeof(tracing_mnt), "%s", mountpoint); > snprintf(tracing_path, sizeof(tracing_path), "%s/%s", > mountpoint, tracing); > snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s", > @@ -109,19 +111,10 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename) > "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'"); > break; > case EACCES: { > - const char *mountpoint = debugfs__mountpoint(); > - > - if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) { > - const char *tracefs_mntpoint = tracefs__mountpoint(); > - > - if (tracefs_mntpoint) > - mountpoint = tracefs__mountpoint(); > - } > - > snprintf(buf, size, > "Error:\tNo permissions to read %s/%s\n" > "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n", > - tracing_events_path, filename, mountpoint); > + tracing_events_path, filename, tracing_mnt); > } > break; > default: > LGTM. David