1 // SPDX-License-Identifier: GPL-2.0
3 * Process version 2 NFS requests.
5 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
8 #include <linux/namei.h>
14 typedef struct svc_rqst svc_rqst;
15 typedef struct svc_buf svc_buf;
17 #define NFSDDBG_FACILITY NFSDDBG_PROC
21 nfsd_proc_null(struct svc_rqst *rqstp)
27 nfsd_return_attrs(__be32 err, struct nfsd_attrstat *resp)
30 return fh_getattr(&resp->fh, &resp->stat);
33 nfsd_return_dirop(__be32 err, struct nfsd_diropres *resp)
36 return fh_getattr(&resp->fh, &resp->stat);
39 * Get a file's attributes
40 * N.B. After this call resp->fh needs an fh_put
43 nfsd_proc_getattr(struct svc_rqst *rqstp)
45 struct nfsd_fhandle *argp = rqstp->rq_argp;
46 struct nfsd_attrstat *resp = rqstp->rq_resp;
48 dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh));
50 fh_copy(&resp->fh, &argp->fh);
51 nfserr = fh_verify(rqstp, &resp->fh, 0,
52 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
53 return nfsd_return_attrs(nfserr, resp);
57 * Set a file's attributes
58 * N.B. After this call resp->fh needs an fh_put
61 nfsd_proc_setattr(struct svc_rqst *rqstp)
63 struct nfsd_sattrargs *argp = rqstp->rq_argp;
64 struct nfsd_attrstat *resp = rqstp->rq_resp;
65 struct iattr *iap = &argp->attrs;
69 dprintk("nfsd: SETATTR %s, valid=%x, size=%ld\n",
71 argp->attrs.ia_valid, (long) argp->attrs.ia_size);
73 fhp = fh_copy(&resp->fh, &argp->fh);
76 * NFSv2 does not differentiate between "set-[ac]time-to-now"
77 * which only requires access, and "set-[ac]time-to-X" which
79 * So if it looks like it might be "set both to the same time which
80 * is close to now", and if setattr_prepare fails, then we
81 * convert to "set to now" instead of "set to explicit time"
83 * We only call setattr_prepare as the last test as technically
84 * it is not an interface that we should be using.
86 #define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET)
87 #define MAX_TOUCH_TIME_ERROR (30*60)
88 if ((iap->ia_valid & BOTH_TIME_SET) == BOTH_TIME_SET &&
89 iap->ia_mtime.tv_sec == iap->ia_atime.tv_sec) {
93 * Now just make sure time is in the right ballpark.
94 * Solaris, at least, doesn't seem to care what the time
95 * request is. We require it be within 30 minutes of now.
97 time_t delta = iap->ia_atime.tv_sec - get_seconds();
99 nfserr = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP);
105 if (delta < MAX_TOUCH_TIME_ERROR &&
106 setattr_prepare(fhp->fh_dentry, iap) != 0) {
108 * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME.
109 * This will cause notify_change to set these times
112 iap->ia_valid &= ~BOTH_TIME_SET;
116 nfserr = nfsd_setattr(rqstp, fhp, iap, 0, (time_t)0);
118 return nfsd_return_attrs(nfserr, resp);
121 /* Obsolete, replaced by MNTPROC_MNT. */
123 nfsd_proc_root(struct svc_rqst *rqstp)
129 * Look up a path name component
130 * Note: the dentry in the resp->fh may be negative if the file
132 * N.B. After this call resp->fh needs an fh_put
135 nfsd_proc_lookup(struct svc_rqst *rqstp)
137 struct nfsd_diropargs *argp = rqstp->rq_argp;
138 struct nfsd_diropres *resp = rqstp->rq_resp;
141 dprintk("nfsd: LOOKUP %s %.*s\n",
142 SVCFH_fmt(&argp->fh), argp->len, argp->name);
144 fh_init(&resp->fh, NFS_FHSIZE);
145 nfserr = nfsd_lookup(rqstp, &argp->fh, argp->name, argp->len,
149 return nfsd_return_dirop(nfserr, resp);
156 nfsd_proc_readlink(struct svc_rqst *rqstp)
158 struct nfsd_readlinkargs *argp = rqstp->rq_argp;
159 struct nfsd_readlinkres *resp = rqstp->rq_resp;
162 dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp->fh));
164 /* Read the symlink. */
165 resp->len = NFS_MAXPATHLEN;
166 nfserr = nfsd_readlink(rqstp, &argp->fh, argp->buffer, &resp->len);
173 * Read a portion of a file.
174 * N.B. After this call resp->fh needs an fh_put
177 nfsd_proc_read(struct svc_rqst *rqstp)
179 struct nfsd_readargs *argp = rqstp->rq_argp;
180 struct nfsd_readres *resp = rqstp->rq_resp;
183 dprintk("nfsd: READ %s %d bytes at %d\n",
184 SVCFH_fmt(&argp->fh),
185 argp->count, argp->offset);
187 /* Obtain buffer pointer for payload. 19 is 1 word for
188 * status, 17 words for fattr, and 1 word for the byte count.
191 if (NFSSVC_MAXBLKSIZE_V2 < argp->count) {
192 char buf[RPC_MAX_ADDRBUFLEN];
194 "oversized read request from %s (%d bytes)\n",
195 svc_print_addr(rqstp, buf, sizeof(buf)),
197 argp->count = NFSSVC_MAXBLKSIZE_V2;
199 svc_reserve_auth(rqstp, (19<<2) + argp->count + 4);
201 resp->count = argp->count;
202 nfserr = nfsd_read(rqstp, fh_copy(&resp->fh, &argp->fh),
204 rqstp->rq_vec, argp->vlen,
207 if (nfserr) return nfserr;
208 return fh_getattr(&resp->fh, &resp->stat);
213 nfsd_proc_writecache(struct svc_rqst *rqstp)
219 * Write data to a file
220 * N.B. After this call resp->fh needs an fh_put
223 nfsd_proc_write(struct svc_rqst *rqstp)
225 struct nfsd_writeargs *argp = rqstp->rq_argp;
226 struct nfsd_attrstat *resp = rqstp->rq_resp;
228 unsigned long cnt = argp->len;
230 dprintk("nfsd: WRITE %s %u bytes at %d\n",
231 SVCFH_fmt(&argp->fh),
232 argp->len, argp->offset);
234 nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), argp->offset,
235 rqstp->rq_vec, argp->vlen, &cnt, NFS_DATA_SYNC);
236 return nfsd_return_attrs(nfserr, resp);
240 * CREATE processing is complicated. The keyword here is `overloaded.'
241 * The parent directory is kept locked between the check for existence
242 * and the actual create() call in compliance with VFS protocols.
243 * N.B. After this call _both_ argp->fh and resp->fh need an fh_put
246 nfsd_proc_create(struct svc_rqst *rqstp)
248 struct nfsd_createargs *argp = rqstp->rq_argp;
249 struct nfsd_diropres *resp = rqstp->rq_resp;
250 svc_fh *dirfhp = &argp->fh;
251 svc_fh *newfhp = &resp->fh;
252 struct iattr *attr = &argp->attrs;
254 struct dentry *dchild;
258 dev_t rdev = 0, wanted = new_decode_dev(attr->ia_size);
260 dprintk("nfsd: CREATE %s %.*s\n",
261 SVCFH_fmt(dirfhp), argp->len, argp->name);
263 /* First verify the parent file handle */
264 nfserr = fh_verify(rqstp, dirfhp, S_IFDIR, NFSD_MAY_EXEC);
266 goto done; /* must fh_put dirfhp even on error */
268 /* Check for NFSD_MAY_WRITE in nfsd_create if necessary */
270 nfserr = nfserr_exist;
271 if (isdotent(argp->name, argp->len))
273 hosterr = fh_want_write(dirfhp);
275 nfserr = nfserrno(hosterr);
279 fh_lock_nested(dirfhp, I_MUTEX_PARENT);
280 dchild = lookup_one_len(argp->name, dirfhp->fh_dentry, argp->len);
281 if (IS_ERR(dchild)) {
282 nfserr = nfserrno(PTR_ERR(dchild));
285 fh_init(newfhp, NFS_FHSIZE);
286 nfserr = fh_compose(newfhp, dirfhp->fh_export, dchild, dirfhp);
287 if (!nfserr && d_really_is_negative(dchild))
288 nfserr = nfserr_noent;
291 if (nfserr != nfserr_noent)
294 * If the new file handle wasn't verified, we can't tell
295 * whether the file exists or not. Time to bail ...
297 nfserr = nfserr_acces;
298 if (!newfhp->fh_dentry) {
300 "nfsd_proc_create: file handle not verified\n");
305 inode = d_inode(newfhp->fh_dentry);
307 /* Unfudge the mode bits */
308 if (attr->ia_valid & ATTR_MODE) {
309 type = attr->ia_mode & S_IFMT;
310 mode = attr->ia_mode & ~S_IFMT;
312 /* no type, so if target exists, assume same as that,
313 * else assume a file */
315 type = inode->i_mode & S_IFMT;
319 /* reserve rdev for later checking */
320 rdev = inode->i_rdev;
321 attr->ia_valid |= ATTR_SIZE;
325 /* this is probably a permission check..
326 * at least IRIX implements perm checking on
327 * echo thing > device-special-file-or-pipe
328 * by doing a CREATE with type==0
330 nfserr = nfsd_permission(rqstp,
333 NFSD_MAY_WRITE|NFSD_MAY_LOCAL_ACCESS);
334 if (nfserr && nfserr != nfserr_rofs)
341 type = inode->i_mode & S_IFMT;
342 mode = inode->i_mode & ~S_IFMT;
348 attr->ia_valid |= ATTR_MODE;
349 attr->ia_mode = mode;
351 /* Special treatment for non-regular files according to the
352 * gospel of sun micro
354 if (type != S_IFREG) {
355 if (type != S_IFBLK && type != S_IFCHR) {
357 } else if (type == S_IFCHR && !(attr->ia_valid & ATTR_SIZE)) {
358 /* If you think you've seen the worst, grok this. */
361 /* Okay, char or block special */
366 /* we've used the SIZE information, so discard it */
367 attr->ia_valid &= ~ATTR_SIZE;
369 /* Make sure the type and device matches */
370 nfserr = nfserr_exist;
371 if (inode && type != (inode->i_mode & S_IFMT))
377 /* File doesn't exist. Create it and set attrs */
378 nfserr = nfsd_create_locked(rqstp, dirfhp, argp->name,
379 argp->len, attr, type, rdev, newfhp);
380 } else if (type == S_IFREG) {
381 dprintk("nfsd: existing %s, valid=%x, size=%ld\n",
382 argp->name, attr->ia_valid, (long) attr->ia_size);
383 /* File already exists. We ignore all attributes except
384 * size, so that creat() behaves exactly like
385 * open(..., O_CREAT|O_TRUNC|O_WRONLY).
387 attr->ia_valid &= ATTR_SIZE;
389 nfserr = nfsd_setattr(rqstp, newfhp, attr, 0, (time_t)0);
393 /* We don't really need to unlock, as fh_put does it. */
395 fh_drop_write(dirfhp);
398 return nfsd_return_dirop(nfserr, resp);
402 nfsd_proc_remove(struct svc_rqst *rqstp)
404 struct nfsd_diropargs *argp = rqstp->rq_argp;
407 dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp->fh),
408 argp->len, argp->name);
410 /* Unlink. -SIFDIR means file must not be a directory */
411 nfserr = nfsd_unlink(rqstp, &argp->fh, -S_IFDIR, argp->name, argp->len);
417 nfsd_proc_rename(struct svc_rqst *rqstp)
419 struct nfsd_renameargs *argp = rqstp->rq_argp;
422 dprintk("nfsd: RENAME %s %.*s -> \n",
423 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname);
424 dprintk("nfsd: -> %s %.*s\n",
425 SVCFH_fmt(&argp->tfh), argp->tlen, argp->tname);
427 nfserr = nfsd_rename(rqstp, &argp->ffh, argp->fname, argp->flen,
428 &argp->tfh, argp->tname, argp->tlen);
435 nfsd_proc_link(struct svc_rqst *rqstp)
437 struct nfsd_linkargs *argp = rqstp->rq_argp;
440 dprintk("nfsd: LINK %s ->\n",
441 SVCFH_fmt(&argp->ffh));
442 dprintk("nfsd: %s %.*s\n",
443 SVCFH_fmt(&argp->tfh),
447 nfserr = nfsd_link(rqstp, &argp->tfh, argp->tname, argp->tlen,
455 nfsd_proc_symlink(struct svc_rqst *rqstp)
457 struct nfsd_symlinkargs *argp = rqstp->rq_argp;
461 dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n",
462 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname,
463 argp->tlen, argp->tname);
465 fh_init(&newfh, NFS_FHSIZE);
467 * Crazy hack: the request fits in a page, and already-decoded
468 * attributes follow argp->tname, so it's safe to just write a
469 * null to ensure it's null-terminated:
471 argp->tname[argp->tlen] = '\0';
472 nfserr = nfsd_symlink(rqstp, &argp->ffh, argp->fname, argp->flen,
473 argp->tname, &newfh);
481 * Make directory. This operation is not idempotent.
482 * N.B. After this call resp->fh needs an fh_put
485 nfsd_proc_mkdir(struct svc_rqst *rqstp)
487 struct nfsd_createargs *argp = rqstp->rq_argp;
488 struct nfsd_diropres *resp = rqstp->rq_resp;
491 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
493 if (resp->fh.fh_dentry) {
495 "nfsd_proc_mkdir: response already verified??\n");
498 argp->attrs.ia_valid &= ~ATTR_SIZE;
499 fh_init(&resp->fh, NFS_FHSIZE);
500 nfserr = nfsd_create(rqstp, &argp->fh, argp->name, argp->len,
501 &argp->attrs, S_IFDIR, 0, &resp->fh);
503 return nfsd_return_dirop(nfserr, resp);
510 nfsd_proc_rmdir(struct svc_rqst *rqstp)
512 struct nfsd_diropargs *argp = rqstp->rq_argp;
515 dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
517 nfserr = nfsd_unlink(rqstp, &argp->fh, S_IFDIR, argp->name, argp->len);
523 * Read a portion of a directory.
526 nfsd_proc_readdir(struct svc_rqst *rqstp)
528 struct nfsd_readdirargs *argp = rqstp->rq_argp;
529 struct nfsd_readdirres *resp = rqstp->rq_resp;
534 dprintk("nfsd: READDIR %s %d bytes at %d\n",
535 SVCFH_fmt(&argp->fh),
536 argp->count, argp->cookie);
538 /* Shrink to the client read size */
539 count = (argp->count >> 2) - 2;
541 /* Make sure we've room for the NULL ptr & eof flag */
546 resp->buffer = argp->buffer;
548 resp->buflen = count;
549 resp->common.err = nfs_ok;
550 /* Read directory and encode entries on the fly */
551 offset = argp->cookie;
552 nfserr = nfsd_readdir(rqstp, &argp->fh, &offset,
553 &resp->common, nfssvc_encode_entry);
555 resp->count = resp->buffer - argp->buffer;
557 *resp->offset = htonl(offset);
564 * Get file system info
567 nfsd_proc_statfs(struct svc_rqst *rqstp)
569 struct nfsd_fhandle *argp = rqstp->rq_argp;
570 struct nfsd_statfsres *resp = rqstp->rq_resp;
573 dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp->fh));
575 nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats,
576 NFSD_MAY_BYPASS_GSS_ON_ROOT);
582 * NFSv2 Server procedures.
583 * Only the results of non-idempotent operations are cached.
585 struct nfsd_void { int dummy; };
587 #define ST 1 /* status */
588 #define FH 8 /* filehandle */
589 #define AT 18 /* attributes */
591 static const struct svc_procedure nfsd_procedures2[18] = {
593 .pc_func = nfsd_proc_null,
594 .pc_decode = nfssvc_decode_void,
595 .pc_encode = nfssvc_encode_void,
596 .pc_argsize = sizeof(struct nfsd_void),
597 .pc_ressize = sizeof(struct nfsd_void),
598 .pc_cachetype = RC_NOCACHE,
601 [NFSPROC_GETATTR] = {
602 .pc_func = nfsd_proc_getattr,
603 .pc_decode = nfssvc_decode_fhandle,
604 .pc_encode = nfssvc_encode_attrstat,
605 .pc_release = nfssvc_release_fhandle,
606 .pc_argsize = sizeof(struct nfsd_fhandle),
607 .pc_ressize = sizeof(struct nfsd_attrstat),
608 .pc_cachetype = RC_NOCACHE,
609 .pc_xdrressize = ST+AT,
611 [NFSPROC_SETATTR] = {
612 .pc_func = nfsd_proc_setattr,
613 .pc_decode = nfssvc_decode_sattrargs,
614 .pc_encode = nfssvc_encode_attrstat,
615 .pc_release = nfssvc_release_fhandle,
616 .pc_argsize = sizeof(struct nfsd_sattrargs),
617 .pc_ressize = sizeof(struct nfsd_attrstat),
618 .pc_cachetype = RC_REPLBUFF,
619 .pc_xdrressize = ST+AT,
622 .pc_func = nfsd_proc_root,
623 .pc_decode = nfssvc_decode_void,
624 .pc_encode = nfssvc_encode_void,
625 .pc_argsize = sizeof(struct nfsd_void),
626 .pc_ressize = sizeof(struct nfsd_void),
627 .pc_cachetype = RC_NOCACHE,
631 .pc_func = nfsd_proc_lookup,
632 .pc_decode = nfssvc_decode_diropargs,
633 .pc_encode = nfssvc_encode_diropres,
634 .pc_release = nfssvc_release_fhandle,
635 .pc_argsize = sizeof(struct nfsd_diropargs),
636 .pc_ressize = sizeof(struct nfsd_diropres),
637 .pc_cachetype = RC_NOCACHE,
638 .pc_xdrressize = ST+FH+AT,
640 [NFSPROC_READLINK] = {
641 .pc_func = nfsd_proc_readlink,
642 .pc_decode = nfssvc_decode_readlinkargs,
643 .pc_encode = nfssvc_encode_readlinkres,
644 .pc_argsize = sizeof(struct nfsd_readlinkargs),
645 .pc_ressize = sizeof(struct nfsd_readlinkres),
646 .pc_cachetype = RC_NOCACHE,
647 .pc_xdrressize = ST+1+NFS_MAXPATHLEN/4,
650 .pc_func = nfsd_proc_read,
651 .pc_decode = nfssvc_decode_readargs,
652 .pc_encode = nfssvc_encode_readres,
653 .pc_release = nfssvc_release_fhandle,
654 .pc_argsize = sizeof(struct nfsd_readargs),
655 .pc_ressize = sizeof(struct nfsd_readres),
656 .pc_cachetype = RC_NOCACHE,
657 .pc_xdrressize = ST+AT+1+NFSSVC_MAXBLKSIZE_V2/4,
659 [NFSPROC_WRITECACHE] = {
660 .pc_func = nfsd_proc_writecache,
661 .pc_decode = nfssvc_decode_void,
662 .pc_encode = nfssvc_encode_void,
663 .pc_argsize = sizeof(struct nfsd_void),
664 .pc_ressize = sizeof(struct nfsd_void),
665 .pc_cachetype = RC_NOCACHE,
669 .pc_func = nfsd_proc_write,
670 .pc_decode = nfssvc_decode_writeargs,
671 .pc_encode = nfssvc_encode_attrstat,
672 .pc_release = nfssvc_release_fhandle,
673 .pc_argsize = sizeof(struct nfsd_writeargs),
674 .pc_ressize = sizeof(struct nfsd_attrstat),
675 .pc_cachetype = RC_REPLBUFF,
676 .pc_xdrressize = ST+AT,
679 .pc_func = nfsd_proc_create,
680 .pc_decode = nfssvc_decode_createargs,
681 .pc_encode = nfssvc_encode_diropres,
682 .pc_release = nfssvc_release_fhandle,
683 .pc_argsize = sizeof(struct nfsd_createargs),
684 .pc_ressize = sizeof(struct nfsd_diropres),
685 .pc_cachetype = RC_REPLBUFF,
686 .pc_xdrressize = ST+FH+AT,
689 .pc_func = nfsd_proc_remove,
690 .pc_decode = nfssvc_decode_diropargs,
691 .pc_encode = nfssvc_encode_void,
692 .pc_argsize = sizeof(struct nfsd_diropargs),
693 .pc_ressize = sizeof(struct nfsd_void),
694 .pc_cachetype = RC_REPLSTAT,
698 .pc_func = nfsd_proc_rename,
699 .pc_decode = nfssvc_decode_renameargs,
700 .pc_encode = nfssvc_encode_void,
701 .pc_argsize = sizeof(struct nfsd_renameargs),
702 .pc_ressize = sizeof(struct nfsd_void),
703 .pc_cachetype = RC_REPLSTAT,
707 .pc_func = nfsd_proc_link,
708 .pc_decode = nfssvc_decode_linkargs,
709 .pc_encode = nfssvc_encode_void,
710 .pc_argsize = sizeof(struct nfsd_linkargs),
711 .pc_ressize = sizeof(struct nfsd_void),
712 .pc_cachetype = RC_REPLSTAT,
715 [NFSPROC_SYMLINK] = {
716 .pc_func = nfsd_proc_symlink,
717 .pc_decode = nfssvc_decode_symlinkargs,
718 .pc_encode = nfssvc_encode_void,
719 .pc_argsize = sizeof(struct nfsd_symlinkargs),
720 .pc_ressize = sizeof(struct nfsd_void),
721 .pc_cachetype = RC_REPLSTAT,
725 .pc_func = nfsd_proc_mkdir,
726 .pc_decode = nfssvc_decode_createargs,
727 .pc_encode = nfssvc_encode_diropres,
728 .pc_release = nfssvc_release_fhandle,
729 .pc_argsize = sizeof(struct nfsd_createargs),
730 .pc_ressize = sizeof(struct nfsd_diropres),
731 .pc_cachetype = RC_REPLBUFF,
732 .pc_xdrressize = ST+FH+AT,
735 .pc_func = nfsd_proc_rmdir,
736 .pc_decode = nfssvc_decode_diropargs,
737 .pc_encode = nfssvc_encode_void,
738 .pc_argsize = sizeof(struct nfsd_diropargs),
739 .pc_ressize = sizeof(struct nfsd_void),
740 .pc_cachetype = RC_REPLSTAT,
743 [NFSPROC_READDIR] = {
744 .pc_func = nfsd_proc_readdir,
745 .pc_decode = nfssvc_decode_readdirargs,
746 .pc_encode = nfssvc_encode_readdirres,
747 .pc_argsize = sizeof(struct nfsd_readdirargs),
748 .pc_ressize = sizeof(struct nfsd_readdirres),
749 .pc_cachetype = RC_NOCACHE,
752 .pc_func = nfsd_proc_statfs,
753 .pc_decode = nfssvc_decode_fhandle,
754 .pc_encode = nfssvc_encode_statfsres,
755 .pc_argsize = sizeof(struct nfsd_fhandle),
756 .pc_ressize = sizeof(struct nfsd_statfsres),
757 .pc_cachetype = RC_NOCACHE,
758 .pc_xdrressize = ST+5,
763 static unsigned int nfsd_count2[ARRAY_SIZE(nfsd_procedures2)];
764 const struct svc_version nfsd_version2 = {
767 .vs_proc = nfsd_procedures2,
768 .vs_count = nfsd_count2,
769 .vs_dispatch = nfsd_dispatch,
770 .vs_xdrsize = NFS2_SVC_XDRSIZE,
774 * Map errnos to NFS errnos.
784 { nfserr_perm, -EPERM },
785 { nfserr_noent, -ENOENT },
787 { nfserr_nxio, -ENXIO },
788 { nfserr_fbig, -E2BIG },
789 { nfserr_acces, -EACCES },
790 { nfserr_exist, -EEXIST },
791 { nfserr_xdev, -EXDEV },
792 { nfserr_mlink, -EMLINK },
793 { nfserr_nodev, -ENODEV },
794 { nfserr_notdir, -ENOTDIR },
795 { nfserr_isdir, -EISDIR },
796 { nfserr_inval, -EINVAL },
797 { nfserr_fbig, -EFBIG },
798 { nfserr_nospc, -ENOSPC },
799 { nfserr_rofs, -EROFS },
800 { nfserr_mlink, -EMLINK },
801 { nfserr_nametoolong, -ENAMETOOLONG },
802 { nfserr_notempty, -ENOTEMPTY },
804 { nfserr_dquot, -EDQUOT },
806 { nfserr_stale, -ESTALE },
807 { nfserr_jukebox, -ETIMEDOUT },
808 { nfserr_jukebox, -ERESTARTSYS },
809 { nfserr_jukebox, -EAGAIN },
810 { nfserr_jukebox, -EWOULDBLOCK },
811 { nfserr_jukebox, -ENOMEM },
812 { nfserr_io, -ETXTBSY },
813 { nfserr_notsupp, -EOPNOTSUPP },
814 { nfserr_toosmall, -ETOOSMALL },
815 { nfserr_serverfault, -ESERVERFAULT },
816 { nfserr_serverfault, -ENFILE },
817 { nfserr_io, -EUCLEAN },
818 { nfserr_perm, -ENOKEY },
822 for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) {
823 if (nfs_errtbl[i].syserr == errno)
824 return nfs_errtbl[i].nfserr;
826 WARN_ONCE(1, "nfsd: non-standard errno: %d\n", errno);