bpf_strcspn(9)
π bpf_strcspn(9) β bestie edition π
okay so this page is bpf_strcspn from the Kernel API Manual, and it's genuinely one of the cutest little helpers out there, no cap.
β¨ NAME β¨
bpf_strcspn β literally calculates the length of the initial substring of @s__ign that does not contain any letters from @reject__ign. it's giving "how far can I walk before I hit one of your ick letters" energy π¦
πΈ SYNOPSIS πΈ
__bpf_kfunc int bpf_strcspn (const char *s__ign , const char *reject__ign );
that's it. that's the whole vibe check. two strings in, one int out π
π ARGUMENTS π
s__ignβ the string we're searching through. the main character, tbh πreject__ignβ the string we're searching for. the reject list, the ick list, the "if I see any of these I'm stopping" list π
β RETURN β
>=0β the length of the initial substring ofs__ignthat does not contain letters fromreject__ign. slay, a non-negative number, we love to see it β¨-EFAULTβ cannot read one of the strings. π literally can't even read it-E2BIGβ one of the strings is too large. too much, bestie, it's too much π-ERANGEβ one of the strings is outside of kernel address space. wrong neighbourhood fr fr π
π₯ SEE ALSO π₯
kernel file ./kernel/bpf/helpers.c, plus the whole friend group:
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_strnchr(9), bpf_strchr(9), bpf_strchrnul(9), bpf_strrchr(9), bpf_strnlen(9), bpf_strlen(9), bpf_strspn(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 I said, huge friend group. iykyk π
ngl bestie,strcspnis the complement ofstrspnβ it stops at the first character that's in the reject set. read it twice, it clicks π§
that's the whole page, bestie β brought to you by the ./kernel/bpf girlies, October 2026, kernel docs edition π
π«Ά
π¦ 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