diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2008-07-31 12:16:51 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-10-23 05:13:04 -0400 |
commit | 2628b766363aa3791e816a7e5807373ef551c776 (patch) | |
tree | aa8006667673484d5f784a083bdbc8f40894357f /fs/nfsd | |
parent | f3f8e17571934ea253339e15c4ec9b34ea623c6b (diff) |
[PATCH] Factor out nfsd_do_readdir() into its own function
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/vfs.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index aa1d0d6489a1..14eda20cc291 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -1813,6 +1813,29 @@ out: | |||
1813 | return err; | 1813 | return err; |
1814 | } | 1814 | } |
1815 | 1815 | ||
1816 | static int nfsd_do_readdir(struct file *file, filldir_t func, | ||
1817 | struct readdir_cd *cdp, loff_t *offsetp) | ||
1818 | { | ||
1819 | int host_err; | ||
1820 | |||
1821 | /* | ||
1822 | * Read the directory entries. This silly loop is necessary because | ||
1823 | * readdir() is not guaranteed to fill up the entire buffer, but | ||
1824 | * may choose to do less. | ||
1825 | */ | ||
1826 | do { | ||
1827 | cdp->err = nfserr_eof; /* will be cleared on successful read */ | ||
1828 | host_err = vfs_readdir(file, func, cdp); | ||
1829 | } while (host_err >=0 && cdp->err == nfs_ok); | ||
1830 | |||
1831 | *offsetp = vfs_llseek(file, 0, 1); | ||
1832 | |||
1833 | if (host_err) | ||
1834 | return nfserrno(host_err); | ||
1835 | else | ||
1836 | return cdp->err; | ||
1837 | } | ||
1838 | |||
1816 | /* | 1839 | /* |
1817 | * Read entries from a directory. | 1840 | * Read entries from a directory. |
1818 | * The NFSv3/4 verifier we ignore for now. | 1841 | * 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 | struct readdir_cd *cdp, filldir_t func) | 1845 | struct readdir_cd *cdp, filldir_t func) |
1823 | { | 1846 | { |
1824 | __be32 err; | 1847 | __be32 err; |
1825 | int host_err; | ||
1826 | struct file *file; | 1848 | struct file *file; |
1827 | loff_t offset = *offsetp; | 1849 | loff_t offset = *offsetp; |
1828 | 1850 | ||
@@ -1836,21 +1858,7 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp, | |||
1836 | goto out_close; | 1858 | goto out_close; |
1837 | } | 1859 | } |
1838 | 1860 | ||
1839 | /* | 1861 | err = nfsd_do_readdir(file, func, cdp, offsetp); |
1840 | * Read the directory entries. This silly loop is necessary because | ||
1841 | * readdir() is not guaranteed to fill up the entire buffer, but | ||
1842 | * may choose to do less. | ||
1843 | */ | ||
1844 | |||
1845 | do { | ||
1846 | cdp->err = nfserr_eof; /* will be cleared on successful read */ | ||
1847 | host_err = vfs_readdir(file, func, cdp); | ||
1848 | } while (host_err >=0 && cdp->err == nfs_ok); | ||
1849 | if (host_err) | ||
1850 | err = nfserrno(host_err); | ||
1851 | else | ||
1852 | err = cdp->err; | ||
1853 | *offsetp = vfs_llseek(file, 0, 1); | ||
1854 | 1862 | ||
1855 | if (err == nfserr_eof || err == nfserr_toosmall) | 1863 | if (err == nfserr_eof || err == nfserr_toosmall) |
1856 | err = nfs_ok; /* can still be found in ->err */ | 1864 | err = nfs_ok; /* can still be found in ->err */ |