fscrypt_enc...lock_inplace(9)
๐ธ fscrypt_encrypt_block_inplace โ the Kernel API Manual, bestie edition ๐ธ
okay so this is a page from the Kernel API Manual (yes, that one) and it's about fscrypt_encrypt_block_inplace(9), which is giving "encrypt one filesystem block right where it already lives" energy. no copying, no moving, just glow-up in place. ๐
โจ NAME โจ
fscrypt_encrypt_block_inplace โ Encrypt a filesystem block in-place
like, literally in-place. the block stays exactly where it is and just gets encrypted on the spot. iconic behavior, no cap. ๐ฅ
๐ SYNOPSIS ๐
int fscrypt_encrypt_block_inplace (const struct inode *inode , struct
page *page , unsigned int len , unsigned int offs , u64 lblk_num );
she takes five arguments and returns an int. that's the whole vibe. โจ
๐ฆ ARGUMENTS ๐ฆ
inodeโ The inode to which this block belongs. yes she needs to know whose block this is, it's giving "who's your mother" energy. ๐pageโ The page containing the block to encrypt. this is the actual vessel, the main character page, the one holding the block. ๐ซถlenโ Size of block to encrypt. This must be a multiple ofFSCRYPT_CONTENTS_ALIGNMENT. not "should", not "ideally" โ must. don't test her. ๐offsโ Byte offset withinpageat which the block to encrypt begins. so like, where in the page the block actually starts. ๐ฏlblk_numโ Filesystem logical block number of the block, i.e. the 0-based number of the block within the file. zero-based, so the first one is0, not1, yes really, that's just how it is. ๐
๐ DESCRIPTION ๐
so the whole point: this encrypts a possibly-compressed filesystem block that lives in an arbitrary page โ and like, key detail โ not necessarily in the original pagecache page. so she's flexible, she's versatile, she's not gonna gatekeep which page the block is chilling in. ๐ง
because of that flexibility, you must specify inode and lblk_num, since they literally cannot be determined from page alone. the page doesn't know its own lore. ๐ญ
heads up bestie: this function only supports non-block-based filesystems that don't support sub-block data units (as indicated by the fscrypt_operations fields). so if your fs is block-based or does sub-block data units, this is not the function for you, sorry, next. ๐
๐ RETURN ๐
0on success ๐-errnoon failure ๐
she's simple like that. love that for her. ๐
๐ฎ SEE ALSO ๐ฎ
Kernel file ./fs/crypto/crypto.c โ and the whole friend group:
fscrypt_free_bounce_page(9)fscrypt_encrypt_pagecache_blocks(9)fscrypt_decrypt_block_inplace(9)fscrypt_initialize(9)
the squad, fr fr. ๐ซถโจ
and that's the page!! source lives at ./fs/crypto, from October 2026, in the Kernel API Manual โ so like, bookmark it, screenshot it, send it to the group chat, whatever you gotta do. mwah ๐๐
๐ฆ 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