Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1213903

Re: [PATCH 04/11] perf tools: Move debugfs__strerror_open into util.c object

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 04/11] perf tools: Move debugfs__strerror_open into util.c object
Date 2015-08-26 16:00 +0200
Message-ID <q1Jp9-7wp-25@gated-at.bofh.it> (permalink)
References <q1Jfs-7l6-5@gated-at.bofh.it> <q1Jfs-7l6-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <jolsa@kernel.org>
> ---
>  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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 04/11] perf tools: Move debugfs__strerror_open into util.c object Jiri Olsa <jolsa@kernel.org> - 2015-08-26 15:50 +0200
  Re: [PATCH 04/11] perf tools: Move debugfs__strerror_open into  util.c object Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-26 16:00 +0200
    Re: [PATCH 04/11] perf tools: Move debugfs__strerror_open into  util.c object Jiri Olsa <jolsa@redhat.com> - 2015-08-26 16:20 +0200
  Re: [PATCH 04/11] perf tools: Move debugfs__strerror_open into  util.c object Matt Fleming <matt@codeblueprint.co.uk> - 2015-08-28 15:00 +0200

csiph-web