fscrypt_prepare_symlink(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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 long target is, 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 ✨

  • 0 on success β€” slay, we ate πŸ‘‘
  • -ENAMETOOLONG if the symlink target is too long β€” the closet was too small, tragic 🌸
  • -ENOKEY if the encryption key is missing β€” where is she. where did she go. πŸ”
  • any other -errno code if something went wrong while setting up the encryption key β€” a general "it's giving complications" situation πŸ’€

✨ SEE ALSO ✨

go read those too, iykyk 🌈


fr fr though β€” if disk_link->name comes back NULL, do not panic and do not skip the fscrypt_encrypt_symlink step. 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