vmsplice(2)
๐ vmsplice(2) ๐
okay bestie, welcome to the System Calls Manual, section 2. this is the one, this is the girl. let's get into it ๐ซถ
โจ NAME โจ
vmsplice โ splice user pages to/from a pipe
๐ LIBRARY ๐
Standard C library (libc, -lc)
๐ SYNOPSIS ๐
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <fcntl.h>
ssize_t vmsplice(int fd, const struct iovec *iov,
size_t nr_segs, unsigned int flags);
๐ธ DESCRIPTION ๐ธ
so here's the tea, bestie. if fd is opened for writing, vmsplice() takes nr_segs ranges of your user memory โ the ones described by iov โ and maps them into a pipe. and if fd is opened for reading, it does the opposite: it fills nr_segs ranges of user memory described by iov from a pipe. ๐ฆ
the file descriptor fd must refer to a pipe. no pipe, no party. ๐
the pointer iov points at an array of iovec structures, exactly as described in iovec(3type).
the flags argument is a bit mask that you build by ORing together zero or more of these values:
SPLICE_F_MOVE
unused for vmsplice(). literally just hanging out. go read splice(2) if you're curious. ๐
SPLICE_F_NONBLOCK
do not block on I/O. that's it, that's the vibe. more deets in splice(2).
SPLICE_F_MORE
currently has no effect for vmsplice(), but it might get implemented in the future. she's booked but not confirmed. see splice(2).
SPLICE_F_GIFT
ok this one's the main character. ๐
the user pages are a gift to the kernel. and when i say gift i mean it โ the application may not modify this memory ever, otherwise the page cache and on-disk data may differ. no takebacks, no regifting, no editing. ๐ญ
why would you do this? because gifting pages to the kernel means a subsequent splice(2) SPLICE_F_MOVE can actually move the pages. if you don't specify this flag, then a subsequent splice(2) SPLICE_F_MOVE has to copy the pages instead. move > copy, obviously.
also, data must be properly page aligned โ both in memory and in length. both!! if your length is off, we have a problem.
๐ซถ RETURN VALUE ๐ซถ
on a successful slay, vmsplice() returns the number of bytes transferred to the pipe.
on error, it returns -1 and errno is set to tell you what went wrong. ๐
๐จ ERRORS ๐จ
EAGAINโSPLICE_F_NONBLOCKwas specified inflags, and the operation would block.EBADFโfdis either not valid, or doesn't refer to a pipe.EINVALโnr_segsis greater thanIOV_MAX; or memory not aligned ifSPLICE_F_GIFTset.ENOMEMโ out of memory.
โญ STANDARDS โญ
Linux. that's the whole list, bestie.
๐ HISTORY ๐
Linux 2.6.17, glibc 2.5. a classic, an icon, a legend. โจ
๐ NOTES ๐
vmsplice() follows the other vectorized read/write type functions when it comes to limitations on the number of segments being passed in. that limit is IOV_MAX, as defined in <limits.h>. and currently? that limit is 1024. periodt.
and here's the plot twist ๐ โ vmsplice() really supports true splicing only from user memory to a pipe. in the opposite direction, it actually just copies the data to user space. it's not actually splicing, it's cosplaying as splicing. ๐
but lowkey that's fine, because it makes the interface nice and symmetric and enables people to build on vmsplice() with room for future improvement in performance. she's got potential, okay?? ๐
๐ SEE ALSO ๐
and that's the whole page, bestie!! this was pulled from Linux man-pages 6.20, dated 2026-02-08, and it's the vmsplice(2) page itself. go forth and splice responsibly. no cap. ๐
๐โจ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 2006, Jens Axboe <axboe@kernel.dk>
- Copyright 2006, Michael Kerrisk <mtk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms