Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755689AbbHZNwt (ORCPT ); Wed, 26 Aug 2015 09:52:49 -0400 Received: from mail.kernel.org ([198.145.29.136]:50033 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751859AbbHZNwr (ORCPT ); Wed, 26 Aug 2015 09:52:47 -0400 Date: Wed, 26 Aug 2015 10:52:42 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: lkml , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra , Matt Fleming , =?iso-8859-1?Q?Rapha=EBl?= Beamonte Subject: Re: [PATCH 04/11] perf tools: Move debugfs__strerror_open into util.c object Message-ID: <20150826135242.GD18596@kernel.org> References: <1440596813-12844-1-git-send-email-jolsa@kernel.org> <1440596813-12844-5-git-send-email-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1440596813-12844-5-git-send-email-jolsa@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6005 Lines: 175 Em Wed, Aug 26, 2015 at 03:46:46PM +0200, Jiri Olsa escreveu: > Moving debugfs__strerror_open out of api/fs/debugfs.c, > because it's not debugfs specific. It'll be changed to > consider tracefs mount as well in following patches. If it is "debugfs__" it should not deal with tracefs, right? My feeling is that they should be decoupled more, not the other way around :-\ - Arnaldo > Link: http://lkml.kernel.org/n/tip-bq0f0l4r0bjvy0pjp4m759kv@git.kernel.org > Signed-off-by: Jiri Olsa > --- > tools/lib/api/fs/debugfs.c | 51 --------------------------------------------- > tools/lib/api/fs/debugfs.h | 3 --- > tools/perf/util/util.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ > tools/perf/util/util.h | 2 ++ > 4 files changed, 54 insertions(+), 54 deletions(-) > > diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c > index eb7cf4d18f8a..896c3595c9df 100644 > --- a/tools/lib/api/fs/debugfs.c > +++ b/tools/lib/api/fs/debugfs.c > @@ -76,54 +76,3 @@ out: > return debugfs_mountpoint; > } > > -int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename) > -{ > - char sbuf[128]; > - > - switch (err) { > - case ENOENT: > - if (debugfs_found) { > - snprintf(buf, size, > - "Error:\tFile %s/%s not found.\n" > - "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n", > - debugfs_mountpoint, filename); > - break; > - } > - snprintf(buf, size, "%s", > - "Error:\tUnable to find debugfs\n" > - "Hint:\tWas your kernel compiled with debugfs support?\n" > - "Hint:\tIs the debugfs filesystem mounted?\n" > - "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'"); > - break; > - case EACCES: { > - const char *mountpoint = debugfs_mountpoint; > - > - if (!access(debugfs_mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) { > - const char *tracefs_mntpoint = tracefs_find_mountpoint(); > - > - if (tracefs_mntpoint) > - mountpoint = tracefs_mntpoint; > - } > - > - snprintf(buf, size, > - "Error:\tNo permissions to read %s/%s\n" > - "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n", > - debugfs_mountpoint, filename, mountpoint); > - } > - break; > - default: > - snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf))); > - break; > - } > - > - return 0; > -} > - > -int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name) > -{ > - char path[PATH_MAX]; > - > - snprintf(path, PATH_MAX, "tracing/events/%s/%s", sys, name ?: "*"); > - > - return debugfs__strerror_open(err, buf, size, path); > -} > diff --git a/tools/lib/api/fs/debugfs.h b/tools/lib/api/fs/debugfs.h > index 455023698d2b..19a618e9dbc1 100644 > --- a/tools/lib/api/fs/debugfs.h > +++ b/tools/lib/api/fs/debugfs.h > @@ -17,7 +17,4 @@ char *debugfs_mount(const char *mountpoint); > > extern char debugfs_mountpoint[]; > > -int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename); > -int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name); > - > #endif /* __API_DEBUGFS_H__ */ > diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c > index 7acafb3c5592..03d1d74a5ede 100644 > --- a/tools/perf/util/util.c > +++ b/tools/perf/util/util.c > @@ -442,6 +442,58 @@ void perf_debugfs_set_path(const char *mntpt) > set_tracing_events_path("tracing/", mntpt); > } > > +int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename) > +{ > + char sbuf[128]; > + > + switch (err) { > + case ENOENT: > + if (debugfs_configured()) { > + snprintf(buf, size, > + "Error:\tFile %s/%s not found.\n" > + "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n", > + debugfs_mountpoint, filename); > + break; > + } > + snprintf(buf, size, "%s", > + "Error:\tUnable to find debugfs\n" > + "Hint:\tWas your kernel compiled with debugfs support?\n" > + "Hint:\tIs the debugfs filesystem mounted?\n" > + "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'"); > + break; > + case EACCES: { > + const char *mountpoint = debugfs_mountpoint; > + > + if (!access(debugfs_mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) { > + const char *tracefs_mntpoint = tracefs_find_mountpoint(); > + > + if (tracefs_mntpoint) > + mountpoint = tracefs_mntpoint; > + } > + > + snprintf(buf, size, > + "Error:\tNo permissions to read %s/%s\n" > + "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n", > + debugfs_mountpoint, filename, mountpoint); > + } > + break; > + default: > + snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf))); > + break; > + } > + > + return 0; > +} > + > +int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name) > +{ > + char path[PATH_MAX]; > + > + snprintf(path, PATH_MAX, "tracing/events/%s/%s", sys, name ?: "*"); > + > + return debugfs__strerror_open(err, buf, size, path); > +} > + > char *get_tracing_file(const char *name) > { > char *file; > diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h > index 291be1d84bc3..da48c00ab0db 100644 > --- a/tools/perf/util/util.h > +++ b/tools/perf/util/util.h > @@ -87,6 +87,8 @@ extern char tracing_path[]; > extern char tracing_events_path[]; > extern void perf_debugfs_set_path(const char *mountpoint); > const char *perf_debugfs_mount(const char *mountpoint); > +int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename); > +int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name); > char *get_tracing_file(const char *name); > void put_tracing_file(char *file); > > -- > 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/