fscrypt_prepare_lookup(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 set DCACHE_NOKEY_NAME on the dentry if the lookup is by no-key name. in that case, the filesystem must assign the dentry a dentry_operations which contains fscrypt_d_revalidate (or contains a d_revalidate method that calls fscrypt_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 -errno code β€” yeah, something else went sideways, handle it πŸ™ˆ

πŸ¦‹ SEE ALSO πŸ¦‹

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