sg_pcopy_to_buffer(9)
β¨ sg_pcopy_to_buffer β¨
okay so bestie, welcome to the sg_pcopy_to_buffer page π
this is straight out of the Kernel API Manual section 9, and honestly? it's a little icon of a function. let's get into it π«Ά
πΈ NAME πΈ
sg_pcopy_to_buffer β copy from an SG list to a linear buffer, no cap π
like, that's literally the whole vibe. scatter-gather list goes in, nice flat linear buffer comes out. slay.
π¦ SYNOPSIS π¦
size_t sg_pcopy_to_buffer (struct scatterlist *sgl , unsigned int nents
, void *buf , size_t buflen , off_t skip );
look at her signature. it's giving five whole arguments and she knows it π
π ARGUMENTS π
sglβ the SG list itself. this is the main character, the source of truth, the one we're copying out of πnentsβ number of SG entries. like, how many of them we're dealing with. you gotta tell her, she's not psychic β¨bufβ where to copy to. this is the destination, the linear buffer, the place all the data is gonna land πΈbuflenβ the number of bytes to copy. exact amount, bestie, don't eyeball it π―skipβ number of bytes to skip before copying. yes, we're doing a little hop-skip-jump before we start π (it's anoff_t, so it's got range)
π DESCRIPTION π
Returns the number of copied bytes. that's it. that's the whole description. short and iconic, periodt π
ngl bestie this is one of those functions where the return value usage matters β take the number of copied bytes seriously and don't assume it's always equal to buflen π
π₯ SEE ALSO π₯
aaand here comes the whole friend group π€ all of these live in the kernel file ./lib/scatterlist.c β go say hi:
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_buffer(9)sg_copy_from_buffer(9)sg_copy_to_buffer(9)sg_pcopy_from_buffer(9)sg_zero_buffer(9)extract_iter_to_sg(9)
every single one of them, in order, exactly as the original listed them β I would never do my besties dirty by trimming the list π«Ά
π little note: this page is filed under ./lib in the kernel tree, and the version stamp on it is October 2026.
aaand that's the page! ty for coming to my ted talk, go write some scatterlist code, ily, bye ππβ¨π
π¦ 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