fscrypt_symlink_getattr(9)
π fscrypt_symlink_getattr(9) β from the Kernel API Manual, bestie β¨
Okay so picture this: you're deep in the kernel, you crack open section 9 of the manual, and this little icon pops up. It's fscrypt_symlink_getattr, and she's here to fix your symlink sizes. Let's get into it π
β¨ NAME β¨
fscrypt_symlink_getattr β sets the correct st_size for encrypted symlinks. That's her whole job. Slay.
π¦ SYNOPSIS π¦
int fscrypt_symlink_getattr (const struct path *path , struct kstat *stat );
Look at that signature. Immaculate. Returning an int like the confident queen she is π
πΈ ARGUMENTS πΈ
pathβ the path for the encrypted symlink that's being queried. Like, which symlink are we even talking about, bestie? This is how you tell her.statβ thestructthat's getting filled up with the symlink's attributes. She's the vessel. The canvas. The empty cup being filled with knowledge π
π DESCRIPTION π
Okay so here's the tea. Normally st_size would just be the length of the encrypted symlink target β but that's not what userspace actually sees, and honestly? That's giving lie energy. π So this function overrides st_size on encrypted symlinks to be the length of the decrypted symlink target instead, or the no-key encoded symlink target if the key is unavailable.
Why does this matter? Because st_size has to match the symlink target that userspace actually sees. POSIX requires it, periodt, and some userspace programs literally depend on it. No cap. If you broke this, things would be a whole mess π
Now, the cost of all this glamour: it requires reading the symlink target from disk if needed, setting up the inode's encryption key if possible, and then decrypting or encoding the symlink target. So yeah β this makes lstat more heavyweight than it normally is. She's doing a lot of work behind the scenes π
But wait, it gets better β¨ Decrypted symlink targets get cached in ->i_link, so usually the symlink won't have to be read and decrypted all over again later if/when it's actually followed, or if readlink is called, or if lstat is called again. Efficient queen behavior. Obsessed π«Ά
β RETURN β
0on success π-errnoon failure π
π₯ SEE ALSO π₯
Kernel file ./fs/crypto/hooks.c β go read her, she's iconic:
fscrypt_file_open(9)fscrypt_prepare_lookup_partial(9)fscrypt_prepare_setflags(9)fscrypt_prepare_symlink(9)fscrypt_get_symlink(9)
Aight bestie, that's the whole page π Huge shoutout to ./fs/crypto, dated October 2026, home of fscrypt_symlink_getattr(9) β she ate and left absolutely no crumbs πβ¨
π¦ 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