fscrypt_set_bio_crypt_ctx(9)
π fscrypt_set_bio_crypt_ctx
okay so bestie, we're in the Kernel API Manual today and the star of the show is fscrypt_set_bio_crypt_ctx(9) β literally the function that gets a file contents bio all dressed up for inline crypto β¨
πΈ NAME πΈ
fscrypt_set_bio_crypt_ctx β prep a file contents bio for inline crypto π
β¨ SYNOPSIS β¨
void fscrypt_set_bio_crypt_ctx (struct bio *bio , const struct inode
*inode , loff_t pos , gfp_t gfp_mask );
π«Ά ARGUMENTS π«Ά
bioβ a bio that's eventually gonna get submitted to the file πinodeβ the file's inode, yep that oneposβ the first file position (in bytes) in the I/O πgfp_maskβ memory allocation flags. and listen, these must be a waiting mask so thatbio_crypt_set_ctxcan't fail. no cap, that's a hard requirement π
π¦ DESCRIPTION π¦
So like β if the contents of the file should be encrypted (or decrypted), then you assign the appropriate encryption context to the bio. that's the whole vibe π
Normally the bio should be newly allocated (i.e. no pages added yet), because otherwise fscrypt_mergeable_bio won't work as intended. so don't be out here adding pages first and then acting surprised π
Good news tho: the encryption context will be freed automatically when the bio is freed. self-cleaning, iconic, main character energy π
π₯ SEE ALSO π₯
- Kernel file
./fs/crypto/block.c fscrypt_mergeable_bio(9)fscrypt_limit_io_blocks(9)fscrypt_zeroout_range(9)
okay that's the whole page bestie, go forth and encrypt responsibly π
shoutout to the source ./fs/crypto, dated October 2026 β mwah, we love a documented kernel π«Άβ¨
π¦ 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