FreeBSD/sys/fs/tmpfs/tmpfs_subr.c
/*
 * Attaches the directory entry de to the directory represented by vp.
 * Note that this does not change the link count of the node pointed by
 * the directory entry, as this is done by tmpfs_alloc_dirent.
 */
Attaches the directory entry de to the directory represented by vp.
Note that this does not change the link count of the node pointed by
the directory entry, as this is done by tmpfs_alloc_dirent.
Attaches the directory entry de to the directory represented by vp . Note that this does not change the link count of the node pointed by the directory entry as this is done by tmpfs_alloc_dirent .
void
tmpfs_dir_attach(struct vnode *vp, struct tmpfs_dirent *de)
{
	struct tmpfs_node *dnode;
	struct tmpfs_dirent *xde, *nde;
	ASSERT_VOP_ELOCKED(vp, __func__);
	MPASS(de->td_namelen > 0);
	MPASS(de->td_hash >= TMPFS_DIRCOOKIE_MIN);
	MPASS(de->td_cookie == de->td_hash);
	dnode = VP_TO_TMPFS_DIR(vp);
	dnode->tn_dir.tn_readdir_lastn = 0;
	dnode->tn_dir.tn_readdir_lastp = NULL;
	MPASS(!tmpfs_dirent_dup(de));
	xde = RB_INSERT(tmpfs_dir, &dnode->tn_dir.tn_dirhead, de);
	if (xde != NULL && tmpfs_dirent_duphead(xde))
		tmpfs_dir_attach_dup(dnode, &xde->ud.td_duphead, de);
	else if (xde != NULL) {
		MPASS(!tmpfs_dirent_dup(xde));
		tmpfs_alloc_dirent(VFS_TO_TMPFS(vp->v_mount), NULL, NULL, 0,
		    &nde);
		memcpy(nde, xde, sizeof(*xde));
		xde->td_cookie |= TMPFS_DIRCOOKIE_DUPHEAD;
		LIST_INIT(&xde->ud.td_duphead);
		xde->td_namelen = 0;
		xde->td_node = NULL;
		tmpfs_dir_attach_dup(dnode, &xde->ud.td_duphead, nde);
		tmpfs_dir_attach_dup(dnode, &xde->ud.td_duphead, de);
	}
	dnode->tn_size += sizeof(struct tmpfs_dirent);
	dnode->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED | \
	    TMPFS_NODE_MODIFIED;
	tmpfs_update(vp);
}
void tmpfs_dir_attach ( struct vnode * vp , struct tmpfs_dirent * de ) { struct tmpfs_node * dnode ; struct tmpfs_dirent * xde , * nde ; ASSERT_VOP_ELOCKED ( vp , __func__ ) ; MPASS ( de -> td_namelen > 0 ) ; MPASS ( de -> td_hash >= TMPFS_DIRCOOKIE_MIN ) ; MPASS ( de -> td_cookie == de -> td_hash ) ; dnode = VP_TO_TMPFS_DIR ( vp ) ; dnode -> tn_dir . tn_readdir_lastn = 0 ; dnode -> tn_dir . tn_readdir_lastp = NULL ; MPASS ( ! tmpfs_dirent_dup ( de ) ) ; xde = RB_INSERT ( tmpfs_dir , & dnode -> tn_dir . tn_dirhead , de ) ; if ( xde != NULL && tmpfs_dirent_duphead ( xde ) ) tmpfs_dir_attach_dup ( dnode , & xde -> ud . td_duphead , de ) ; else if ( xde != NULL ) { MPASS ( ! tmpfs_dirent_dup ( xde ) ) ; tmpfs_alloc_dirent ( VFS_TO_TMPFS ( vp -> v_mount ) , NULL , NULL , 0 , & nde ) ; memcpy ( nde , xde , sizeof ( * xde ) ) ; xde -> td_cookie |= TMPFS_DIRCOOKIE_DUPHEAD ; LIST_INIT ( & xde -> ud . td_duphead ) ; xde -> td_namelen = 0 ; xde -> td_node = NULL ; tmpfs_dir_attach_dup ( dnode , & xde -> ud . td_duphead , nde ) ; tmpfs_dir_attach_dup ( dnode , & xde -> ud . td_duphead , de ) ; } dnode -> tn_size += sizeof ( struct tmpfs_dirent ) ; dnode -> tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED ; tmpfs_update ( vp ) ; }
Attaches the directory entry de to the directory represented by vp.
Attaches the directory entry de to the directory represented by vp .
/*
		 * Allocate new duphead. Swap xde with duphead to avoid
		 * adding/removing elements with the same hash.
		 */ /* *nde = *xde; XXX gcc 4.2.1 may generate invalid code. */