glob_match(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

glob_match(9) πŸ’…βœ¨

okay bestie, welcome to the Kernel API Manual glow-up of glob_match(9) β€” manual name folded in right here, no boring header line needed 🫢

🌸 NAME 🌸

glob_match β€” Shell-style pattern matching, like !fnmatch(pat, str, 0) πŸ’–

✨ SYNOPSIS ✨

__noinline bool glob_match (char const __arena *pat , char const __arena
*str );

πŸŽ€ ARGUMENTS πŸŽ€

  • pat β€” Shell-style pattern to match, e.g. "*.[ch]". πŸ¦‹
  • str β€” String to match. The pattern must match the entire string. πŸ‘‘

πŸ’… DESCRIPTION πŸ’…

okay so this does shell-style glob matching, and it returns true (1) if the match succeeds, or false (0) if it fails. It’s equivalent to !fnmatch(pat, str, 0). periodt ✨

Pattern metacharacters are ?, *, [ and .. (And, inside character classes, !, - and ].) πŸŽ€

This is small and simple implementation intended for device blacklists where a string is matched against a number of patterns. Thus, it does not preprocess the patterns. It is non-recursive, and run-time is at most quadratic: strlen(str)*strlen(pat). πŸ”₯

An example of the worst case is glob_match("*aaaaa", "aaaaaaaaaa"); β€” it takes 6 passes over the pattern before matching the string. πŸ’€

Like !fnmatch(pat, str, 0) and unlike the shell, this does NOT treat / or leading . specially; it isn’t actually used for pathnames. πŸ™ˆ

Note that according to glob(7) (and unlike bash), character classes are complemented by a leading !; this does not support the regex-style [^a-z] syntax. 🧚

An opening bracket without a matching close is matched literally. πŸŽ€

πŸ¦‹ SEE ALSO πŸ¦‹

  • Kernel file ./tools/testing/selftests/bpf/bpf_arena_strsearch.h ⭐

mwah πŸ’‹ this lil page came from ./tools/testing/selftests/bpf, dated October 2026. bye bestie! 🫢

πŸ“¦ where this page comes from