vfs_prepare_mode(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… vfs_prepare_mode(9) πŸ’…

Okay so this is a page straight out of the Kernel API Manual, and honestly? It's a little baddie of a helper that deserves way more hype than it gets. Bestie, let's get into it β€” vfs_prepare_mode is literally out here doing the vibe check on file modes before anything gets created. Iconic behaviour, no cap. πŸŽ€


✨ NAME ✨

vfs_prepare_mode β€” prepare the mode to be used for a new inode πŸ¦‹

Like, get the mode ready. That's the whole job. She's a preparer, a little pre-game ritual for inodes. 🌸


🌈 SYNOPSIS 🌈

umode_t vfs_prepare_mode (struct mnt_idmap *idmap , const struct inode
*dir , umode_t mode , umode_t mask_perms , umode_t type );

Yes she takes five arguments, yes she's high maintenance, and yes she's worth it. Read the next section before you @ me. πŸ’…


πŸ”₯ ARGUMENTS πŸ”₯

  • idmap β€” the idmap of the mount that the inode was found from. iykyk, it's the id mapping situation for wherever this inode lives. πŸ—ΊοΈ
  • dir β€” the parent directory of the new inode. Your new file's mom, basically. 🫢
  • mode β€” the mode of the new inode. The permissions aesthetic she's serving. ✨
  • mask_perms β€” the allowed permission by the vfs. The vfs sets the boundaries, she respects them. 🚧
  • type β€” the type of file to be created. Regular? Directory? Something spicier? You tell her. πŸ“

πŸ’– DESCRIPTION πŸ’–

Okay so picture this: this helper ⭐ consolidates ⭐ and ⭐ enforces ⭐ the vfs restrictions on the mode of a brand-new object that's about to be created. She's the one making sure the rules are followed before anything gets to exist. Main character energy, fr fr.

Now the interesting part πŸ’€ β€” umask stripping depends on whether the filesystem supports POSIX ACLs. (See the kernel documentation for mode_strip_umask, bestie, it's literally right there and it explains the whole thing.) πŸ‘‘

Moving umask stripping after setgid stripping is what allows the same ordering for both non-POSIX ACL filesystems and POSIX ACL supporting filesystems. So like, one consistent order for everybody. Slay. Ordering matters and she's not about to let it get messy. πŸŽ€


πŸ‘‘ RETURN πŸ‘‘

The mode to be passed to the filesystem. That's it, that's the tea. She hands you back the prepared mode and you go live your life. πŸ¦‹


🫢 SEE ALSO 🫢

Honestly this list is giving deep lore, and there's a Kernel file involved β€” ./fs/namei.c β€” so buckle up, bestie. Every single one of these is part of the saga:


πŸ’€ Friendly reminder that this page lives under ./fs and is dated October 2026 β€” so if you're reading this from the future, hiiii, hope the kernel's still slaying.

Okay that's the whole page, bestie! Go forth and prepare those modes. Periodt. πŸŒˆπŸ’…βœ¨

πŸ“¦ where this page comes from