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