1 // SPDX-License-Identifier: GPL-2.0
3 * Process version 3 NFS requests.
5 * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de>
9 #include <linux/ext2_fs.h>
10 #include <linux/magic.h>
11 #include <linux/namei.h>
17 #define NFSDDBG_FACILITY NFSDDBG_PROC
19 static int nfs3_ftypes[] = {
26 S_IFSOCK, /* NF3SOCK */
27 S_IFIFO, /* NF3FIFO */
34 nfsd3_proc_null(struct svc_rqst *rqstp)
40 * Get a file's attributes
43 nfsd3_proc_getattr(struct svc_rqst *rqstp)
45 struct nfsd_fhandle *argp = rqstp->rq_argp;
46 struct nfsd3_attrstat *resp = rqstp->rq_resp;
48 dprintk("nfsd: GETATTR(3) %s\n",
49 SVCFH_fmt(&argp->fh));
51 fh_copy(&resp->fh, &argp->fh);
52 resp->status = fh_verify(rqstp, &resp->fh, 0,
53 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
54 if (resp->status != nfs_ok)
57 resp->status = fh_getattr(&resp->fh, &resp->stat);
63 * Set a file's attributes
66 nfsd3_proc_setattr(struct svc_rqst *rqstp)
68 struct nfsd3_sattrargs *argp = rqstp->rq_argp;
69 struct nfsd3_attrstat *resp = rqstp->rq_resp;
70 struct nfsd_attrs attrs = {
71 .na_iattr = &argp->attrs,
74 dprintk("nfsd: SETATTR(3) %s\n",
75 SVCFH_fmt(&argp->fh));
77 fh_copy(&resp->fh, &argp->fh);
78 resp->status = nfsd_setattr(rqstp, &resp->fh, &attrs,
79 argp->check_guard, argp->guardtime);
84 * Look up a path name component
87 nfsd3_proc_lookup(struct svc_rqst *rqstp)
89 struct nfsd3_diropargs *argp = rqstp->rq_argp;
90 struct nfsd3_diropres *resp = rqstp->rq_resp;
92 dprintk("nfsd: LOOKUP(3) %s %.*s\n",
97 fh_copy(&resp->dirfh, &argp->fh);
98 fh_init(&resp->fh, NFS3_FHSIZE);
100 resp->status = nfsd_lookup(rqstp, &resp->dirfh,
101 argp->name, argp->len,
110 nfsd3_proc_access(struct svc_rqst *rqstp)
112 struct nfsd3_accessargs *argp = rqstp->rq_argp;
113 struct nfsd3_accessres *resp = rqstp->rq_resp;
115 dprintk("nfsd: ACCESS(3) %s 0x%x\n",
116 SVCFH_fmt(&argp->fh),
119 fh_copy(&resp->fh, &argp->fh);
120 resp->access = argp->access;
121 resp->status = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
129 nfsd3_proc_readlink(struct svc_rqst *rqstp)
131 struct nfsd_fhandle *argp = rqstp->rq_argp;
132 struct nfsd3_readlinkres *resp = rqstp->rq_resp;
134 dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh));
136 /* Read the symlink. */
137 fh_copy(&resp->fh, &argp->fh);
138 resp->len = NFS3_MAXPATHLEN;
139 resp->pages = rqstp->rq_next_page++;
140 resp->status = nfsd_readlink(rqstp, &resp->fh,
141 page_address(*resp->pages), &resp->len);
146 * Read a portion of a file.
149 nfsd3_proc_read(struct svc_rqst *rqstp)
151 struct nfsd3_readargs *argp = rqstp->rq_argp;
152 struct nfsd3_readres *resp = rqstp->rq_resp;
156 dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n",
157 SVCFH_fmt(&argp->fh),
158 (unsigned long) argp->count,
159 (unsigned long long) argp->offset);
161 argp->count = min_t(u32, argp->count, svc_max_payload(rqstp));
162 argp->count = min_t(u32, argp->count, rqstp->rq_res.buflen);
163 if (argp->offset > (u64)OFFSET_MAX)
164 argp->offset = (u64)OFFSET_MAX;
165 if (argp->offset + argp->count > (u64)OFFSET_MAX)
166 argp->count = (u64)OFFSET_MAX - argp->offset;
170 resp->pages = rqstp->rq_next_page;
172 struct page *page = *(rqstp->rq_next_page++);
174 rqstp->rq_vec[v].iov_base = page_address(page);
175 rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE);
176 len -= rqstp->rq_vec[v].iov_len;
180 /* Obtain buffer pointer for payload.
181 * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof)
182 * + 1 (xdr opaque byte count) = 26
184 resp->count = argp->count;
185 svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4);
187 fh_copy(&resp->fh, &argp->fh);
188 resp->status = nfsd_read(rqstp, &resp->fh, argp->offset,
189 rqstp->rq_vec, v, &resp->count, &resp->eof);
194 * Write data to a file
197 nfsd3_proc_write(struct svc_rqst *rqstp)
199 struct nfsd3_writeargs *argp = rqstp->rq_argp;
200 struct nfsd3_writeres *resp = rqstp->rq_resp;
201 unsigned long cnt = argp->len;
204 dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n",
205 SVCFH_fmt(&argp->fh),
207 (unsigned long long) argp->offset,
208 argp->stable? " stable" : "");
210 resp->status = nfserr_fbig;
211 if (argp->offset > (u64)OFFSET_MAX ||
212 argp->offset + argp->len > (u64)OFFSET_MAX)
215 fh_copy(&resp->fh, &argp->fh);
216 resp->committed = argp->stable;
217 nvecs = svc_fill_write_vector(rqstp, &argp->payload);
219 resp->status = nfsd_write(rqstp, &resp->fh, argp->offset,
220 rqstp->rq_vec, nvecs, &cnt,
221 resp->committed, resp->verf);
227 * Implement NFSv3's unchecked, guarded, and exclusive CREATE
228 * semantics for regular files. Except for the created file,
229 * this operation is stateless on the server.
231 * Upon return, caller must release @fhp and @resfhp.
234 nfsd3_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
235 struct svc_fh *resfhp, struct nfsd3_createargs *argp)
237 struct iattr *iap = &argp->attrs;
238 struct dentry *parent, *child;
239 struct nfsd_attrs attrs = {
242 __u32 v_mtime, v_atime;
247 if (isdotent(argp->name, argp->len))
249 if (!(iap->ia_valid & ATTR_MODE))
252 status = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_EXEC);
253 if (status != nfs_ok)
256 parent = fhp->fh_dentry;
257 inode = d_inode(parent);
259 host_err = fh_want_write(fhp);
261 return nfserrno(host_err);
263 inode_lock_nested(inode, I_MUTEX_PARENT);
265 child = lookup_one_len(argp->name, parent, argp->len);
267 status = nfserrno(PTR_ERR(child));
271 if (d_really_is_negative(child)) {
272 status = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_CREATE);
273 if (status != nfs_ok)
277 status = fh_compose(resfhp, fhp->fh_export, child, fhp);
278 if (status != nfs_ok)
283 if (argp->createmode == NFS3_CREATE_EXCLUSIVE) {
284 u32 *verifier = (u32 *)argp->verf;
287 * Solaris 7 gets confused (bugid 4218508) if these have
288 * the high bit set, as do xfs filesystems without the
289 * "bigtime" feature. So just clear the high bits.
291 v_mtime = verifier[0] & 0x7fffffff;
292 v_atime = verifier[1] & 0x7fffffff;
295 if (d_really_is_positive(child)) {
298 switch (argp->createmode) {
299 case NFS3_CREATE_UNCHECKED:
300 if (!d_is_reg(child))
302 iap->ia_valid &= ATTR_SIZE;
304 case NFS3_CREATE_GUARDED:
305 status = nfserr_exist;
307 case NFS3_CREATE_EXCLUSIVE:
308 if (d_inode(child)->i_mtime.tv_sec == v_mtime &&
309 d_inode(child)->i_atime.tv_sec == v_atime &&
310 d_inode(child)->i_size == 0) {
313 status = nfserr_exist;
318 if (!IS_POSIXACL(inode))
319 iap->ia_mode &= ~current_umask();
321 fh_fill_pre_attrs(fhp);
322 host_err = vfs_create(&init_user_ns, inode, child, iap->ia_mode, true);
324 status = nfserrno(host_err);
327 fh_fill_post_attrs(fhp);
329 /* A newly created file already has a file size of zero. */
330 if ((iap->ia_valid & ATTR_SIZE) && (iap->ia_size == 0))
331 iap->ia_valid &= ~ATTR_SIZE;
332 if (argp->createmode == NFS3_CREATE_EXCLUSIVE) {
333 iap->ia_valid = ATTR_MTIME | ATTR_ATIME |
334 ATTR_MTIME_SET | ATTR_ATIME_SET;
335 iap->ia_mtime.tv_sec = v_mtime;
336 iap->ia_atime.tv_sec = v_atime;
337 iap->ia_mtime.tv_nsec = 0;
338 iap->ia_atime.tv_nsec = 0;
342 status = nfsd_create_setattr(rqstp, fhp, resfhp, &attrs);
346 if (child && !IS_ERR(child))
353 nfsd3_proc_create(struct svc_rqst *rqstp)
355 struct nfsd3_createargs *argp = rqstp->rq_argp;
356 struct nfsd3_diropres *resp = rqstp->rq_resp;
357 svc_fh *dirfhp, *newfhp;
359 dprintk("nfsd: CREATE(3) %s %.*s\n",
360 SVCFH_fmt(&argp->fh),
364 dirfhp = fh_copy(&resp->dirfh, &argp->fh);
365 newfhp = fh_init(&resp->fh, NFS3_FHSIZE);
367 resp->status = nfsd3_create_file(rqstp, dirfhp, newfhp, argp);
372 * Make directory. This operation is not idempotent.
375 nfsd3_proc_mkdir(struct svc_rqst *rqstp)
377 struct nfsd3_createargs *argp = rqstp->rq_argp;
378 struct nfsd3_diropres *resp = rqstp->rq_resp;
379 struct nfsd_attrs attrs = {
380 .na_iattr = &argp->attrs,
383 dprintk("nfsd: MKDIR(3) %s %.*s\n",
384 SVCFH_fmt(&argp->fh),
388 argp->attrs.ia_valid &= ~ATTR_SIZE;
389 fh_copy(&resp->dirfh, &argp->fh);
390 fh_init(&resp->fh, NFS3_FHSIZE);
391 resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
392 &attrs, S_IFDIR, 0, &resp->fh);
397 nfsd3_proc_symlink(struct svc_rqst *rqstp)
399 struct nfsd3_symlinkargs *argp = rqstp->rq_argp;
400 struct nfsd3_diropres *resp = rqstp->rq_resp;
401 struct nfsd_attrs attrs = {
402 .na_iattr = &argp->attrs,
405 if (argp->tlen == 0) {
406 resp->status = nfserr_inval;
409 if (argp->tlen > NFS3_MAXPATHLEN) {
410 resp->status = nfserr_nametoolong;
414 argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first,
415 page_address(rqstp->rq_arg.pages[0]),
417 if (IS_ERR(argp->tname)) {
418 resp->status = nfserrno(PTR_ERR(argp->tname));
422 dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n",
423 SVCFH_fmt(&argp->ffh),
424 argp->flen, argp->fname,
425 argp->tlen, argp->tname);
427 fh_copy(&resp->dirfh, &argp->ffh);
428 fh_init(&resp->fh, NFS3_FHSIZE);
429 resp->status = nfsd_symlink(rqstp, &resp->dirfh, argp->fname,
430 argp->flen, argp->tname, &attrs, &resp->fh);
437 * Make socket/fifo/device.
440 nfsd3_proc_mknod(struct svc_rqst *rqstp)
442 struct nfsd3_mknodargs *argp = rqstp->rq_argp;
443 struct nfsd3_diropres *resp = rqstp->rq_resp;
444 struct nfsd_attrs attrs = {
445 .na_iattr = &argp->attrs,
450 dprintk("nfsd: MKNOD(3) %s %.*s\n",
451 SVCFH_fmt(&argp->fh),
455 fh_copy(&resp->dirfh, &argp->fh);
456 fh_init(&resp->fh, NFS3_FHSIZE);
458 if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) {
459 rdev = MKDEV(argp->major, argp->minor);
460 if (MAJOR(rdev) != argp->major ||
461 MINOR(rdev) != argp->minor) {
462 resp->status = nfserr_inval;
465 } else if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO) {
466 resp->status = nfserr_badtype;
470 type = nfs3_ftypes[argp->ftype];
471 resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
472 &attrs, type, rdev, &resp->fh);
478 * Remove file/fifo/socket etc.
481 nfsd3_proc_remove(struct svc_rqst *rqstp)
483 struct nfsd3_diropargs *argp = rqstp->rq_argp;
484 struct nfsd3_attrstat *resp = rqstp->rq_resp;
486 dprintk("nfsd: REMOVE(3) %s %.*s\n",
487 SVCFH_fmt(&argp->fh),
491 /* Unlink. -S_IFDIR means file must not be a directory */
492 fh_copy(&resp->fh, &argp->fh);
493 resp->status = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR,
494 argp->name, argp->len);
502 nfsd3_proc_rmdir(struct svc_rqst *rqstp)
504 struct nfsd3_diropargs *argp = rqstp->rq_argp;
505 struct nfsd3_attrstat *resp = rqstp->rq_resp;
507 dprintk("nfsd: RMDIR(3) %s %.*s\n",
508 SVCFH_fmt(&argp->fh),
512 fh_copy(&resp->fh, &argp->fh);
513 resp->status = nfsd_unlink(rqstp, &resp->fh, S_IFDIR,
514 argp->name, argp->len);
519 nfsd3_proc_rename(struct svc_rqst *rqstp)
521 struct nfsd3_renameargs *argp = rqstp->rq_argp;
522 struct nfsd3_renameres *resp = rqstp->rq_resp;
524 dprintk("nfsd: RENAME(3) %s %.*s ->\n",
525 SVCFH_fmt(&argp->ffh),
528 dprintk("nfsd: -> %s %.*s\n",
529 SVCFH_fmt(&argp->tfh),
533 fh_copy(&resp->ffh, &argp->ffh);
534 fh_copy(&resp->tfh, &argp->tfh);
535 resp->status = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen,
536 &resp->tfh, argp->tname, argp->tlen);
541 nfsd3_proc_link(struct svc_rqst *rqstp)
543 struct nfsd3_linkargs *argp = rqstp->rq_argp;
544 struct nfsd3_linkres *resp = rqstp->rq_resp;
546 dprintk("nfsd: LINK(3) %s ->\n",
547 SVCFH_fmt(&argp->ffh));
548 dprintk("nfsd: -> %s %.*s\n",
549 SVCFH_fmt(&argp->tfh),
553 fh_copy(&resp->fh, &argp->ffh);
554 fh_copy(&resp->tfh, &argp->tfh);
555 resp->status = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen,
560 static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp,
561 struct nfsd3_readdirres *resp,
564 struct xdr_buf *buf = &resp->dirlist;
565 struct xdr_stream *xdr = &resp->xdr;
566 unsigned int sendbuf = min_t(unsigned int, rqstp->rq_res.buflen,
567 svc_max_payload(rqstp));
569 memset(buf, 0, sizeof(*buf));
571 /* Reserve room for the NULL ptr & eof flag (-2 words) */
572 buf->buflen = clamp(count, (u32)(XDR_UNIT * 2), sendbuf);
573 buf->buflen -= XDR_UNIT * 2;
574 buf->pages = rqstp->rq_next_page;
575 rqstp->rq_next_page += (buf->buflen + PAGE_SIZE - 1) >> PAGE_SHIFT;
577 xdr_init_encode_pages(xdr, buf, buf->pages, NULL);
581 * Read a portion of a directory.
584 nfsd3_proc_readdir(struct svc_rqst *rqstp)
586 struct nfsd3_readdirargs *argp = rqstp->rq_argp;
587 struct nfsd3_readdirres *resp = rqstp->rq_resp;
590 dprintk("nfsd: READDIR(3) %s %d bytes at %d\n",
591 SVCFH_fmt(&argp->fh),
592 argp->count, (u32) argp->cookie);
594 nfsd3_init_dirlist_pages(rqstp, resp, argp->count);
596 fh_copy(&resp->fh, &argp->fh);
597 resp->common.err = nfs_ok;
598 resp->cookie_offset = 0;
600 offset = argp->cookie;
601 resp->status = nfsd_readdir(rqstp, &resp->fh, &offset,
602 &resp->common, nfs3svc_encode_entry3);
603 memcpy(resp->verf, argp->verf, 8);
604 nfs3svc_encode_cookie3(resp, offset);
606 /* Recycle only pages that were part of the reply */
607 rqstp->rq_next_page = resp->xdr.page_ptr + 1;
613 * Read a portion of a directory, including file handles and attrs.
614 * For now, we choose to ignore the dircount parameter.
617 nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
619 struct nfsd3_readdirargs *argp = rqstp->rq_argp;
620 struct nfsd3_readdirres *resp = rqstp->rq_resp;
623 dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",
624 SVCFH_fmt(&argp->fh),
625 argp->count, (u32) argp->cookie);
627 nfsd3_init_dirlist_pages(rqstp, resp, argp->count);
629 fh_copy(&resp->fh, &argp->fh);
630 resp->common.err = nfs_ok;
631 resp->cookie_offset = 0;
633 offset = argp->cookie;
635 resp->status = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP);
636 if (resp->status != nfs_ok)
639 if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS) {
640 resp->status = nfserr_notsupp;
644 resp->status = nfsd_readdir(rqstp, &resp->fh, &offset,
645 &resp->common, nfs3svc_encode_entryplus3);
646 memcpy(resp->verf, argp->verf, 8);
647 nfs3svc_encode_cookie3(resp, offset);
649 /* Recycle only pages that were part of the reply */
650 rqstp->rq_next_page = resp->xdr.page_ptr + 1;
657 * Get file system stats
660 nfsd3_proc_fsstat(struct svc_rqst *rqstp)
662 struct nfsd_fhandle *argp = rqstp->rq_argp;
663 struct nfsd3_fsstatres *resp = rqstp->rq_resp;
665 dprintk("nfsd: FSSTAT(3) %s\n",
666 SVCFH_fmt(&argp->fh));
668 resp->status = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0);
674 * Get file system info
677 nfsd3_proc_fsinfo(struct svc_rqst *rqstp)
679 struct nfsd_fhandle *argp = rqstp->rq_argp;
680 struct nfsd3_fsinfores *resp = rqstp->rq_resp;
681 u32 max_blocksize = svc_max_payload(rqstp);
683 dprintk("nfsd: FSINFO(3) %s\n",
684 SVCFH_fmt(&argp->fh));
686 resp->f_rtmax = max_blocksize;
687 resp->f_rtpref = max_blocksize;
688 resp->f_rtmult = PAGE_SIZE;
689 resp->f_wtmax = max_blocksize;
690 resp->f_wtpref = max_blocksize;
691 resp->f_wtmult = PAGE_SIZE;
692 resp->f_dtpref = max_blocksize;
693 resp->f_maxfilesize = ~(u32) 0;
694 resp->f_properties = NFS3_FSF_DEFAULT;
696 resp->status = fh_verify(rqstp, &argp->fh, 0,
697 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
699 /* Check special features of the file system. May request
700 * different read/write sizes for file systems known to have
701 * problems with large blocks */
702 if (resp->status == nfs_ok) {
703 struct super_block *sb = argp->fh.fh_dentry->d_sb;
705 /* Note that we don't care for remote fs's here */
706 if (sb->s_magic == MSDOS_SUPER_MAGIC) {
707 resp->f_properties = NFS3_FSF_BILLYBOY;
709 resp->f_maxfilesize = sb->s_maxbytes;
717 * Get pathconf info for the specified file
720 nfsd3_proc_pathconf(struct svc_rqst *rqstp)
722 struct nfsd_fhandle *argp = rqstp->rq_argp;
723 struct nfsd3_pathconfres *resp = rqstp->rq_resp;
725 dprintk("nfsd: PATHCONF(3) %s\n",
726 SVCFH_fmt(&argp->fh));
728 /* Set default pathconf */
729 resp->p_link_max = 255; /* at least */
730 resp->p_name_max = 255; /* at least */
731 resp->p_no_trunc = 0;
732 resp->p_chown_restricted = 1;
733 resp->p_case_insensitive = 0;
734 resp->p_case_preserving = 1;
736 resp->status = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP);
738 if (resp->status == nfs_ok) {
739 struct super_block *sb = argp->fh.fh_dentry->d_sb;
741 /* Note that we don't care for remote fs's here */
742 switch (sb->s_magic) {
743 case EXT2_SUPER_MAGIC:
744 resp->p_link_max = EXT2_LINK_MAX;
745 resp->p_name_max = EXT2_NAME_LEN;
747 case MSDOS_SUPER_MAGIC:
748 resp->p_case_insensitive = 1;
749 resp->p_case_preserving = 0;
759 * Commit a file (range) to stable storage.
762 nfsd3_proc_commit(struct svc_rqst *rqstp)
764 struct nfsd3_commitargs *argp = rqstp->rq_argp;
765 struct nfsd3_commitres *resp = rqstp->rq_resp;
767 dprintk("nfsd: COMMIT(3) %s %u@%Lu\n",
768 SVCFH_fmt(&argp->fh),
770 (unsigned long long) argp->offset);
772 fh_copy(&resp->fh, &argp->fh);
773 resp->status = nfsd_commit(rqstp, &resp->fh, argp->offset,
774 argp->count, resp->verf);
780 * NFSv3 Server procedures.
781 * Only the results of non-idempotent operations are cached.
783 #define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat
784 #define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat
785 #define nfsd3_mkdirargs nfsd3_createargs
786 #define nfsd3_readdirplusargs nfsd3_readdirargs
787 #define nfsd3_fhandleargs nfsd_fhandle
788 #define nfsd3_attrstatres nfsd3_attrstat
789 #define nfsd3_wccstatres nfsd3_attrstat
790 #define nfsd3_createres nfsd3_diropres
792 #define ST 1 /* status*/
793 #define FH 17 /* filehandle with length */
794 #define AT 21 /* attributes */
795 #define pAT (1+AT) /* post attributes - conditional */
796 #define WC (7+pAT) /* WCC attributes */
798 static const struct svc_procedure nfsd_procedures3[22] = {
800 .pc_func = nfsd3_proc_null,
801 .pc_decode = nfssvc_decode_voidarg,
802 .pc_encode = nfssvc_encode_voidres,
803 .pc_argsize = sizeof(struct nfsd_voidargs),
804 .pc_argzero = sizeof(struct nfsd_voidargs),
805 .pc_ressize = sizeof(struct nfsd_voidres),
806 .pc_cachetype = RC_NOCACHE,
810 [NFS3PROC_GETATTR] = {
811 .pc_func = nfsd3_proc_getattr,
812 .pc_decode = nfs3svc_decode_fhandleargs,
813 .pc_encode = nfs3svc_encode_getattrres,
814 .pc_release = nfs3svc_release_fhandle,
815 .pc_argsize = sizeof(struct nfsd_fhandle),
816 .pc_argzero = sizeof(struct nfsd_fhandle),
817 .pc_ressize = sizeof(struct nfsd3_attrstatres),
818 .pc_cachetype = RC_NOCACHE,
819 .pc_xdrressize = ST+AT,
820 .pc_name = "GETATTR",
822 [NFS3PROC_SETATTR] = {
823 .pc_func = nfsd3_proc_setattr,
824 .pc_decode = nfs3svc_decode_sattrargs,
825 .pc_encode = nfs3svc_encode_wccstatres,
826 .pc_release = nfs3svc_release_fhandle,
827 .pc_argsize = sizeof(struct nfsd3_sattrargs),
828 .pc_argzero = sizeof(struct nfsd3_sattrargs),
829 .pc_ressize = sizeof(struct nfsd3_wccstatres),
830 .pc_cachetype = RC_REPLBUFF,
831 .pc_xdrressize = ST+WC,
832 .pc_name = "SETATTR",
834 [NFS3PROC_LOOKUP] = {
835 .pc_func = nfsd3_proc_lookup,
836 .pc_decode = nfs3svc_decode_diropargs,
837 .pc_encode = nfs3svc_encode_lookupres,
838 .pc_release = nfs3svc_release_fhandle2,
839 .pc_argsize = sizeof(struct nfsd3_diropargs),
840 .pc_argzero = sizeof(struct nfsd3_diropargs),
841 .pc_ressize = sizeof(struct nfsd3_diropres),
842 .pc_cachetype = RC_NOCACHE,
843 .pc_xdrressize = ST+FH+pAT+pAT,
846 [NFS3PROC_ACCESS] = {
847 .pc_func = nfsd3_proc_access,
848 .pc_decode = nfs3svc_decode_accessargs,
849 .pc_encode = nfs3svc_encode_accessres,
850 .pc_release = nfs3svc_release_fhandle,
851 .pc_argsize = sizeof(struct nfsd3_accessargs),
852 .pc_argzero = sizeof(struct nfsd3_accessargs),
853 .pc_ressize = sizeof(struct nfsd3_accessres),
854 .pc_cachetype = RC_NOCACHE,
855 .pc_xdrressize = ST+pAT+1,
858 [NFS3PROC_READLINK] = {
859 .pc_func = nfsd3_proc_readlink,
860 .pc_decode = nfs3svc_decode_fhandleargs,
861 .pc_encode = nfs3svc_encode_readlinkres,
862 .pc_release = nfs3svc_release_fhandle,
863 .pc_argsize = sizeof(struct nfsd_fhandle),
864 .pc_argzero = sizeof(struct nfsd_fhandle),
865 .pc_ressize = sizeof(struct nfsd3_readlinkres),
866 .pc_cachetype = RC_NOCACHE,
867 .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4,
868 .pc_name = "READLINK",
871 .pc_func = nfsd3_proc_read,
872 .pc_decode = nfs3svc_decode_readargs,
873 .pc_encode = nfs3svc_encode_readres,
874 .pc_release = nfs3svc_release_fhandle,
875 .pc_argsize = sizeof(struct nfsd3_readargs),
876 .pc_argzero = sizeof(struct nfsd3_readargs),
877 .pc_ressize = sizeof(struct nfsd3_readres),
878 .pc_cachetype = RC_NOCACHE,
879 .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4,
883 .pc_func = nfsd3_proc_write,
884 .pc_decode = nfs3svc_decode_writeargs,
885 .pc_encode = nfs3svc_encode_writeres,
886 .pc_release = nfs3svc_release_fhandle,
887 .pc_argsize = sizeof(struct nfsd3_writeargs),
888 .pc_argzero = sizeof(struct nfsd3_writeargs),
889 .pc_ressize = sizeof(struct nfsd3_writeres),
890 .pc_cachetype = RC_REPLBUFF,
891 .pc_xdrressize = ST+WC+4,
894 [NFS3PROC_CREATE] = {
895 .pc_func = nfsd3_proc_create,
896 .pc_decode = nfs3svc_decode_createargs,
897 .pc_encode = nfs3svc_encode_createres,
898 .pc_release = nfs3svc_release_fhandle2,
899 .pc_argsize = sizeof(struct nfsd3_createargs),
900 .pc_argzero = sizeof(struct nfsd3_createargs),
901 .pc_ressize = sizeof(struct nfsd3_createres),
902 .pc_cachetype = RC_REPLBUFF,
903 .pc_xdrressize = ST+(1+FH+pAT)+WC,
907 .pc_func = nfsd3_proc_mkdir,
908 .pc_decode = nfs3svc_decode_mkdirargs,
909 .pc_encode = nfs3svc_encode_createres,
910 .pc_release = nfs3svc_release_fhandle2,
911 .pc_argsize = sizeof(struct nfsd3_mkdirargs),
912 .pc_argzero = sizeof(struct nfsd3_mkdirargs),
913 .pc_ressize = sizeof(struct nfsd3_createres),
914 .pc_cachetype = RC_REPLBUFF,
915 .pc_xdrressize = ST+(1+FH+pAT)+WC,
918 [NFS3PROC_SYMLINK] = {
919 .pc_func = nfsd3_proc_symlink,
920 .pc_decode = nfs3svc_decode_symlinkargs,
921 .pc_encode = nfs3svc_encode_createres,
922 .pc_release = nfs3svc_release_fhandle2,
923 .pc_argsize = sizeof(struct nfsd3_symlinkargs),
924 .pc_argzero = sizeof(struct nfsd3_symlinkargs),
925 .pc_ressize = sizeof(struct nfsd3_createres),
926 .pc_cachetype = RC_REPLBUFF,
927 .pc_xdrressize = ST+(1+FH+pAT)+WC,
928 .pc_name = "SYMLINK",
931 .pc_func = nfsd3_proc_mknod,
932 .pc_decode = nfs3svc_decode_mknodargs,
933 .pc_encode = nfs3svc_encode_createres,
934 .pc_release = nfs3svc_release_fhandle2,
935 .pc_argsize = sizeof(struct nfsd3_mknodargs),
936 .pc_argzero = sizeof(struct nfsd3_mknodargs),
937 .pc_ressize = sizeof(struct nfsd3_createres),
938 .pc_cachetype = RC_REPLBUFF,
939 .pc_xdrressize = ST+(1+FH+pAT)+WC,
942 [NFS3PROC_REMOVE] = {
943 .pc_func = nfsd3_proc_remove,
944 .pc_decode = nfs3svc_decode_diropargs,
945 .pc_encode = nfs3svc_encode_wccstatres,
946 .pc_release = nfs3svc_release_fhandle,
947 .pc_argsize = sizeof(struct nfsd3_diropargs),
948 .pc_argzero = sizeof(struct nfsd3_diropargs),
949 .pc_ressize = sizeof(struct nfsd3_wccstatres),
950 .pc_cachetype = RC_REPLBUFF,
951 .pc_xdrressize = ST+WC,
955 .pc_func = nfsd3_proc_rmdir,
956 .pc_decode = nfs3svc_decode_diropargs,
957 .pc_encode = nfs3svc_encode_wccstatres,
958 .pc_release = nfs3svc_release_fhandle,
959 .pc_argsize = sizeof(struct nfsd3_diropargs),
960 .pc_argzero = sizeof(struct nfsd3_diropargs),
961 .pc_ressize = sizeof(struct nfsd3_wccstatres),
962 .pc_cachetype = RC_REPLBUFF,
963 .pc_xdrressize = ST+WC,
966 [NFS3PROC_RENAME] = {
967 .pc_func = nfsd3_proc_rename,
968 .pc_decode = nfs3svc_decode_renameargs,
969 .pc_encode = nfs3svc_encode_renameres,
970 .pc_release = nfs3svc_release_fhandle2,
971 .pc_argsize = sizeof(struct nfsd3_renameargs),
972 .pc_argzero = sizeof(struct nfsd3_renameargs),
973 .pc_ressize = sizeof(struct nfsd3_renameres),
974 .pc_cachetype = RC_REPLBUFF,
975 .pc_xdrressize = ST+WC+WC,
979 .pc_func = nfsd3_proc_link,
980 .pc_decode = nfs3svc_decode_linkargs,
981 .pc_encode = nfs3svc_encode_linkres,
982 .pc_release = nfs3svc_release_fhandle2,
983 .pc_argsize = sizeof(struct nfsd3_linkargs),
984 .pc_argzero = sizeof(struct nfsd3_linkargs),
985 .pc_ressize = sizeof(struct nfsd3_linkres),
986 .pc_cachetype = RC_REPLBUFF,
987 .pc_xdrressize = ST+pAT+WC,
990 [NFS3PROC_READDIR] = {
991 .pc_func = nfsd3_proc_readdir,
992 .pc_decode = nfs3svc_decode_readdirargs,
993 .pc_encode = nfs3svc_encode_readdirres,
994 .pc_release = nfs3svc_release_fhandle,
995 .pc_argsize = sizeof(struct nfsd3_readdirargs),
996 .pc_argzero = sizeof(struct nfsd3_readdirargs),
997 .pc_ressize = sizeof(struct nfsd3_readdirres),
998 .pc_cachetype = RC_NOCACHE,
999 .pc_name = "READDIR",
1001 [NFS3PROC_READDIRPLUS] = {
1002 .pc_func = nfsd3_proc_readdirplus,
1003 .pc_decode = nfs3svc_decode_readdirplusargs,
1004 .pc_encode = nfs3svc_encode_readdirres,
1005 .pc_release = nfs3svc_release_fhandle,
1006 .pc_argsize = sizeof(struct nfsd3_readdirplusargs),
1007 .pc_argzero = sizeof(struct nfsd3_readdirplusargs),
1008 .pc_ressize = sizeof(struct nfsd3_readdirres),
1009 .pc_cachetype = RC_NOCACHE,
1010 .pc_name = "READDIRPLUS",
1012 [NFS3PROC_FSSTAT] = {
1013 .pc_func = nfsd3_proc_fsstat,
1014 .pc_decode = nfs3svc_decode_fhandleargs,
1015 .pc_encode = nfs3svc_encode_fsstatres,
1016 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
1017 .pc_argzero = sizeof(struct nfsd3_fhandleargs),
1018 .pc_ressize = sizeof(struct nfsd3_fsstatres),
1019 .pc_cachetype = RC_NOCACHE,
1020 .pc_xdrressize = ST+pAT+2*6+1,
1021 .pc_name = "FSSTAT",
1023 [NFS3PROC_FSINFO] = {
1024 .pc_func = nfsd3_proc_fsinfo,
1025 .pc_decode = nfs3svc_decode_fhandleargs,
1026 .pc_encode = nfs3svc_encode_fsinfores,
1027 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
1028 .pc_argzero = sizeof(struct nfsd3_fhandleargs),
1029 .pc_ressize = sizeof(struct nfsd3_fsinfores),
1030 .pc_cachetype = RC_NOCACHE,
1031 .pc_xdrressize = ST+pAT+12,
1032 .pc_name = "FSINFO",
1034 [NFS3PROC_PATHCONF] = {
1035 .pc_func = nfsd3_proc_pathconf,
1036 .pc_decode = nfs3svc_decode_fhandleargs,
1037 .pc_encode = nfs3svc_encode_pathconfres,
1038 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
1039 .pc_argzero = sizeof(struct nfsd3_fhandleargs),
1040 .pc_ressize = sizeof(struct nfsd3_pathconfres),
1041 .pc_cachetype = RC_NOCACHE,
1042 .pc_xdrressize = ST+pAT+6,
1043 .pc_name = "PATHCONF",
1045 [NFS3PROC_COMMIT] = {
1046 .pc_func = nfsd3_proc_commit,
1047 .pc_decode = nfs3svc_decode_commitargs,
1048 .pc_encode = nfs3svc_encode_commitres,
1049 .pc_release = nfs3svc_release_fhandle,
1050 .pc_argsize = sizeof(struct nfsd3_commitargs),
1051 .pc_argzero = sizeof(struct nfsd3_commitargs),
1052 .pc_ressize = sizeof(struct nfsd3_commitres),
1053 .pc_cachetype = RC_NOCACHE,
1054 .pc_xdrressize = ST+WC+2,
1055 .pc_name = "COMMIT",
1059 static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)];
1060 const struct svc_version nfsd_version3 = {
1063 .vs_proc = nfsd_procedures3,
1064 .vs_dispatch = nfsd_dispatch,
1065 .vs_count = nfsd_count3,
1066 .vs_xdrsize = NFS3_SVC_XDRSIZE,