fscrypt_setup_filename(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– fscrypt_setup_filename(9) πŸ’–

okay so this is a page from the Kernel API Manual, bestie β€” it's fscrypt_setup_filename(9) and it's literally about getting your filename ready before you go poking around in a directory that might be encrypted. lowkey iconic kernel internals. let's get into it 🫢


✨ NAME ✨

fscrypt_setup_filename β€” prepare to search a possibly encrypted directory

like, you're about to look something up in a dir and it might be encrypted, so you gotta prep first. that's the whole vibe check πŸ”₯


🌸 SYNOPSIS 🌸

int fscrypt_setup_filename (struct inode *dir , const struct qstr *iname
, int lookup , struct fscrypt_name *fname );

that's the signature, no cap. copy it exactly, don't be out here "fixing" the spacing πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • dir β€” the directory that will be searched. the scene of the crime πŸŽ€
  • iname β€” the user-provided filename being searched for. like, the name the user typed, fr fr.
  • lookup β€” this one's a lil boolean-ish situation, so listen up:
    • 1 if we're allowed to proceed without the key, because it's ->lookup or we're finding the dir_entry for deletion;
    • 0 if we cannot proceed without the key, because we're going to create the dir_entry.
  • fname β€” the filename information to be filled in. it's the output struct, she gets decorated ✨

πŸ’œ DESCRIPTION πŸ’œ

okay so here's the tea. given a user-provided filename iname, this function sets fname->disk_name to the name that would be stored in the on-disk directory entry β€” if possible. not me being all "if possible" about it 😭

if the directory is unencrypted, this is simply iname. easy. no encryption arc, we move on.

else β€” if we have the directory's encryption key β€” then iname is the plaintext, so we encrypt it to get the disk_name.

else, for keyless lookup operations, iname should be a no-key name, so we decode it to get the struct fscrypt_nokey_name. and bestie, non-lookup operations will be impossible in this case, so we fail them with ENOKEY. that's not me being dramatic, that's literally what it says πŸ’€

🌟 if it's successful, fscrypt_free_filename must be called later to clean up. don't forget. she's your responsibility now. clean up after yourself, periodt.

⭐ RETURN ⭐

  • 0 on success πŸŽ‰
  • -errno on failure πŸ™ˆ

that's it. that's the return. very demure, very mindful.


🌈 SEE ALSO 🌈

all the siblings in the fscrypt filename cinematic universe, go check them out πŸ‘‘


πŸŽ€ and that's the whole page, bestie! this one lives in ./fs/crypto, dated October 2026 β€” so like, future vibes only. stay encrypted, stay slay πŸ’–βœ¨πŸ’…

πŸ“¦ where this page comes from