fscrypt_setup_filename(9)
π 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:1if we're allowed to proceed without the key, because it's->lookupor we're finding the dir_entry for deletion;0if 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 β
0on success π-errnoon 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 π
- Kernel file
./fs/crypto/fname.c fscrypt_fname_encrypt(9)fname_decrypt(9)fscrypt_fname_encrypted_size(9)fscrypt_fname_alloc_buffer(9)fscrypt_fname_free_buffer(9)fscrypt_fname_disk_to_usr(9)fscrypt_match_name(9)fscrypt_fname_siphash(9)
π 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
- 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