FreeBSD/sys/fs/tmpfs/tmpfs_subr.c
/*
 * Helper function for tmpfs_readdir.  Creates a '..' entry for the given
 * directory and returns it in the uio space.  The function returns 0
 * on success, -1 if there was not enough space in the uio structure to
 * hold the directory entry or an appropriate error code if another
 * error happens.
 */
Helper function for tmpfs_readdir.  Creates a '..' entry for the given
directory and returns it in the uio space.  The function returns 0
on success, -1 if there was not enough space in the uio structure to
hold the directory entry or an appropriate error code if another
error happens.
Helper function for tmpfs_readdir . Creates a ' .. ' entry for the given directory and returns it in the uio space . The function returns 0 on success - 1 if there was not enough space in the uio structure to hold the directory entry or an appropriate error code if another error happens .
static int
tmpfs_dir_getdotdotdent(struct tmpfs_node *node, struct uio *uio)
{
	int error;
	struct dirent dent;
	TMPFS_VALIDATE_DIR(node);
	MPASS(uio->uio_offset == TMPFS_DIRCOOKIE_DOTDOT);
	TMPFS_ASSERT_LOCKED(node);
	if (node->tn_dir.tn_parent == NULL) {
		return (ENOENT);
	}
	TMPFS_NODE_LOCK(node->tn_dir.tn_parent);
	dent.d_fileno = node->tn_dir.tn_parent->tn_id;
	TMPFS_NODE_UNLOCK(node->tn_dir.tn_parent);
	dent.d_type = DT_DIR;
	dent.d_namlen = 2;
	dent.d_name[0] = '.';
	dent.d_name[1] = '.';
	dent.d_name[2] = '\0';
	dent.d_reclen = GENERIC_DIRSIZ(&dent);
	if (dent.d_reclen > uio->uio_resid)
		error = EJUSTRETURN;
	else
		error = uiomove(&dent, dent.d_reclen, uio);
	node->tn_status |= TMPFS_NODE_ACCESSED;
	return error;
}
static int tmpfs_dir_getdotdotdent ( struct tmpfs_node * node , struct uio * uio ) { int error ; struct dirent dent ; TMPFS_VALIDATE_DIR ( node ) ; MPASS ( uio -> uio_offset == TMPFS_DIRCOOKIE_DOTDOT ) ; TMPFS_ASSERT_LOCKED ( node ) ; if ( node -> tn_dir . tn_parent == NULL ) { return ( ENOENT ) ; } TMPFS_NODE_LOCK ( node -> tn_dir . tn_parent ) ; dent . d_fileno = node -> tn_dir . tn_parent -> tn_id ; TMPFS_NODE_UNLOCK ( node -> tn_dir . tn_parent ) ; dent . d_type = DT_DIR ; dent . d_namlen = 2 ; dent . d_name [ 0 ] = ' ' ; dent . d_name [ 1 ] = ' ' ; dent . d_name [ 2 ] = ' \0 ' ; dent . d_reclen = GENERIC_DIRSIZ ( & dent ) ; if ( dent . d_reclen > uio -> uio_resid ) error = EJUSTRETURN ; else error = uiomove ( & dent , dent . d_reclen , uio ) ; node -> tn_status |= TMPFS_NODE_ACCESSED ; return error ; }
Helper function for tmpfs_readdir.
Helper function for tmpfs_readdir .
/*
	 * Return ENOENT if the current node is already removed.
	 */