/* If the end of the buffer has been reached, return -EAGAIN, if not, return the offset within the buffer of the next entry to be read.  */
static int find_dirent_index(nfs_readdir_descriptor_t *desc)
/* If the end of the buffer has been reached, return -EAGAIN, if not, return the offset within the buffer of the next entry to be read.  */
static int find_dirent_index(nfs_readdir_descriptor_t *desc)
{
	struct nfs_entry *entry = desc->entry;
	int		loop_count = 0,
			status;
	for(;;) {
		status = dir_decode(desc);
		if (status)
			break;
		dfprintk(DIRCACHE, "NFS: found cookie %Lu at index %Ld\n",
				(unsigned long long)entry->cookie, desc->current_index);
		if (desc->file->f_pos == desc->current_index) {
			*desc->dir_cookie = entry->cookie;
			break;
		}
		desc->current_index++;
		if (loop_count++ > 200) {
			loop_count = 0;
			schedule();
		}
	}
	return status;
}