fscrypt_prepare_lookup(9)
π fscrypt_prepare_lookup(9) β the Kernel API Manual, but make it make sense
okay so bestie, this one lives in the Kernel API Manual section 9, and it's literally the little prep step before your filesystem goes digging for a filename inside a directory that might be encrypted πβ¨
β¨ SYNOPSIS β¨
int fscrypt_prepare_lookup (struct inode *dir , struct dentry *dentry ,
struct fscrypt_name *fname );
that's the whole signature, character for character, no notes π«Ά
π ARGUMENTS π
dirβ the directory you're searching through. the main character of this search, honestly πdentryβ the filename being looked up. the thing you're hunting for π¦fnameβ (output) the name you'll actually use to search the on-disk directory. it's giving "here's the answer, take it" π
πΈ DESCRIPTION πΈ
so you're about to do ->lookup in a directory that may be encrypted, and this function gets you ready by figuring out the name that will actually, literally be used to search the directory on-disk. prep work. outfit planning before the function goes out. no cap π§
here's the vibe check on how it decides:
- if the directory's encryption policy is supported by this kernel and its encryption key is available β the lookup is assumed to be by plaintext name β¨
- otherwise β the lookup is assumed to be by no-key name π
and now the important part, the part where you cannot zone out bestie:
this will setDCACHE_NOKEY_NAMEon the dentry if the lookup is by no-key name. in that case, the filesystem must assign the dentry adentry_operationswhich containsfscrypt_d_revalidate(or contains ad_revalidatemethod that callsfscrypt_d_revalidate), so that the dentry will be invalidated if the directory's encryption key is later added. π₯
like, that's the whole reason the revalidate hook exists here β key shows up later, dentry gets invalidated. periodt. don't skip it π
β RETURN β
0β success, we ate π-ENOENTβ the directory's key is unavailable but the filename isn't a valid no-key name, so a negative dentry should be created π₯²- another
-errnocode β yeah, something else went sideways, handle it π
π¦ SEE ALSO π¦
- Kernel file
./include/linux/fscrypt.h fscrypt_needs_contents_encryption(9)fscrypt_is_nokey_name(9)fscrypt_has_encryption_key(9)fscrypt_prepare_link(9)fscrypt_prepare_rename(9)fscrypt_prepare_readdir(9)fscrypt_prepare_setattr(9)fscrypt_encrypt_symlink(9)
the whole friend group, all linked, all iconic π
okay that's the page!! this one shipped from ./include/linux back in October 2026, and yes the header/footer both say fscrypt_prepare_lookup(9) because consistency is a love language π go forth and lookup responsibly, 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