bpf_strnchr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bpf_strnchr(9) β€” like, the kernel API manual, bestie

okay so you opened the manpage for bpf_strnchr(9) and you're probably like "what is this, a string function? in MY kernel?" and yes babes, it is, and it's lowkey iconic. this is the bpf_strnchr page from the Kernel API Manual and we're gonna get through it together, no cap. πŸŽ€


✨ NAME ✨

bpf_strnchr β€” find a character in a length-limited string. that's it, that's the whole vibe. it's giving "where's my letter" energy. πŸ”


🌸 SYNOPSIS 🌸

__bpf_kfunc int bpf_strnchr (const char *s__ign , size_t count , char c );

look at that signature. __bpf_kfunc, returns an int, takes three things. she's simple, she's clean, she's a kfunc. periodt. πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • s__ign β€” the string you're searching through. yes bestie, the one with the suspicious name β€” that __ign suffix is literally part of it, don't come for me, just copy it exactly. πŸ“
  • count β€” how many characters you're willing to look at. it's a cap. a limit. a boundary. respect it. 🚧
  • c β€” the character you're hunting for. the main character of this whole operation, honestly. πŸ‘‘

πŸ’– DESCRIPTION πŸ’–

so the whole point: it looks for c inside s__ign, but only within the first count characters. bounded searching, we love a queen who knows her limits. 🫢

⚠️ important little note, and it's kinda the cutest part: the NUL-terminator is considered part of the string, and can be searched for. so like, if you're looking for '\0', that's completely valid, she's on the guest list too. not me finding that genuinely delightful 😭

πŸ”₯ RETURN πŸ”₯

here's the vibe check on what you get back:

  • >=0 β€” index of the first occurrence of c within s__ign. slay, she found it, here's where. πŸ“
  • -ENOENT β€” c not found in the first count characters of s__ign. she's just not there babe, we looked, it's over. πŸ’€
  • -EFAULT β€” cannot read s__ign. like, at all. unreadable. blocked. πŸ™ˆ
  • -E2BIG β€” s__ign is too large. girl, that's too much string, we can't. 🫠
  • -ERANGE β€” s__ign is outside of kernel address space. wrong neighborhood entirely, not our jurisdiction. 🚫

🌈 SEE ALSO 🌈

first things first, the kernel file to go look at is ./kernel/bpf/helpers.c β€” that's where the magic lives. 🧚

and then there's the friend group, the whole entourage, the guest list. every single one of these, bestie:

like, the whole squad. iykyk. 🫢✨


and that's the page!! πŸŽ€ this lil slice of documentation came to you from ./kernel/bpf and it's dated October 2026 β€” so go forth and search strings responsibly, bestie. mwah. πŸ’œπŸŒΈ

πŸ“¦ where this page comes from