fscrypt_prepare_setattr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… fscrypt_prepare_setattr(9) πŸ’…

okay bestie, this page is from the Kernel API Manual, and it’s lowkey essential for anyone touching a possibly-encrypted inode. let’s get into it πŸ¦‹


πŸŽ€ NAME πŸŽ€

fscrypt_prepare_setattr β€” prepare to change a possibly-encrypted inode’s attributes ✨

✨ SYNOPSIS ✨

int fscrypt_prepare_setattr (struct dentry *dentry , struct iattr *attr
);

🫢 ARGUMENTS 🫢

  • dentry β€” the dentry through which the inode is being changed. that’s the doorway, bestie πŸšͺ✨
  • attr β€” the attributes to change. slay, let’s edit some metadata πŸ’…

πŸ”₯ DESCRIPTION πŸ”₯

okay so the whole vibe is: prepare for ->setattr on a possibly-encrypted inode. no cap. On an encrypted file, most attribute changes are allowed even without the encryption key β€” iconic behavior, honestly. BUT without the encryption key we do have to forbid truncates. periodt.

Why? because the size being truncated to may not be a multiple of the filesystem block size, and in that case we’d have to decrypt the final block, zero the portion past i_size, and re-encrypt it. that’s giving β€œwhole extra chore” 😭

(we could allow truncating to a filesystem block boundary, but it’s simpler to just forbid all truncates --- and we already forbid all other contents modifications without the key.) so yeah, truncates are not invited to the no-key party πŸ’€

⭐ RETURN ⭐

0 on success, -ENOKEY if the key is missing, or another -errno code if a problem occurred while setting up the encryption key. that’s the return vibe check πŸ’–

🌈 SEE ALSO 🌈


mwah πŸ’‹ β€” source/version: ./include/linux; date: October 2026. periodt. πŸŽ€

πŸ“¦ where this page comes from