fscrypt_enc...lock_inplace(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐ŸŒธ 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 of FSCRYPT_CONTENTS_ALIGNMENT. not "should", not "ideally" โ€” must. don't test her. ๐Ÿ’€
  • offs โ€” Byte offset within page at 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 is 0, not 1, 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 ๐ŸŒŸ

  • 0 on success ๐ŸŽ‰
  • -errno on failure ๐Ÿ˜”

she's simple like that. love that for her. ๐Ÿ’œ


๐Ÿ”ฎ SEE ALSO ๐Ÿ”ฎ

Kernel file ./fs/crypto/crypto.c โ€” and the whole friend group:

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