kernel_recvmsg(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’Œ kernel_recvmsg β€” bestie edition

okay so this is a page from the Kernel API Manual (yes, the kernel kernel, we're in kernel space rn, no cap) and it's about kernel_recvmsg, which is literally how you receive a message from a socket when you're living that kernel-space life. sit down, grab a strawberry πŸ“, let's get into it.


✨ NAME ✨

kernel_recvmsg β€” receive a message from a socket, but make it kernel space 🫢


✨ SYNOPSIS ✨

int kernel_recvmsg (struct socket *sock , struct msghdr *msg , struct
kvec *vec , size_t num , size_t size , int flags );

that's the whole signature, copy it exactly, do not freestyle it πŸ’…


✨ ARGUMENTS ✨

  • sock β€” the socket you're receiving the message from. your source. your origin story. 🌸
  • msg β€” the received message. this is where the good stuff lands. πŸ’–
  • vec β€” input scatter/gather array for the message data. the s/g icon of the group chat. ✨
  • num β€” the size of that input s/g array. how many of them there are. πŸŽ€
  • size β€” number of bytes to read. yes, bytes. respect the units. πŸ¦‹
  • flags β€” message flags, like MSG_DONTWAIT, etc... the "etc..." is doing a lot of heavy lifting here but that's what the page says, iykyk 😭

✨ DESCRIPTION ✨

so here's the tea 🍡 β€” on return, the msg structure contains the scatter/gather array that you passed in through the vec argument. and not just as-is, bestie: the array gets modified so that it consists of the unfilled portion of the original array. it slims down. it's giving what's left over, and honestly? iconic. πŸ‘‘

the returned value is the total number of bytes received, or an error. that's it. total bytes, or error. two outcomes, no in-between, periodt. πŸ”₯


✨ SEE ALSO ✨

the page also shouts out the kernel file ./net/socket.c and a whole friend group of related functions β€” go say hi to all of them, don't leave anyone on read πŸ’œ:


okay that's the whole page, you ate that πŸ’…βœ¨ mwah πŸŽ€

this cutie lives in ./net and the page is dated October 2026, so like… future vibes, main character energy, kernel_recvmsg(9) forever πŸŒˆπŸ’–πŸ¦‹

πŸ“¦ where this page comes from