FreeBSD/sys/fs/unionfs/union_subr.c
/*
 * Create a new whiteout.
 * 
 * dvp should be locked on entry and will be locked on return.
 */
Create a new whiteout.

dvp should be locked on entry and will be locked on return.
Create a new whiteout . dvp should be locked on entry and will be locked on return .
int
unionfs_mkwhiteout(struct vnode *dvp, struct componentname *cnp,
		   struct thread *td, char *path)
{
	int		error;
	struct vnode   *wvp;
	struct componentname cn;
	struct mount   *mp;
	if (path == NULL)
		path = cnp->cn_nameptr;
	wvp = NULLVP;
	if ((error = unionfs_relookup(dvp, &wvp, cnp, &cn, td, path, strlen(path), CREATE)))
		return (error);
	if (wvp != NULLVP) {
		if (cn.cn_flags & HASBUF) {
			uma_zfree(namei_zone, cn.cn_pnbuf);
			cn.cn_flags &= ~HASBUF;
		}
		if (dvp == wvp)
			vrele(wvp);
		else
			vput(wvp);
		return (EEXIST);
	}
	if ((error = vn_start_write(dvp, &mp, V_WAIT | PCATCH)))
		goto unionfs_mkwhiteout_free_out;
	error = VOP_WHITEOUT(dvp, &cn, CREATE);
	vn_finished_write(mp);
unionfs_mkwhiteout_free_out:
	if (cn.cn_flags & HASBUF) {
		uma_zfree(namei_zone, cn.cn_pnbuf);
		cn.cn_flags &= ~HASBUF;
	}
	return (error);
}
int unionfs_mkwhiteout ( struct vnode * dvp , struct componentname * cnp , struct thread * td , char * path ) { int error ; struct vnode * wvp ; struct componentname cn ; struct mount * mp ; if ( path == NULL ) path = cnp -> cn_nameptr ; wvp = NULLVP ; if ( ( error = unionfs_relookup ( dvp , & wvp , cnp , & cn , td , path , strlen ( path ) , CREATE ) ) ) return ( error ) ; if ( wvp != NULLVP ) { if ( cn . cn_flags & HASBUF ) { uma_zfree ( namei_zone , cn . cn_pnbuf ) ; cn . cn_flags &= ~ HASBUF ; } if ( dvp == wvp ) vrele ( wvp ) ; else vput ( wvp ) ; return ( EEXIST ) ; } if ( ( error = vn_start_write ( dvp , & mp , V_WAIT | PCATCH ) ) ) goto unionfs_mkwhiteout_free_out ; error = VOP_WHITEOUT ( dvp , & cn , CREATE ) ; vn_finished_write ( mp ) ; unionfs_mkwhiteout_free_out : if ( cn . cn_flags & HASBUF ) { uma_zfree ( namei_zone , cn . cn_pnbuf ) ; cn . cn_flags &= ~ HASBUF ; } return ( error ) ; }
Create a new whiteout.
Create a new whiteout .