bpf_strnchr(9)
π 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__ignsuffix 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 ofcwithins__ign. slay, she found it, here's where. π-ENOENTβcnot found in the firstcountcharacters ofs__ign. she's just not there babe, we looked, it's over. π-EFAULTβ cannot reads__ign. like, at all. unreadable. blocked. π-E2BIGβs__ignis too large. girl, that's too much string, we can't. π«-ERANGEβs__ignis 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:
bpf_obj_new(9),bpf_percpu_obj_new(9),bpf_obj_drop(9),bpf_percpu_obj_drop(9),bpf_refcount_acquire(9)bpf_list_push_front(9),bpf_list_push_back(9),bpf_rbtree_add(9)bpf_task_acquire(9),bpf_task_release(9)bpf_cgroup_acquire(9),bpf_cgroup_release(9),bpf_cgroup_ancestor(9),bpf_cgroup_from_id(9)bpf_task_under_cgroup(9),bpf_task_get_cgroup1(9),bpf_task_from_pid(9),bpf_task_from_vpid(9)bpf_dynptr_slice(9),bpf_dynptr_slice_rdwr(9),bpf_dynptr_copy(9),bpf_dynptr_memset(9)bpf_iter_bits_new(9),bpf_iter_bits_next(9),bpf_iter_bits_destroy(9)bpf_copy_from_user_str(9),bpf_copy_from_user_task_str(9)bpf_strcmp(9),bpf_strcasecmp(9),bpf_strchr(9),bpf_strchrnul(9),bpf_strrchr(9),bpf_strnlen(9),bpf_strlen(9),bpf_strspn(9),bpf_strcspn(9),bpf_strstr(9),bpf_strcasestr(9),bpf_strnstr(9),bpf_strncasestr(9)bpf_lookup_user_key(9),bpf_lookup_system_key(9),bpf_key_put(9),bpf_verify_pkcs7_signature(9)bpf_task_work_schedule_signal(9),bpf_task_work_schedule_resume(9),bpf_timer_cancel_async(9)
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
- 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