memcpy_from_file_folio(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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_SIZE if the folio comes from HIGHMEM (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 πŸ‘‘:

iykyk 🧚


πŸŽ€ Friendly reminder fr fr: len is a maximum, the folio and PAGE_SIZE under HIGHMEM get 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