VOP_ACCESS(9)

πŸ’– VOP_ACCESS β€” check access permissions of a file or Unix domain socket πŸ’–

okay bestie, welcome to the Kernel Developer's Manual, page VOP_ACCESS(9). yes we're in the kernel now, yes it's giving main character energy, and yes you're gonna understand it. let's go ✨


πŸŽ€ NAME πŸŽ€

VOP_ACCESS, VOP_ACCESSX β€” check access permissions of a file or Unix domain socket


🌸 SYNOPSIS 🌸

#include <sys/param.h>
#include <sys/vnode.h>

int
VOP_ACCESS(struct vnode *vp, accmode_t accmode, struct ucred *cred,
    struct thread *td);

int
VOP_ACCESSX(struct vnode *vp, accmode_t accmode, struct ucred *cred,
    struct thread *td);

πŸ¦‹ DESCRIPTION πŸ¦‹

so this entry point checks the access permissions of the file against the credentials you hand it. that's the whole vibe. it's a permission vibe check, for files.

its arguments are, bestie, listen up:

  • vp β€” the vnode of the file we're checking. the file in question, the it-girl, the subject πŸ’…
  • accmode β€” the type of access required. like, what are we even trying to do here?
  • cred β€” the user credentials to check. who's asking? πŸ‘€
  • td β€” the thread which is checking. the one doing the asking, fr fr.

so accmode is a mask that can contain flags described in <sys/vnode.h>, e.g. VREAD, VWRITE or VEXEC.

now here's the tea πŸ“: for VOP_ACCESS(), the only flags that may be set in accmode are VEXEC, VWRITE, VREAD, VADMIN and VAPPEND. that's it, that's the list, no cap. if you wanna check for other flags, you have to use VOP_ACCESSX() instead. different function, different energy, periodt.


πŸ”’ LOCKS πŸ”’

the vnode will be locked on entry and should remain locked on return. it goes in locked, it comes out locked. we don't unlock things we didn't lock, bestie, that's not the move πŸ™ˆ


⭐ RETURN VALUES ⭐

  • if the file is accessible in the specified way β†’ zero is returned. slay, we ate πŸ’–
  • otherwise β†’ an appropriate error code is returned. it's giving rejection 😭

πŸ’€ ERRORS πŸ’€

  • [EPERM] β€” an attempt was made to change an immutable file. it's immutable, girl, you literally cannot. respect the boundaries.
  • [EACCES] β€” the permission bits of the file mode or the ACL do not permit the requested access. the permission bits said no, and the ACL also said no. it's a no from both of them βœ‹

πŸ‘‘ SEE ALSO πŸ‘‘

vaccess(9), vaccess_acl_nfs4(9), vaccess_acl_posix1e(9), vnode(9)

go read those too, iykyk, expanding your kernel knowledge is highkey the move 🌈


πŸ’œ AUTHORS πŸ’œ

this manual page was written by Doug Rabson. we love Doug. iconic behavior, thank you for your service 🫢


and that's the whole page, bestie!! this beauty is from the Debian manual set, dated September 18, 2009 β€” yeah it's an elder but it's still THAT girl, and it's still VOP_ACCESS(9). stay safe out there, check your permissions, and never let a vnode out of a lock you put it in πŸ’…βœ¨πŸ’–

πŸ“¦ where this page comes from