summaryrefslogtreecommitdiffstats
path: root/tools/lib/api/fs/findfs.c
diff options
context:
space:
mode:
authorChris Zankel <chris@zankel.net>2016-01-21 05:16:13 +0000
committerChris Zankel <chris@zankel.net>2016-01-21 05:16:13 +0000
commitd1208404dd477c142680437137c9996b95bfd508 (patch)
tree0cba53f59f487c0de2b1a0d9fb1b11ae27de96ec /tools/lib/api/fs/findfs.c
parentafaa7c542cc9c4d8a99ba252a8ea5e8bc7c897e2 (diff)
parentafd2ff9b7e1b367172f18ba7f693dfb62bdcb2dc (diff)
downloadtalos-op-linux-d1208404dd477c142680437137c9996b95bfd508.tar.gz
talos-op-linux-d1208404dd477c142680437137c9996b95bfd508.zip
Merge tag 'v4.4'
Linux 4.4
Diffstat (limited to 'tools/lib/api/fs/findfs.c')
-rw-r--r--tools/lib/api/fs/findfs.c63
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 @@
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-#include <sys/vfs.h>
-
-#include "findfs.h"
-
-/* verify that a mountpoint is actually the type we want */
-
-int valid_mountpoint(const char *mount, long magic)
-{
- struct statfs st_fs;
-
- if (statfs(mount, &st_fs) < 0)
- return -ENOENT;
- else if ((long)st_fs.f_type != magic)
- return -ENOENT;
-
- return 0;
-}
-
-/* find the path to a mounted file system */
-const char *find_mountpoint(const char *fstype, long magic,
- char *mountpoint, int len,
- const char * const *known_mountpoints)
-{
- const char * const *ptr;
- char format[128];
- char type[100];
- FILE *fp;
-
- if (known_mountpoints) {
- ptr = known_mountpoints;
- while (*ptr) {
- if (valid_mountpoint(*ptr, magic) == 0) {
- strncpy(mountpoint, *ptr, len - 1);
- mountpoint[len-1] = 0;
- return mountpoint;
- }
- ptr++;
- }
- }
-
- /* give up and parse /proc/mounts */
- fp = fopen("/proc/mounts", "r");
- if (fp == NULL)
- return NULL;
-
- snprintf(format, 128, "%%*s %%%ds %%99s %%*s %%*d %%*d\n", len);
-
- while (fscanf(fp, format, mountpoint, type) == 2) {
- if (strcmp(type, fstype) == 0)
- break;
- }
- fclose(fp);
-
- if (strcmp(type, fstype) != 0)
- return NULL;
-
- return mountpoint;
-}
OpenPOWER on IntegriCloud