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