FreeBSD/sys/fs/tmpfs/tmpfs_subr.c
/*
 * Destroys the node pointed to by node from the file system 'tmp'.
 * If the node does not belong to the given mount point, the results are
 * unpredicted.
 *
 * If the node references a directory; no entries are allowed because
 * their removal could need a recursive algorithm, something forbidden in
 * kernel space.  Furthermore, there is not need to provide such
 * functionality (recursive removal) because the only primitives offered
 * to the user are the removal of empty directories and the deletion of
 * individual files.
 *
 * Note that nodes are not really deleted; in fact, when a node has been
 * allocated, it cannot be deleted during the whole life of the file
 * system.  Instead, they are moved to the available list and remain there
 * until reused.
 */
Destroys the node pointed to by node from the file system 'tmp'.
If the node does not belong to the given mount point, the results are
unpredicted.

If the node references a directory; no entries are allowed because
their removal could need a recursive algorithm, something forbidden in
kernel space.  Furthermore, there is not need to provide such
functionality (recursive removal) because the only primitives offered
to the user are the removal of empty directories and the deletion of
individual files.

Note that nodes are not really deleted; in fact, when a node has been
allocated, it cannot be deleted during the whole life of the file
system.  Instead, they are moved to the available list and remain there
until reused.
Destroys the node pointed to by node from the file system ' tmp ' . If the node does not belong to the given mount point the results are unpredicted . If the node references a directory ; no entries are allowed because their removal could need a recursive algorithm something forbidden in kernel space . Furthermore there is not need to provide such functionality ( recursive removal ) because the only primitives offered to the user are the removal of empty directories and the deletion of individual files . Note that nodes are not really deleted ; in fact when a node has been allocated it cannot be deleted during the whole life of the file system . Instead they are moved to the available list and remain there until reused .
void
tmpfs_free_node(struct tmpfs_mount *tmp, struct tmpfs_node *node)
{
	vm_object_t uobj;
#ifdef INVARIANTS
	TMPFS_NODE_LOCK(node);
	MPASS(node->tn_vnode == NULL);
	MPASS((node->tn_vpstate & TMPFS_VNODE_ALLOCATING) == 0);
	TMPFS_NODE_UNLOCK(node);
#endif
	TMPFS_LOCK(tmp);
	LIST_REMOVE(node, tn_entries);
	tmp->tm_nodes_inuse--;
	TMPFS_UNLOCK(tmp);
	switch (node->tn_type) {
	case VNON:
	case VBLK:
	case VCHR:
	case VDIR:
	case VFIFO:
	case VSOCK:
		break;
	case VLNK:
		free(node->tn_link, M_TMPFSNAME);
		break;
	case VREG:
		uobj = node->tn_reg.tn_aobj;
		if (uobj != NULL) {
			TMPFS_LOCK(tmp);
			tmp->tm_pages_used -= uobj->size;
			TMPFS_UNLOCK(tmp);
			KASSERT((uobj->flags & OBJ_TMPFS) == 0,
			    ("leaked OBJ_TMPFS node %p vm_obj %p", node, uobj));
			vm_object_deallocate(uobj);
		}
		break;
	default:
		panic("tmpfs_free_node: type %p %d", node, (int)node->tn_type);
	}
	free_unr(tmp->tm_ino_unr, node->tn_id);
	uma_zfree(tmp->tm_node_pool, node);
}
void tmpfs_free_node ( struct tmpfs_mount * tmp , struct tmpfs_node * node ) { vm_object_t uobj ; #ifdef INVARIANTS TMPFS_NODE_LOCK ( node ) ; MPASS ( node -> tn_vnode == NULL ) ; MPASS ( ( node -> tn_vpstate & TMPFS_VNODE_ALLOCATING ) == 0 ) ; TMPFS_NODE_UNLOCK ( node ) ; #endif TMPFS_LOCK ( tmp ) ; LIST_REMOVE ( node , tn_entries ) ; tmp -> tm_nodes_inuse -- ; TMPFS_UNLOCK ( tmp ) ; switch ( node -> tn_type ) { case VNON : case VBLK : case VCHR : case VDIR : case VFIFO : case VSOCK : break ; case VLNK : free ( node -> tn_link , M_TMPFSNAME ) ; break ; case VREG : uobj = node -> tn_reg . tn_aobj ; if ( uobj != NULL ) { TMPFS_LOCK ( tmp ) ; tmp -> tm_pages_used -= uobj -> size ; TMPFS_UNLOCK ( tmp ) ; KASSERT ( ( uobj -> flags & OBJ_TMPFS ) == 0 , ( " " , node , uobj ) ) ; vm_object_deallocate ( uobj ) ; } break ; default : panic ( " " , node , ( int ) node -> tn_type ) ; } free_unr ( tmp -> tm_ino_unr , node -> tn_id ) ; uma_zfree ( tmp -> tm_node_pool , node ) ; }
Destroys the node pointed to by node from the file system 'tmp'.
Destroys the node pointed to by node from the file system ' tmp ' .
/* Do not do anything.  VNON is provided to let the
		 * allocation routine clean itself easily by avoiding
		 * duplicating code in it. */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */