generic_permission(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… generic_permission(9) β€” the Kernel API Manual, bestie edition

okay so this is a page from the Kernel API Manual, and the whole main character here is generic_permission(9). she checks whether you're allowed to touch a file on a Posix-like filesystem. let's get into it ✨


🌸 NAME 🌸

generic_permission β€” literally just checking for access rights on a Posix-like filesystem. that's it. that's the vibe check 🫢


πŸŽ€ SYNOPSIS πŸŽ€

int generic_permission (struct mnt_idmap *idmap , struct inode *inode ,
       int mask );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • idmap β€” the idmap of the mount that the inode was found from. yes it matters, keep reading πŸ’…
  • inode β€” the inode we're checking access rights for. the actual file-ish thing, no cap.
  • mask β€” the right to check for, i.e. MAY_READ, MAY_WRITE, MAY_EXEC, MAY_NOT_BLOCK … the little "…" means there's more where that came from, k? πŸ™ˆ

✨ DESCRIPTION ✨

So. This one is used to check for read/write/execute permissions on a file. and here's the iconic part: we use "fsuid" for this, which lets us set arbitrary permissions for filesystem access without changing the "normal" uids that are used for other things. that's the whole slay. separate concerns, periodt πŸ’…

generic_permission is rcu-walk aware, bestie. it returns -ECHILD in case an rcu-walk request cannot be satisfied (eg. requires blocking or too much complexity). and then? it would just get called again in ref-walk mode. no drama, it's giving "try again later" energy 😭

okay now the idmap part, pay attention πŸ”₯

If the inode has been found through an idmapped mount, the idmap of the vfsmount must be passed through idmap. This 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 β€” simply pass nop_mnt_idmap. easy. done. bye 🧚

ngl, if you skip the idmap argument when you actually need it, that's a you problem. pass nop_mnt_idmap only when it's non-idmapped or you really do want the raw inode. 🫢

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./fs/namei.c and honestly the whole friend group:

like, the entire fs/namei.c roster showed up to the party 🌈


πŸ’– that's the whole page, bestie πŸ’–

cute little sign-off: this one comes from ./fs, dated October 2026, and yeah β€” it's generic_permission(9) all the way down. go check some permissions, you icon. πŸŽ€πŸŒΈπŸ¦‹πŸ’œ

πŸ“¦ where this page comes from