fscrypt_prepare_setattr(9)
π 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 π
- Kernel file
./include/linux/fscrypt.h fscrypt_needs_contents_encryption(9)fscrypt_is_nokey_name(9)fscrypt_has_encryption_key(9)fscrypt_prepare_link(9)fscrypt_prepare_rename(9)fscrypt_prepare_lookup(9)fscrypt_prepare_readdir(9)fscrypt_encrypt_symlink(9)
mwah π β source/version: ./include/linux; date: October 2026. periodt. π
π¦ 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