MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vn_access

Function vn_access

freebsd/kern/vfs_syscalls.c:2010–2036  ·  view source on GitHub ↗

* Check access permissions using passed credentials. */

Source from the content-addressed store, hash-verified

2008 * Check access permissions using passed credentials.
2009 */
2010static int
2011vn_access(struct vnode *vp, int user_flags, struct ucred *cred,
2012 struct thread *td)
2013{
2014 accmode_t accmode;
2015 int error;
2016
2017 /* Flags == 0 means only check for existence. */
2018 if (user_flags == 0)
2019 return (0);
2020
2021 accmode = 0;
2022 if (user_flags & R_OK)
2023 accmode |= VREAD;
2024 if (user_flags & W_OK)
2025 accmode |= VWRITE;
2026 if (user_flags & X_OK)
2027 accmode |= VEXEC;
2028#ifdef MAC
2029 error = mac_vnode_check_access(cred, vp, accmode);
2030 if (error != 0)
2031 return (error);
2032#endif
2033 if ((accmode & VWRITE) == 0 || (error = vn_writechk(vp)) == 0)
2034 error = VOP_ACCESS(vp, accmode, cred, td);
2035 return (error);
2036}
2037
2038/*
2039 * Check access permissions using "real" credentials.

Callers 1

kern_accessatFunction · 0.85

Calls 2

mac_vnode_check_accessFunction · 0.85
vn_writechkFunction · 0.85

Tested by

no test coverage detected