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

Function setfown

freebsd/kern/vfs_syscalls.c:2915–2938  ·  view source on GitHub ↗

* Common implementation for chown(), lchown(), and fchown() */

Source from the content-addressed store, hash-verified

2913 * Common implementation for chown(), lchown(), and fchown()
2914 */
2915int
2916setfown(struct thread *td, struct ucred *cred, struct vnode *vp, uid_t uid,
2917 gid_t gid)
2918{
2919 struct mount *mp;
2920 struct vattr vattr;
2921 int error;
2922
2923 if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
2924 return (error);
2925 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
2926 VATTR_NULL(&vattr);
2927 vattr.va_uid = uid;
2928 vattr.va_gid = gid;
2929#ifdef MAC
2930 error = mac_vnode_check_setowner(cred, vp, vattr.va_uid,
2931 vattr.va_gid);
2932 if (error == 0)
2933#endif
2934 error = VOP_SETATTR(vp, &vattr, cred);
2935 VOP_UNLOCK(vp);
2936 vn_finished_write(mp);
2937 return (error);
2938}
2939
2940/*
2941 * Set ownership given a path name.

Callers 2

vn_chownFunction · 0.85
kern_fchownatFunction · 0.85

Calls 4

vn_start_writeFunction · 0.85
vn_lockFunction · 0.85
mac_vnode_check_setownerFunction · 0.85
vn_finished_writeFunction · 0.85

Tested by

no test coverage detected