copy_splice_read(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… copy_splice_read(9) β€” the Kernel API Manual glow-up πŸŽ€

okay bestie, so this one lives in section 9 of the Kernel API Manual, and it's genuinely such a serve. it's called copy_splice_read and it's about copying data out of a file and splicing that copy straight into a pipe. no cap, it's giving "middle of the plumbing but make it fashion".


✨ NAME ✨

copy_splice_read β€” copy data from a file and splice the copy into a pipe 🫢


🌸 SYNOPSIS 🌸

ssize_t copy_splice_read (struct file *in , loff_t *ppos , struct
pipe_inode_info *pipe , size_t len , unsigned int flags );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • in β€” the file you're reading from, bestie. that's the source, the main character.
  • ppos β€” a pointer to the file position to read from πŸ“
  • pipe β€” the pipe we're splicing into. that's the destination, the it-girl of the operation.
  • len β€” the amount to splice, i.e. how much we're moving.
  • flags β€” the SPLICE_F_* flags πŸ’«

πŸ’– DESCRIPTION πŸ’–

so here's the vibe. this function allocates a whole bunch of pages β€” enough to hold the amount of data you asked for (but limited by the remaining pipe capacity, okay, so don't get too excited, the pipe gets a say 🫠). then it passes those pages to the file's ->read_iter so they get read into, and after that it splices the used pages into the pipe.

like, allocate β†’ read into β†’ splice. the whole little routine. slay ✨


πŸ‘‘ RETURN πŸ‘‘

on success, the number of bytes read gets returned, and *ppos will be updated if appropriate πŸŽ€. also, lowkey important:

  • 0 gets returned if there's no more data to be read β€” that's your "we're done here" moment.
  • -EAGAIN gets returned if the pipe had no space 😭
  • some other negative error code gets returned on error.
  • and a short read may occur if the pipe has insufficient space, we reach the end of the data, or we hit a hole πŸ•³οΈ. not a bug, just how it goes.

🌈 SEE ALSO 🌈

the kernel file ./fs/splice.c πŸ’œ and all its friends:


and that's the whole page, bestie 🧚 this one shipped out of ./fs in October 2026, and it's literally titled copy_splice_read(9). go forth and splice responsibly πŸ’…πŸ”₯

πŸ“¦ where this page comes from