Commit 2628b766 authored by David Woodhouse's avatar David Woodhouse Committed by Al Viro

[PATCH] Factor out nfsd_do_readdir() into its own function

Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent f3f8e175
...@@ -1813,6 +1813,29 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, ...@@ -1813,6 +1813,29 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
return err; return err;
} }
static int nfsd_do_readdir(struct file *file, filldir_t func,
struct readdir_cd *cdp, loff_t *offsetp)
{
int host_err;
/*
* Read the directory entries. This silly loop is necessary because
* readdir() is not guaranteed to fill up the entire buffer, but
* may choose to do less.
*/
do {
cdp->err = nfserr_eof; /* will be cleared on successful read */
host_err = vfs_readdir(file, func, cdp);
} while (host_err >=0 && cdp->err == nfs_ok);
*offsetp = vfs_llseek(file, 0, 1);
if (host_err)
return nfserrno(host_err);
else
return cdp->err;
}
/* /*
* Read entries from a directory. * Read entries from a directory.
* The NFSv3/4 verifier we ignore for now. * The NFSv3/4 verifier we ignore for now.
...@@ -1822,7 +1845,6 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp, ...@@ -1822,7 +1845,6 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
struct readdir_cd *cdp, filldir_t func) struct readdir_cd *cdp, filldir_t func)
{ {
__be32 err; __be32 err;
int host_err;
struct file *file; struct file *file;
loff_t offset = *offsetp; loff_t offset = *offsetp;
...@@ -1836,21 +1858,7 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp, ...@@ -1836,21 +1858,7 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
goto out_close; goto out_close;
} }
/* err = nfsd_do_readdir(file, func, cdp, offsetp);
* Read the directory entries. This silly loop is necessary because
* readdir() is not guaranteed to fill up the entire buffer, but
* may choose to do less.
*/
do {
cdp->err = nfserr_eof; /* will be cleared on successful read */
host_err = vfs_readdir(file, func, cdp);
} while (host_err >=0 && cdp->err == nfs_ok);
if (host_err)
err = nfserrno(host_err);
else
err = cdp->err;
*offsetp = vfs_llseek(file, 0, 1);
if (err == nfserr_eof || err == nfserr_toosmall) if (err == nfserr_eof || err == nfserr_toosmall)
err = nfs_ok; /* can still be found in ->err */ err = nfs_ok; /* can still be found in ->err */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment