FreeBSD/sys/fs/ext2fs/ext2_vnops.c
/*
 * Change the mode on a file.
 * Inode must be locked before calling.
 */
Change the mode on a file.
Inode must be locked before calling.
Change the mode on a file . Inode must be locked before calling .
static int
ext2_chmod(struct vnode *vp, int mode, struct ucred *cred, struct thread *td)
{
	struct inode *ip = VTOI(vp);
	int error;
	if ((error = VOP_ACCESS(vp, VADMIN, cred, td)))
		return (error);
	if (vp->v_type != VDIR && (mode & S_ISTXT)) {
		error = priv_check_cred(cred, PRIV_VFS_STICKYFILE, 0);
		if (error)
			return (EFTYPE);
	}
	if (!groupmember(ip->i_gid, cred) && (mode & ISGID)) {
		error = priv_check_cred(cred, PRIV_VFS_SETGID, 0);
		if (error)
			return (error);
	}
	ip->i_mode &= ~ALLPERMS;
	ip->i_mode |= (mode & ALLPERMS);
	ip->i_flag |= IN_CHANGE;
	return (0);
}
static int ext2_chmod ( struct vnode * vp , int mode , struct ucred * cred , struct thread * td ) { struct inode * ip = VTOI ( vp ) ; int error ; if ( ( error = VOP_ACCESS ( vp , VADMIN , cred , td ) ) ) return ( error ) ; if ( vp -> v_type != VDIR && ( mode & S_ISTXT ) ) { error = priv_check_cred ( cred , PRIV_VFS_STICKYFILE , 0 ) ; if ( error ) return ( EFTYPE ) ; } if ( ! groupmember ( ip -> i_gid , cred ) && ( mode & ISGID ) ) { error = priv_check_cred ( cred , PRIV_VFS_SETGID , 0 ) ; if ( error ) return ( error ) ; } ip -> i_mode &= ~ ALLPERMS ; ip -> i_mode |= ( mode & ALLPERMS ) ; ip -> i_flag |= IN_CHANGE ; return ( 0 ) ; }
Change the mode on a file.
Change the mode on a file .
/*
	 * To modify the permissions on a file, must possess VADMIN
	 * for that file.
	 */ /*
	 * Privileged processes may set the sticky bit on non-directories,
	 * as well as set the setgid bit on a file with a group that the
	 * process is not a member of.
	 */