search_binfmt_handler(9)
π search_binfmt_handler(9) β like, the kernel API manual, bestie π
okay so real talk, this one's from the Kernel API Manual and it's genuinely such a cute lil function. It's called search_binfmt_handler and it does exactly what it says on the tin: it goes looking for a binary handler. Let's get into it β¨
πΈ SYNOPSIS πΈ
struct binfmt_misc_entry * search_binfmt_handler (struct binfmt_misc
*misc , struct linux_binprm *bprm );
That return type is struct binfmt_misc_entry *, no cap β she's giving pointer-to-entry realness π
π¦ ARGUMENTS π¦
miscβ your handle to thebinfmt_miscinstance. Like, this is the whole world we're searching in, bestie π«Άbprmβ the binary we're trying to find a handler for. The main character of this operation, honestly π
π DESCRIPTION π
So here's the vibe: this function searches for a binary type handler for bprm in the list of registered binary type handlers. Simple enough, right?
A 'B' entry's match program is the one that decides whether the handler applies. And listen β that match program may sleep to read the binary. Not a drill, it's allowed to do that, and that's lowkey important for the locking situation below π
The matched entry gets returned with a reference taken while the walk still held it. Meanwhile, a dying entry β one that's been unlinked with its last reference gone β cannot be matched, so the walk just moves on. She's gone, we're not matching her, periodt π
ok so this part is the actual important bit: the caller must hold the bm_entries_srcu read lock, and that's exactly what allows an entry's evaluation to sleep. Do not skip this, fr fr π
β RETURN β
- referenced binary type list entry on success π₯
NULLon failure π
That's it. That's the whole return section. Iconic brevity, honestly π
π SEE ALSO π
The kernel file ./fs/binfmt_misc.c β yes, that's where all the magic lives π§
And the whole squad of related functions, because she does not exist in a vacuum bestie:
struct binfmt_misc_flag(9)get_binfmt_handler(9)binfmt_misc_find_interp(9)entry_attach_interpreter(9)put_binfmt_handler(9)current_binfmt_misc(9)entry_select_interpreter(9)entry_invocation_flags(9)entry_open_interpreter(9)build_interp_argv(9)i_binfmt_misc(9)bm_evict_inode(9)unlink_binfmt_handler(9)remove_binfmt_handler(9)bm_unlink(9)bm_entry_add_interp(9)
aaaand that's the page!! this one's living in ./fs and it's dated October 2026, so future-core of her honestly π¦π go hold that bm_entries_srcu read lock and slay, bestie πΈβ¨
π¦ 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