FreeBSD/sys/fs/tmpfs/tmpfs_subr.c
/*
 * Looks for a directory entry in the directory represented by node.
 * 'cnp' describes the name of the entry to look for.  Note that the .
 * and .. components are not allowed as they do not physically exist
 * within directories.
 *
 * Returns a pointer to the entry when found, otherwise NULL.
 */
Looks for a directory entry in the directory represented by node.
'cnp' describes the name of the entry to look for.  Note that the .
and .. components are not allowed as they do not physically exist
within directories.

Returns a pointer to the entry when found, otherwise NULL.
Looks for a directory entry in the directory represented by node . ' cnp ' describes the name of the entry to look for . Note that the . and .. components are not allowed as they do not physically exist within directories . Returns a pointer to the entry when found otherwise NULL .
struct tmpfs_dirent *
tmpfs_dir_lookup(struct tmpfs_node *node, struct tmpfs_node *f,
    struct componentname *cnp)
{
	struct tmpfs_dir_duphead *duphead;
	struct tmpfs_dirent *de;
	uint32_t hash;
	MPASS(IMPLIES(cnp->cn_namelen == 1, cnp->cn_nameptr[0] != '.'));
	MPASS(IMPLIES(cnp->cn_namelen == 2, !(cnp->cn_nameptr[0] == '.' &&
	    cnp->cn_nameptr[1] == '.')));
	TMPFS_VALIDATE_DIR(node);
	hash = tmpfs_dirent_hash(cnp->cn_nameptr, cnp->cn_namelen);
	de = tmpfs_dir_xlookup_hash(node, hash);
	if (de != NULL && tmpfs_dirent_duphead(de)) {
		duphead = &de->ud.td_duphead;
		LIST_FOREACH(de, duphead, uh.td_dup.entries) {
			if (TMPFS_DIRENT_MATCHES(de, cnp->cn_nameptr,
			    cnp->cn_namelen))
				break;
		}
	} else if (de != NULL) {
		if (!TMPFS_DIRENT_MATCHES(de, cnp->cn_nameptr,
		    cnp->cn_namelen))
			de = NULL;
	}
	if (de != NULL && f != NULL && de->td_node != f)
		de = NULL;
	return (de);
}
struct tmpfs_dirent * tmpfs_dir_lookup ( struct tmpfs_node * node , struct tmpfs_node * f , struct componentname * cnp ) { struct tmpfs_dir_duphead * duphead ; struct tmpfs_dirent * de ; uint32_t hash ; MPASS ( IMPLIES ( cnp -> cn_namelen == 1 , cnp -> cn_nameptr [ 0 ] != ' ' ) ) ; MPASS ( IMPLIES ( cnp -> cn_namelen == 2 , ! ( cnp -> cn_nameptr [ 0 ] == ' ' && cnp -> cn_nameptr [ 1 ] == ' ' ) ) ) ; TMPFS_VALIDATE_DIR ( node ) ; hash = tmpfs_dirent_hash ( cnp -> cn_nameptr , cnp -> cn_namelen ) ; de = tmpfs_dir_xlookup_hash ( node , hash ) ; if ( de != NULL && tmpfs_dirent_duphead ( de ) ) { duphead = & de -> ud . td_duphead ; LIST_FOREACH ( de , duphead , uh . td_dup . entries ) { if ( TMPFS_DIRENT_MATCHES ( de , cnp -> cn_nameptr , cnp -> cn_namelen ) ) break ; } } else if ( de != NULL ) { if ( ! TMPFS_DIRENT_MATCHES ( de , cnp -> cn_nameptr , cnp -> cn_namelen ) ) de = NULL ; } if ( de != NULL && f != NULL && de -> td_node != f ) de = NULL ; return ( de ) ; }
Looks for a directory entry in the directory represented by node.
Looks for a directory entry in the directory represented by node .