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