Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools lib api fs tracing_path: Remove two unused MAX_PATH paths

tracing_mnt was set but never written. tracing_events_path was set and
read on errors paths, but its value is exactly tracing_path with a
"/events" appended, so we can derive the value in the error
paths. There appears to have been a missing "/" when
tracing_events_path was initialized.

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20230526183401.2326121-8-irogers@google.com
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ross Zwisler <zwisler@chromium.org>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
20dcad8f 89df62c3

+6 -11
+6 -11
tools/lib/api/fs/tracing_path.c
··· 13 13 14 14 #include "tracing_path.h" 15 15 16 - static char tracing_mnt[PATH_MAX] = "/sys/kernel/debug"; 17 16 static char tracing_path[PATH_MAX] = "/sys/kernel/tracing"; 18 - static char tracing_events_path[PATH_MAX] = "/sys/kernel/tracing/events"; 19 17 20 18 static void __tracing_path_set(const char *tracing, const char *mountpoint) 21 19 { 22 - snprintf(tracing_mnt, sizeof(tracing_mnt), "%s", mountpoint); 23 20 snprintf(tracing_path, sizeof(tracing_path), "%s/%s", 24 21 mountpoint, tracing); 25 - snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s", 26 - mountpoint, tracing, "events"); 27 22 } 28 23 29 24 static const char *tracing_path_tracefs_mount(void) ··· 144 149 /* sdt markers */ 145 150 if (!strncmp(filename, "sdt_", 4)) { 146 151 snprintf(buf, size, 147 - "Error:\tFile %s/%s not found.\n" 152 + "Error:\tFile %s/events/%s not found.\n" 148 153 "Hint:\tSDT event cannot be directly recorded on.\n" 149 154 "\tPlease first use 'perf probe %s:%s' before recording it.\n", 150 - tracing_events_path, filename, sys, name); 155 + tracing_path, filename, sys, name); 151 156 } else { 152 157 snprintf(buf, size, 153 - "Error:\tFile %s/%s not found.\n" 158 + "Error:\tFile %s/events/%s not found.\n" 154 159 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n", 155 - tracing_events_path, filename); 160 + tracing_path, filename); 156 161 } 157 162 break; 158 163 } ··· 164 169 break; 165 170 case EACCES: { 166 171 snprintf(buf, size, 167 - "Error:\tNo permissions to read %s/%s\n" 172 + "Error:\tNo permissions to read %s/events/%s\n" 168 173 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n", 169 - tracing_events_path, filename, tracing_path_mount()); 174 + tracing_path, filename, tracing_path_mount()); 170 175 } 171 176 break; 172 177 default: