shmem_kernel_file_setup(9)
π shmem_kernel_file_setup(9) π
okay so bestie, welcome to the Kernel API Manual β¨ this one's about shmem_kernel_file_setup, and it's lowkey a whole vibe. it hands you an unlinked file that lives in tmpfs, and here's the thing β it must be kernel internal. no cap.
πΈ NAME πΈ
shmem_kernel_file_setup β get an unlinked file living in tmpfs which must be kernel internal.
and listen, this part is important so pay attention π«Ά β there will be NO LSM permission checks against the underlying inode. none. zero. so anyone using this interface must do their LSM checks at a higher layer. the users are the big_key and shm implementations, and LSM checks are provided at the key or shm level rather than at the inode. periodt. π
β οΈ bestie please internalise this β no inode-level LSM checks happen here, so if you're the caller, the responsibility is yours at a higher layer. don't skip it. π
β¨ SYNOPSIS β¨
struct file * shmem_kernel_file_setup (const char *name , loff_t size ,
vma_flags_t flags );
like, that's the whole signature. she's simple, she's iconic π
π ARGUMENTS π
nameβ name for dentry (to be seen in/proc/<pid>/maps) π so yes, it's gonna show up in the maps file, that's the whole point.sizeβ size to be set for the file πΈ that's your file size, set it, own it.flagsβVMA_NORESERVE_BITsuppresses pre-accounting of the entire object size π that's the specific flag bit and the specific behaviour, fr fr.
π¦ SEE ALSO π¦
Kernel file ./mm/shmem.c and honestly the whole shmem fam π
shmem_recalc_inode(9)shmem_writeout(9)shmem_get_folio(9)shmem_file_setup(9)shmem_file_setup_with_mnt(9)shmem_zero_setup(9)shmem_zero_setup_desc(9)shmem_read_folio_gfp(9)
π shoutout to./mmfor housing all of this, and this beauty is dated October 2026, filed undershmem_kernel_file_setup(9). mwah, go read the source 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