bpf_strcasestr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bpf_strcasestr πŸ’…

okay so this is a page from the Kernel API Manual (section 9, kernel API, iykyk), and it's all about bpf_strcasestr β€” the function that finds the first substring in a string while ignoring the case of the characters. literally the "i don't care if you're shouting" version of a substring search 🫢


✨ NAME ✨

bpf_strcasestr β€” find the first substring in a string, ignoring the case of the characters πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

__bpf_kfunc int bpf_strcasestr (const char *s1__ign , const char *s2__ign );

that's the whole signature bestie, no cap. two const char * args, both marked __ign, returns an int, and it's a __bpf_kfunc πŸ‘‘


🌸 ARGUMENTS 🌸

  • s1__ign β€” the string to be searched. this is the one you're digging through, the main character of the search πŸ”
  • s2__ign β€” the string to search for. the little guy you're looking for inside s1__ign 🐣

🌈 RETURN 🌈

here's the vibe check on what you get back β€” it's an int, so read the sign, okay?

  • >=0 β€” index of the first character of the first occurrence of s2__ign within s1__ign ⭐ (zero or bigger = found it, and here's exactly where it starts)
  • -ENOENT β€” s2__ign is not a substring of s1__ign 😭 (it's just not in there, sorry bestie)
  • -EFAULT β€” cannot read one of the strings πŸ™ˆ (something's not readable)
  • -E2BIG β€” one of the strings is too large πŸ’€ (that string ate and then ate some more)
  • -ERANGE β€” one of the strings is outside of kernel address space 🚫 (not our address space, not our problem)
fr fr, check the return value every time. 0 and up is a hit, negative is a hard no β€” and each negative has a different reason, so don't lump them together πŸ’…

πŸ¦‹ SEE ALSO πŸ¦‹

so many friends πŸ’– first up, the kernel file: ./kernel/bpf/helpers.c β€” that's where the family lives. then, the whole crew:

the string-search girlies in particular β€” bpf_strstr(9), bpf_strnstr(9), bpf_strcasecmp(9), bpf_strncasestr(9) β€” are literally siblings of this one, so go say hi 🌸

that's the whole page bestie, no notes πŸ’… this one ships out of ./kernel/bpf and it's dated October 2026 β€” mwah, go find your substrings πŸŽ€βœ¨πŸ«Ά

πŸ“¦ where this page comes from