diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-30 00:45:05 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-30 00:45:05 +0100 |
commit | 35b54a3c247235b1bffe2a22784a1d5be10267f3 (patch) | |
tree | 4fa803d221cd4895fde17a611edc9ae2a32ddc35 | |
parent | eba7fe6bb9fdc89cf9d4d33043cd3856253d303d (diff) | |
download | busybox-w32-35b54a3c247235b1bffe2a22784a1d5be10267f3.tar.gz busybox-w32-35b54a3c247235b1bffe2a22784a1d5be10267f3.tar.bz2 busybox-w32-35b54a3c247235b1bffe2a22784a1d5be10267f3.zip |
libbb: match_fstype() is unreadable in the extreme, fixing it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | libbb/match_fstype.c | 20 | ||||
-rw-r--r-- | util-linux/mount.c | 2 | ||||
-rw-r--r-- | util-linux/umount.c | 4 |
4 files changed, 12 insertions, 16 deletions
diff --git a/include/libbb.h b/include/libbb.h index 07fe20dac..b054e0559 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1312,8 +1312,8 @@ const struct hwtype *get_hwtype(const char *name) FAST_FUNC; | |||
1312 | const struct hwtype *get_hwntype(int type) FAST_FUNC; | 1312 | const struct hwtype *get_hwntype(int type) FAST_FUNC; |
1313 | 1313 | ||
1314 | 1314 | ||
1315 | extern int fstype_matches(const char *fstype, const char *comma_list) FAST_FUNC; | ||
1315 | #ifdef HAVE_MNTENT_H | 1316 | #ifdef HAVE_MNTENT_H |
1316 | extern int match_fstype(const struct mntent *mt, const char *fstypes) FAST_FUNC; | ||
1317 | extern struct mntent *find_mount_point(const char *name, int subdir_too) FAST_FUNC; | 1317 | extern struct mntent *find_mount_point(const char *name, int subdir_too) FAST_FUNC; |
1318 | #endif | 1318 | #endif |
1319 | extern void erase_mtab(const char * name) FAST_FUNC; | 1319 | extern void erase_mtab(const char * name) FAST_FUNC; |
diff --git a/libbb/match_fstype.c b/libbb/match_fstype.c index b066b4211..6046bc6db 100644 --- a/libbb/match_fstype.c +++ b/libbb/match_fstype.c | |||
@@ -12,34 +12,30 @@ | |||
12 | 12 | ||
13 | #include "libbb.h" | 13 | #include "libbb.h" |
14 | 14 | ||
15 | #ifdef HAVE_MNTENT_H | 15 | int FAST_FUNC fstype_matches(const char *fstype, const char *comma_list) |
16 | |||
17 | int FAST_FUNC match_fstype(const struct mntent *mt, const char *t_fstype) | ||
18 | { | 16 | { |
19 | int match = 1; | 17 | int match = 1; |
20 | 18 | ||
21 | if (!t_fstype) | 19 | if (!comma_list) |
22 | return match; | 20 | return match; |
23 | 21 | ||
24 | if (t_fstype[0] == 'n' && t_fstype[1] == 'o') { | 22 | if (comma_list[0] == 'n' && comma_list[1] == 'o') { |
25 | match--; | 23 | match--; |
26 | t_fstype += 2; | 24 | comma_list += 2; |
27 | } | 25 | } |
28 | 26 | ||
29 | while (1) { | 27 | while (1) { |
30 | char *after_mnt_type = is_prefixed_with(t_fstype, mt->mnt_type); | 28 | char *after_mnt_type = is_prefixed_with(comma_list, fstype); |
31 | if (after_mnt_type | 29 | if (after_mnt_type |
32 | && (*after_mnt_type == '\0' || *after_mnt_type == ',') | 30 | && (*after_mnt_type == '\0' || *after_mnt_type == ',') |
33 | ) { | 31 | ) { |
34 | return match; | 32 | return match; |
35 | } | 33 | } |
36 | t_fstype = strchr(t_fstype, ','); | 34 | comma_list = strchr(comma_list, ','); |
37 | if (!t_fstype) | 35 | if (!comma_list) |
38 | break; | 36 | break; |
39 | t_fstype++; | 37 | comma_list++; |
40 | } | 38 | } |
41 | 39 | ||
42 | return !match; | 40 | return !match; |
43 | } | 41 | } |
44 | |||
45 | #endif /* HAVE_MNTENT_H */ | ||
diff --git a/util-linux/mount.c b/util-linux/mount.c index 4f5dced10..f0245f714 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -2312,7 +2312,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
2312 | bb_error_msg_and_die(bb_msg_you_must_be_root); | 2312 | bb_error_msg_and_die(bb_msg_you_must_be_root); |
2313 | 2313 | ||
2314 | // Does type match? (NULL matches always) | 2314 | // Does type match? (NULL matches always) |
2315 | if (!match_fstype(mtcur, fstype)) | 2315 | if (!fstype_matches(mtcur->mnt_type, fstype)) |
2316 | continue; | 2316 | continue; |
2317 | 2317 | ||
2318 | // Skip noauto and swap anyway | 2318 | // Skip noauto and swap anyway |
diff --git a/util-linux/umount.c b/util-linux/umount.c index 78eef57a5..c958fd552 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c | |||
@@ -125,8 +125,8 @@ int umount_main(int argc UNUSED_PARAM, char **argv) | |||
125 | } else { | 125 | } else { |
126 | setup_common_bufsiz(); | 126 | setup_common_bufsiz(); |
127 | while (getmntent_r(fp, &me, bb_common_bufsiz1, COMMON_BUFSIZE)) { | 127 | while (getmntent_r(fp, &me, bb_common_bufsiz1, COMMON_BUFSIZE)) { |
128 | /* Match fstype if passed */ | 128 | /* Match fstype (fstype==NULL matches always) */ |
129 | if (!match_fstype(&me, fstype)) | 129 | if (!fstype_matches(me.mnt_type, fstype)) |
130 | continue; | 130 | continue; |
131 | m = xzalloc(sizeof(*m)); | 131 | m = xzalloc(sizeof(*m)); |
132 | m->next = mtl; | 132 | m->next = mtl; |