diff options
| author | Chris Zankel <[email protected]> | 2015-04-14 03:51:35 +0000 | 
|---|---|---|
| committer | Chris Zankel <[email protected]> | 2015-04-14 03:51:35 +0000 | 
| commit | 7ead5b7e4a3cf4a16579a8f164022345b93fe972 (patch) | |
| tree | 0a9b9497f53d1593c9e2ac197b2e686ea74a9975 /tools/lib/api/fs/debugfs.c | |
| parent | 834a316eeebcb75316c0a7d9088fa638c52dc584 (diff) | |
| parent | 39a8804455fb23f09157341d3ba7db6d7ae6ee76 (diff) | |
Merge tag 'v4.0' into for_next
Linux 4.0
Diffstat (limited to 'tools/lib/api/fs/debugfs.c')
| -rw-r--r-- | tools/lib/api/fs/debugfs.c | 43 | 
1 files changed, 43 insertions, 0 deletions
| diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c index 86ea2d7b8845..d2b18e887071 100644 --- a/tools/lib/api/fs/debugfs.c +++ b/tools/lib/api/fs/debugfs.c @@ -1,3 +1,4 @@ +#define _GNU_SOURCE  #include <errno.h>  #include <stdio.h>  #include <stdlib.h> @@ -98,3 +99,45 @@ char *debugfs_mount(const char *mountpoint)  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: +		snprintf(buf, size, +			 "Error:\tNo permissions to read %s/%s\n" +			 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n", +			 debugfs_mountpoint, filename, debugfs_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); +} |