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;
71 dprintk("nfsd: SETATTR(3) %s\n",
72 SVCFH_fmt(&argp->fh));
74 fh_copy(&resp->fh, &argp->fh);
75 resp->status = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,
76 argp->check_guard, argp->guardtime);
81 * Look up a path name component
84 nfsd3_proc_lookup(struct svc_rqst *rqstp)
86 struct nfsd3_diropargs *argp = rqstp->rq_argp;
87 struct nfsd3_diropres *resp = rqstp->rq_resp;
89 dprintk("nfsd: LOOKUP(3) %s %.*s\n",
94 fh_copy(&resp->dirfh, &argp->fh);
95 fh_init(&resp->fh, NFS3_FHSIZE);
97 resp->status = nfsd_lookup(rqstp, &resp->dirfh,
98 argp->name, argp->len,
107 nfsd3_proc_access(struct svc_rqst *rqstp)
109 struct nfsd3_accessargs *argp = rqstp->rq_argp;
110 struct nfsd3_accessres *resp = rqstp->rq_resp;
112 dprintk("nfsd: ACCESS(3) %s 0x%x\n",
113 SVCFH_fmt(&argp->fh),
116 fh_copy(&resp->fh, &argp->fh);
117 resp->access = argp->access;
118 resp->status = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
126 nfsd3_proc_readlink(struct svc_rqst *rqstp)
128 struct nfsd_fhandle *argp = rqstp->rq_argp;
129 struct nfsd3_readlinkres *resp = rqstp->rq_resp;
131 dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh));
133 /* Read the symlink. */
134 fh_copy(&resp->fh, &argp->fh);
135 resp->len = NFS3_MAXPATHLEN;
136 resp->pages = rqstp->rq_next_page++;
137 resp->status = nfsd_readlink(rqstp, &resp->fh,
138 page_address(*resp->pages), &resp->len);
143 * Read a portion of a file.
146 nfsd3_proc_read(struct svc_rqst *rqstp)
148 struct nfsd3_readargs *argp = rqstp->rq_argp;
149 struct nfsd3_readres *resp = rqstp->rq_resp;
150 u32 max_blocksize = svc_max_payload(rqstp);
154 dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n",
155 SVCFH_fmt(&argp->fh),
156 (unsigned long) argp->count,
157 (unsigned long long) argp->offset);
159 argp->count = min_t(u32, argp->count, max_blocksize);
160 if (argp->offset > (u64)OFFSET_MAX)
161 argp->offset = (u64)OFFSET_MAX;
162 if (argp->offset + argp->count > (u64)OFFSET_MAX)
163 argp->count = (u64)OFFSET_MAX - argp->offset;
167 resp->pages = rqstp->rq_next_page;
169 struct page *page = *(rqstp->rq_next_page++);
171 rqstp->rq_vec[v].iov_base = page_address(page);
172 rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE);
173 len -= rqstp->rq_vec[v].iov_len;
177 /* Obtain buffer pointer for payload.
178 * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof)
179 * + 1 (xdr opaque byte count) = 26
181 resp->count = argp->count;
182 svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4);
184 fh_copy(&resp->fh, &argp->fh);
185 resp->status = nfsd_read(rqstp, &resp->fh, argp->offset,
186 rqstp->rq_vec, v, &resp->count, &resp->eof);
191 * Write data to a file
194 nfsd3_proc_write(struct svc_rqst *rqstp)
196 struct nfsd3_writeargs *argp = rqstp->rq_argp;
197 struct nfsd3_writeres *resp = rqstp->rq_resp;
198 unsigned long cnt = argp->len;
201 dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n",
202 SVCFH_fmt(&argp->fh),
204 (unsigned long long) argp->offset,
205 argp->stable? " stable" : "");
207 resp->status = nfserr_fbig;
208 if (argp->offset > (u64)OFFSET_MAX ||
209 argp->offset + argp->len > (u64)OFFSET_MAX)
212 fh_copy(&resp->fh, &argp->fh);
213 resp->committed = argp->stable;
214 nvecs = svc_fill_write_vector(rqstp, &argp->payload);
216 resp->status = nfsd_write(rqstp, &resp->fh, argp->offset,
217 rqstp->rq_vec, nvecs, &cnt,
218 resp->committed, resp->verf);
224 * Implement NFSv3's unchecked, guarded, and exclusive CREATE
225 * semantics for regular files. Except for the created file,
226 * this operation is stateless on the server.
228 * Upon return, caller must release @fhp and @resfhp.
231 nfsd3_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
232 struct svc_fh *resfhp, struct nfsd3_createargs *argp)
234 struct iattr *iap = &argp->attrs;
235 struct dentry *parent, *child;
236 __u32 v_mtime, v_atime;
241 if (isdotent(argp->name, argp->len))
243 if (!(iap->ia_valid & ATTR_MODE))
246 status = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_EXEC);
247 if (status != nfs_ok)
250 parent = fhp->fh_dentry;
251 inode = d_inode(parent);
253 host_err = fh_want_write(fhp);
255 return nfserrno(host_err);
257 fh_lock_nested(fhp, I_MUTEX_PARENT);
259 child = lookup_one_len(argp->name, parent, argp->len);
261 status = nfserrno(PTR_ERR(child));
265 if (d_really_is_negative(child)) {
266 status = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_CREATE);
267 if (status != nfs_ok)
271 status = fh_compose(resfhp, fhp->fh_export, child, fhp);
272 if (status != nfs_ok)
277 if (argp->createmode == NFS3_CREATE_EXCLUSIVE) {
278 u32 *verifier = (u32 *)argp->verf;
281 * Solaris 7 gets confused (bugid 4218508) if these have
282 * the high bit set, as do xfs filesystems without the
283 * "bigtime" feature. So just clear the high bits.
285 v_mtime = verifier[0] & 0x7fffffff;
286 v_atime = verifier[1] & 0x7fffffff;
289 if (d_really_is_positive(child)) {
292 switch (argp->createmode) {
293 case NFS3_CREATE_UNCHECKED:
294 if (!d_is_reg(child))
296 iap->ia_valid &= ATTR_SIZE;
298 case NFS3_CREATE_GUARDED:
299 status = nfserr_exist;
301 case NFS3_CREATE_EXCLUSIVE:
302 if (d_inode(child)->i_mtime.tv_sec == v_mtime &&
303 d_inode(child)->i_atime.tv_sec == v_atime &&
304 d_inode(child)->i_size == 0) {
307 status = nfserr_exist;
312 if (!IS_POSIXACL(inode))
313 iap->ia_mode &= ~current_umask();
315 host_err = vfs_create(&init_user_ns, inode, child, iap->ia_mode, true);
317 status = nfserrno(host_err);
321 /* A newly created file already has a file size of zero. */
322 if ((iap->ia_valid & ATTR_SIZE) && (iap->ia_size == 0))
323 iap->ia_valid &= ~ATTR_SIZE;
324 if (argp->createmode == NFS3_CREATE_EXCLUSIVE) {
325 iap->ia_valid = ATTR_MTIME | ATTR_ATIME |
326 ATTR_MTIME_SET | ATTR_ATIME_SET;
327 iap->ia_mtime.tv_sec = v_mtime;
328 iap->ia_atime.tv_sec = v_atime;
329 iap->ia_mtime.tv_nsec = 0;
330 iap->ia_atime.tv_nsec = 0;
334 status = nfsd_create_setattr(rqstp, fhp, resfhp, iap);
338 if (child && !IS_ERR(child))
345 nfsd3_proc_create(struct svc_rqst *rqstp)
347 struct nfsd3_createargs *argp = rqstp->rq_argp;
348 struct nfsd3_diropres *resp = rqstp->rq_resp;
349 svc_fh *dirfhp, *newfhp;
351 dprintk("nfsd: CREATE(3) %s %.*s\n",
352 SVCFH_fmt(&argp->fh),
356 dirfhp = fh_copy(&resp->dirfh, &argp->fh);
357 newfhp = fh_init(&resp->fh, NFS3_FHSIZE);
359 resp->status = nfsd3_create_file(rqstp, dirfhp, newfhp, argp);
364 * Make directory. This operation is not idempotent.
367 nfsd3_proc_mkdir(struct svc_rqst *rqstp)
369 struct nfsd3_createargs *argp = rqstp->rq_argp;
370 struct nfsd3_diropres *resp = rqstp->rq_resp;
372 dprintk("nfsd: MKDIR(3) %s %.*s\n",
373 SVCFH_fmt(&argp->fh),
377 argp->attrs.ia_valid &= ~ATTR_SIZE;
378 fh_copy(&resp->dirfh, &argp->fh);
379 fh_init(&resp->fh, NFS3_FHSIZE);
380 resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
381 &argp->attrs, S_IFDIR, 0, &resp->fh);
382 fh_unlock(&resp->dirfh);
387 nfsd3_proc_symlink(struct svc_rqst *rqstp)
389 struct nfsd3_symlinkargs *argp = rqstp->rq_argp;
390 struct nfsd3_diropres *resp = rqstp->rq_resp;
392 if (argp->tlen == 0) {
393 resp->status = nfserr_inval;
396 if (argp->tlen > NFS3_MAXPATHLEN) {
397 resp->status = nfserr_nametoolong;
401 argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first,
402 page_address(rqstp->rq_arg.pages[0]),
404 if (IS_ERR(argp->tname)) {
405 resp->status = nfserrno(PTR_ERR(argp->tname));
409 dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n",
410 SVCFH_fmt(&argp->ffh),
411 argp->flen, argp->fname,
412 argp->tlen, argp->tname);
414 fh_copy(&resp->dirfh, &argp->ffh);
415 fh_init(&resp->fh, NFS3_FHSIZE);
416 resp->status = nfsd_symlink(rqstp, &resp->dirfh, argp->fname,
417 argp->flen, argp->tname, &resp->fh);
424 * Make socket/fifo/device.
427 nfsd3_proc_mknod(struct svc_rqst *rqstp)
429 struct nfsd3_mknodargs *argp = rqstp->rq_argp;
430 struct nfsd3_diropres *resp = rqstp->rq_resp;
434 dprintk("nfsd: MKNOD(3) %s %.*s\n",
435 SVCFH_fmt(&argp->fh),
439 fh_copy(&resp->dirfh, &argp->fh);
440 fh_init(&resp->fh, NFS3_FHSIZE);
442 if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) {
443 rdev = MKDEV(argp->major, argp->minor);
444 if (MAJOR(rdev) != argp->major ||
445 MINOR(rdev) != argp->minor) {
446 resp->status = nfserr_inval;
449 } else if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO) {
450 resp->status = nfserr_badtype;
454 type = nfs3_ftypes[argp->ftype];
455 resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
456 &argp->attrs, type, rdev, &resp->fh);
457 fh_unlock(&resp->dirfh);
463 * Remove file/fifo/socket etc.
466 nfsd3_proc_remove(struct svc_rqst *rqstp)
468 struct nfsd3_diropargs *argp = rqstp->rq_argp;
469 struct nfsd3_attrstat *resp = rqstp->rq_resp;
471 dprintk("nfsd: REMOVE(3) %s %.*s\n",
472 SVCFH_fmt(&argp->fh),
476 /* Unlink. -S_IFDIR means file must not be a directory */
477 fh_copy(&resp->fh, &argp->fh);
478 resp->status = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR,
479 argp->name, argp->len);
480 fh_unlock(&resp->fh);
488 nfsd3_proc_rmdir(struct svc_rqst *rqstp)
490 struct nfsd3_diropargs *argp = rqstp->rq_argp;
491 struct nfsd3_attrstat *resp = rqstp->rq_resp;
493 dprintk("nfsd: RMDIR(3) %s %.*s\n",
494 SVCFH_fmt(&argp->fh),
498 fh_copy(&resp->fh, &argp->fh);
499 resp->status = nfsd_unlink(rqstp, &resp->fh, S_IFDIR,
500 argp->name, argp->len);
501 fh_unlock(&resp->fh);
506 nfsd3_proc_rename(struct svc_rqst *rqstp)
508 struct nfsd3_renameargs *argp = rqstp->rq_argp;
509 struct nfsd3_renameres *resp = rqstp->rq_resp;
511 dprintk("nfsd: RENAME(3) %s %.*s ->\n",
512 SVCFH_fmt(&argp->ffh),
515 dprintk("nfsd: -> %s %.*s\n",
516 SVCFH_fmt(&argp->tfh),
520 fh_copy(&resp->ffh, &argp->ffh);
521 fh_copy(&resp->tfh, &argp->tfh);
522 resp->status = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen,
523 &resp->tfh, argp->tname, argp->tlen);
528 nfsd3_proc_link(struct svc_rqst *rqstp)
530 struct nfsd3_linkargs *argp = rqstp->rq_argp;
531 struct nfsd3_linkres *resp = rqstp->rq_resp;
533 dprintk("nfsd: LINK(3) %s ->\n",
534 SVCFH_fmt(&argp->ffh));
535 dprintk("nfsd: -> %s %.*s\n",
536 SVCFH_fmt(&argp->tfh),
540 fh_copy(&resp->fh, &argp->ffh);
541 fh_copy(&resp->tfh, &argp->tfh);
542 resp->status = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen,
547 static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp,
548 struct nfsd3_readdirres *resp,
551 struct xdr_buf *buf = &resp->dirlist;
552 struct xdr_stream *xdr = &resp->xdr;
554 count = clamp(count, (u32)(XDR_UNIT * 2), svc_max_payload(rqstp));
556 memset(buf, 0, sizeof(*buf));
558 /* Reserve room for the NULL ptr & eof flag (-2 words) */
559 buf->buflen = count - XDR_UNIT * 2;
560 buf->pages = rqstp->rq_next_page;
561 rqstp->rq_next_page += (buf->buflen + PAGE_SIZE - 1) >> PAGE_SHIFT;
563 /* This is xdr_init_encode(), but it assumes that
564 * the head kvec has already been consumed. */
565 xdr_set_scratch_buffer(xdr, NULL, 0);
567 xdr->page_ptr = buf->pages;
569 xdr->p = page_address(*buf->pages);
570 xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE);
575 * Read a portion of a directory.
578 nfsd3_proc_readdir(struct svc_rqst *rqstp)
580 struct nfsd3_readdirargs *argp = rqstp->rq_argp;
581 struct nfsd3_readdirres *resp = rqstp->rq_resp;
584 dprintk("nfsd: READDIR(3) %s %d bytes at %d\n",
585 SVCFH_fmt(&argp->fh),
586 argp->count, (u32) argp->cookie);
588 nfsd3_init_dirlist_pages(rqstp, resp, argp->count);
590 fh_copy(&resp->fh, &argp->fh);
591 resp->common.err = nfs_ok;
592 resp->cookie_offset = 0;
594 offset = argp->cookie;
595 resp->status = nfsd_readdir(rqstp, &resp->fh, &offset,
596 &resp->common, nfs3svc_encode_entry3);
597 memcpy(resp->verf, argp->verf, 8);
598 nfs3svc_encode_cookie3(resp, offset);
600 /* Recycle only pages that were part of the reply */
601 rqstp->rq_next_page = resp->xdr.page_ptr + 1;
607 * Read a portion of a directory, including file handles and attrs.
608 * For now, we choose to ignore the dircount parameter.
611 nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
613 struct nfsd3_readdirargs *argp = rqstp->rq_argp;
614 struct nfsd3_readdirres *resp = rqstp->rq_resp;
617 dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",
618 SVCFH_fmt(&argp->fh),
619 argp->count, (u32) argp->cookie);
621 nfsd3_init_dirlist_pages(rqstp, resp, argp->count);
623 fh_copy(&resp->fh, &argp->fh);
624 resp->common.err = nfs_ok;
625 resp->cookie_offset = 0;
627 offset = argp->cookie;
629 resp->status = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP);
630 if (resp->status != nfs_ok)
633 if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS) {
634 resp->status = nfserr_notsupp;
638 resp->status = nfsd_readdir(rqstp, &resp->fh, &offset,
639 &resp->common, nfs3svc_encode_entryplus3);
640 memcpy(resp->verf, argp->verf, 8);
641 nfs3svc_encode_cookie3(resp, offset);
643 /* Recycle only pages that were part of the reply */
644 rqstp->rq_next_page = resp->xdr.page_ptr + 1;
651 * Get file system stats
654 nfsd3_proc_fsstat(struct svc_rqst *rqstp)
656 struct nfsd_fhandle *argp = rqstp->rq_argp;
657 struct nfsd3_fsstatres *resp = rqstp->rq_resp;
659 dprintk("nfsd: FSSTAT(3) %s\n",
660 SVCFH_fmt(&argp->fh));
662 resp->status = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0);
668 * Get file system info
671 nfsd3_proc_fsinfo(struct svc_rqst *rqstp)
673 struct nfsd_fhandle *argp = rqstp->rq_argp;
674 struct nfsd3_fsinfores *resp = rqstp->rq_resp;
675 u32 max_blocksize = svc_max_payload(rqstp);
677 dprintk("nfsd: FSINFO(3) %s\n",
678 SVCFH_fmt(&argp->fh));
680 resp->f_rtmax = max_blocksize;
681 resp->f_rtpref = max_blocksize;
682 resp->f_rtmult = PAGE_SIZE;
683 resp->f_wtmax = max_blocksize;
684 resp->f_wtpref = max_blocksize;
685 resp->f_wtmult = PAGE_SIZE;
686 resp->f_dtpref = max_blocksize;
687 resp->f_maxfilesize = ~(u32) 0;
688 resp->f_properties = NFS3_FSF_DEFAULT;
690 resp->status = fh_verify(rqstp, &argp->fh, 0,
691 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
693 /* Check special features of the file system. May request
694 * different read/write sizes for file systems known to have
695 * problems with large blocks */
696 if (resp->status == nfs_ok) {
697 struct super_block *sb = argp->fh.fh_dentry->d_sb;
699 /* Note that we don't care for remote fs's here */
700 if (sb->s_magic == MSDOS_SUPER_MAGIC) {
701 resp->f_properties = NFS3_FSF_BILLYBOY;
703 resp->f_maxfilesize = sb->s_maxbytes;
711 * Get pathconf info for the specified file
714 nfsd3_proc_pathconf(struct svc_rqst *rqstp)
716 struct nfsd_fhandle *argp = rqstp->rq_argp;
717 struct nfsd3_pathconfres *resp = rqstp->rq_resp;
719 dprintk("nfsd: PATHCONF(3) %s\n",
720 SVCFH_fmt(&argp->fh));
722 /* Set default pathconf */
723 resp->p_link_max = 255; /* at least */
724 resp->p_name_max = 255; /* at least */
725 resp->p_no_trunc = 0;
726 resp->p_chown_restricted = 1;
727 resp->p_case_insensitive = 0;
728 resp->p_case_preserving = 1;
730 resp->status = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP);
732 if (resp->status == nfs_ok) {
733 struct super_block *sb = argp->fh.fh_dentry->d_sb;
735 /* Note that we don't care for remote fs's here */
736 switch (sb->s_magic) {
737 case EXT2_SUPER_MAGIC:
738 resp->p_link_max = EXT2_LINK_MAX;
739 resp->p_name_max = EXT2_NAME_LEN;
741 case MSDOS_SUPER_MAGIC:
742 resp->p_case_insensitive = 1;
743 resp->p_case_preserving = 0;
753 * Commit a file (range) to stable storage.
756 nfsd3_proc_commit(struct svc_rqst *rqstp)
758 struct nfsd3_commitargs *argp = rqstp->rq_argp;
759 struct nfsd3_commitres *resp = rqstp->rq_resp;
761 dprintk("nfsd: COMMIT(3) %s %u@%Lu\n",
762 SVCFH_fmt(&argp->fh),
764 (unsigned long long) argp->offset);
766 fh_copy(&resp->fh, &argp->fh);
767 resp->status = nfsd_commit(rqstp, &resp->fh, argp->offset,
768 argp->count, resp->verf);
774 * NFSv3 Server procedures.
775 * Only the results of non-idempotent operations are cached.
777 #define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat
778 #define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat
779 #define nfsd3_mkdirargs nfsd3_createargs
780 #define nfsd3_readdirplusargs nfsd3_readdirargs
781 #define nfsd3_fhandleargs nfsd_fhandle
782 #define nfsd3_attrstatres nfsd3_attrstat
783 #define nfsd3_wccstatres nfsd3_attrstat
784 #define nfsd3_createres nfsd3_diropres
786 #define ST 1 /* status*/
787 #define FH 17 /* filehandle with length */
788 #define AT 21 /* attributes */
789 #define pAT (1+AT) /* post attributes - conditional */
790 #define WC (7+pAT) /* WCC attributes */
792 static const struct svc_procedure nfsd_procedures3[22] = {
794 .pc_func = nfsd3_proc_null,
795 .pc_decode = nfssvc_decode_voidarg,
796 .pc_encode = nfssvc_encode_voidres,
797 .pc_argsize = sizeof(struct nfsd_voidargs),
798 .pc_ressize = sizeof(struct nfsd_voidres),
799 .pc_cachetype = RC_NOCACHE,
803 [NFS3PROC_GETATTR] = {
804 .pc_func = nfsd3_proc_getattr,
805 .pc_decode = nfs3svc_decode_fhandleargs,
806 .pc_encode = nfs3svc_encode_getattrres,
807 .pc_release = nfs3svc_release_fhandle,
808 .pc_argsize = sizeof(struct nfsd_fhandle),
809 .pc_ressize = sizeof(struct nfsd3_attrstatres),
810 .pc_cachetype = RC_NOCACHE,
811 .pc_xdrressize = ST+AT,
812 .pc_name = "GETATTR",
814 [NFS3PROC_SETATTR] = {
815 .pc_func = nfsd3_proc_setattr,
816 .pc_decode = nfs3svc_decode_sattrargs,
817 .pc_encode = nfs3svc_encode_wccstatres,
818 .pc_release = nfs3svc_release_fhandle,
819 .pc_argsize = sizeof(struct nfsd3_sattrargs),
820 .pc_ressize = sizeof(struct nfsd3_wccstatres),
821 .pc_cachetype = RC_REPLBUFF,
822 .pc_xdrressize = ST+WC,
823 .pc_name = "SETATTR",
825 [NFS3PROC_LOOKUP] = {
826 .pc_func = nfsd3_proc_lookup,
827 .pc_decode = nfs3svc_decode_diropargs,
828 .pc_encode = nfs3svc_encode_lookupres,
829 .pc_release = nfs3svc_release_fhandle2,
830 .pc_argsize = sizeof(struct nfsd3_diropargs),
831 .pc_ressize = sizeof(struct nfsd3_diropres),
832 .pc_cachetype = RC_NOCACHE,
833 .pc_xdrressize = ST+FH+pAT+pAT,
836 [NFS3PROC_ACCESS] = {
837 .pc_func = nfsd3_proc_access,
838 .pc_decode = nfs3svc_decode_accessargs,
839 .pc_encode = nfs3svc_encode_accessres,
840 .pc_release = nfs3svc_release_fhandle,
841 .pc_argsize = sizeof(struct nfsd3_accessargs),
842 .pc_ressize = sizeof(struct nfsd3_accessres),
843 .pc_cachetype = RC_NOCACHE,
844 .pc_xdrressize = ST+pAT+1,
847 [NFS3PROC_READLINK] = {
848 .pc_func = nfsd3_proc_readlink,
849 .pc_decode = nfs3svc_decode_fhandleargs,
850 .pc_encode = nfs3svc_encode_readlinkres,
851 .pc_release = nfs3svc_release_fhandle,
852 .pc_argsize = sizeof(struct nfsd_fhandle),
853 .pc_ressize = sizeof(struct nfsd3_readlinkres),
854 .pc_cachetype = RC_NOCACHE,
855 .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4,
856 .pc_name = "READLINK",
859 .pc_func = nfsd3_proc_read,
860 .pc_decode = nfs3svc_decode_readargs,
861 .pc_encode = nfs3svc_encode_readres,
862 .pc_release = nfs3svc_release_fhandle,
863 .pc_argsize = sizeof(struct nfsd3_readargs),
864 .pc_ressize = sizeof(struct nfsd3_readres),
865 .pc_cachetype = RC_NOCACHE,
866 .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4,
870 .pc_func = nfsd3_proc_write,
871 .pc_decode = nfs3svc_decode_writeargs,
872 .pc_encode = nfs3svc_encode_writeres,
873 .pc_release = nfs3svc_release_fhandle,
874 .pc_argsize = sizeof(struct nfsd3_writeargs),
875 .pc_ressize = sizeof(struct nfsd3_writeres),
876 .pc_cachetype = RC_REPLBUFF,
877 .pc_xdrressize = ST+WC+4,
880 [NFS3PROC_CREATE] = {
881 .pc_func = nfsd3_proc_create,
882 .pc_decode = nfs3svc_decode_createargs,
883 .pc_encode = nfs3svc_encode_createres,
884 .pc_release = nfs3svc_release_fhandle2,
885 .pc_argsize = sizeof(struct nfsd3_createargs),
886 .pc_ressize = sizeof(struct nfsd3_createres),
887 .pc_cachetype = RC_REPLBUFF,
888 .pc_xdrressize = ST+(1+FH+pAT)+WC,
892 .pc_func = nfsd3_proc_mkdir,
893 .pc_decode = nfs3svc_decode_mkdirargs,
894 .pc_encode = nfs3svc_encode_createres,
895 .pc_release = nfs3svc_release_fhandle2,
896 .pc_argsize = sizeof(struct nfsd3_mkdirargs),
897 .pc_ressize = sizeof(struct nfsd3_createres),
898 .pc_cachetype = RC_REPLBUFF,
899 .pc_xdrressize = ST+(1+FH+pAT)+WC,
902 [NFS3PROC_SYMLINK] = {
903 .pc_func = nfsd3_proc_symlink,
904 .pc_decode = nfs3svc_decode_symlinkargs,
905 .pc_encode = nfs3svc_encode_createres,
906 .pc_release = nfs3svc_release_fhandle2,
907 .pc_argsize = sizeof(struct nfsd3_symlinkargs),
908 .pc_ressize = sizeof(struct nfsd3_createres),
909 .pc_cachetype = RC_REPLBUFF,
910 .pc_xdrressize = ST+(1+FH+pAT)+WC,
911 .pc_name = "SYMLINK",
914 .pc_func = nfsd3_proc_mknod,
915 .pc_decode = nfs3svc_decode_mknodargs,
916 .pc_encode = nfs3svc_encode_createres,
917 .pc_release = nfs3svc_release_fhandle2,
918 .pc_argsize = sizeof(struct nfsd3_mknodargs),
919 .pc_ressize = sizeof(struct nfsd3_createres),
920 .pc_cachetype = RC_REPLBUFF,
921 .pc_xdrressize = ST+(1+FH+pAT)+WC,
924 [NFS3PROC_REMOVE] = {
925 .pc_func = nfsd3_proc_remove,
926 .pc_decode = nfs3svc_decode_diropargs,
927 .pc_encode = nfs3svc_encode_wccstatres,
928 .pc_release = nfs3svc_release_fhandle,
929 .pc_argsize = sizeof(struct nfsd3_diropargs),
930 .pc_ressize = sizeof(struct nfsd3_wccstatres),
931 .pc_cachetype = RC_REPLBUFF,
932 .pc_xdrressize = ST+WC,
936 .pc_func = nfsd3_proc_rmdir,
937 .pc_decode = nfs3svc_decode_diropargs,
938 .pc_encode = nfs3svc_encode_wccstatres,
939 .pc_release = nfs3svc_release_fhandle,
940 .pc_argsize = sizeof(struct nfsd3_diropargs),
941 .pc_ressize = sizeof(struct nfsd3_wccstatres),
942 .pc_cachetype = RC_REPLBUFF,
943 .pc_xdrressize = ST+WC,
946 [NFS3PROC_RENAME] = {
947 .pc_func = nfsd3_proc_rename,
948 .pc_decode = nfs3svc_decode_renameargs,
949 .pc_encode = nfs3svc_encode_renameres,
950 .pc_release = nfs3svc_release_fhandle2,
951 .pc_argsize = sizeof(struct nfsd3_renameargs),
952 .pc_ressize = sizeof(struct nfsd3_renameres),
953 .pc_cachetype = RC_REPLBUFF,
954 .pc_xdrressize = ST+WC+WC,
958 .pc_func = nfsd3_proc_link,
959 .pc_decode = nfs3svc_decode_linkargs,
960 .pc_encode = nfs3svc_encode_linkres,
961 .pc_release = nfs3svc_release_fhandle2,
962 .pc_argsize = sizeof(struct nfsd3_linkargs),
963 .pc_ressize = sizeof(struct nfsd3_linkres),
964 .pc_cachetype = RC_REPLBUFF,
965 .pc_xdrressize = ST+pAT+WC,
968 [NFS3PROC_READDIR] = {
969 .pc_func = nfsd3_proc_readdir,
970 .pc_decode = nfs3svc_decode_readdirargs,
971 .pc_encode = nfs3svc_encode_readdirres,
972 .pc_release = nfs3svc_release_fhandle,
973 .pc_argsize = sizeof(struct nfsd3_readdirargs),
974 .pc_ressize = sizeof(struct nfsd3_readdirres),
975 .pc_cachetype = RC_NOCACHE,
976 .pc_name = "READDIR",
978 [NFS3PROC_READDIRPLUS] = {
979 .pc_func = nfsd3_proc_readdirplus,
980 .pc_decode = nfs3svc_decode_readdirplusargs,
981 .pc_encode = nfs3svc_encode_readdirres,
982 .pc_release = nfs3svc_release_fhandle,
983 .pc_argsize = sizeof(struct nfsd3_readdirplusargs),
984 .pc_ressize = sizeof(struct nfsd3_readdirres),
985 .pc_cachetype = RC_NOCACHE,
986 .pc_name = "READDIRPLUS",
988 [NFS3PROC_FSSTAT] = {
989 .pc_func = nfsd3_proc_fsstat,
990 .pc_decode = nfs3svc_decode_fhandleargs,
991 .pc_encode = nfs3svc_encode_fsstatres,
992 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
993 .pc_ressize = sizeof(struct nfsd3_fsstatres),
994 .pc_cachetype = RC_NOCACHE,
995 .pc_xdrressize = ST+pAT+2*6+1,
998 [NFS3PROC_FSINFO] = {
999 .pc_func = nfsd3_proc_fsinfo,
1000 .pc_decode = nfs3svc_decode_fhandleargs,
1001 .pc_encode = nfs3svc_encode_fsinfores,
1002 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
1003 .pc_ressize = sizeof(struct nfsd3_fsinfores),
1004 .pc_cachetype = RC_NOCACHE,
1005 .pc_xdrressize = ST+pAT+12,
1006 .pc_name = "FSINFO",
1008 [NFS3PROC_PATHCONF] = {
1009 .pc_func = nfsd3_proc_pathconf,
1010 .pc_decode = nfs3svc_decode_fhandleargs,
1011 .pc_encode = nfs3svc_encode_pathconfres,
1012 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
1013 .pc_ressize = sizeof(struct nfsd3_pathconfres),
1014 .pc_cachetype = RC_NOCACHE,
1015 .pc_xdrressize = ST+pAT+6,
1016 .pc_name = "PATHCONF",
1018 [NFS3PROC_COMMIT] = {
1019 .pc_func = nfsd3_proc_commit,
1020 .pc_decode = nfs3svc_decode_commitargs,
1021 .pc_encode = nfs3svc_encode_commitres,
1022 .pc_release = nfs3svc_release_fhandle,
1023 .pc_argsize = sizeof(struct nfsd3_commitargs),
1024 .pc_ressize = sizeof(struct nfsd3_commitres),
1025 .pc_cachetype = RC_NOCACHE,
1026 .pc_xdrressize = ST+WC+2,
1027 .pc_name = "COMMIT",
1031 static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)];
1032 const struct svc_version nfsd_version3 = {
1035 .vs_proc = nfsd_procedures3,
1036 .vs_dispatch = nfsd_dispatch,
1037 .vs_count = nfsd_count3,
1038 .vs_xdrsize = NFS3_SVC_XDRSIZE,