5 |
* This allows us to match fstypes that start with no like so |
* This allows us to match fstypes that start with no like so |
6 |
* mount -at ,noddy |
* mount -at ,noddy |
7 |
* |
* |
8 |
* Returns 0 for a match, otherwise -1 |
* Returns 1 for a match, otherwise 0 |
9 |
* |
* |
10 |
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
11 |
*/ |
*/ |
12 |
|
|
13 |
#include "libbb.h" |
#include "libbb.h" |
14 |
|
|
15 |
int FAST_FUNC match_fstype(const struct mntent *mt, const char *fstype) |
int FAST_FUNC match_fstype(const struct mntent *mt, const char *t_fstype) |
16 |
{ |
{ |
17 |
int no = 0; |
int match = 1; |
18 |
int len; |
int len; |
19 |
|
|
20 |
if (!mt) |
if (!t_fstype) |
21 |
return -1; |
return match; |
22 |
|
|
23 |
if (!fstype) |
if (t_fstype[0] == 'n' && t_fstype[1] == 'o') { |
24 |
return 0; |
match--; |
25 |
|
t_fstype += 2; |
|
if (fstype[0] == 'n' && fstype[1] == 'o') { |
|
|
no = -1; |
|
|
fstype += 2; |
|
26 |
} |
} |
27 |
|
|
28 |
len = strlen(mt->mnt_type); |
len = strlen(mt->mnt_type); |
29 |
while (fstype) { |
while (1) { |
30 |
if (!strncmp(mt->mnt_type, fstype, len) |
if (strncmp(mt->mnt_type, t_fstype, len) == 0 |
31 |
&& (!fstype[len] || fstype[len] == ',') |
&& (t_fstype[len] == '\0' || t_fstype[len] == ',') |
32 |
) { |
) { |
33 |
return no; |
return match; |
34 |
} |
} |
35 |
fstype = strchr(fstype, ','); |
t_fstype = strchr(t_fstype, ','); |
36 |
if (fstype) |
if (!t_fstype) |
37 |
fstype++; |
break; |
38 |
|
t_fstype++; |
39 |
} |
} |
40 |
|
|
41 |
return -(no + 1); |
return !match; |
42 |
} |
} |