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

tools lib api fs: Remove debugfs, tracefs and findfs objects

We have all the functionality in fs.c, let's remove unneeded
objects.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-15-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
60a1133a 4605eab3

-288
-3
tools/lib/api/fs/Build
··· 1 1 libapi-y += fs.o 2 2 libapi-y += tracing_path.o 3 - libapi-y += debugfs.o 4 - libapi-y += findfs.o 5 - libapi-y += tracefs.o
-77
tools/lib/api/fs/debugfs.c
··· 1 - #define _GNU_SOURCE 2 - #include <errno.h> 3 - #include <stdio.h> 4 - #include <stdlib.h> 5 - #include <string.h> 6 - #include <unistd.h> 7 - #include <stdbool.h> 8 - #include <sys/vfs.h> 9 - #include <sys/types.h> 10 - #include <sys/stat.h> 11 - #include <sys/mount.h> 12 - #include <linux/kernel.h> 13 - 14 - #include "debugfs.h" 15 - #include "tracefs.h" 16 - 17 - #ifndef DEBUGFS_DEFAULT_PATH 18 - #define DEBUGFS_DEFAULT_PATH "/sys/kernel/debug" 19 - #endif 20 - 21 - char debugfs_mountpoint[PATH_MAX + 1] = DEBUGFS_DEFAULT_PATH; 22 - 23 - static const char * const debugfs_known_mountpoints[] = { 24 - DEBUGFS_DEFAULT_PATH, 25 - "/debug", 26 - 0, 27 - }; 28 - 29 - static bool debugfs_found; 30 - 31 - bool debugfs_configured(void) 32 - { 33 - return debugfs_find_mountpoint() != NULL; 34 - } 35 - 36 - /* find the path to the mounted debugfs */ 37 - const char *debugfs_find_mountpoint(void) 38 - { 39 - const char *ret; 40 - 41 - if (debugfs_found) 42 - return (const char *)debugfs_mountpoint; 43 - 44 - ret = find_mountpoint("debugfs", (long) DEBUGFS_MAGIC, 45 - debugfs_mountpoint, PATH_MAX + 1, 46 - debugfs_known_mountpoints); 47 - if (ret) 48 - debugfs_found = true; 49 - 50 - return ret; 51 - } 52 - 53 - /* mount the debugfs somewhere if it's not mounted */ 54 - char *debugfs_mount(const char *mountpoint) 55 - { 56 - /* see if it's already mounted */ 57 - if (debugfs_find_mountpoint()) 58 - goto out; 59 - 60 - /* if not mounted and no argument */ 61 - if (mountpoint == NULL) { 62 - /* see if environment variable set */ 63 - mountpoint = getenv(PERF_DEBUGFS_ENVIRONMENT); 64 - /* if no environment variable, use default */ 65 - if (mountpoint == NULL) 66 - mountpoint = DEBUGFS_DEFAULT_PATH; 67 - } 68 - 69 - if (mount(NULL, mountpoint, "debugfs", 0, NULL) < 0) 70 - return NULL; 71 - 72 - /* save the mountpoint */ 73 - debugfs_found = true; 74 - strncpy(debugfs_mountpoint, mountpoint, sizeof(debugfs_mountpoint)); 75 - out: 76 - return debugfs_mountpoint; 77 - }
-23
tools/lib/api/fs/debugfs.h
··· 1 - #ifndef __API_DEBUGFS_H__ 2 - #define __API_DEBUGFS_H__ 3 - 4 - #include "findfs.h" 5 - 6 - #ifndef DEBUGFS_MAGIC 7 - #define DEBUGFS_MAGIC 0x64626720 8 - #endif 9 - 10 - #ifndef PERF_DEBUGFS_ENVIRONMENT 11 - #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR" 12 - #endif 13 - 14 - bool debugfs_configured(void); 15 - const char *debugfs_find_mountpoint(void); 16 - char *debugfs_mount(const char *mountpoint); 17 - 18 - extern char debugfs_mountpoint[]; 19 - 20 - int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename); 21 - int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name); 22 - 23 - #endif /* __API_DEBUGFS_H__ */
-63
tools/lib/api/fs/findfs.c
··· 1 - #include <errno.h> 2 - #include <stdio.h> 3 - #include <stdlib.h> 4 - #include <string.h> 5 - #include <stdbool.h> 6 - #include <sys/vfs.h> 7 - 8 - #include "findfs.h" 9 - 10 - /* verify that a mountpoint is actually the type we want */ 11 - 12 - int valid_mountpoint(const char *mount, long magic) 13 - { 14 - struct statfs st_fs; 15 - 16 - if (statfs(mount, &st_fs) < 0) 17 - return -ENOENT; 18 - else if ((long)st_fs.f_type != magic) 19 - return -ENOENT; 20 - 21 - return 0; 22 - } 23 - 24 - /* find the path to a mounted file system */ 25 - const char *find_mountpoint(const char *fstype, long magic, 26 - char *mountpoint, int len, 27 - const char * const *known_mountpoints) 28 - { 29 - const char * const *ptr; 30 - char format[128]; 31 - char type[100]; 32 - FILE *fp; 33 - 34 - if (known_mountpoints) { 35 - ptr = known_mountpoints; 36 - while (*ptr) { 37 - if (valid_mountpoint(*ptr, magic) == 0) { 38 - strncpy(mountpoint, *ptr, len - 1); 39 - mountpoint[len-1] = 0; 40 - return mountpoint; 41 - } 42 - ptr++; 43 - } 44 - } 45 - 46 - /* give up and parse /proc/mounts */ 47 - fp = fopen("/proc/mounts", "r"); 48 - if (fp == NULL) 49 - return NULL; 50 - 51 - snprintf(format, 128, "%%*s %%%ds %%99s %%*s %%*d %%*d\n", len); 52 - 53 - while (fscanf(fp, format, mountpoint, type) == 2) { 54 - if (strcmp(type, fstype) == 0) 55 - break; 56 - } 57 - fclose(fp); 58 - 59 - if (strcmp(type, fstype) != 0) 60 - return NULL; 61 - 62 - return mountpoint; 63 - }
-23
tools/lib/api/fs/findfs.h
··· 1 - #ifndef __API_FINDFS_H__ 2 - #define __API_FINDFS_H__ 3 - 4 - #include <stdbool.h> 5 - 6 - #define _STR(x) #x 7 - #define STR(x) _STR(x) 8 - 9 - /* 10 - * On most systems <limits.h> would have given us this, but not on some systems 11 - * (e.g. GNU/Hurd). 12 - */ 13 - #ifndef PATH_MAX 14 - #define PATH_MAX 4096 15 - #endif 16 - 17 - const char *find_mountpoint(const char *fstype, long magic, 18 - char *mountpoint, int len, 19 - const char * const *known_mountpoints); 20 - 21 - int valid_mountpoint(const char *mount, long magic); 22 - 23 - #endif /* __API_FINDFS_H__ */
-78
tools/lib/api/fs/tracefs.c
··· 1 - #include <errno.h> 2 - #include <stdio.h> 3 - #include <stdlib.h> 4 - #include <string.h> 5 - #include <unistd.h> 6 - #include <stdbool.h> 7 - #include <sys/vfs.h> 8 - #include <sys/types.h> 9 - #include <sys/stat.h> 10 - #include <sys/mount.h> 11 - #include <linux/kernel.h> 12 - 13 - #include "tracefs.h" 14 - 15 - #ifndef TRACEFS_DEFAULT_PATH 16 - #define TRACEFS_DEFAULT_PATH "/sys/kernel/tracing" 17 - #endif 18 - 19 - char tracefs_mountpoint[PATH_MAX + 1] = TRACEFS_DEFAULT_PATH; 20 - 21 - static const char * const tracefs_known_mountpoints[] = { 22 - TRACEFS_DEFAULT_PATH, 23 - "/sys/kernel/debug/tracing", 24 - "/tracing", 25 - "/trace", 26 - 0, 27 - }; 28 - 29 - static bool tracefs_found; 30 - 31 - bool tracefs_configured(void) 32 - { 33 - return tracefs_find_mountpoint() != NULL; 34 - } 35 - 36 - /* find the path to the mounted tracefs */ 37 - const char *tracefs_find_mountpoint(void) 38 - { 39 - const char *ret; 40 - 41 - if (tracefs_found) 42 - return (const char *)tracefs_mountpoint; 43 - 44 - ret = find_mountpoint("tracefs", (long) TRACEFS_MAGIC, 45 - tracefs_mountpoint, PATH_MAX + 1, 46 - tracefs_known_mountpoints); 47 - 48 - if (ret) 49 - tracefs_found = true; 50 - 51 - return ret; 52 - } 53 - 54 - /* mount the tracefs somewhere if it's not mounted */ 55 - char *tracefs_mount(const char *mountpoint) 56 - { 57 - /* see if it's already mounted */ 58 - if (tracefs_find_mountpoint()) 59 - goto out; 60 - 61 - /* if not mounted and no argument */ 62 - if (mountpoint == NULL) { 63 - /* see if environment variable set */ 64 - mountpoint = getenv(PERF_TRACEFS_ENVIRONMENT); 65 - /* if no environment variable, use default */ 66 - if (mountpoint == NULL) 67 - mountpoint = TRACEFS_DEFAULT_PATH; 68 - } 69 - 70 - if (mount(NULL, mountpoint, "tracefs", 0, NULL) < 0) 71 - return NULL; 72 - 73 - /* save the mountpoint */ 74 - tracefs_found = true; 75 - strncpy(tracefs_mountpoint, mountpoint, sizeof(tracefs_mountpoint)); 76 - out: 77 - return tracefs_mountpoint; 78 - }
-21
tools/lib/api/fs/tracefs.h
··· 1 - #ifndef __API_TRACEFS_H__ 2 - #define __API_TRACEFS_H__ 3 - 4 - #include "findfs.h" 5 - 6 - #ifndef TRACEFS_MAGIC 7 - #define TRACEFS_MAGIC 0x74726163 8 - #endif 9 - 10 - #ifndef PERF_TRACEFS_ENVIRONMENT 11 - #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR" 12 - #endif 13 - 14 - bool tracefs_configured(void); 15 - const char *tracefs_find_mountpoint(void); 16 - int tracefs_valid_mountpoint(const char *debugfs); 17 - char *tracefs_mount(const char *mountpoint); 18 - 19 - extern char tracefs_mountpoint[]; 20 - 21 - #endif /* __API_DEBUGFS_H__ */