match_fstype.c 844 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Match fstypes for use in mount unmount
  4. * We accept notmpfs,nfs but not notmpfs,nonfs
  5. * This allows us to match fstypes that start with no like so
  6. * mount -at ,noddy
  7. *
  8. * Returns 1 for a match, otherwise 0
  9. *
  10. * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  11. */
  12. #include "libbb.h"
  13. int FAST_FUNC fstype_matches(const char *fstype, const char *comma_list)
  14. {
  15. int match = 1;
  16. if (!comma_list)
  17. return match;
  18. if (comma_list[0] == 'n' && comma_list[1] == 'o') {
  19. match--;
  20. comma_list += 2;
  21. }
  22. while (1) {
  23. char *after_mnt_type = is_prefixed_with(comma_list, fstype);
  24. if (after_mnt_type
  25. && (*after_mnt_type == '\0' || *after_mnt_type == ',')
  26. ) {
  27. return match;
  28. }
  29. comma_list = strchr(comma_list, ',');
  30. if (!comma_list)
  31. break;
  32. comma_list++;
  33. }
  34. return !match;
  35. }