memcpy_from_file_folio(9)
π memcpy_from_file_folio β the Kernel API Manual, bestie edition π
Okay so like, this one lives in the Kernel API Manual (section 9, the kernel-functions girlies β¨) and honestly? It's giving "small function, big responsibility." Let me put you on π«Ά
πΈ NAME πΈ
memcpy_from_file_folio β literally just copy some bytes from a file folio. That's it. That's the whole vibe. π
β¨ SYNOPSIS β¨
size_t memcpy_from_file_folio (char *to , struct folio *folio , loff_t
pos , size_t len );
Like, look at her. Returns a size_t, takes four args, no drama. π
π¦ ARGUMENTS π¦
toβ the destination buffer, aka where the bytes are moving to. She's the receiving end, the main character of the copy operation πfolioβ the folio you're copying from. The source. The origin story β¨posβ the position in the file. Like, where are we even, bestie? πlenβ the maximum number of bytes to copy. Max, not guaranteed β remember that, it comes back later π
π DESCRIPTION π
So the whole point: copy up to len bytes from this folio. Copy up to β not "exactly," not "at least," up to π₯
And the way the actual amount can get capped? Two things:
- It may be limited by
PAGE_SIZEif the folio comes fromHIGHMEM(yes, HIGHMEM is still a thing and she's still out here applying limits π) - It's also limited by the size of the folio itself, obviously, because you can't copy more bytes than actually exist, no cap π
So like, do the vibe check: you asked for len, but the folio might be like "bestie, no, here's less." π
β RETURN β
The number of bytes actually copied from the folio. So check it! Don't just assume you got your full len, because you might not have π
π SEE ALSO π
Kernel file ./include/linux/highmem.h β and the whole highmem friend group, honestly, they all show up together π:
kmap(9)kunmap(9)kmap_to_page(9)kmap_flush_unused(9)kmap_local_page(9)kmap_local_folio(9)kmap_atomic(9)clear_user_page(9)clear_user_pages(9)clear_user_highpage(9)clear_user_highpages(9)vma_alloc_zeroed_movable_folio(9)memcpy_from_folio(9)memcpy_to_folio(9)folio_zero_tail(9)folio_fill_tail(9)folio_zero_segments(9)folio_zero_segment(9)folio_zero_range(9)folio_release_kmap(9)
iykyk π§
π Friendly reminder fr fr:lenis a maximum, the folio andPAGE_SIZEunderHIGHMEMget a vote too, and the return value is your receipts. Periodt. π
Source: ./include/linux β dated October 2026, from the Kernel API Manual, section 9. Bye bestie, go copy some bytes 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