sockfd_lookup(9)
πΈ NAME πΈ
okay so bestie, this is sockfd_lookup(9) from the Kernel API Manual, and it's literally the glow-up that takes you from a file number to its socket slot. iconic behavior, no cap.
β¨ SYNOPSIS β¨
struct socket * sockfd_lookup (int fd , int *err );
π«Ά ARGUMENTS π«Ά
fdβ the file handle, bestie. that's the starting point.errβ a pointer where an error code gets returned. it's giving "leave a note if things go sideways" energy.
π DESCRIPTION π
so here's the tea: the file handle you pass in gets locked, and the socket it's bound to is returned to you. slay.
if an error happens, the err pointer gets overwritten with a negative errno code, and you get NULL back. that's the vibe check failing, fr fr.
the function is out here checking for both invalid handles and passing a handle which is not a socket. it's not letting impostors through. π
on success, the socket object pointer is returned. periodt. β¨
π¦ SEE ALSO π¦
also mentions the Kernel file ./net/socket.c, plus this whole friend group of kernel icons:
move_addr_to_kernel(9)move_addr_to_user(9)sock_read_xattr(9)sock_alloc_file(9)sock_from_file(9)sock_alloc(9)sock_release(9)sock_sendmsg(9)kernel_sendmsg(9)sock_recvmsg(9)kernel_recvmsg(9)sock_create_lite(9)__sock_create(9)sock_create(9)sock_create_kern(9)sock_register(9)sock_unregister(9)kernel_bind(9)kernel_listen(9)kernel_accept(9)kernel_connect(9)kernel_getsockname(9)kernel_getpeername(9)kernel_sock_shutdown(9)kernel_sock_ip_overhead(9)
xoxo, your kernel bestie π β from source/version ./net, dated October 2026 β¨
π¦ 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