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;
155 dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp->fh));
157 /* Read the symlink. */
158 resp->len = NFS_MAXPATHLEN;
159 resp->page = *(rqstp->rq_next_page++);
160 resp->status = nfsd_readlink(rqstp, &argp->fh,
161 page_address(resp->page), &resp->len);
168 * Read a portion of a file.
169 * N.B. After this call resp->fh needs an fh_put
172 nfsd_proc_read(struct svc_rqst *rqstp)
174 struct nfsd_readargs *argp = rqstp->rq_argp;
175 struct nfsd_readres *resp = rqstp->rq_resp;
180 dprintk("nfsd: READ %s %d bytes at %d\n",
181 SVCFH_fmt(&argp->fh),
182 argp->count, argp->offset);
184 argp->count = min_t(u32, argp->count, NFSSVC_MAXBLKSIZE_V2);
188 resp->pages = rqstp->rq_next_page;
190 struct page *page = *(rqstp->rq_next_page++);
192 rqstp->rq_vec[v].iov_base = page_address(page);
193 rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE);
194 len -= rqstp->rq_vec[v].iov_len;
198 /* Obtain buffer pointer for payload. 19 is 1 word for
199 * status, 17 words for fattr, and 1 word for the byte count.
201 svc_reserve_auth(rqstp, (19<<2) + argp->count + 4);
203 resp->count = argp->count;
204 fh_copy(&resp->fh, &argp->fh);
205 resp->status = nfsd_read(rqstp, &resp->fh, argp->offset,
206 rqstp->rq_vec, v, &resp->count, &eof);
207 if (resp->status == nfs_ok)
208 resp->status = fh_getattr(&resp->fh, &resp->stat);
209 else if (resp->status == nfserr_jukebox)
210 return rpc_drop_reply;
216 nfsd_proc_writecache(struct svc_rqst *rqstp)
222 * Write data to a file
223 * N.B. After this call resp->fh needs an fh_put
226 nfsd_proc_write(struct svc_rqst *rqstp)
228 struct nfsd_writeargs *argp = rqstp->rq_argp;
229 struct nfsd_attrstat *resp = rqstp->rq_resp;
230 unsigned long cnt = argp->len;
233 dprintk("nfsd: WRITE %s %u bytes at %d\n",
234 SVCFH_fmt(&argp->fh),
235 argp->len, argp->offset);
237 nvecs = svc_fill_write_vector(rqstp, &argp->payload);
239 resp->status = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh),
240 argp->offset, rqstp->rq_vec, nvecs,
241 &cnt, NFS_DATA_SYNC, NULL);
242 if (resp->status == nfs_ok)
243 resp->status = fh_getattr(&resp->fh, &resp->stat);
244 else if (resp->status == nfserr_jukebox)
245 return rpc_drop_reply;
250 * CREATE processing is complicated. The keyword here is `overloaded.'
251 * The parent directory is kept locked between the check for existence
252 * and the actual create() call in compliance with VFS protocols.
253 * N.B. After this call _both_ argp->fh and resp->fh need an fh_put
256 nfsd_proc_create(struct svc_rqst *rqstp)
258 struct nfsd_createargs *argp = rqstp->rq_argp;
259 struct nfsd_diropres *resp = rqstp->rq_resp;
260 svc_fh *dirfhp = &argp->fh;
261 svc_fh *newfhp = &resp->fh;
262 struct iattr *attr = &argp->attrs;
264 struct dentry *dchild;
267 dev_t rdev = 0, wanted = new_decode_dev(attr->ia_size);
269 dprintk("nfsd: CREATE %s %.*s\n",
270 SVCFH_fmt(dirfhp), argp->len, argp->name);
272 /* First verify the parent file handle */
273 resp->status = fh_verify(rqstp, dirfhp, S_IFDIR, NFSD_MAY_EXEC);
274 if (resp->status != nfs_ok)
275 goto done; /* must fh_put dirfhp even on error */
277 /* Check for NFSD_MAY_WRITE in nfsd_create if necessary */
279 resp->status = nfserr_exist;
280 if (isdotent(argp->name, argp->len))
282 hosterr = fh_want_write(dirfhp);
284 resp->status = nfserrno(hosterr);
288 fh_lock_nested(dirfhp, I_MUTEX_PARENT);
289 dchild = lookup_one_len(argp->name, dirfhp->fh_dentry, argp->len);
290 if (IS_ERR(dchild)) {
291 resp->status = nfserrno(PTR_ERR(dchild));
294 fh_init(newfhp, NFS_FHSIZE);
295 resp->status = fh_compose(newfhp, dirfhp->fh_export, dchild, dirfhp);
296 if (!resp->status && d_really_is_negative(dchild))
297 resp->status = nfserr_noent;
300 if (resp->status != nfserr_noent)
303 * If the new file handle wasn't verified, we can't tell
304 * whether the file exists or not. Time to bail ...
306 resp->status = nfserr_acces;
307 if (!newfhp->fh_dentry) {
309 "nfsd_proc_create: file handle not verified\n");
314 inode = d_inode(newfhp->fh_dentry);
316 /* Unfudge the mode bits */
317 if (attr->ia_valid & ATTR_MODE) {
318 type = attr->ia_mode & S_IFMT;
319 mode = attr->ia_mode & ~S_IFMT;
321 /* no type, so if target exists, assume same as that,
322 * else assume a file */
324 type = inode->i_mode & S_IFMT;
328 /* reserve rdev for later checking */
329 rdev = inode->i_rdev;
330 attr->ia_valid |= ATTR_SIZE;
334 /* this is probably a permission check..
335 * at least IRIX implements perm checking on
336 * echo thing > device-special-file-or-pipe
337 * by doing a CREATE with type==0
339 resp->status = nfsd_permission(rqstp,
342 NFSD_MAY_WRITE|NFSD_MAY_LOCAL_ACCESS);
343 if (resp->status && resp->status != nfserr_rofs)
350 type = inode->i_mode & S_IFMT;
351 mode = inode->i_mode & ~S_IFMT;
357 attr->ia_valid |= ATTR_MODE;
358 attr->ia_mode = mode;
360 /* Special treatment for non-regular files according to the
361 * gospel of sun micro
363 if (type != S_IFREG) {
364 if (type != S_IFBLK && type != S_IFCHR) {
366 } else if (type == S_IFCHR && !(attr->ia_valid & ATTR_SIZE)) {
367 /* If you think you've seen the worst, grok this. */
370 /* Okay, char or block special */
375 /* we've used the SIZE information, so discard it */
376 attr->ia_valid &= ~ATTR_SIZE;
378 /* Make sure the type and device matches */
379 resp->status = nfserr_exist;
380 if (inode && inode_wrong_type(inode, type))
384 resp->status = nfs_ok;
386 /* File doesn't exist. Create it and set attrs */
387 resp->status = nfsd_create_locked(rqstp, dirfhp, argp->name,
388 argp->len, attr, type, rdev,
390 } else if (type == S_IFREG) {
391 dprintk("nfsd: existing %s, valid=%x, size=%ld\n",
392 argp->name, attr->ia_valid, (long) attr->ia_size);
393 /* File already exists. We ignore all attributes except
394 * size, so that creat() behaves exactly like
395 * open(..., O_CREAT|O_TRUNC|O_WRONLY).
397 attr->ia_valid &= ATTR_SIZE;
399 resp->status = nfsd_setattr(rqstp, newfhp, attr, 0,
404 /* We don't really need to unlock, as fh_put does it. */
406 fh_drop_write(dirfhp);
409 if (resp->status != nfs_ok)
411 resp->status = fh_getattr(&resp->fh, &resp->stat);
417 nfsd_proc_remove(struct svc_rqst *rqstp)
419 struct nfsd_diropargs *argp = rqstp->rq_argp;
420 struct nfsd_stat *resp = rqstp->rq_resp;
422 dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp->fh),
423 argp->len, argp->name);
425 /* Unlink. -SIFDIR means file must not be a directory */
426 resp->status = nfsd_unlink(rqstp, &argp->fh, -S_IFDIR,
427 argp->name, argp->len);
433 nfsd_proc_rename(struct svc_rqst *rqstp)
435 struct nfsd_renameargs *argp = rqstp->rq_argp;
436 struct nfsd_stat *resp = rqstp->rq_resp;
438 dprintk("nfsd: RENAME %s %.*s -> \n",
439 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname);
440 dprintk("nfsd: -> %s %.*s\n",
441 SVCFH_fmt(&argp->tfh), argp->tlen, argp->tname);
443 resp->status = nfsd_rename(rqstp, &argp->ffh, argp->fname, argp->flen,
444 &argp->tfh, argp->tname, argp->tlen);
451 nfsd_proc_link(struct svc_rqst *rqstp)
453 struct nfsd_linkargs *argp = rqstp->rq_argp;
454 struct nfsd_stat *resp = rqstp->rq_resp;
456 dprintk("nfsd: LINK %s ->\n",
457 SVCFH_fmt(&argp->ffh));
458 dprintk("nfsd: %s %.*s\n",
459 SVCFH_fmt(&argp->tfh),
463 resp->status = nfsd_link(rqstp, &argp->tfh, argp->tname, argp->tlen,
471 nfsd_proc_symlink(struct svc_rqst *rqstp)
473 struct nfsd_symlinkargs *argp = rqstp->rq_argp;
474 struct nfsd_stat *resp = rqstp->rq_resp;
477 if (argp->tlen > NFS_MAXPATHLEN) {
478 resp->status = nfserr_nametoolong;
482 argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first,
483 page_address(rqstp->rq_arg.pages[0]),
485 if (IS_ERR(argp->tname)) {
486 resp->status = nfserrno(PTR_ERR(argp->tname));
490 dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n",
491 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname,
492 argp->tlen, argp->tname);
494 fh_init(&newfh, NFS_FHSIZE);
495 resp->status = nfsd_symlink(rqstp, &argp->ffh, argp->fname, argp->flen,
496 argp->tname, &newfh);
506 * Make directory. This operation is not idempotent.
507 * N.B. After this call resp->fh needs an fh_put
510 nfsd_proc_mkdir(struct svc_rqst *rqstp)
512 struct nfsd_createargs *argp = rqstp->rq_argp;
513 struct nfsd_diropres *resp = rqstp->rq_resp;
515 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
517 if (resp->fh.fh_dentry) {
519 "nfsd_proc_mkdir: response already verified??\n");
522 argp->attrs.ia_valid &= ~ATTR_SIZE;
523 fh_init(&resp->fh, NFS_FHSIZE);
524 resp->status = nfsd_create(rqstp, &argp->fh, argp->name, argp->len,
525 &argp->attrs, S_IFDIR, 0, &resp->fh);
527 if (resp->status != nfs_ok)
530 resp->status = fh_getattr(&resp->fh, &resp->stat);
539 nfsd_proc_rmdir(struct svc_rqst *rqstp)
541 struct nfsd_diropargs *argp = rqstp->rq_argp;
542 struct nfsd_stat *resp = rqstp->rq_resp;
544 dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
546 resp->status = nfsd_unlink(rqstp, &argp->fh, S_IFDIR,
547 argp->name, argp->len);
552 static void nfsd_init_dirlist_pages(struct svc_rqst *rqstp,
553 struct nfsd_readdirres *resp,
556 struct xdr_buf *buf = &resp->dirlist;
557 struct xdr_stream *xdr = &resp->xdr;
559 count = clamp(count, (u32)(XDR_UNIT * 2), svc_max_payload(rqstp));
561 memset(buf, 0, sizeof(*buf));
563 /* Reserve room for the NULL ptr & eof flag (-2 words) */
564 buf->buflen = count - XDR_UNIT * 2;
565 buf->pages = rqstp->rq_next_page;
566 rqstp->rq_next_page++;
568 /* This is xdr_init_encode(), but it assumes that
569 * the head kvec has already been consumed. */
570 xdr_set_scratch_buffer(xdr, NULL, 0);
572 xdr->page_ptr = buf->pages;
574 xdr->p = page_address(*buf->pages);
575 xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE);
580 * Read a portion of a directory.
583 nfsd_proc_readdir(struct svc_rqst *rqstp)
585 struct nfsd_readdirargs *argp = rqstp->rq_argp;
586 struct nfsd_readdirres *resp = rqstp->rq_resp;
589 dprintk("nfsd: READDIR %s %d bytes at %d\n",
590 SVCFH_fmt(&argp->fh),
591 argp->count, argp->cookie);
593 nfsd_init_dirlist_pages(rqstp, resp, argp->count);
595 resp->common.err = nfs_ok;
596 resp->cookie_offset = 0;
597 offset = argp->cookie;
598 resp->status = nfsd_readdir(rqstp, &argp->fh, &offset,
599 &resp->common, nfssvc_encode_entry);
600 nfssvc_encode_nfscookie(resp, offset);
607 * Get file system info
610 nfsd_proc_statfs(struct svc_rqst *rqstp)
612 struct nfsd_fhandle *argp = rqstp->rq_argp;
613 struct nfsd_statfsres *resp = rqstp->rq_resp;
615 dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp->fh));
617 resp->status = nfsd_statfs(rqstp, &argp->fh, &resp->stats,
618 NFSD_MAY_BYPASS_GSS_ON_ROOT);
624 * NFSv2 Server procedures.
625 * Only the results of non-idempotent operations are cached.
628 #define ST 1 /* status */
629 #define FH 8 /* filehandle */
630 #define AT 18 /* attributes */
632 static const struct svc_procedure nfsd_procedures2[18] = {
634 .pc_func = nfsd_proc_null,
635 .pc_decode = nfssvc_decode_voidarg,
636 .pc_encode = nfssvc_encode_voidres,
637 .pc_argsize = sizeof(struct nfsd_voidargs),
638 .pc_ressize = sizeof(struct nfsd_voidres),
639 .pc_cachetype = RC_NOCACHE,
643 [NFSPROC_GETATTR] = {
644 .pc_func = nfsd_proc_getattr,
645 .pc_decode = nfssvc_decode_fhandleargs,
646 .pc_encode = nfssvc_encode_attrstatres,
647 .pc_release = nfssvc_release_attrstat,
648 .pc_argsize = sizeof(struct nfsd_fhandle),
649 .pc_ressize = sizeof(struct nfsd_attrstat),
650 .pc_cachetype = RC_NOCACHE,
651 .pc_xdrressize = ST+AT,
652 .pc_name = "GETATTR",
654 [NFSPROC_SETATTR] = {
655 .pc_func = nfsd_proc_setattr,
656 .pc_decode = nfssvc_decode_sattrargs,
657 .pc_encode = nfssvc_encode_attrstatres,
658 .pc_release = nfssvc_release_attrstat,
659 .pc_argsize = sizeof(struct nfsd_sattrargs),
660 .pc_ressize = sizeof(struct nfsd_attrstat),
661 .pc_cachetype = RC_REPLBUFF,
662 .pc_xdrressize = ST+AT,
663 .pc_name = "SETATTR",
666 .pc_func = nfsd_proc_root,
667 .pc_decode = nfssvc_decode_voidarg,
668 .pc_encode = nfssvc_encode_voidres,
669 .pc_argsize = sizeof(struct nfsd_voidargs),
670 .pc_ressize = sizeof(struct nfsd_voidres),
671 .pc_cachetype = RC_NOCACHE,
676 .pc_func = nfsd_proc_lookup,
677 .pc_decode = nfssvc_decode_diropargs,
678 .pc_encode = nfssvc_encode_diropres,
679 .pc_release = nfssvc_release_diropres,
680 .pc_argsize = sizeof(struct nfsd_diropargs),
681 .pc_ressize = sizeof(struct nfsd_diropres),
682 .pc_cachetype = RC_NOCACHE,
683 .pc_xdrressize = ST+FH+AT,
686 [NFSPROC_READLINK] = {
687 .pc_func = nfsd_proc_readlink,
688 .pc_decode = nfssvc_decode_fhandleargs,
689 .pc_encode = nfssvc_encode_readlinkres,
690 .pc_argsize = sizeof(struct nfsd_fhandle),
691 .pc_ressize = sizeof(struct nfsd_readlinkres),
692 .pc_cachetype = RC_NOCACHE,
693 .pc_xdrressize = ST+1+NFS_MAXPATHLEN/4,
694 .pc_name = "READLINK",
697 .pc_func = nfsd_proc_read,
698 .pc_decode = nfssvc_decode_readargs,
699 .pc_encode = nfssvc_encode_readres,
700 .pc_release = nfssvc_release_readres,
701 .pc_argsize = sizeof(struct nfsd_readargs),
702 .pc_ressize = sizeof(struct nfsd_readres),
703 .pc_cachetype = RC_NOCACHE,
704 .pc_xdrressize = ST+AT+1+NFSSVC_MAXBLKSIZE_V2/4,
707 [NFSPROC_WRITECACHE] = {
708 .pc_func = nfsd_proc_writecache,
709 .pc_decode = nfssvc_decode_voidarg,
710 .pc_encode = nfssvc_encode_voidres,
711 .pc_argsize = sizeof(struct nfsd_voidargs),
712 .pc_ressize = sizeof(struct nfsd_voidres),
713 .pc_cachetype = RC_NOCACHE,
715 .pc_name = "WRITECACHE",
718 .pc_func = nfsd_proc_write,
719 .pc_decode = nfssvc_decode_writeargs,
720 .pc_encode = nfssvc_encode_attrstatres,
721 .pc_release = nfssvc_release_attrstat,
722 .pc_argsize = sizeof(struct nfsd_writeargs),
723 .pc_ressize = sizeof(struct nfsd_attrstat),
724 .pc_cachetype = RC_REPLBUFF,
725 .pc_xdrressize = ST+AT,
729 .pc_func = nfsd_proc_create,
730 .pc_decode = nfssvc_decode_createargs,
731 .pc_encode = nfssvc_encode_diropres,
732 .pc_release = nfssvc_release_diropres,
733 .pc_argsize = sizeof(struct nfsd_createargs),
734 .pc_ressize = sizeof(struct nfsd_diropres),
735 .pc_cachetype = RC_REPLBUFF,
736 .pc_xdrressize = ST+FH+AT,
740 .pc_func = nfsd_proc_remove,
741 .pc_decode = nfssvc_decode_diropargs,
742 .pc_encode = nfssvc_encode_statres,
743 .pc_argsize = sizeof(struct nfsd_diropargs),
744 .pc_ressize = sizeof(struct nfsd_stat),
745 .pc_cachetype = RC_REPLSTAT,
750 .pc_func = nfsd_proc_rename,
751 .pc_decode = nfssvc_decode_renameargs,
752 .pc_encode = nfssvc_encode_statres,
753 .pc_argsize = sizeof(struct nfsd_renameargs),
754 .pc_ressize = sizeof(struct nfsd_stat),
755 .pc_cachetype = RC_REPLSTAT,
760 .pc_func = nfsd_proc_link,
761 .pc_decode = nfssvc_decode_linkargs,
762 .pc_encode = nfssvc_encode_statres,
763 .pc_argsize = sizeof(struct nfsd_linkargs),
764 .pc_ressize = sizeof(struct nfsd_stat),
765 .pc_cachetype = RC_REPLSTAT,
769 [NFSPROC_SYMLINK] = {
770 .pc_func = nfsd_proc_symlink,
771 .pc_decode = nfssvc_decode_symlinkargs,
772 .pc_encode = nfssvc_encode_statres,
773 .pc_argsize = sizeof(struct nfsd_symlinkargs),
774 .pc_ressize = sizeof(struct nfsd_stat),
775 .pc_cachetype = RC_REPLSTAT,
777 .pc_name = "SYMLINK",
780 .pc_func = nfsd_proc_mkdir,
781 .pc_decode = nfssvc_decode_createargs,
782 .pc_encode = nfssvc_encode_diropres,
783 .pc_release = nfssvc_release_diropres,
784 .pc_argsize = sizeof(struct nfsd_createargs),
785 .pc_ressize = sizeof(struct nfsd_diropres),
786 .pc_cachetype = RC_REPLBUFF,
787 .pc_xdrressize = ST+FH+AT,
791 .pc_func = nfsd_proc_rmdir,
792 .pc_decode = nfssvc_decode_diropargs,
793 .pc_encode = nfssvc_encode_statres,
794 .pc_argsize = sizeof(struct nfsd_diropargs),
795 .pc_ressize = sizeof(struct nfsd_stat),
796 .pc_cachetype = RC_REPLSTAT,
800 [NFSPROC_READDIR] = {
801 .pc_func = nfsd_proc_readdir,
802 .pc_decode = nfssvc_decode_readdirargs,
803 .pc_encode = nfssvc_encode_readdirres,
804 .pc_argsize = sizeof(struct nfsd_readdirargs),
805 .pc_ressize = sizeof(struct nfsd_readdirres),
806 .pc_cachetype = RC_NOCACHE,
807 .pc_name = "READDIR",
810 .pc_func = nfsd_proc_statfs,
811 .pc_decode = nfssvc_decode_fhandleargs,
812 .pc_encode = nfssvc_encode_statfsres,
813 .pc_argsize = sizeof(struct nfsd_fhandle),
814 .pc_ressize = sizeof(struct nfsd_statfsres),
815 .pc_cachetype = RC_NOCACHE,
816 .pc_xdrressize = ST+5,
822 static unsigned int nfsd_count2[ARRAY_SIZE(nfsd_procedures2)];
823 const struct svc_version nfsd_version2 = {
826 .vs_proc = nfsd_procedures2,
827 .vs_count = nfsd_count2,
828 .vs_dispatch = nfsd_dispatch,
829 .vs_xdrsize = NFS2_SVC_XDRSIZE,
833 * Map errnos to NFS errnos.
843 { nfserr_perm, -EPERM },
844 { nfserr_noent, -ENOENT },
846 { nfserr_nxio, -ENXIO },
847 { nfserr_fbig, -E2BIG },
848 { nfserr_stale, -EBADF },
849 { nfserr_acces, -EACCES },
850 { nfserr_exist, -EEXIST },
851 { nfserr_xdev, -EXDEV },
852 { nfserr_mlink, -EMLINK },
853 { nfserr_nodev, -ENODEV },
854 { nfserr_notdir, -ENOTDIR },
855 { nfserr_isdir, -EISDIR },
856 { nfserr_inval, -EINVAL },
857 { nfserr_fbig, -EFBIG },
858 { nfserr_nospc, -ENOSPC },
859 { nfserr_rofs, -EROFS },
860 { nfserr_mlink, -EMLINK },
861 { nfserr_nametoolong, -ENAMETOOLONG },
862 { nfserr_notempty, -ENOTEMPTY },
864 { nfserr_dquot, -EDQUOT },
866 { nfserr_stale, -ESTALE },
867 { nfserr_jukebox, -ETIMEDOUT },
868 { nfserr_jukebox, -ERESTARTSYS },
869 { nfserr_jukebox, -EAGAIN },
870 { nfserr_jukebox, -EWOULDBLOCK },
871 { nfserr_jukebox, -ENOMEM },
872 { nfserr_io, -ETXTBSY },
873 { nfserr_notsupp, -EOPNOTSUPP },
874 { nfserr_toosmall, -ETOOSMALL },
875 { nfserr_serverfault, -ESERVERFAULT },
876 { nfserr_serverfault, -ENFILE },
877 { nfserr_io, -EREMOTEIO },
878 { nfserr_stale, -EOPENSTALE },
879 { nfserr_io, -EUCLEAN },
880 { nfserr_perm, -ENOKEY },
881 { nfserr_no_grace, -ENOGRACE},
885 for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) {
886 if (nfs_errtbl[i].syserr == errno)
887 return nfs_errtbl[i].nfserr;
889 WARN_ONCE(1, "nfsd: non-standard errno: %d\n", errno);