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

Function setfmode

freebsd/kern/vfs_syscalls.c:2792–2812  ·  view source on GitHub ↗

* Common implementation code for chmod(), lchmod() and fchmod(). */

Source from the content-addressed store, hash-verified

2790 * Common implementation code for chmod(), lchmod() and fchmod().
2791 */
2792int
2793setfmode(struct thread *td, struct ucred *cred, struct vnode *vp, int mode)
2794{
2795 struct mount *mp;
2796 struct vattr vattr;
2797 int error;
2798
2799 if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
2800 return (error);
2801 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
2802 VATTR_NULL(&vattr);
2803 vattr.va_mode = mode & ALLPERMS;
2804#ifdef MAC
2805 error = mac_vnode_check_setmode(cred, vp, vattr.va_mode);
2806 if (error == 0)
2807#endif
2808 error = VOP_SETATTR(vp, &vattr, cred);
2809 VOP_UNLOCK(vp);
2810 vn_finished_write(mp);
2811 return (error);
2812}
2813
2814/*
2815 * Change mode of a file given path name.

Callers 2

vn_chmodFunction · 0.85
kern_fchmodatFunction · 0.85

Calls 4

vn_start_writeFunction · 0.85
vn_lockFunction · 0.85
mac_vnode_check_setmodeFunction · 0.85
vn_finished_writeFunction · 0.85

Tested by

no test coverage detected