* This allows us to match fstypes that start with no like so
* mount -at ,noddy
*
- * Returns 0 for a match, otherwise -1
+ * Returns 1 for a match, otherwise 0
*
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
-
#include "libbb.h"
-int match_fstype(const struct mntent *mt, const char *fstype)
+int FAST_FUNC fstype_matches(const char *fstype, const char *comma_list)
{
- int no = 0;
- int len;
+ int match = 1;
- if (!mt)
- return -1;
-
- if (!fstype)
- return 0;
+ if (!comma_list)
+ return match;
- if (fstype[0] == 'n' && fstype[1] == 'o') {
- no = -1;
- fstype += 2;
+ if (comma_list[0] == 'n' && comma_list[1] == 'o') {
+ match--;
+ comma_list += 2;
}
- len = strlen(mt->mnt_type);
- while (fstype) {
- if (!strncmp(mt->mnt_type, fstype, len)
- && (!fstype[len] || fstype[len] == ',')
+ while (1) {
+ char *after_mnt_type = is_prefixed_with(comma_list, fstype);
+ if (after_mnt_type
+ && (*after_mnt_type == '\0' || *after_mnt_type == ',')
) {
- return no;
+ return match;
}
- fstype = strchr(fstype, ',');
- if (fstype)
- fstype++;
+ comma_list = strchr(comma_list, ',');
+ if (!comma_list)
+ break;
+ comma_list++;
}
- return -(no + 1);
+ return !match;
}