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