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