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
)))
40 * Find path of a device mounted to the given point.
45 FILE *fp
= fopen("/proc/mounts", "r");
46 static char line
[256];
52 while (fgets(line
, sizeof(line
), fp
)) {
53 char *s
, *t
= strstr(line
, " ");
80 find_mount_point(char *block
, int mtd_only
)
82 FILE *fp
= fopen("/proc/mounts", "r");
83 static char line
[256];
84 int len
= strlen(block
);
90 while (fgets(line
, sizeof(line
), fp
)) {
91 if (!strncmp(line
, block
, len
)) {
92 char *p
= &line
[len
+ 1];
93 char *t
= strstr(p
, " ");
104 strncmp(t
, "jffs2", 5) &&
105 strncmp(t
, "ubifs", 5)) {
107 fprintf(stderr
, "block is mounted with wrong fs\n");
122 find_filesystem(char *fs
)
124 FILE *fp
= fopen("/proc/filesystems", "r");
125 static char line
[256];
129 fprintf(stderr
, "opening /proc/filesystems failed: %s\n", strerror(errno
));
133 while (ret
&& fgets(line
, sizeof(line
), fp
))
134 if (strstr(line
, fs
))