/*
 * Once we've found the start of the dirent within a page: fill 'er up...
 */
static 
int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
		   filldir_t filldir)
{
	struct file	*file = desc->file;
	struct nfs_entry *entry = desc->entry;
	unsigned long	fileid;
	int		loop_count = 0,
			res;

	dfprintk(VFS, "NFS: nfs_do_filldir() filling starting @ cookie %Lu\n", (long long)desc->target);

	for(;;) {
		unsigned d_type = DT_UNKNOWN;
		/* Note: entry->prev_cookie contains the cookie for
		 *	 retrieving the current dirent on the server */
		fileid = nfs_fileid_to_ino_t(entry->ino);

		/* Use readdirplus info */
		if (desc->plus && (entry->fattr->valid & NFS_ATTR_FATTR))
			d_type = nfs_type_to_d_type(entry->fattr->type);

		res = filldir(dirent, entry->name, entry->len, 
			      entry->prev_cookie, fileid, d_type);
		if (res < 0)
			break;
		file->f_pos = desc->target = entry->cookie;
		if (dir_decode(desc) != 0) {
			desc->page_index ++;
			break;
		}
		if (loop_count++ > 200) {
			loop_count = 0;
			schedule();
		}
	}
	dir_page_release(desc);

	dfprintk(VFS, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n", (long long)desc->target, res);
	return res;
}
Beispiel #2
0
/* vsnfs_do_filldir :- Main routine that reads the dirents from the page returned
 * by server and fills them in the client.
 */
static
int vsnfs_do_filldir(vsnfs_readdir_descriptor_t *desc, void *dirent,
           filldir_t filldir)
{
	struct file *file = desc->file;
    struct vsnfs_entry *entry = desc->entry;
    unsigned long fileid;
    unsigned int d_type;
    int res, status;

	vsnfs_trace(KERN_ERR, "VSNFS: vsnfs_do_filldir() filling starting @ cookie %Lu\n", (long long)desc->target);

	for(;;) {
		status = dir_decode(desc);
		if (status < 0) {
			res = status;
			goto out;
		}

        fileid = entry->ino;
        d_type = entry->fh->type;

        res = filldir(dirent, entry->name, entry->len, entry->offset, fileid, d_type);
		if (res < 0) {
			vsnfs_trace(KERN_ERR, "Filldir failed\n");
			goto out;
		}

		if (entry->eof == 1) {
			file->f_pos = 4096;
			break;
		}
    }

    dir_page_release(desc);
out:
    return res;
}