Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Process version 3 NFS requests. |
| 4 | * |
| 5 | * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de> |
| 6 | */ |
| 7 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/fs.h> |
| 9 | #include <linux/ext2_fs.h> |
Qinghuang Feng | 12214cb | 2009-01-12 03:13:53 +0800 | [diff] [blame] | 10 | #include <linux/magic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Boaz Harrosh | 9a74af2 | 2009-12-03 20:30:56 +0200 | [diff] [blame] | 12 | #include "cache.h" |
| 13 | #include "xdr3.h" |
J. Bruce Fields | 0a3adad | 2009-11-04 18:12:35 -0500 | [diff] [blame] | 14 | #include "vfs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
| 17 | |
| 18 | #define RETURN_STATUS(st) { resp->status = (st); return (st); } |
| 19 | |
| 20 | static int nfs3_ftypes[] = { |
| 21 | 0, /* NF3NON */ |
| 22 | S_IFREG, /* NF3REG */ |
| 23 | S_IFDIR, /* NF3DIR */ |
| 24 | S_IFBLK, /* NF3BLK */ |
| 25 | S_IFCHR, /* NF3CHR */ |
| 26 | S_IFLNK, /* NF3LNK */ |
| 27 | S_IFSOCK, /* NF3SOCK */ |
| 28 | S_IFIFO, /* NF3FIFO */ |
| 29 | }; |
| 30 | |
| 31 | /* |
| 32 | * NULL call. |
| 33 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 34 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 35 | nfsd3_proc_null(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | { |
| 37 | return nfs_ok; |
| 38 | } |
| 39 | |
| 40 | /* |
| 41 | * Get a file's attributes |
| 42 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 43 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 44 | nfsd3_proc_getattr(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 46 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 47 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 48 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | dprintk("nfsd: GETATTR(3) %s\n", |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 51 | SVCFH_fmt(&argp->fh)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | fh_copy(&resp->fh, &argp->fh); |
J. Bruce Fields | 04716e6 | 2008-08-07 13:00:20 -0400 | [diff] [blame] | 54 | nfserr = fh_verify(rqstp, &resp->fh, 0, |
| 55 | NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT); |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 56 | if (nfserr) |
| 57 | RETURN_STATUS(nfserr); |
| 58 | |
Al Viro | 3dadecc | 2013-01-24 02:18:08 -0500 | [diff] [blame] | 59 | nfserr = fh_getattr(&resp->fh, &resp->stat); |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | RETURN_STATUS(nfserr); |
| 62 | } |
| 63 | |
| 64 | /* |
| 65 | * Set a file's attributes |
| 66 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 67 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 68 | nfsd3_proc_setattr(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 70 | struct nfsd3_sattrargs *argp = rqstp->rq_argp; |
| 71 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 72 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
| 74 | dprintk("nfsd: SETATTR(3) %s\n", |
| 75 | SVCFH_fmt(&argp->fh)); |
| 76 | |
| 77 | fh_copy(&resp->fh, &argp->fh); |
| 78 | nfserr = nfsd_setattr(rqstp, &resp->fh, &argp->attrs, |
| 79 | argp->check_guard, argp->guardtime); |
| 80 | RETURN_STATUS(nfserr); |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | * Look up a path name component |
| 85 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 86 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 87 | nfsd3_proc_lookup(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 89 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
| 90 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 91 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | |
| 93 | dprintk("nfsd: LOOKUP(3) %s %.*s\n", |
| 94 | SVCFH_fmt(&argp->fh), |
| 95 | argp->len, |
| 96 | argp->name); |
| 97 | |
| 98 | fh_copy(&resp->dirfh, &argp->fh); |
| 99 | fh_init(&resp->fh, NFS3_FHSIZE); |
| 100 | |
| 101 | nfserr = nfsd_lookup(rqstp, &resp->dirfh, |
| 102 | argp->name, |
| 103 | argp->len, |
| 104 | &resp->fh); |
| 105 | RETURN_STATUS(nfserr); |
| 106 | } |
| 107 | |
| 108 | /* |
| 109 | * Check file access |
| 110 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 111 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 112 | nfsd3_proc_access(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 114 | struct nfsd3_accessargs *argp = rqstp->rq_argp; |
| 115 | struct nfsd3_accessres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 116 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
| 118 | dprintk("nfsd: ACCESS(3) %s 0x%x\n", |
| 119 | SVCFH_fmt(&argp->fh), |
| 120 | argp->access); |
| 121 | |
| 122 | fh_copy(&resp->fh, &argp->fh); |
| 123 | resp->access = argp->access; |
| 124 | nfserr = nfsd_access(rqstp, &resp->fh, &resp->access, NULL); |
| 125 | RETURN_STATUS(nfserr); |
| 126 | } |
| 127 | |
| 128 | /* |
| 129 | * Read a symlink. |
| 130 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 131 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 132 | nfsd3_proc_readlink(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 134 | struct nfsd3_readlinkargs *argp = rqstp->rq_argp; |
| 135 | struct nfsd3_readlinkres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 136 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | |
| 138 | dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh)); |
| 139 | |
| 140 | /* Read the symlink. */ |
| 141 | fh_copy(&resp->fh, &argp->fh); |
| 142 | resp->len = NFS3_MAXPATHLEN; |
| 143 | nfserr = nfsd_readlink(rqstp, &resp->fh, argp->buffer, &resp->len); |
| 144 | RETURN_STATUS(nfserr); |
| 145 | } |
| 146 | |
| 147 | /* |
| 148 | * Read a portion of a file. |
| 149 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 150 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 151 | nfsd3_proc_read(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 153 | struct nfsd3_readargs *argp = rqstp->rq_argp; |
| 154 | struct nfsd3_readres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 155 | __be32 nfserr; |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 156 | u32 max_blocksize = svc_max_payload(rqstp); |
Benjamin Coddington | ac503e4 | 2016-03-22 10:28:36 -0400 | [diff] [blame] | 157 | unsigned long cnt = min(argp->count, max_blocksize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 159 | dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | SVCFH_fmt(&argp->fh), |
| 161 | (unsigned long) argp->count, |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 162 | (unsigned long long) argp->offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | |
| 164 | /* Obtain buffer pointer for payload. |
| 165 | * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof) |
| 166 | * + 1 (xdr opaque byte count) = 26 |
| 167 | */ |
Benjamin Coddington | ac503e4 | 2016-03-22 10:28:36 -0400 | [diff] [blame] | 168 | resp->count = cnt; |
Jeff Layton | cd12301 | 2007-05-09 02:34:50 -0700 | [diff] [blame] | 169 | svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
| 171 | fh_copy(&resp->fh, &argp->fh); |
J. Bruce Fields | 039a87c | 2010-07-30 11:33:32 -0400 | [diff] [blame] | 172 | nfserr = nfsd_read(rqstp, &resp->fh, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | argp->offset, |
NeilBrown | 3cc03b1 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 174 | rqstp->rq_vec, argp->vlen, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | &resp->count); |
| 176 | if (nfserr == 0) { |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 177 | struct inode *inode = d_inode(resp->fh.fh_dentry); |
Benjamin Coddington | ac503e4 | 2016-03-22 10:28:36 -0400 | [diff] [blame] | 178 | resp->eof = nfsd_eof_on_read(cnt, resp->count, argp->offset, |
| 179 | inode->i_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | RETURN_STATUS(nfserr); |
| 183 | } |
| 184 | |
| 185 | /* |
| 186 | * Write data to a file |
| 187 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 188 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 189 | nfsd3_proc_write(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 191 | struct nfsd3_writeargs *argp = rqstp->rq_argp; |
| 192 | struct nfsd3_writeres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 193 | __be32 nfserr; |
David Shaw | 31dec25 | 2009-03-05 20:16:14 -0500 | [diff] [blame] | 194 | unsigned long cnt = argp->len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 196 | dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | SVCFH_fmt(&argp->fh), |
| 198 | argp->len, |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 199 | (unsigned long long) argp->offset, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | argp->stable? " stable" : ""); |
| 201 | |
| 202 | fh_copy(&resp->fh, &argp->fh); |
| 203 | resp->committed = argp->stable; |
Kinglong Mee | 52e380e | 2016-12-31 21:00:13 +0800 | [diff] [blame] | 204 | nfserr = nfsd_write(rqstp, &resp->fh, argp->offset, |
| 205 | rqstp->rq_vec, argp->vlen, |
| 206 | &cnt, resp->committed); |
David Shaw | 31dec25 | 2009-03-05 20:16:14 -0500 | [diff] [blame] | 207 | resp->count = cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | RETURN_STATUS(nfserr); |
| 209 | } |
| 210 | |
| 211 | /* |
| 212 | * With NFSv3, CREATE processing is a lot easier than with NFSv2. |
| 213 | * At least in theory; we'll see how it fares in practice when the |
| 214 | * first reports about SunOS compatibility problems start to pour in... |
| 215 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 216 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 217 | nfsd3_proc_create(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 219 | struct nfsd3_createargs *argp = rqstp->rq_argp; |
| 220 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | svc_fh *dirfhp, *newfhp = NULL; |
| 222 | struct iattr *attr; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 223 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
| 225 | dprintk("nfsd: CREATE(3) %s %.*s\n", |
| 226 | SVCFH_fmt(&argp->fh), |
| 227 | argp->len, |
| 228 | argp->name); |
| 229 | |
| 230 | dirfhp = fh_copy(&resp->dirfh, &argp->fh); |
| 231 | newfhp = fh_init(&resp->fh, NFS3_FHSIZE); |
| 232 | attr = &argp->attrs; |
| 233 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | /* Unfudge the mode bits */ |
| 235 | attr->ia_mode &= ~S_IFMT; |
| 236 | if (!(attr->ia_valid & ATTR_MODE)) { |
| 237 | attr->ia_valid |= ATTR_MODE; |
| 238 | attr->ia_mode = S_IFREG; |
| 239 | } else { |
| 240 | attr->ia_mode = (attr->ia_mode & ~S_IFMT) | S_IFREG; |
| 241 | } |
| 242 | |
| 243 | /* Now create the file and set attributes */ |
Mi Jinlong | ac6721a | 2011-04-20 17:06:25 +0800 | [diff] [blame] | 244 | nfserr = do_nfsd_create(rqstp, dirfhp, argp->name, argp->len, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | attr, newfhp, |
J. Bruce Fields | 95c7a20 | 2012-07-27 15:50:11 -0400 | [diff] [blame] | 246 | argp->createmode, (u32 *)argp->verf, NULL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | |
| 248 | RETURN_STATUS(nfserr); |
| 249 | } |
| 250 | |
| 251 | /* |
| 252 | * Make directory. This operation is not idempotent. |
| 253 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 254 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 255 | nfsd3_proc_mkdir(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 257 | struct nfsd3_createargs *argp = rqstp->rq_argp; |
| 258 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 259 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
| 261 | dprintk("nfsd: MKDIR(3) %s %.*s\n", |
| 262 | SVCFH_fmt(&argp->fh), |
| 263 | argp->len, |
| 264 | argp->name); |
| 265 | |
| 266 | argp->attrs.ia_valid &= ~ATTR_SIZE; |
| 267 | fh_copy(&resp->dirfh, &argp->fh); |
| 268 | fh_init(&resp->fh, NFS3_FHSIZE); |
| 269 | nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len, |
| 270 | &argp->attrs, S_IFDIR, 0, &resp->fh); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 271 | fh_unlock(&resp->dirfh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | RETURN_STATUS(nfserr); |
| 273 | } |
| 274 | |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 275 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 276 | nfsd3_proc_symlink(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 278 | struct nfsd3_symlinkargs *argp = rqstp->rq_argp; |
| 279 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 280 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | |
| 282 | dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n", |
| 283 | SVCFH_fmt(&argp->ffh), |
| 284 | argp->flen, argp->fname, |
| 285 | argp->tlen, argp->tname); |
| 286 | |
| 287 | fh_copy(&resp->dirfh, &argp->ffh); |
| 288 | fh_init(&resp->fh, NFS3_FHSIZE); |
| 289 | nfserr = nfsd_symlink(rqstp, &resp->dirfh, argp->fname, argp->flen, |
Kinglong Mee | 1e444f5 | 2014-07-01 17:48:02 +0800 | [diff] [blame] | 290 | argp->tname, &resp->fh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | RETURN_STATUS(nfserr); |
| 292 | } |
| 293 | |
| 294 | /* |
| 295 | * Make socket/fifo/device. |
| 296 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 297 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 298 | nfsd3_proc_mknod(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 300 | struct nfsd3_mknodargs *argp = rqstp->rq_argp; |
| 301 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 302 | __be32 nfserr; |
| 303 | int type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | dev_t rdev = 0; |
| 305 | |
| 306 | dprintk("nfsd: MKNOD(3) %s %.*s\n", |
| 307 | SVCFH_fmt(&argp->fh), |
| 308 | argp->len, |
| 309 | argp->name); |
| 310 | |
| 311 | fh_copy(&resp->dirfh, &argp->fh); |
| 312 | fh_init(&resp->fh, NFS3_FHSIZE); |
| 313 | |
| 314 | if (argp->ftype == 0 || argp->ftype >= NF3BAD) |
| 315 | RETURN_STATUS(nfserr_inval); |
| 316 | if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) { |
| 317 | rdev = MKDEV(argp->major, argp->minor); |
| 318 | if (MAJOR(rdev) != argp->major || |
| 319 | MINOR(rdev) != argp->minor) |
| 320 | RETURN_STATUS(nfserr_inval); |
| 321 | } else |
| 322 | if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO) |
| 323 | RETURN_STATUS(nfserr_inval); |
| 324 | |
| 325 | type = nfs3_ftypes[argp->ftype]; |
| 326 | nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len, |
| 327 | &argp->attrs, type, rdev, &resp->fh); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 328 | fh_unlock(&resp->dirfh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | RETURN_STATUS(nfserr); |
| 330 | } |
| 331 | |
| 332 | /* |
| 333 | * Remove file/fifo/socket etc. |
| 334 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 335 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 336 | nfsd3_proc_remove(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 338 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
| 339 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 340 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
| 342 | dprintk("nfsd: REMOVE(3) %s %.*s\n", |
| 343 | SVCFH_fmt(&argp->fh), |
| 344 | argp->len, |
| 345 | argp->name); |
| 346 | |
| 347 | /* Unlink. -S_IFDIR means file must not be a directory */ |
| 348 | fh_copy(&resp->fh, &argp->fh); |
| 349 | nfserr = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, argp->name, argp->len); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 350 | fh_unlock(&resp->fh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | RETURN_STATUS(nfserr); |
| 352 | } |
| 353 | |
| 354 | /* |
| 355 | * Remove a directory |
| 356 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 357 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 358 | nfsd3_proc_rmdir(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 360 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
| 361 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 362 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | |
| 364 | dprintk("nfsd: RMDIR(3) %s %.*s\n", |
| 365 | SVCFH_fmt(&argp->fh), |
| 366 | argp->len, |
| 367 | argp->name); |
| 368 | |
| 369 | fh_copy(&resp->fh, &argp->fh); |
| 370 | nfserr = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, argp->name, argp->len); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 371 | fh_unlock(&resp->fh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | RETURN_STATUS(nfserr); |
| 373 | } |
| 374 | |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 375 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 376 | nfsd3_proc_rename(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 378 | struct nfsd3_renameargs *argp = rqstp->rq_argp; |
| 379 | struct nfsd3_renameres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 380 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | |
| 382 | dprintk("nfsd: RENAME(3) %s %.*s ->\n", |
| 383 | SVCFH_fmt(&argp->ffh), |
| 384 | argp->flen, |
| 385 | argp->fname); |
| 386 | dprintk("nfsd: -> %s %.*s\n", |
| 387 | SVCFH_fmt(&argp->tfh), |
| 388 | argp->tlen, |
| 389 | argp->tname); |
| 390 | |
| 391 | fh_copy(&resp->ffh, &argp->ffh); |
| 392 | fh_copy(&resp->tfh, &argp->tfh); |
| 393 | nfserr = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen, |
| 394 | &resp->tfh, argp->tname, argp->tlen); |
| 395 | RETURN_STATUS(nfserr); |
| 396 | } |
| 397 | |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 398 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 399 | nfsd3_proc_link(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 401 | struct nfsd3_linkargs *argp = rqstp->rq_argp; |
| 402 | struct nfsd3_linkres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 403 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | |
| 405 | dprintk("nfsd: LINK(3) %s ->\n", |
| 406 | SVCFH_fmt(&argp->ffh)); |
| 407 | dprintk("nfsd: -> %s %.*s\n", |
| 408 | SVCFH_fmt(&argp->tfh), |
| 409 | argp->tlen, |
| 410 | argp->tname); |
| 411 | |
| 412 | fh_copy(&resp->fh, &argp->ffh); |
| 413 | fh_copy(&resp->tfh, &argp->tfh); |
| 414 | nfserr = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen, |
| 415 | &resp->fh); |
| 416 | RETURN_STATUS(nfserr); |
| 417 | } |
| 418 | |
| 419 | /* |
| 420 | * Read a portion of a directory. |
| 421 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 422 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 423 | nfsd3_proc_readdir(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 425 | struct nfsd3_readdirargs *argp = rqstp->rq_argp; |
| 426 | struct nfsd3_readdirres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 427 | __be32 nfserr; |
| 428 | int count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | |
| 430 | dprintk("nfsd: READDIR(3) %s %d bytes at %d\n", |
| 431 | SVCFH_fmt(&argp->fh), |
| 432 | argp->count, (u32) argp->cookie); |
| 433 | |
| 434 | /* Make sure we've room for the NULL ptr & eof flag, and shrink to |
| 435 | * client read size */ |
| 436 | count = (argp->count >> 2) - 2; |
| 437 | |
| 438 | /* Read directory and encode entries on the fly */ |
| 439 | fh_copy(&resp->fh, &argp->fh); |
| 440 | |
| 441 | resp->buflen = count; |
| 442 | resp->common.err = nfs_ok; |
| 443 | resp->buffer = argp->buffer; |
| 444 | resp->rqstp = rqstp; |
| 445 | nfserr = nfsd_readdir(rqstp, &resp->fh, (loff_t*) &argp->cookie, |
| 446 | &resp->common, nfs3svc_encode_entry); |
| 447 | memcpy(resp->verf, argp->verf, 8); |
| 448 | resp->count = resp->buffer - argp->buffer; |
| 449 | if (resp->offset) |
| 450 | xdr_encode_hyper(resp->offset, argp->cookie); |
| 451 | |
| 452 | RETURN_STATUS(nfserr); |
| 453 | } |
| 454 | |
| 455 | /* |
| 456 | * Read a portion of a directory, including file handles and attrs. |
| 457 | * For now, we choose to ignore the dircount parameter. |
| 458 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 459 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 460 | nfsd3_proc_readdirplus(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 462 | struct nfsd3_readdirargs *argp = rqstp->rq_argp; |
| 463 | struct nfsd3_readdirres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 464 | __be32 nfserr; |
| 465 | int count = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | loff_t offset; |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 467 | struct page **p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | caddr_t page_addr = NULL; |
| 469 | |
| 470 | dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n", |
| 471 | SVCFH_fmt(&argp->fh), |
| 472 | argp->count, (u32) argp->cookie); |
| 473 | |
| 474 | /* Convert byte count to number of words (i.e. >> 2), |
| 475 | * and reserve room for the NULL ptr & eof flag (-2 words) */ |
| 476 | resp->count = (argp->count >> 2) - 2; |
| 477 | |
| 478 | /* Read directory and encode entries on the fly */ |
| 479 | fh_copy(&resp->fh, &argp->fh); |
| 480 | |
| 481 | resp->common.err = nfs_ok; |
| 482 | resp->buffer = argp->buffer; |
| 483 | resp->buflen = resp->count; |
| 484 | resp->rqstp = rqstp; |
| 485 | offset = argp->cookie; |
Rajesh Ghanekar | 18c01ab | 2014-08-01 22:17:30 -0400 | [diff] [blame] | 486 | |
| 487 | nfserr = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP); |
| 488 | if (nfserr) |
| 489 | RETURN_STATUS(nfserr); |
| 490 | |
| 491 | if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS) |
| 492 | RETURN_STATUS(nfserr_notsupp); |
| 493 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | nfserr = nfsd_readdir(rqstp, &resp->fh, |
| 495 | &offset, |
| 496 | &resp->common, |
| 497 | nfs3svc_encode_entry_plus); |
| 498 | memcpy(resp->verf, argp->verf, 8); |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 499 | for (p = rqstp->rq_respages + 1; p < rqstp->rq_next_page; p++) { |
| 500 | page_addr = page_address(*p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | |
| 502 | if (((caddr_t)resp->buffer >= page_addr) && |
| 503 | ((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) { |
| 504 | count += (caddr_t)resp->buffer - page_addr; |
| 505 | break; |
| 506 | } |
| 507 | count += PAGE_SIZE; |
| 508 | } |
| 509 | resp->count = count >> 2; |
| 510 | if (resp->offset) { |
| 511 | if (unlikely(resp->offset1)) { |
| 512 | /* we ended up with offset on a page boundary */ |
| 513 | *resp->offset = htonl(offset >> 32); |
| 514 | *resp->offset1 = htonl(offset & 0xffffffff); |
| 515 | resp->offset1 = NULL; |
| 516 | } else { |
| 517 | xdr_encode_hyper(resp->offset, offset); |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | RETURN_STATUS(nfserr); |
| 522 | } |
| 523 | |
| 524 | /* |
| 525 | * Get file system stats |
| 526 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 527 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 528 | nfsd3_proc_fsstat(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 530 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 531 | struct nfsd3_fsstatres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 532 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | |
| 534 | dprintk("nfsd: FSSTAT(3) %s\n", |
| 535 | SVCFH_fmt(&argp->fh)); |
| 536 | |
J. Bruce Fields | 04716e6 | 2008-08-07 13:00:20 -0400 | [diff] [blame] | 537 | nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | fh_put(&argp->fh); |
| 539 | RETURN_STATUS(nfserr); |
| 540 | } |
| 541 | |
| 542 | /* |
| 543 | * Get file system info |
| 544 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 545 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 546 | nfsd3_proc_fsinfo(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 548 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 549 | struct nfsd3_fsinfores *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 550 | __be32 nfserr; |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 551 | u32 max_blocksize = svc_max_payload(rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | |
| 553 | dprintk("nfsd: FSINFO(3) %s\n", |
| 554 | SVCFH_fmt(&argp->fh)); |
| 555 | |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 556 | resp->f_rtmax = max_blocksize; |
| 557 | resp->f_rtpref = max_blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | resp->f_rtmult = PAGE_SIZE; |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 559 | resp->f_wtmax = max_blocksize; |
| 560 | resp->f_wtpref = max_blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | resp->f_wtmult = PAGE_SIZE; |
| 562 | resp->f_dtpref = PAGE_SIZE; |
| 563 | resp->f_maxfilesize = ~(u32) 0; |
| 564 | resp->f_properties = NFS3_FSF_DEFAULT; |
| 565 | |
J. Bruce Fields | 04716e6 | 2008-08-07 13:00:20 -0400 | [diff] [blame] | 566 | nfserr = fh_verify(rqstp, &argp->fh, 0, |
| 567 | NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | |
| 569 | /* Check special features of the file system. May request |
| 570 | * different read/write sizes for file systems known to have |
| 571 | * problems with large blocks */ |
| 572 | if (nfserr == 0) { |
Al Viro | fc64005 | 2016-04-10 01:33:30 -0400 | [diff] [blame] | 573 | struct super_block *sb = argp->fh.fh_dentry->d_sb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | |
| 575 | /* Note that we don't care for remote fs's here */ |
Qinghuang Feng | 12214cb | 2009-01-12 03:13:53 +0800 | [diff] [blame] | 576 | if (sb->s_magic == MSDOS_SUPER_MAGIC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | resp->f_properties = NFS3_FSF_BILLYBOY; |
| 578 | } |
| 579 | resp->f_maxfilesize = sb->s_maxbytes; |
| 580 | } |
| 581 | |
| 582 | fh_put(&argp->fh); |
| 583 | RETURN_STATUS(nfserr); |
| 584 | } |
| 585 | |
| 586 | /* |
| 587 | * Get pathconf info for the specified file |
| 588 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 589 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 590 | nfsd3_proc_pathconf(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 592 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 593 | struct nfsd3_pathconfres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 594 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | |
| 596 | dprintk("nfsd: PATHCONF(3) %s\n", |
| 597 | SVCFH_fmt(&argp->fh)); |
| 598 | |
| 599 | /* Set default pathconf */ |
| 600 | resp->p_link_max = 255; /* at least */ |
| 601 | resp->p_name_max = 255; /* at least */ |
| 602 | resp->p_no_trunc = 0; |
| 603 | resp->p_chown_restricted = 1; |
| 604 | resp->p_case_insensitive = 0; |
| 605 | resp->p_case_preserving = 1; |
| 606 | |
Miklos Szeredi | 8837abc | 2008-06-16 13:20:29 +0200 | [diff] [blame] | 607 | nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | |
| 609 | if (nfserr == 0) { |
Al Viro | fc64005 | 2016-04-10 01:33:30 -0400 | [diff] [blame] | 610 | struct super_block *sb = argp->fh.fh_dentry->d_sb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | |
| 612 | /* Note that we don't care for remote fs's here */ |
| 613 | switch (sb->s_magic) { |
| 614 | case EXT2_SUPER_MAGIC: |
| 615 | resp->p_link_max = EXT2_LINK_MAX; |
| 616 | resp->p_name_max = EXT2_NAME_LEN; |
| 617 | break; |
Qinghuang Feng | 12214cb | 2009-01-12 03:13:53 +0800 | [diff] [blame] | 618 | case MSDOS_SUPER_MAGIC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | resp->p_case_insensitive = 1; |
| 620 | resp->p_case_preserving = 0; |
| 621 | break; |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | fh_put(&argp->fh); |
| 626 | RETURN_STATUS(nfserr); |
| 627 | } |
| 628 | |
| 629 | |
| 630 | /* |
| 631 | * Commit a file (range) to stable storage. |
| 632 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 633 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 634 | nfsd3_proc_commit(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 636 | struct nfsd3_commitargs *argp = rqstp->rq_argp; |
| 637 | struct nfsd3_commitres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 638 | __be32 nfserr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | |
| 640 | dprintk("nfsd: COMMIT(3) %s %u@%Lu\n", |
| 641 | SVCFH_fmt(&argp->fh), |
| 642 | argp->count, |
| 643 | (unsigned long long) argp->offset); |
| 644 | |
| 645 | if (argp->offset > NFS_OFFSET_MAX) |
| 646 | RETURN_STATUS(nfserr_inval); |
| 647 | |
| 648 | fh_copy(&resp->fh, &argp->fh); |
| 649 | nfserr = nfsd_commit(rqstp, &resp->fh, argp->offset, argp->count); |
| 650 | |
| 651 | RETURN_STATUS(nfserr); |
| 652 | } |
| 653 | |
| 654 | |
| 655 | /* |
| 656 | * NFSv3 Server procedures. |
| 657 | * Only the results of non-idempotent operations are cached. |
| 658 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | #define nfs3svc_decode_fhandleargs nfs3svc_decode_fhandle |
| 660 | #define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat |
| 661 | #define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat |
| 662 | #define nfsd3_mkdirargs nfsd3_createargs |
| 663 | #define nfsd3_readdirplusargs nfsd3_readdirargs |
| 664 | #define nfsd3_fhandleargs nfsd_fhandle |
| 665 | #define nfsd3_fhandleres nfsd3_attrstat |
| 666 | #define nfsd3_attrstatres nfsd3_attrstat |
| 667 | #define nfsd3_wccstatres nfsd3_attrstat |
| 668 | #define nfsd3_createres nfsd3_diropres |
| 669 | #define nfsd3_voidres nfsd3_voidargs |
| 670 | struct nfsd3_voidargs { int dummy; }; |
| 671 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | #define ST 1 /* status*/ |
| 673 | #define FH 17 /* filehandle with length */ |
| 674 | #define AT 21 /* attributes */ |
| 675 | #define pAT (1+AT) /* post attributes - conditional */ |
| 676 | #define WC (7+pAT) /* WCC attributes */ |
| 677 | |
Christoph Hellwig | 860bda2 | 2017-05-12 16:11:49 +0200 | [diff] [blame] | 678 | static const struct svc_procedure nfsd_procedures3[22] = { |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 679 | [NFS3PROC_NULL] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 680 | .pc_func = nfsd3_proc_null, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 681 | .pc_encode = nfs3svc_encode_voidres, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 682 | .pc_argsize = sizeof(struct nfsd3_voidargs), |
| 683 | .pc_ressize = sizeof(struct nfsd3_voidres), |
| 684 | .pc_cachetype = RC_NOCACHE, |
| 685 | .pc_xdrressize = ST, |
| 686 | }, |
| 687 | [NFS3PROC_GETATTR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 688 | .pc_func = nfsd3_proc_getattr, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 689 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 690 | .pc_encode = nfs3svc_encode_attrstatres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 691 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 692 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
| 693 | .pc_ressize = sizeof(struct nfsd3_attrstatres), |
| 694 | .pc_cachetype = RC_NOCACHE, |
| 695 | .pc_xdrressize = ST+AT, |
| 696 | }, |
| 697 | [NFS3PROC_SETATTR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 698 | .pc_func = nfsd3_proc_setattr, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 699 | .pc_decode = nfs3svc_decode_sattrargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 700 | .pc_encode = nfs3svc_encode_wccstatres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 701 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 702 | .pc_argsize = sizeof(struct nfsd3_sattrargs), |
| 703 | .pc_ressize = sizeof(struct nfsd3_wccstatres), |
| 704 | .pc_cachetype = RC_REPLBUFF, |
| 705 | .pc_xdrressize = ST+WC, |
| 706 | }, |
| 707 | [NFS3PROC_LOOKUP] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 708 | .pc_func = nfsd3_proc_lookup, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 709 | .pc_decode = nfs3svc_decode_diropargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 710 | .pc_encode = nfs3svc_encode_diropres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 711 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 712 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
| 713 | .pc_ressize = sizeof(struct nfsd3_diropres), |
| 714 | .pc_cachetype = RC_NOCACHE, |
| 715 | .pc_xdrressize = ST+FH+pAT+pAT, |
| 716 | }, |
| 717 | [NFS3PROC_ACCESS] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 718 | .pc_func = nfsd3_proc_access, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 719 | .pc_decode = nfs3svc_decode_accessargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 720 | .pc_encode = nfs3svc_encode_accessres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 721 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 722 | .pc_argsize = sizeof(struct nfsd3_accessargs), |
| 723 | .pc_ressize = sizeof(struct nfsd3_accessres), |
| 724 | .pc_cachetype = RC_NOCACHE, |
| 725 | .pc_xdrressize = ST+pAT+1, |
| 726 | }, |
| 727 | [NFS3PROC_READLINK] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 728 | .pc_func = nfsd3_proc_readlink, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 729 | .pc_decode = nfs3svc_decode_readlinkargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 730 | .pc_encode = nfs3svc_encode_readlinkres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 731 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 732 | .pc_argsize = sizeof(struct nfsd3_readlinkargs), |
| 733 | .pc_ressize = sizeof(struct nfsd3_readlinkres), |
| 734 | .pc_cachetype = RC_NOCACHE, |
| 735 | .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4, |
| 736 | }, |
| 737 | [NFS3PROC_READ] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 738 | .pc_func = nfsd3_proc_read, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 739 | .pc_decode = nfs3svc_decode_readargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 740 | .pc_encode = nfs3svc_encode_readres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 741 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 742 | .pc_argsize = sizeof(struct nfsd3_readargs), |
| 743 | .pc_ressize = sizeof(struct nfsd3_readres), |
| 744 | .pc_cachetype = RC_NOCACHE, |
| 745 | .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4, |
| 746 | }, |
| 747 | [NFS3PROC_WRITE] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 748 | .pc_func = nfsd3_proc_write, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 749 | .pc_decode = nfs3svc_decode_writeargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 750 | .pc_encode = nfs3svc_encode_writeres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 751 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 752 | .pc_argsize = sizeof(struct nfsd3_writeargs), |
| 753 | .pc_ressize = sizeof(struct nfsd3_writeres), |
| 754 | .pc_cachetype = RC_REPLBUFF, |
| 755 | .pc_xdrressize = ST+WC+4, |
| 756 | }, |
| 757 | [NFS3PROC_CREATE] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 758 | .pc_func = nfsd3_proc_create, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 759 | .pc_decode = nfs3svc_decode_createargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 760 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 761 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 762 | .pc_argsize = sizeof(struct nfsd3_createargs), |
| 763 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 764 | .pc_cachetype = RC_REPLBUFF, |
| 765 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
| 766 | }, |
| 767 | [NFS3PROC_MKDIR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 768 | .pc_func = nfsd3_proc_mkdir, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 769 | .pc_decode = nfs3svc_decode_mkdirargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 770 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 771 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 772 | .pc_argsize = sizeof(struct nfsd3_mkdirargs), |
| 773 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 774 | .pc_cachetype = RC_REPLBUFF, |
| 775 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
| 776 | }, |
| 777 | [NFS3PROC_SYMLINK] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 778 | .pc_func = nfsd3_proc_symlink, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 779 | .pc_decode = nfs3svc_decode_symlinkargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 780 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 781 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 782 | .pc_argsize = sizeof(struct nfsd3_symlinkargs), |
| 783 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 784 | .pc_cachetype = RC_REPLBUFF, |
| 785 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
| 786 | }, |
| 787 | [NFS3PROC_MKNOD] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 788 | .pc_func = nfsd3_proc_mknod, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 789 | .pc_decode = nfs3svc_decode_mknodargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 790 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 791 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 792 | .pc_argsize = sizeof(struct nfsd3_mknodargs), |
| 793 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 794 | .pc_cachetype = RC_REPLBUFF, |
| 795 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
| 796 | }, |
| 797 | [NFS3PROC_REMOVE] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 798 | .pc_func = nfsd3_proc_remove, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 799 | .pc_decode = nfs3svc_decode_diropargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 800 | .pc_encode = nfs3svc_encode_wccstatres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 801 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 802 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
| 803 | .pc_ressize = sizeof(struct nfsd3_wccstatres), |
| 804 | .pc_cachetype = RC_REPLBUFF, |
| 805 | .pc_xdrressize = ST+WC, |
| 806 | }, |
| 807 | [NFS3PROC_RMDIR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 808 | .pc_func = nfsd3_proc_rmdir, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 809 | .pc_decode = nfs3svc_decode_diropargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 810 | .pc_encode = nfs3svc_encode_wccstatres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 811 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 812 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
| 813 | .pc_ressize = sizeof(struct nfsd3_wccstatres), |
| 814 | .pc_cachetype = RC_REPLBUFF, |
| 815 | .pc_xdrressize = ST+WC, |
| 816 | }, |
| 817 | [NFS3PROC_RENAME] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 818 | .pc_func = nfsd3_proc_rename, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 819 | .pc_decode = nfs3svc_decode_renameargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 820 | .pc_encode = nfs3svc_encode_renameres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 821 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 822 | .pc_argsize = sizeof(struct nfsd3_renameargs), |
| 823 | .pc_ressize = sizeof(struct nfsd3_renameres), |
| 824 | .pc_cachetype = RC_REPLBUFF, |
| 825 | .pc_xdrressize = ST+WC+WC, |
| 826 | }, |
| 827 | [NFS3PROC_LINK] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 828 | .pc_func = nfsd3_proc_link, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 829 | .pc_decode = nfs3svc_decode_linkargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 830 | .pc_encode = nfs3svc_encode_linkres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 831 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 832 | .pc_argsize = sizeof(struct nfsd3_linkargs), |
| 833 | .pc_ressize = sizeof(struct nfsd3_linkres), |
| 834 | .pc_cachetype = RC_REPLBUFF, |
| 835 | .pc_xdrressize = ST+pAT+WC, |
| 836 | }, |
| 837 | [NFS3PROC_READDIR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 838 | .pc_func = nfsd3_proc_readdir, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 839 | .pc_decode = nfs3svc_decode_readdirargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 840 | .pc_encode = nfs3svc_encode_readdirres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 841 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 842 | .pc_argsize = sizeof(struct nfsd3_readdirargs), |
| 843 | .pc_ressize = sizeof(struct nfsd3_readdirres), |
| 844 | .pc_cachetype = RC_NOCACHE, |
| 845 | }, |
| 846 | [NFS3PROC_READDIRPLUS] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 847 | .pc_func = nfsd3_proc_readdirplus, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 848 | .pc_decode = nfs3svc_decode_readdirplusargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 849 | .pc_encode = nfs3svc_encode_readdirres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 850 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 851 | .pc_argsize = sizeof(struct nfsd3_readdirplusargs), |
| 852 | .pc_ressize = sizeof(struct nfsd3_readdirres), |
| 853 | .pc_cachetype = RC_NOCACHE, |
| 854 | }, |
| 855 | [NFS3PROC_FSSTAT] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 856 | .pc_func = nfsd3_proc_fsstat, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 857 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 858 | .pc_encode = nfs3svc_encode_fsstatres, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 859 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
| 860 | .pc_ressize = sizeof(struct nfsd3_fsstatres), |
| 861 | .pc_cachetype = RC_NOCACHE, |
| 862 | .pc_xdrressize = ST+pAT+2*6+1, |
| 863 | }, |
| 864 | [NFS3PROC_FSINFO] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 865 | .pc_func = nfsd3_proc_fsinfo, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 866 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 867 | .pc_encode = nfs3svc_encode_fsinfores, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 868 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
| 869 | .pc_ressize = sizeof(struct nfsd3_fsinfores), |
| 870 | .pc_cachetype = RC_NOCACHE, |
| 871 | .pc_xdrressize = ST+pAT+12, |
| 872 | }, |
| 873 | [NFS3PROC_PATHCONF] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 874 | .pc_func = nfsd3_proc_pathconf, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 875 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 876 | .pc_encode = nfs3svc_encode_pathconfres, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 877 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
| 878 | .pc_ressize = sizeof(struct nfsd3_pathconfres), |
| 879 | .pc_cachetype = RC_NOCACHE, |
| 880 | .pc_xdrressize = ST+pAT+6, |
| 881 | }, |
| 882 | [NFS3PROC_COMMIT] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 883 | .pc_func = nfsd3_proc_commit, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 884 | .pc_decode = nfs3svc_decode_commitargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 885 | .pc_encode = nfs3svc_encode_commitres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 886 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 887 | .pc_argsize = sizeof(struct nfsd3_commitargs), |
| 888 | .pc_ressize = sizeof(struct nfsd3_commitres), |
| 889 | .pc_cachetype = RC_NOCACHE, |
| 890 | .pc_xdrressize = ST+WC+2, |
| 891 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | }; |
| 893 | |
Christoph Hellwig | 7fd38af | 2017-05-08 23:40:27 +0200 | [diff] [blame] | 894 | static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)]; |
Christoph Hellwig | e967918 | 2017-05-12 16:21:37 +0200 | [diff] [blame] | 895 | const struct svc_version nfsd_version3 = { |
| 896 | .vs_vers = 3, |
| 897 | .vs_nproc = 22, |
| 898 | .vs_proc = nfsd_procedures3, |
| 899 | .vs_dispatch = nfsd_dispatch, |
| 900 | .vs_count = nfsd_count3, |
| 901 | .vs_xdrsize = NFS3_SVC_XDRSIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | }; |