diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1997-12-06 23:51:34 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1997-12-06 23:51:34 +0000 |
commit | 230e5ab6a084ed50470f101934782dbf54b0d06b (patch) | |
tree | 5dd821c8d33f450470588e7a543f74bf74306e9e /fs/nfs/proc.c | |
parent | c9b1c8a64c6444d189856f1e26bdcb8b4cd0113a (diff) |
Merge with Linux 2.1.67.
Diffstat (limited to 'fs/nfs/proc.c')
-rw-r--r-- | fs/nfs/proc.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 58dcd95d0..416ed294e 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -250,25 +250,43 @@ nfs_proc_rmdir(struct nfs_server *server, struct nfs_fh *dir, const char *name) */ int nfs_proc_readdir(struct nfs_server *server, struct nfs_fh *fhandle, - u32 cookie, unsigned int size, struct nfs_entry *entry) + u32 cookie, unsigned int size, __u32 *entry) { struct nfs_readdirargs arg; struct nfs_readdirres res; void * buffer; + unsigned int buf_size = PAGE_SIZE; int status; /* First get a temp buffer for the readdir reply */ - while (!(buffer = (void *) get_free_page(GFP_USER))) { - need_resched = 1; - schedule(); - if (signalled()) - return -ERESTARTSYS; - } + /* N.B. does this really need to be cleared? */ + status = -ENOMEM; + buffer = (void *) get_free_page(GFP_KERNEL); + if (!buffer) + goto out; + + /* + * Calculate the effective size the buffer. To make sure + * that the returned data will fit into the user's buffer, + * we decrease the buffer size as necessary. + * + * Note: NFS returns three __u32 values for each entry, + * and we assume that the data is packed into the user + * buffer with the same efficiency. + */ + if (size < buf_size) + buf_size = size; + if (server->rsize < buf_size) + buf_size = server->rsize; +#if 0 +printk("nfs_proc_readdir: user size=%d, rsize=%d, buf_size=%d\n", +size, server->rsize, buf_size); +#endif arg.fh = fhandle; arg.cookie = cookie; arg.buffer = buffer; - arg.bufsiz = server->rsize < PAGE_SIZE? server->rsize : PAGE_SIZE; + arg.bufsiz = buf_size; res.buffer = entry; res.bufsiz = size; @@ -276,6 +294,7 @@ nfs_proc_readdir(struct nfs_server *server, struct nfs_fh *fhandle, status = rpc_call(server->client, NFSPROC_READDIR, &arg, &res, 0); dprintk("NFS reply readdir: %d\n", status); free_page((unsigned long) buffer); +out: return status; } |