setattr_prepare(9)
π setattr_prepare β the vibe check before you touch a dentry's attributes
okay so this is setattr_prepare(9) from the Kernel API Manual, and bestie, it's literally the bouncer at the club door for attribute changes. No cap. π
β¨ NAME β¨
setattr_prepare β check if attribute changes to a dentry are allowed π
π¦ SYNOPSIS π¦
int setattr_prepare (struct mnt_idmap *idmap , struct dentry *dentry ,
struct iattr *attr );
πΈ ARGUMENTS πΈ
idmapβ the idmap of the mount the inode was found from πΊοΈdentryβ the dentry we're checking, bestie, this is the one under the microscope πattrβ the attributes we wanna change β¨
π DESCRIPTION π
So what this does is check if we're allowed to change the attributes hanging out in attr on the given dentry. And it's not just a vibe check β it does the normal unix access permission checks, plus checks for rlimits and others too. Thorough queen. π
It also clears the SGID bit from mode if the user isn't allowed to set it. Rude but fair. And file capabilities plus IMA extended attributes get cleared if ATTR_KILL_PRIV is set. π§Ή
Now here's the idmapped mount tea β β if the inode was found through an idmapped mount, the idmap of the vfsmount must be passed through idmap. The function will then take care to map the inode according to idmap before checking permissions. On non-idmapped mounts, or if permission checking is to be performed on the raw inode, just simply pass nop_mnt_idmap. Easy. π
Should be called as the first thing in ->setattr implementations β possibly after taking additional locks. Like, first. Don't skip this step, i'm begging π
π«Ά SEE ALSO π«Ά
Kernel file ./fs/attr.c β and these iconic siblings:
setattr_should_drop_sgid(9)setattr_should_drop_suidgid(9)chown_ok(9)chgrp_ok(9)inode_newsize_ok(9)setattr_copy_mgtime(9)setattr_copy(9)notify_change(9)
and that's the whole page, bestie!! π this one's from the ./fs source, October 2026 edition of the Kernel API Manual β go forth and prepare those attributes 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