FreeBSD/sys/fs/tmpfs/tmpfs_subr.c
/*
 * Change flags of the given vnode.
 * Caller should execute tmpfs_update on vp after a successful execution.
 * The vnode must be locked on entry and remain locked on exit.
 */
Change flags of the given vnode.
Caller should execute tmpfs_update on vp after a successful execution.
The vnode must be locked on entry and remain locked on exit.
Change flags of the given vnode . Caller should execute tmpfs_update on vp after a successful execution . The vnode must be locked on entry and remain locked on exit .
int
tmpfs_chflags(struct vnode *vp, u_long flags, struct ucred *cred,
    struct thread *p)
{
	int error;
	struct tmpfs_node *node;
	MPASS(VOP_ISLOCKED(vp));
	node = VP_TO_TMPFS_NODE(vp);
	if ((flags & ~(SF_APPEND | SF_ARCHIVED | SF_IMMUTABLE | SF_NOUNLINK |
	    UF_APPEND | UF_ARCHIVE | UF_HIDDEN | UF_IMMUTABLE | UF_NODUMP |
	    UF_NOUNLINK | UF_OFFLINE | UF_OPAQUE | UF_READONLY | UF_REPARSE |
	    UF_SPARSE | UF_SYSTEM)) != 0)
		return (EOPNOTSUPP);
	if (vp->v_mount->mnt_flag & MNT_RDONLY)
		return EROFS;
	if ((error = VOP_ACCESS(vp, VADMIN, cred, p)))
		return (error);
	if (!priv_check_cred(cred, PRIV_VFS_SYSFLAGS, 0)) {
		if (node->tn_flags &
		    (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) {
			error = securelevel_gt(cred, 0);
			if (error)
				return (error);
		}
	} else {
		if (node->tn_flags &
		    (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) ||
		    ((flags ^ node->tn_flags) & SF_SETTABLE))
			return (EPERM);
	}
	node->tn_flags = flags;
	node->tn_status |= TMPFS_NODE_CHANGED;
	MPASS(VOP_ISLOCKED(vp));
	return 0;
}
int tmpfs_chflags ( struct vnode * vp , u_long flags , struct ucred * cred , struct thread * p ) { int error ; struct tmpfs_node * node ; MPASS ( VOP_ISLOCKED ( vp ) ) ; node = VP_TO_TMPFS_NODE ( vp ) ; if ( ( flags & ~ ( SF_APPEND | SF_ARCHIVED | SF_IMMUTABLE | SF_NOUNLINK | UF_APPEND | UF_ARCHIVE | UF_HIDDEN | UF_IMMUTABLE | UF_NODUMP | UF_NOUNLINK | UF_OFFLINE | UF_OPAQUE | UF_READONLY | UF_REPARSE | UF_SPARSE | UF_SYSTEM ) ) != 0 ) return ( EOPNOTSUPP ) ; if ( vp -> v_mount -> mnt_flag & MNT_RDONLY ) return EROFS ; if ( ( error = VOP_ACCESS ( vp , VADMIN , cred , p ) ) ) return ( error ) ; if ( ! priv_check_cred ( cred , PRIV_VFS_SYSFLAGS , 0 ) ) { if ( node -> tn_flags & ( SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND ) ) { error = securelevel_gt ( cred , 0 ) ; if ( error ) return ( error ) ; } } else { if ( node -> tn_flags & ( SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND ) || ( ( flags ^ node -> tn_flags ) & SF_SETTABLE ) ) return ( EPERM ) ; } node -> tn_flags = flags ; node -> tn_status |= TMPFS_NODE_CHANGED ; MPASS ( VOP_ISLOCKED ( vp ) ) ; return 0 ; }
Change flags of the given vnode.
Change flags of the given vnode .
/* Disallow this operation if the file system is mounted read-only. */ /*
	 * Callers may only modify the file flags on objects they
	 * have VADMIN rights for.
	 */ /*
	 * Unprivileged processes are not permitted to unset system
	 * flags, or modify flags if any system flags are set.
	 */