35e37e7ffe061f92412eaec3fa7366f11f1bca40
2 * Copyright (C) 2014 John Crispin <blogic@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2.1
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
18 #include "../fs-state.h"
21 find_overlay_mount(char *overlay
)
23 FILE *fp
= fopen("/proc/mounts", "r");
24 static char line
[256];
30 while (ret
&& fgets(line
, sizeof(line
), fp
))
31 if (!strncmp(line
, overlay
, strlen(overlay
)))
42 FILE *fp
= fopen("/proc/mounts", "r");
43 static char line
[256];
49 while (fgets(line
, sizeof(line
), fp
)) {
50 char *s
, *t
= strstr(line
, " ");
76 find_mount_point(char *block
, char *fs
)
78 FILE *fp
= fopen("/proc/mounts", "r");
79 static char line
[256];
80 int len
= strlen(block
);
86 while (fgets(line
, sizeof(line
), fp
)) {
87 if (!strncmp(line
, block
, len
)) {
88 char *p
= &line
[len
+ 1];
89 char *t
= strstr(p
, " ");
99 if (fs
&& strncmp(t
, fs
, strlen(fs
))) {
101 fprintf(stderr
, "block is mounted with wrong fs\n");
116 find_filesystem(char *fs
)
118 FILE *fp
= fopen("/proc/filesystems", "r");
119 static char line
[256];
123 fprintf(stderr
, "opening /proc/filesystems failed: %s\n", strerror(errno
));
127 while (ret
&& fgets(line
, sizeof(line
), fp
))
128 if (strstr(line
, fs
))