glob_match(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms