sg_copy_buffer(9)
π
sg_copy_buffer β bestie's guide to shuttling bytes between a linear buffer and an SG list β¨
okay so this one is from the Kernel API Manual (that's the manual name, keep up π«Ά), and honestly? it's a lil workhorse. It copies data between a boring flat linear buffer and a fancy scatterlist (SG) list. That's it. That's the whole vibe. No cap.
πΈ SYNOPSIS πΈ
size_t sg_copy_buffer (struct scatterlist *sgl , unsigned int nents ,
void *buf , size_t buflen , off_t skip , bool to_buffer );
π ARGUMENTS π
sglβ the SG list, aka the main character of this whole operation π«Άnentsβ how many SG entries there are (count 'em)bufβ where to copy frombuflenβ the number of bytes to copy (yes, exactly this many, no more no less π )skipβ how many bytes to skip before we start copying. like scrolling past the intro, iykykto_bufferβ the transfer direction, and it's literally just abool:true== from an sg list to a bufferfalse== from a buffer to an sg list
π DESCRIPTION π
Returns the number of copied bytes. that's the whole bit β the return value is your count, periodt. β
lowkey obsessed with how this function just does the thing and tells you how many bytes it did it to. no drama, no notes. π₯
π SEE ALSO π
Kernel file ./lib/scatterlist.c, plus this whole friend group of scatterlist functions (all (9) section, obviously β kernel internals only π
):
sg_nents(9)sg_nents_for_len(9)sg_nents_for_dma(9)sg_last(9)sg_init_table(9)sg_init_one(9)__sg_free_table(9)sg_free_append_table(9)sg_free_table(9)__sg_alloc_table(9)sg_alloc_table(9)sg_alloc_append_table_from_pages(9)sg_alloc_table_from_pages_segment(9)sgl_alloc_order(9)sgl_alloc(9)sgl_free_n_order(9)sgl_free_order(9)sgl_free(9)sg_miter_start(9)sg_miter_skip(9)sg_miter_next(9)sg_miter_stop(9)sg_copy_from_buffer(9)sg_copy_to_buffer(9)sg_pcopy_from_buffer(9)sg_pcopy_to_buffer(9)sg_zero_buffer(9)extract_iter_to_sg(9)
likeβ¦ the whole extended universe fr fr π
β¨ anyway bestie that's the page!! live from ./lib, dated October 2026 β catch you in the next scatterlist ππ¦π
π¦ 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