1 // SPDX-License-Identifier: GPL-2.0
3 * Process version 2 NFS requests.
8 #include <linux/namei.h>
14 #define NFSDDBG_FACILITY NFSDDBG_PROC
17 nfsd_proc_null(struct svc_rqst *rqstp)
23 * Get a file's attributes
24 * N.B. After this call resp->fh needs an fh_put
27 nfsd_proc_getattr(struct svc_rqst *rqstp)
29 struct nfsd_fhandle *argp = rqstp->rq_argp;
30 struct nfsd_attrstat *resp = rqstp->rq_resp;
32 dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh));
34 fh_copy(&resp->fh, &argp->fh);
35 resp->status = fh_verify(rqstp, &resp->fh, 0,
36 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
37 if (resp->status != nfs_ok)
39 resp->status = fh_getattr(&resp->fh, &resp->stat);
45 * Set a file's attributes
46 * N.B. After this call resp->fh needs an fh_put
49 nfsd_proc_setattr(struct svc_rqst *rqstp)
51 struct nfsd_sattrargs *argp = rqstp->rq_argp;
52 struct nfsd_attrstat *resp = rqstp->rq_resp;
53 struct iattr *iap = &argp->attrs;
56 dprintk("nfsd: SETATTR %s, valid=%x, size=%ld\n",
58 argp->attrs.ia_valid, (long) argp->attrs.ia_size);
60 fhp = fh_copy(&resp->fh, &argp->fh);
63 * NFSv2 does not differentiate between "set-[ac]time-to-now"
64 * which only requires access, and "set-[ac]time-to-X" which
66 * So if it looks like it might be "set both to the same time which
67 * is close to now", and if setattr_prepare fails, then we
68 * convert to "set to now" instead of "set to explicit time"
70 * We only call setattr_prepare as the last test as technically
71 * it is not an interface that we should be using.
73 #define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET)
74 #define MAX_TOUCH_TIME_ERROR (30*60)
75 if ((iap->ia_valid & BOTH_TIME_SET) == BOTH_TIME_SET &&
76 iap->ia_mtime.tv_sec == iap->ia_atime.tv_sec) {
80 * Now just make sure time is in the right ballpark.
81 * Solaris, at least, doesn't seem to care what the time
82 * request is. We require it be within 30 minutes of now.
84 time64_t delta = iap->ia_atime.tv_sec - ktime_get_real_seconds();
86 resp->status = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP);
87 if (resp->status != nfs_ok)
92 if (delta < MAX_TOUCH_TIME_ERROR &&
93 setattr_prepare(&init_user_ns, fhp->fh_dentry, iap) != 0) {
95 * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME.
96 * This will cause notify_change to set these times
99 iap->ia_valid &= ~BOTH_TIME_SET;
103 resp->status = nfsd_setattr(rqstp, fhp, iap, 0, (time64_t)0);
104 if (resp->status != nfs_ok)
107 resp->status = fh_getattr(&resp->fh, &resp->stat);
112 /* Obsolete, replaced by MNTPROC_MNT. */
114 nfsd_proc_root(struct svc_rqst *rqstp)
120 * Look up a path name component
121 * Note: the dentry in the resp->fh may be negative if the file
123 * N.B. After this call resp->fh needs an fh_put
126 nfsd_proc_lookup(struct svc_rqst *rqstp)
128 struct nfsd_diropargs *argp = rqstp->rq_argp;
129 struct nfsd_diropres *resp = rqstp->rq_resp;
131 dprintk("nfsd: LOOKUP %s %.*s\n",
132 SVCFH_fmt(&argp->fh), argp->len, argp->name);
134 fh_init(&resp->fh, NFS_FHSIZE);
135 resp->status = nfsd_lookup(rqstp, &argp->fh, argp->name, argp->len,
138 if (resp->status != nfs_ok)
141 resp->status = fh_getattr(&resp->fh, &resp->stat);
150 nfsd_proc_readlink(struct svc_rqst *rqstp)
152 struct nfsd_fhandle *argp = rqstp->rq_argp;
153 struct nfsd_readlinkres *resp = rqstp->rq_resp;
154 char *buffer = page_address(*(rqstp->rq_next_page++));
156 dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp->fh));
158 /* Read the symlink. */
159 resp->len = NFS_MAXPATHLEN;
160 resp->status = nfsd_readlink(rqstp, &argp->fh, buffer, &resp->len);
167 * Read a portion of a file.
168 * N.B. After this call resp->fh needs an fh_put
171 nfsd_proc_read(struct svc_rqst *rqstp)
173 struct nfsd_readargs *argp = rqstp->rq_argp;
174 struct nfsd_readres *resp = rqstp->rq_resp;
179 dprintk("nfsd: READ %s %d bytes at %d\n",
180 SVCFH_fmt(&argp->fh),
181 argp->count, argp->offset);
183 argp->count = min_t(u32, argp->count, NFSSVC_MAXBLKSIZE_V2);
188 struct page *page = *(rqstp->rq_next_page++);
190 rqstp->rq_vec[v].iov_base = page_address(page);
191 rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE);
192 len -= rqstp->rq_vec[v].iov_len;
196 /* Obtain buffer pointer for payload. 19 is 1 word for
197 * status, 17 words for fattr, and 1 word for the byte count.
199 svc_reserve_auth(rqstp, (19<<2) + argp->count + 4);
201 resp->count = argp->count;
202 fh_copy(&resp->fh, &argp->fh);
203 resp->status = nfsd_read(rqstp, &resp->fh, argp->offset,
204 rqstp->rq_vec, v, &resp->count, &eof);
205 if (resp->status == nfs_ok)
206 resp->status = fh_getattr(&resp->fh, &resp->stat);
207 else if (resp->status == nfserr_jukebox)
208 return rpc_drop_reply;
214 nfsd_proc_writecache(struct svc_rqst *rqstp)
220 * Write data to a file
221 * N.B. After this call resp->fh needs an fh_put
224 nfsd_proc_write(struct svc_rqst *rqstp)
226 struct nfsd_writeargs *argp = rqstp->rq_argp;
227 struct nfsd_attrstat *resp = rqstp->rq_resp;
228 unsigned long cnt = argp->len;
231 dprintk("nfsd: WRITE %s %d bytes at %d\n",
232 SVCFH_fmt(&argp->fh),
233 argp->len, argp->offset);
235 nvecs = svc_fill_write_vector(rqstp, rqstp->rq_arg.pages,
238 resp->status = nfserr_io;
242 resp->status = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh),
243 argp->offset, rqstp->rq_vec, nvecs,
244 &cnt, NFS_DATA_SYNC, NULL);
245 if (resp->status == nfs_ok)
246 resp->status = fh_getattr(&resp->fh, &resp->stat);
247 else if (resp->status == nfserr_jukebox)
248 return rpc_drop_reply;
254 * CREATE processing is complicated. The keyword here is `overloaded.'
255 * The parent directory is kept locked between the check for existence
256 * and the actual create() call in compliance with VFS protocols.
257 * N.B. After this call _both_ argp->fh and resp->fh need an fh_put
260 nfsd_proc_create(struct svc_rqst *rqstp)
262 struct nfsd_createargs *argp = rqstp->rq_argp;
263 struct nfsd_diropres *resp = rqstp->rq_resp;
264 svc_fh *dirfhp = &argp->fh;
265 svc_fh *newfhp = &resp->fh;
266 struct iattr *attr = &argp->attrs;
268 struct dentry *dchild;
271 dev_t rdev = 0, wanted = new_decode_dev(attr->ia_size);
273 dprintk("nfsd: CREATE %s %.*s\n",
274 SVCFH_fmt(dirfhp), argp->len, argp->name);
276 /* First verify the parent file handle */
277 resp->status = fh_verify(rqstp, dirfhp, S_IFDIR, NFSD_MAY_EXEC);
278 if (resp->status != nfs_ok)
279 goto done; /* must fh_put dirfhp even on error */
281 /* Check for NFSD_MAY_WRITE in nfsd_create if necessary */
283 resp->status = nfserr_exist;
284 if (isdotent(argp->name, argp->len))
286 hosterr = fh_want_write(dirfhp);
288 resp->status = nfserrno(hosterr);
292 fh_lock_nested(dirfhp, I_MUTEX_PARENT);
293 dchild = lookup_one_len(argp->name, dirfhp->fh_dentry, argp->len);
294 if (IS_ERR(dchild)) {
295 resp->status = nfserrno(PTR_ERR(dchild));
298 fh_init(newfhp, NFS_FHSIZE);
299 resp->status = fh_compose(newfhp, dirfhp->fh_export, dchild, dirfhp);
300 if (!resp->status && d_really_is_negative(dchild))
301 resp->status = nfserr_noent;
304 if (resp->status != nfserr_noent)
307 * If the new file handle wasn't verified, we can't tell
308 * whether the file exists or not. Time to bail ...
310 resp->status = nfserr_acces;
311 if (!newfhp->fh_dentry) {
313 "nfsd_proc_create: file handle not verified\n");
318 inode = d_inode(newfhp->fh_dentry);
320 /* Unfudge the mode bits */
321 if (attr->ia_valid & ATTR_MODE) {
322 type = attr->ia_mode & S_IFMT;
323 mode = attr->ia_mode & ~S_IFMT;
325 /* no type, so if target exists, assume same as that,
326 * else assume a file */
328 type = inode->i_mode & S_IFMT;
332 /* reserve rdev for later checking */
333 rdev = inode->i_rdev;
334 attr->ia_valid |= ATTR_SIZE;
338 /* this is probably a permission check..
339 * at least IRIX implements perm checking on
340 * echo thing > device-special-file-or-pipe
341 * by doing a CREATE with type==0
343 resp->status = nfsd_permission(rqstp,
346 NFSD_MAY_WRITE|NFSD_MAY_LOCAL_ACCESS);
347 if (resp->status && resp->status != nfserr_rofs)
354 type = inode->i_mode & S_IFMT;
355 mode = inode->i_mode & ~S_IFMT;
361 attr->ia_valid |= ATTR_MODE;
362 attr->ia_mode = mode;
364 /* Special treatment for non-regular files according to the
365 * gospel of sun micro
367 if (type != S_IFREG) {
368 if (type != S_IFBLK && type != S_IFCHR) {
370 } else if (type == S_IFCHR && !(attr->ia_valid & ATTR_SIZE)) {
371 /* If you think you've seen the worst, grok this. */
374 /* Okay, char or block special */
379 /* we've used the SIZE information, so discard it */
380 attr->ia_valid &= ~ATTR_SIZE;
382 /* Make sure the type and device matches */
383 resp->status = nfserr_exist;
384 if (inode && type != (inode->i_mode & S_IFMT))
388 resp->status = nfs_ok;
390 /* File doesn't exist. Create it and set attrs */
391 resp->status = nfsd_create_locked(rqstp, dirfhp, argp->name,
392 argp->len, attr, type, rdev,
394 } else if (type == S_IFREG) {
395 dprintk("nfsd: existing %s, valid=%x, size=%ld\n",
396 argp->name, attr->ia_valid, (long) attr->ia_size);
397 /* File already exists. We ignore all attributes except
398 * size, so that creat() behaves exactly like
399 * open(..., O_CREAT|O_TRUNC|O_WRONLY).
401 attr->ia_valid &= ATTR_SIZE;
403 resp->status = nfsd_setattr(rqstp, newfhp, attr, 0,
408 /* We don't really need to unlock, as fh_put does it. */
410 fh_drop_write(dirfhp);
413 if (resp->status != nfs_ok)
415 resp->status = fh_getattr(&resp->fh, &resp->stat);
421 nfsd_proc_remove(struct svc_rqst *rqstp)
423 struct nfsd_diropargs *argp = rqstp->rq_argp;
424 struct nfsd_stat *resp = rqstp->rq_resp;
426 dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp->fh),
427 argp->len, argp->name);
429 /* Unlink. -SIFDIR means file must not be a directory */
430 resp->status = nfsd_unlink(rqstp, &argp->fh, -S_IFDIR,
431 argp->name, argp->len);
437 nfsd_proc_rename(struct svc_rqst *rqstp)
439 struct nfsd_renameargs *argp = rqstp->rq_argp;
440 struct nfsd_stat *resp = rqstp->rq_resp;
442 dprintk("nfsd: RENAME %s %.*s -> \n",
443 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname);
444 dprintk("nfsd: -> %s %.*s\n",
445 SVCFH_fmt(&argp->tfh), argp->tlen, argp->tname);
447 resp->status = nfsd_rename(rqstp, &argp->ffh, argp->fname, argp->flen,
448 &argp->tfh, argp->tname, argp->tlen);
455 nfsd_proc_link(struct svc_rqst *rqstp)
457 struct nfsd_linkargs *argp = rqstp->rq_argp;
458 struct nfsd_stat *resp = rqstp->rq_resp;
460 dprintk("nfsd: LINK %s ->\n",
461 SVCFH_fmt(&argp->ffh));
462 dprintk("nfsd: %s %.*s\n",
463 SVCFH_fmt(&argp->tfh),
467 resp->status = nfsd_link(rqstp, &argp->tfh, argp->tname, argp->tlen,
475 nfsd_proc_symlink(struct svc_rqst *rqstp)
477 struct nfsd_symlinkargs *argp = rqstp->rq_argp;
478 struct nfsd_stat *resp = rqstp->rq_resp;
481 if (argp->tlen > NFS_MAXPATHLEN) {
482 resp->status = nfserr_nametoolong;
486 argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first,
487 page_address(rqstp->rq_arg.pages[0]),
489 if (IS_ERR(argp->tname)) {
490 resp->status = nfserrno(PTR_ERR(argp->tname));
494 dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n",
495 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname,
496 argp->tlen, argp->tname);
498 fh_init(&newfh, NFS_FHSIZE);
499 resp->status = nfsd_symlink(rqstp, &argp->ffh, argp->fname, argp->flen,
500 argp->tname, &newfh);
510 * Make directory. This operation is not idempotent.
511 * N.B. After this call resp->fh needs an fh_put
514 nfsd_proc_mkdir(struct svc_rqst *rqstp)
516 struct nfsd_createargs *argp = rqstp->rq_argp;
517 struct nfsd_diropres *resp = rqstp->rq_resp;
519 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
521 if (resp->fh.fh_dentry) {
523 "nfsd_proc_mkdir: response already verified??\n");
526 argp->attrs.ia_valid &= ~ATTR_SIZE;
527 fh_init(&resp->fh, NFS_FHSIZE);
528 resp->status = nfsd_create(rqstp, &argp->fh, argp->name, argp->len,
529 &argp->attrs, S_IFDIR, 0, &resp->fh);
531 if (resp->status != nfs_ok)
534 resp->status = fh_getattr(&resp->fh, &resp->stat);
543 nfsd_proc_rmdir(struct svc_rqst *rqstp)
545 struct nfsd_diropargs *argp = rqstp->rq_argp;
546 struct nfsd_stat *resp = rqstp->rq_resp;
548 dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
550 resp->status = nfsd_unlink(rqstp, &argp->fh, S_IFDIR,
551 argp->name, argp->len);
556 static void nfsd_init_dirlist_pages(struct svc_rqst *rqstp,
557 struct nfsd_readdirres *resp,
560 count = min_t(u32, count, PAGE_SIZE);
562 /* Convert byte count to number of words (i.e. >> 2),
563 * and reserve room for the NULL ptr & eof flag (-2 words) */
564 resp->buflen = (count >> 2) - 2;
566 resp->buffer = page_address(*rqstp->rq_next_page);
567 rqstp->rq_next_page++;
571 * Read a portion of a directory.
574 nfsd_proc_readdir(struct svc_rqst *rqstp)
576 struct nfsd_readdirargs *argp = rqstp->rq_argp;
577 struct nfsd_readdirres *resp = rqstp->rq_resp;
581 dprintk("nfsd: READDIR %s %d bytes at %d\n",
582 SVCFH_fmt(&argp->fh),
583 argp->count, argp->cookie);
585 nfsd_init_dirlist_pages(rqstp, resp, argp->count);
586 buffer = resp->buffer;
589 resp->common.err = nfs_ok;
590 /* Read directory and encode entries on the fly */
591 offset = argp->cookie;
592 resp->status = nfsd_readdir(rqstp, &argp->fh, &offset,
593 &resp->common, nfssvc_encode_entry);
595 resp->count = resp->buffer - buffer;
597 *resp->offset = htonl(offset);
604 * Get file system info
607 nfsd_proc_statfs(struct svc_rqst *rqstp)
609 struct nfsd_fhandle *argp = rqstp->rq_argp;
610 struct nfsd_statfsres *resp = rqstp->rq_resp;
612 dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp->fh));
614 resp->status = nfsd_statfs(rqstp, &argp->fh, &resp->stats,
615 NFSD_MAY_BYPASS_GSS_ON_ROOT);
621 * NFSv2 Server procedures.
622 * Only the results of non-idempotent operations are cached.
625 #define ST 1 /* status */
626 #define FH 8 /* filehandle */
627 #define AT 18 /* attributes */
629 static const struct svc_procedure nfsd_procedures2[18] = {
631 .pc_func = nfsd_proc_null,
632 .pc_decode = nfssvc_decode_voidarg,
633 .pc_encode = nfssvc_encode_voidres,
634 .pc_argsize = sizeof(struct nfsd_voidargs),
635 .pc_ressize = sizeof(struct nfsd_voidres),
636 .pc_cachetype = RC_NOCACHE,
640 [NFSPROC_GETATTR] = {
641 .pc_func = nfsd_proc_getattr,
642 .pc_decode = nfssvc_decode_fhandleargs,
643 .pc_encode = nfssvc_encode_attrstat,
644 .pc_release = nfssvc_release_attrstat,
645 .pc_argsize = sizeof(struct nfsd_fhandle),
646 .pc_ressize = sizeof(struct nfsd_attrstat),
647 .pc_cachetype = RC_NOCACHE,
648 .pc_xdrressize = ST+AT,
649 .pc_name = "GETATTR",
651 [NFSPROC_SETATTR] = {
652 .pc_func = nfsd_proc_setattr,
653 .pc_decode = nfssvc_decode_sattrargs,
654 .pc_encode = nfssvc_encode_attrstat,
655 .pc_release = nfssvc_release_attrstat,
656 .pc_argsize = sizeof(struct nfsd_sattrargs),
657 .pc_ressize = sizeof(struct nfsd_attrstat),
658 .pc_cachetype = RC_REPLBUFF,
659 .pc_xdrressize = ST+AT,
660 .pc_name = "SETATTR",
663 .pc_func = nfsd_proc_root,
664 .pc_decode = nfssvc_decode_voidarg,
665 .pc_encode = nfssvc_encode_voidres,
666 .pc_argsize = sizeof(struct nfsd_voidargs),
667 .pc_ressize = sizeof(struct nfsd_voidres),
668 .pc_cachetype = RC_NOCACHE,
673 .pc_func = nfsd_proc_lookup,
674 .pc_decode = nfssvc_decode_diropargs,
675 .pc_encode = nfssvc_encode_diropres,
676 .pc_release = nfssvc_release_diropres,
677 .pc_argsize = sizeof(struct nfsd_diropargs),
678 .pc_ressize = sizeof(struct nfsd_diropres),
679 .pc_cachetype = RC_NOCACHE,
680 .pc_xdrressize = ST+FH+AT,
683 [NFSPROC_READLINK] = {
684 .pc_func = nfsd_proc_readlink,
685 .pc_decode = nfssvc_decode_fhandleargs,
686 .pc_encode = nfssvc_encode_readlinkres,
687 .pc_argsize = sizeof(struct nfsd_fhandle),
688 .pc_ressize = sizeof(struct nfsd_readlinkres),
689 .pc_cachetype = RC_NOCACHE,
690 .pc_xdrressize = ST+1+NFS_MAXPATHLEN/4,
691 .pc_name = "READLINK",
694 .pc_func = nfsd_proc_read,
695 .pc_decode = nfssvc_decode_readargs,
696 .pc_encode = nfssvc_encode_readres,
697 .pc_release = nfssvc_release_readres,
698 .pc_argsize = sizeof(struct nfsd_readargs),
699 .pc_ressize = sizeof(struct nfsd_readres),
700 .pc_cachetype = RC_NOCACHE,
701 .pc_xdrressize = ST+AT+1+NFSSVC_MAXBLKSIZE_V2/4,
704 [NFSPROC_WRITECACHE] = {
705 .pc_func = nfsd_proc_writecache,
706 .pc_decode = nfssvc_decode_voidarg,
707 .pc_encode = nfssvc_encode_voidres,
708 .pc_argsize = sizeof(struct nfsd_voidargs),
709 .pc_ressize = sizeof(struct nfsd_voidres),
710 .pc_cachetype = RC_NOCACHE,
712 .pc_name = "WRITECACHE",
715 .pc_func = nfsd_proc_write,
716 .pc_decode = nfssvc_decode_writeargs,
717 .pc_encode = nfssvc_encode_attrstat,
718 .pc_release = nfssvc_release_attrstat,
719 .pc_argsize = sizeof(struct nfsd_writeargs),
720 .pc_ressize = sizeof(struct nfsd_attrstat),
721 .pc_cachetype = RC_REPLBUFF,
722 .pc_xdrressize = ST+AT,
726 .pc_func = nfsd_proc_create,
727 .pc_decode = nfssvc_decode_createargs,
728 .pc_encode = nfssvc_encode_diropres,
729 .pc_release = nfssvc_release_diropres,
730 .pc_argsize = sizeof(struct nfsd_createargs),
731 .pc_ressize = sizeof(struct nfsd_diropres),
732 .pc_cachetype = RC_REPLBUFF,
733 .pc_xdrressize = ST+FH+AT,
737 .pc_func = nfsd_proc_remove,
738 .pc_decode = nfssvc_decode_diropargs,
739 .pc_encode = nfssvc_encode_stat,
740 .pc_argsize = sizeof(struct nfsd_diropargs),
741 .pc_ressize = sizeof(struct nfsd_stat),
742 .pc_cachetype = RC_REPLSTAT,
747 .pc_func = nfsd_proc_rename,
748 .pc_decode = nfssvc_decode_renameargs,
749 .pc_encode = nfssvc_encode_stat,
750 .pc_argsize = sizeof(struct nfsd_renameargs),
751 .pc_ressize = sizeof(struct nfsd_stat),
752 .pc_cachetype = RC_REPLSTAT,
757 .pc_func = nfsd_proc_link,
758 .pc_decode = nfssvc_decode_linkargs,
759 .pc_encode = nfssvc_encode_stat,
760 .pc_argsize = sizeof(struct nfsd_linkargs),
761 .pc_ressize = sizeof(struct nfsd_stat),
762 .pc_cachetype = RC_REPLSTAT,
766 [NFSPROC_SYMLINK] = {
767 .pc_func = nfsd_proc_symlink,
768 .pc_decode = nfssvc_decode_symlinkargs,
769 .pc_encode = nfssvc_encode_stat,
770 .pc_argsize = sizeof(struct nfsd_symlinkargs),
771 .pc_ressize = sizeof(struct nfsd_stat),
772 .pc_cachetype = RC_REPLSTAT,
774 .pc_name = "SYMLINK",
777 .pc_func = nfsd_proc_mkdir,
778 .pc_decode = nfssvc_decode_createargs,
779 .pc_encode = nfssvc_encode_diropres,
780 .pc_release = nfssvc_release_diropres,
781 .pc_argsize = sizeof(struct nfsd_createargs),
782 .pc_ressize = sizeof(struct nfsd_diropres),
783 .pc_cachetype = RC_REPLBUFF,
784 .pc_xdrressize = ST+FH+AT,
788 .pc_func = nfsd_proc_rmdir,
789 .pc_decode = nfssvc_decode_diropargs,
790 .pc_encode = nfssvc_encode_stat,
791 .pc_argsize = sizeof(struct nfsd_diropargs),
792 .pc_ressize = sizeof(struct nfsd_stat),
793 .pc_cachetype = RC_REPLSTAT,
797 [NFSPROC_READDIR] = {
798 .pc_func = nfsd_proc_readdir,
799 .pc_decode = nfssvc_decode_readdirargs,
800 .pc_encode = nfssvc_encode_readdirres,
801 .pc_argsize = sizeof(struct nfsd_readdirargs),
802 .pc_ressize = sizeof(struct nfsd_readdirres),
803 .pc_cachetype = RC_NOCACHE,
804 .pc_name = "READDIR",
807 .pc_func = nfsd_proc_statfs,
808 .pc_decode = nfssvc_decode_fhandleargs,
809 .pc_encode = nfssvc_encode_statfsres,
810 .pc_argsize = sizeof(struct nfsd_fhandle),
811 .pc_ressize = sizeof(struct nfsd_statfsres),
812 .pc_cachetype = RC_NOCACHE,
813 .pc_xdrressize = ST+5,
819 static unsigned int nfsd_count2[ARRAY_SIZE(nfsd_procedures2)];
820 const struct svc_version nfsd_version2 = {
823 .vs_proc = nfsd_procedures2,
824 .vs_count = nfsd_count2,
825 .vs_dispatch = nfsd_dispatch,
826 .vs_xdrsize = NFS2_SVC_XDRSIZE,
830 * Map errnos to NFS errnos.
840 { nfserr_perm, -EPERM },
841 { nfserr_noent, -ENOENT },
843 { nfserr_nxio, -ENXIO },
844 { nfserr_fbig, -E2BIG },
845 { nfserr_acces, -EACCES },
846 { nfserr_exist, -EEXIST },
847 { nfserr_xdev, -EXDEV },
848 { nfserr_mlink, -EMLINK },
849 { nfserr_nodev, -ENODEV },
850 { nfserr_notdir, -ENOTDIR },
851 { nfserr_isdir, -EISDIR },
852 { nfserr_inval, -EINVAL },
853 { nfserr_fbig, -EFBIG },
854 { nfserr_nospc, -ENOSPC },
855 { nfserr_rofs, -EROFS },
856 { nfserr_mlink, -EMLINK },
857 { nfserr_nametoolong, -ENAMETOOLONG },
858 { nfserr_notempty, -ENOTEMPTY },
860 { nfserr_dquot, -EDQUOT },
862 { nfserr_stale, -ESTALE },
863 { nfserr_jukebox, -ETIMEDOUT },
864 { nfserr_jukebox, -ERESTARTSYS },
865 { nfserr_jukebox, -EAGAIN },
866 { nfserr_jukebox, -EWOULDBLOCK },
867 { nfserr_jukebox, -ENOMEM },
868 { nfserr_io, -ETXTBSY },
869 { nfserr_notsupp, -EOPNOTSUPP },
870 { nfserr_toosmall, -ETOOSMALL },
871 { nfserr_serverfault, -ESERVERFAULT },
872 { nfserr_serverfault, -ENFILE },
873 { nfserr_io, -EUCLEAN },
874 { nfserr_perm, -ENOKEY },
878 for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) {
879 if (nfs_errtbl[i].syserr == errno)
880 return nfs_errtbl[i].nfserr;
882 WARN_ONCE(1, "nfsd: non-standard errno: %d\n", errno);