setattr_prepare(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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:


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