bpf_strchr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

Okay so bpf_strchr(9) is the Kernel API Manual entry for bpf_strchr β€” the function that finds the first occurrence of a character in a string. It’s giving β€œtiny search bar, but for one char,” and honestly? Iconic. ✨

✨ SYNOPSIS ✨

The whole signature flex is:

__bpf_kfunc int bpf_strchr (const char *s__ign , char c );

πŸŽ€ ARGUMENTS πŸŽ€

  • s__ign β€” the string to be searched. This is the main character you’re scanning, bestie.
  • c β€” the character to search for. The one you’re hunting for, fr fr.

🌸 DESCRIPTION 🌸

Lowkey important detail: the NUL-terminator is considered part of the string here, and you can search for it too. Not me pointing that out because it’s exactly the kind of tiny thing that matters, but also yes. 🫢

πŸ”₯ RETURN πŸ”₯

  • >=0 β€” the index of the first occurrence of c within s__ign. Slay, found it.
  • -ENOENT β€” c not found in s__ign. It’s not there, bestie, no cap.
  • -EFAULT β€” cannot read s__ign. The vibe check failed at read time. 😭
  • -E2BIG β€” s__ign is too large. That string ate too much.
  • -ERANGE β€” s__ign is outside of kernel address space. Not in the right neighborhood, periodt.

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./kernel/bpf/helpers.c is the source-file bestie, and the whole cross-ref crew is here β€” every single one, no skipping:


Signed off from ./kernel/bpf β€” October 2026 β€” page bpf_strchr(9) πŸ’…πŸ«Άβœ¨

πŸ“¦ where this page comes from