fscrypt_file_open(9)
π fscrypt_file_open(9) π
okay so bestie, we're in the Kernel API Manual today and the star of the show is fscrypt_file_open β literally the function that gets you ready to open a possibly-encrypted regular file. it's giving gatekeeper energy and honestly? we love her for it. π
β¨ SYNOPSIS β¨
int fscrypt_file_open (struct inode *inode , struct file *filp );
like yeah that's the whole vibe. two args, one int back. no cap. π¦
πΈ ARGUMENTS πΈ
inodeβ the inode being opened. this is the main character of the operation tbh πfilpβ thestruct filebeing set up. the supporting role that still ate π
π DESCRIPTION π
okay so first things first: right now, an encrypted regular file can only be opened if its encryption key is available. access to the raw encrypted contents? not supported, periodt. so what we do is we first set up the inode's encryption key (if that hasn't already been done) and then we return an error if it's unavailable. no key, no entry, sorry bestie π
we also verify something kind of important: if the parent directory (you know, the one from the path via which the file is being opened) is encrypted, then the inode being opened has to use the same encryption policy. why? because this is part of the enforcement that all files in an encrypted directory tree use the same encryption policy β and that's a protection against certain types of offline attacks. shady behavior, blocked. π₯
note that this check is needed even when opening an unencrypted file, since it's forbidden to have an unencrypted file in an encrypted directory. like, the audacity of even trying π
β RETURN β
0on success β slay, we're in π-ENOKEYif the key is missing β the key said "not today" π- or another
-errnocode β yeah, that can happen too, it's giving unpredictable but in a documented way π«Ά
π SEE ALSO π
- Kernel file
./fs/crypto/hooks.c fscrypt_prepare_lookup_partial(9)fscrypt_prepare_setflags(9)fscrypt_prepare_symlink(9)fscrypt_get_symlink(9)fscrypt_symlink_getattr(9)
the whole friend group fr fr, go read them next π§
and that's the page!! brought to you by ./fs/crypto, dated October 2026, and obviously titled fscrypt_file_open(9) β mwah, love u, go encrypt responsibly πβ¨π
π¦ 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