copy_splice_read(9)
π 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β theSPLICE_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:
0gets returned if there's no more data to be read β that's your "we're done here" moment.-EAGAINgets 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:
splice_to_pipe(9)splice_from_pipe_feed(9)splice_from_pipe_next(9)splice_from_pipe_begin(9)splice_from_pipe_end(9)__splice_from_pipe(9)splice_from_pipe(9)iter_file_splice_write(9)splice_to_socket(9)vfs_splice_read(9)splice_direct_to_actor(9)do_splice_direct(9)splice_file_range(9)
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
- 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