match_string(9)
π« match_string(9) β Kernel API Manual π«
okay so bestie, today we're learning about match_string, and honestly? she's a little icon of the kernel string-helper world π
πΈ NAME πΈ
match_string β matches given string in an array. that's it, that's the whole job, and she does it flawlessly π
β¨ SYNOPSIS β¨
int match_string (const char * const *array , size_t n , const char
*string );
literally the whole signature, copied exactly, no cap π₯
π¦ ARGUMENTS π¦
arrayβ array of strings. yes, the place where all your little string besties live π«Άnβ number of strings in the array, or-1for NULL terminated arrays πstringβ string to match with. the one we're out here looking for π
π DESCRIPTION π
This routine will look for a string in an array of strings up to the n-th element in the array or until the first NULL element. so basically she's scrolling the group chat looking for that one specific message π
Historically the value of -1 for n, was used to search in arrays that are NULL terminated. that's the og vibe, iykyk. However, the function does not make a distinction when finishing the search: either n elements have been compared OR the first NULL element was found. so like, she stops at whichever comes first β no favorites, no drama, she just ends the search the same way either way β¨
π§ real talk: don't assume she knows why she stopped. both endings look identical from the outside, bestie.
β RETURN β
index of a string in the array if matches, or -EINVAL otherwise. slay when it hits, -EINVAL when it doesn't π
π SEE ALSO π
Kernel file ./lib/string_helpers.c β plus the whole friend group, and we love them all:
string_get_size(9)parse_int_array_user(9)string_unescape(9)string_escape_mem(9)kasprintf_strarray(9)kfree_strarray(9)skip_spaces(9)strim(9)sysfs_streq(9)__sysfs_match_string(9)strreplace(9)memcpy_and_pad(9)
that's the whole page, bestie β no notes, she ate π β¨
source: ./lib Β· version/date: October 2026 Β· ok bye ily, go read the source and hydrate πΈπ«Άπ
π¦ 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