compat_set_desc_from_vma(9)
π compat_set_desc_from_vma(9) β from the Kernel API Manual, bestie β¨
Okay so buckle up, because this one is a tiny little function with a big identity crisis (affectionate). It lives in section 9 of the Kernel API Manual, and it's literally called compat_set_desc_from_vma. Let's get into it π«Ά
β¨ NAME β¨
compat_set_desc_from_vma β assigns VMA descriptor desc fields from a VMA. That's the whole job. It takes a VMA, and it fills in a descriptor from it. Iconic, efficient, no notes.
πΈ SYNOPSIS πΈ
void compat_set_desc_from_vma (struct vm_area_desc *desc , const struct
file *file , const struct vm_area_struct *vma );
Note the void β it gives nothing back, it just does the thing and returns. Main character energy honestly π
π ARGUMENTS π
descβ a VMA descriptor whose fields need to be set. Like, this is the glow-up target. Its fields are currently unset and we're about to fix that β¨fileβ the file object describing the file beingmmap'd. Yes, that file. The one you're mapping πvmaβ the VMA whose fields we wish to assign todesc. This is the source of truth, the origin story, the blueprint πΈ
π¦ DESCRIPTION π¦
So here's the tea: this is a compatibility function. It exists so that an mmap hook can call mmap_prepare hooks when drivers nest these. That's the whole reason it's here β it's a bridge, a little social connector between two worlds π«Ά
Specifically (and this is the important bit, don't skip it), it allows the construction of a vm_area_desc value, desc, from a VMA, vma, for the purposes of doing this. So: VMA goes in, descriptor comes out, nesting drivers get to talk to each other. Slay π₯
β οΈ Real talk: once the conversion of drivers is complete, this function will no longer be required and will be removed. It's on borrowed time, bestie. Don't build your whole personality around it π
π SEE ALSO π
The Kernel file ./mm/util.c, plus this entire extended friend group:
kfree_const(9), __kmemdup_nul(9), kstrdup(9), kstrdup_const(9), kstrndup(9), kmemdup(9), kmemdup_array(9), kvmemdup(9), kmemdup_nul(9), memdup_user(9), vmemdup_user(9), strndup_user(9), memdup_user_nul(9), randomize_page(9), __account_locked_vm(9), account_locked_vm(9), __vmalloc_array(9), vmalloc_array(9), __vcalloc(9), vcalloc(9), folio_mapping(9), folio_copy(9), get_cmdline(9), mem_dump_obj(9), __compat_vma_mmap(9), compat_vma_mmap(9), snapshot_page(9), mmap_action_prepare(9), mmap_action_complete(9), folio_pte_batch(9), page_range_contiguous(9)
Go read them all. Or at least the compat_vma_mmap ones, they're basically siblings π
Mwah π this page hails from ./mm, dated October 2026, and that's the vibe check complete. Go forth and set those descriptor fields, bestie π§
π¦ 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