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