fscrypt_prepare_symlink(9)
π fscrypt_prepare_symlink(9) π
okay so bestie, welcome to the Kernel API Manual page for fscrypt_prepare_symlink(9) β yes that's the whole name, no she did not come to play with shortening it. this is your girl's guide to getting a possibly-encrypted symlink ready to exist in the world π
β¨ NAME β¨
fscrypt_prepare_symlink β get everything prepped to create a symlink that might be encrypted, no cap π¦
β¨ SYNOPSIS β¨
int fscrypt_prepare_symlink (struct inode *dir , const char *target ,
unsigned int len , unsigned int max_len , struct fscrypt_str *disk_link
);
β¨ ARGUMENTS β¨
dirβ the directory where this symlink is about to be born. her home. her whole vibe. πtargetβ the plaintext symlink target, i.e. the thing the symlink actually points at, before any encryption glow-up β¨lenβ how longtargetis, not counting the null terminator. like, do not include it, that's not part of the length bestie πmax_lenβ the amount of space the filesystem actually has available to store the symlink target. think of it as the closet space and the target better fit πdisk_linkβ (out) the on-disk symlink target that's being prepared. this is where the results get written, so she's an output param, treat her right π
β¨ DESCRIPTION β¨
so what does this function actually do? glad you asked π«Ά
It computes the size the symlink target will need on-disk, stores that size in disk_link->len, and validates it against max_len. and like β important detail β an encrypted symlink may end up longer than the original. yes really. encryption adds length, that's just how it is, don't shoot the messenger π
On top of that, disk_link->name gets set to target if the symlink is gonna be unencrypted. but it's left NULL if the symlink is gonna be encrypted. so if you see a NULL there, that's not a bug, that's the vibe check result π₯
For encrypted symlinks, the filesystem has to call fscrypt_encrypt_symlink later to actually create the on-disk target. and before you ask why it's a whole two-step situation β the reason is that some filesystems genuinely need to know the size of the symlink target before creating the inode. like, for example, to figure out whether it's gonna be a "fast" or "slow" symlink. so the two-step process is doing real work, she's not just being extra π
β¨ RETURN β¨
0on success β slay, we ate π-ENAMETOOLONGif the symlink target is too long β the closet was too small, tragic πΈ-ENOKEYif the encryption key is missing β where is she. where did she go. π- any other
-errnocode if something went wrong while setting up the encryption key β a general "it's giving complications" situation π
β¨ SEE ALSO β¨
- Kernel file
./fs/crypto/hooks.c fscrypt_file_open(9)fscrypt_prepare_lookup_partial(9)fscrypt_prepare_setflags(9)fscrypt_get_symlink(9)fscrypt_symlink_getattr(9)
go read those too, iykyk π
fr fr though β ifdisk_link->namecomes backNULL, do not panic and do not skip thefscrypt_encrypt_symlinkstep. that's the encrypted path and she needs her second step or nothing works. periodt π
k that's the whole page, mwah π β this one lives under ./fs/crypto, dated October 2026, and it's part of the Kernel API Manual. go forth and make symlinks, bestie, and remember: 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