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 "libfstools.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
, int mtd_only
)
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
, " ");
100 strncmp(t
, "jffs2", 5) &&
101 strncmp(t
, "ubifs", 5)) {
103 fprintf(stderr
, "block is mounted with wrong fs\n");
118 find_filesystem(char *fs
)
120 FILE *fp
= fopen("/proc/filesystems", "r");
121 static char line
[256];
125 fprintf(stderr
, "opening /proc/filesystems failed: %s\n", strerror(errno
));
129 while (ret
&& fgets(line
, sizeof(line
), fp
))
130 if (strstr(line
, fs
))