FreeBSD/sys/fs/tmpfs/tmpfs_subr.c
/*
 * Detaches the directory entry de from 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_free_dirent.
 */
Detaches the directory entry de from 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_free_dirent.
Detaches the directory entry de from 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_free_dirent .
void
tmpfs_dir_detach(struct vnode *vp, struct tmpfs_dirent *de)
{
	struct tmpfs_mount *tmp;
	struct tmpfs_dir *head;
	struct tmpfs_node *dnode;
	struct tmpfs_dirent *xde;
	ASSERT_VOP_ELOCKED(vp, __func__);
	dnode = VP_TO_TMPFS_DIR(vp);
	head = &dnode->tn_dir.tn_dirhead;
	dnode->tn_dir.tn_readdir_lastn = 0;
	dnode->tn_dir.tn_readdir_lastp = NULL;
	if (tmpfs_dirent_dup(de)) {
		if (LIST_NEXT(de, uh.td_dup.entries) == NULL) {
			xde = tmpfs_dir_xlookup_hash(dnode, de->td_hash);
			MPASS(tmpfs_dirent_duphead(xde));
		} else
			xde = NULL;
		LIST_REMOVE(de, uh.td_dup.entries);
		LIST_REMOVE(de, uh.td_dup.index_entries);
		if (xde != NULL) {
			if (LIST_EMPTY(&xde->ud.td_duphead)) {
				RB_REMOVE(tmpfs_dir, head, xde);
				tmp = VFS_TO_TMPFS(vp->v_mount);
				MPASS(xde->td_node == NULL);
				tmpfs_free_dirent(tmp, xde);
			}
		}
		de->td_cookie = de->td_hash;
	} else
		RB_REMOVE(tmpfs_dir, head, 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_detach ( struct vnode * vp , struct tmpfs_dirent * de ) { struct tmpfs_mount * tmp ; struct tmpfs_dir * head ; struct tmpfs_node * dnode ; struct tmpfs_dirent * xde ; ASSERT_VOP_ELOCKED ( vp , __func__ ) ; dnode = VP_TO_TMPFS_DIR ( vp ) ; head = & dnode -> tn_dir . tn_dirhead ; dnode -> tn_dir . tn_readdir_lastn = 0 ; dnode -> tn_dir . tn_readdir_lastp = NULL ; if ( tmpfs_dirent_dup ( de ) ) { if ( LIST_NEXT ( de , uh . td_dup . entries ) == NULL ) { xde = tmpfs_dir_xlookup_hash ( dnode , de -> td_hash ) ; MPASS ( tmpfs_dirent_duphead ( xde ) ) ; } else xde = NULL ; LIST_REMOVE ( de , uh . td_dup . entries ) ; LIST_REMOVE ( de , uh . td_dup . index_entries ) ; if ( xde != NULL ) { if ( LIST_EMPTY ( & xde -> ud . td_duphead ) ) { RB_REMOVE ( tmpfs_dir , head , xde ) ; tmp = VFS_TO_TMPFS ( vp -> v_mount ) ; MPASS ( xde -> td_node == NULL ) ; tmpfs_free_dirent ( tmp , xde ) ; } } de -> td_cookie = de -> td_hash ; } else RB_REMOVE ( tmpfs_dir , head , de ) ; dnode -> tn_size -= sizeof ( struct tmpfs_dirent ) ; dnode -> tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED ; tmpfs_update ( vp ) ; }
Detaches the directory entry de from the directory represented by vp.
Detaches the directory entry de from the directory represented by vp .
/* Remove duphead if de was last entry. */