FreeBSD/sys/ufs/ufs/ufs_extattr.c
/*
 * VFS call to manage extended attributes in UFS.  If filename_vp is
 * non-NULL, it must be passed in locked, and regardless of errors in
 * processing, will be unlocked.
 */
VFS call to manage extended attributes in UFS.  If filename_vp is
non-NULL, it must be passed in locked, and regardless of errors in
processing, will be unlocked.
VFS call to manage extended attributes in UFS . If filename_vp is non - NULL it must be passed in locked and regardless of errors in processing will be unlocked .
int
ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp,
    int attrnamespace, const char *attrname)
{
	struct ufsmount *ump = VFSTOUFS(mp);
	struct thread *td = curthread;
	int error;
	error = priv_check(td, PRIV_UFS_EXTATTRCTL);
	if (error) {
		if (filename_vp != NULL)
			VOP_UNLOCK(filename_vp, 0);
		return (error);
	}
	if (ump->um_fstype != UFS1) {
		if (filename_vp != NULL)
			VOP_UNLOCK(filename_vp, 0);
		return (EOPNOTSUPP);
	}
	switch(cmd) {
	case UFS_EXTATTR_CMD_START:
		if (filename_vp != NULL) {
			VOP_UNLOCK(filename_vp, 0);
			return (EINVAL);
		}
		if (attrname != NULL)
			return (EINVAL);
		error = ufs_extattr_start(mp, td);
		return (error);
	case UFS_EXTATTR_CMD_STOP:
		if (filename_vp != NULL) {
			VOP_UNLOCK(filename_vp, 0);
			return (EINVAL);
		}
		if (attrname != NULL)
			return (EINVAL);
		error = ufs_extattr_stop(mp, td);
		return (error);
	case UFS_EXTATTR_CMD_ENABLE:
		if (filename_vp == NULL)
			return (EINVAL);
		if (attrname == NULL) {
			VOP_UNLOCK(filename_vp, 0);
			return (EINVAL);
		}
		ufs_extattr_uepm_lock(ump);
		error = ufs_extattr_enable_with_open(ump, filename_vp,
		    attrnamespace, attrname, td);
		ufs_extattr_uepm_unlock(ump);
		return (error);
	case UFS_EXTATTR_CMD_DISABLE:
		if (filename_vp != NULL) {
			VOP_UNLOCK(filename_vp, 0);
			return (EINVAL);
		}
		if (attrname == NULL)
			return (EINVAL);
		ufs_extattr_uepm_lock(ump);
		error = ufs_extattr_disable(ump, attrnamespace, attrname,
		    td);
		ufs_extattr_uepm_unlock(ump);
		return (error);
	default:
		return (EINVAL);
	}
}
int ufs_extattrctl ( struct mount * mp , int cmd , struct vnode * filename_vp , int attrnamespace , const char * attrname ) { struct ufsmount * ump = VFSTOUFS ( mp ) ; struct thread * td = curthread ; int error ; error = priv_check ( td , PRIV_UFS_EXTATTRCTL ) ; if ( error ) { if ( filename_vp != NULL ) VOP_UNLOCK ( filename_vp , 0 ) ; return ( error ) ; } if ( ump -> um_fstype != UFS1 ) { if ( filename_vp != NULL ) VOP_UNLOCK ( filename_vp , 0 ) ; return ( EOPNOTSUPP ) ; } switch ( cmd ) { case UFS_EXTATTR_CMD_START : if ( filename_vp != NULL ) { VOP_UNLOCK ( filename_vp , 0 ) ; return ( EINVAL ) ; } if ( attrname != NULL ) return ( EINVAL ) ; error = ufs_extattr_start ( mp , td ) ; return ( error ) ; case UFS_EXTATTR_CMD_STOP : if ( filename_vp != NULL ) { VOP_UNLOCK ( filename_vp , 0 ) ; return ( EINVAL ) ; } if ( attrname != NULL ) return ( EINVAL ) ; error = ufs_extattr_stop ( mp , td ) ; return ( error ) ; case UFS_EXTATTR_CMD_ENABLE : if ( filename_vp == NULL ) return ( EINVAL ) ; if ( attrname == NULL ) { VOP_UNLOCK ( filename_vp , 0 ) ; return ( EINVAL ) ; } ufs_extattr_uepm_lock ( ump ) ; error = ufs_extattr_enable_with_open ( ump , filename_vp , attrnamespace , attrname , td ) ; ufs_extattr_uepm_unlock ( ump ) ; return ( error ) ; case UFS_EXTATTR_CMD_DISABLE : if ( filename_vp != NULL ) { VOP_UNLOCK ( filename_vp , 0 ) ; return ( EINVAL ) ; } if ( attrname == NULL ) return ( EINVAL ) ; ufs_extattr_uepm_lock ( ump ) ; error = ufs_extattr_disable ( ump , attrnamespace , attrname , td ) ; ufs_extattr_uepm_unlock ( ump ) ; return ( error ) ; default : return ( EINVAL ) ; } }
VFS call to manage extended attributes in UFS.
VFS call to manage extended attributes in UFS .
/*
	 * Processes with privilege, but in jail, are not allowed to
	 * configure extended attributes.
	 */ /*
	 * We only allow extattrctl(2) on UFS1 file systems, as UFS2 uses
	 * native extended attributes.
	 */ /*
		 * ufs_extattr_enable_with_open() will always unlock the
		 * vnode, regardless of failure.
		 */