diff options
author | Jiri Olsa <jolsa@kernel.org> | 2015-09-02 03:56:44 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-09-14 11:50:15 -0400 |
commit | 60a1133a5b39738671eff1e4d77bedc1ee3fa528 (patch) | |
tree | 646ab3b3dc8c42950b19f27e0b0f99bdfbf75833 /tools/lib/api/fs/findfs.c | |
parent | 4605eab3487dc818b1f3cbee2cd139cca3564be7 (diff) |
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>
Diffstat (limited to 'tools/lib/api/fs/findfs.c')
-rw-r--r-- | tools/lib/api/fs/findfs.c | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/tools/lib/api/fs/findfs.c b/tools/lib/api/fs/findfs.c deleted file mode 100644 index 49946cb6d7af..000000000000 --- a/tools/lib/api/fs/findfs.c +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
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 | } | ||