libbb: match_fstype() is unreadable in the extreme, fixing it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
@ -1312,8 +1312,8 @@ const struct hwtype *get_hwtype(const char *name) FAST_FUNC;
|
|||||||
const struct hwtype *get_hwntype(int type) FAST_FUNC;
|
const struct hwtype *get_hwntype(int type) FAST_FUNC;
|
||||||
|
|
||||||
|
|
||||||
|
extern int fstype_matches(const char *fstype, const char *comma_list) FAST_FUNC;
|
||||||
#ifdef HAVE_MNTENT_H
|
#ifdef HAVE_MNTENT_H
|
||||||
extern int match_fstype(const struct mntent *mt, const char *fstypes) FAST_FUNC;
|
|
||||||
extern struct mntent *find_mount_point(const char *name, int subdir_too) FAST_FUNC;
|
extern struct mntent *find_mount_point(const char *name, int subdir_too) FAST_FUNC;
|
||||||
#endif
|
#endif
|
||||||
extern void erase_mtab(const char * name) FAST_FUNC;
|
extern void erase_mtab(const char * name) FAST_FUNC;
|
||||||
|
@ -12,34 +12,30 @@
|
|||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
#ifdef HAVE_MNTENT_H
|
int FAST_FUNC fstype_matches(const char *fstype, const char *comma_list)
|
||||||
|
|
||||||
int FAST_FUNC match_fstype(const struct mntent *mt, const char *t_fstype)
|
|
||||||
{
|
{
|
||||||
int match = 1;
|
int match = 1;
|
||||||
|
|
||||||
if (!t_fstype)
|
if (!comma_list)
|
||||||
return match;
|
return match;
|
||||||
|
|
||||||
if (t_fstype[0] == 'n' && t_fstype[1] == 'o') {
|
if (comma_list[0] == 'n' && comma_list[1] == 'o') {
|
||||||
match--;
|
match--;
|
||||||
t_fstype += 2;
|
comma_list += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
char *after_mnt_type = is_prefixed_with(t_fstype, mt->mnt_type);
|
char *after_mnt_type = is_prefixed_with(comma_list, fstype);
|
||||||
if (after_mnt_type
|
if (after_mnt_type
|
||||||
&& (*after_mnt_type == '\0' || *after_mnt_type == ',')
|
&& (*after_mnt_type == '\0' || *after_mnt_type == ',')
|
||||||
) {
|
) {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
t_fstype = strchr(t_fstype, ',');
|
comma_list = strchr(comma_list, ',');
|
||||||
if (!t_fstype)
|
if (!comma_list)
|
||||||
break;
|
break;
|
||||||
t_fstype++;
|
comma_list++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !match;
|
return !match;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_MNTENT_H */
|
|
||||||
|
@ -2312,7 +2312,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
bb_error_msg_and_die(bb_msg_you_must_be_root);
|
bb_error_msg_and_die(bb_msg_you_must_be_root);
|
||||||
|
|
||||||
// Does type match? (NULL matches always)
|
// Does type match? (NULL matches always)
|
||||||
if (!match_fstype(mtcur, fstype))
|
if (!fstype_matches(mtcur->mnt_type, fstype))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Skip noauto and swap anyway
|
// Skip noauto and swap anyway
|
||||||
|
@ -125,8 +125,8 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
setup_common_bufsiz();
|
setup_common_bufsiz();
|
||||||
while (getmntent_r(fp, &me, bb_common_bufsiz1, COMMON_BUFSIZE)) {
|
while (getmntent_r(fp, &me, bb_common_bufsiz1, COMMON_BUFSIZE)) {
|
||||||
/* Match fstype if passed */
|
/* Match fstype (fstype==NULL matches always) */
|
||||||
if (!match_fstype(&me, fstype))
|
if (!fstype_matches(me.mnt_type, fstype))
|
||||||
continue;
|
continue;
|
||||||
m = xzalloc(sizeof(*m));
|
m = xzalloc(sizeof(*m));
|
||||||
m->next = mtl;
|
m->next = mtl;
|
||||||
|
Reference in New Issue
Block a user