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 #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);
185 argp->count = min_t(u32, argp->count, rqstp->rq_res.buflen);
189 resp->pages = rqstp->rq_next_page;
191 struct page *page = *(rqstp->rq_next_page++);
193 rqstp->rq_vec[v].iov_base = page_address(page);
194 rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE);
195 len -= rqstp->rq_vec[v].iov_len;
199 /* Obtain buffer pointer for payload. 19 is 1 word for
200 * status, 17 words for fattr, and 1 word for the byte count.
202 svc_reserve_auth(rqstp, (19<<2) + argp->count + 4);
204 resp->count = argp->count;
205 fh_copy(&resp->fh, &argp->fh);
206 resp->status = nfsd_read(rqstp, &resp->fh, argp->offset,
207 rqstp->rq_vec, v, &resp->count, &eof);
208 if (resp->status == nfs_ok)
209 resp->status = fh_getattr(&resp->fh, &resp->stat);
210 else if (resp->status == nfserr_jukebox)
211 return rpc_drop_reply;
217 nfsd_proc_writecache(struct svc_rqst *rqstp)
223 * Write data to a file
224 * N.B. After this call resp->fh needs an fh_put
227 nfsd_proc_write(struct svc_rqst *rqstp)
229 struct nfsd_writeargs *argp = rqstp->rq_argp;
230 struct nfsd_attrstat *resp = rqstp->rq_resp;
231 unsigned long cnt = argp->len;
234 dprintk("nfsd: WRITE %s %u bytes at %d\n",
235 SVCFH_fmt(&argp->fh),
236 argp->len, argp->offset);
238 nvecs = svc_fill_write_vector(rqstp, &argp->payload);
240 resp->status = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh),
241 argp->offset, rqstp->rq_vec, nvecs,
242 &cnt, NFS_DATA_SYNC, NULL);
243 if (resp->status == nfs_ok)
244 resp->status = fh_getattr(&resp->fh, &resp->stat);
245 else if (resp->status == nfserr_jukebox)
246 return rpc_drop_reply;
251 * CREATE processing is complicated. The keyword here is `overloaded.'
252 * The parent directory is kept locked between the check for existence
253 * and the actual create() call in compliance with VFS protocols.
254 * N.B. After this call _both_ argp->fh and resp->fh need an fh_put
257 nfsd_proc_create(struct svc_rqst *rqstp)
259 struct nfsd_createargs *argp = rqstp->rq_argp;
260 struct nfsd_diropres *resp = rqstp->rq_resp;
261 svc_fh *dirfhp = &argp->fh;
262 svc_fh *newfhp = &resp->fh;
263 struct iattr *attr = &argp->attrs;
265 struct dentry *dchild;
268 dev_t rdev = 0, wanted = new_decode_dev(attr->ia_size);
270 dprintk("nfsd: CREATE %s %.*s\n",
271 SVCFH_fmt(dirfhp), argp->len, argp->name);
273 /* First verify the parent file handle */
274 resp->status = fh_verify(rqstp, dirfhp, S_IFDIR, NFSD_MAY_EXEC);
275 if (resp->status != nfs_ok)
276 goto done; /* must fh_put dirfhp even on error */
278 /* Check for NFSD_MAY_WRITE in nfsd_create if necessary */
280 resp->status = nfserr_exist;
281 if (isdotent(argp->name, argp->len))
283 hosterr = fh_want_write(dirfhp);
285 resp->status = nfserrno(hosterr);
289 fh_lock_nested(dirfhp, I_MUTEX_PARENT);
290 dchild = lookup_one_len(argp->name, dirfhp->fh_dentry, argp->len);
291 if (IS_ERR(dchild)) {
292 resp->status = nfserrno(PTR_ERR(dchild));
295 fh_init(newfhp, NFS_FHSIZE);
296 resp->status = fh_compose(newfhp, dirfhp->fh_export, dchild, dirfhp);
297 if (!resp->status && d_really_is_negative(dchild))
298 resp->status = nfserr_noent;
301 if (resp->status != nfserr_noent)
304 * If the new file handle wasn't verified, we can't tell
305 * whether the file exists or not. Time to bail ...
307 resp->status = nfserr_acces;
308 if (!newfhp->fh_dentry) {
310 "nfsd_proc_create: file handle not verified\n");
315 inode = d_inode(newfhp->fh_dentry);
317 /* Unfudge the mode bits */
318 if (attr->ia_valid & ATTR_MODE) {
319 type = attr->ia_mode & S_IFMT;
320 mode = attr->ia_mode & ~S_IFMT;
322 /* no type, so if target exists, assume same as that,
323 * else assume a file */
325 type = inode->i_mode & S_IFMT;
329 /* reserve rdev for later checking */
330 rdev = inode->i_rdev;
331 attr->ia_valid |= ATTR_SIZE;
335 /* this is probably a permission check..
336 * at least IRIX implements perm checking on
337 * echo thing > device-special-file-or-pipe
338 * by doing a CREATE with type==0
340 resp->status = nfsd_permission(rqstp,
343 NFSD_MAY_WRITE|NFSD_MAY_LOCAL_ACCESS);
344 if (resp->status && resp->status != nfserr_rofs)
351 type = inode->i_mode & S_IFMT;
352 mode = inode->i_mode & ~S_IFMT;
358 attr->ia_valid |= ATTR_MODE;
359 attr->ia_mode = mode;
361 /* Special treatment for non-regular files according to the
362 * gospel of sun micro
364 if (type != S_IFREG) {
365 if (type != S_IFBLK && type != S_IFCHR) {
367 } else if (type == S_IFCHR && !(attr->ia_valid & ATTR_SIZE)) {
368 /* If you think you've seen the worst, grok this. */
371 /* Okay, char or block special */
376 /* we've used the SIZE information, so discard it */
377 attr->ia_valid &= ~ATTR_SIZE;
379 /* Make sure the type and device matches */
380 resp->status = nfserr_exist;
381 if (inode && inode_wrong_type(inode, type))
385 resp->status = nfs_ok;
387 /* File doesn't exist. Create it and set attrs */
388 resp->status = nfsd_create_locked(rqstp, dirfhp, argp->name,
389 argp->len, attr, type, rdev,
391 } else if (type == S_IFREG) {
392 dprintk("nfsd: existing %s, valid=%x, size=%ld\n",
393 argp->name, attr->ia_valid, (long) attr->ia_size);
394 /* File already exists. We ignore all attributes except
395 * size, so that creat() behaves exactly like
396 * open(..., O_CREAT|O_TRUNC|O_WRONLY).
398 attr->ia_valid &= ATTR_SIZE;
400 resp->status = nfsd_setattr(rqstp, newfhp, attr, 0,
405 /* We don't really need to unlock, as fh_put does it. */
407 fh_drop_write(dirfhp);
410 if (resp->status != nfs_ok)
412 resp->status = fh_getattr(&resp->fh, &resp->stat);
418 nfsd_proc_remove(struct svc_rqst *rqstp)
420 struct nfsd_diropargs *argp = rqstp->rq_argp;
421 struct nfsd_stat *resp = rqstp->rq_resp;
423 dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp->fh),
424 argp->len, argp->name);
426 /* Unlink. -SIFDIR means file must not be a directory */
427 resp->status = nfsd_unlink(rqstp, &argp->fh, -S_IFDIR,
428 argp->name, argp->len);
434 nfsd_proc_rename(struct svc_rqst *rqstp)
436 struct nfsd_renameargs *argp = rqstp->rq_argp;
437 struct nfsd_stat *resp = rqstp->rq_resp;
439 dprintk("nfsd: RENAME %s %.*s -> \n",
440 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname);
441 dprintk("nfsd: -> %s %.*s\n",
442 SVCFH_fmt(&argp->tfh), argp->tlen, argp->tname);
444 resp->status = nfsd_rename(rqstp, &argp->ffh, argp->fname, argp->flen,
445 &argp->tfh, argp->tname, argp->tlen);
452 nfsd_proc_link(struct svc_rqst *rqstp)
454 struct nfsd_linkargs *argp = rqstp->rq_argp;
455 struct nfsd_stat *resp = rqstp->rq_resp;
457 dprintk("nfsd: LINK %s ->\n",
458 SVCFH_fmt(&argp->ffh));
459 dprintk("nfsd: %s %.*s\n",
460 SVCFH_fmt(&argp->tfh),
464 resp->status = nfsd_link(rqstp, &argp->tfh, argp->tname, argp->tlen,
472 nfsd_proc_symlink(struct svc_rqst *rqstp)
474 struct nfsd_symlinkargs *argp = rqstp->rq_argp;
475 struct nfsd_stat *resp = rqstp->rq_resp;
478 if (argp->tlen > NFS_MAXPATHLEN) {
479 resp->status = nfserr_nametoolong;
483 argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first,
484 page_address(rqstp->rq_arg.pages[0]),
486 if (IS_ERR(argp->tname)) {
487 resp->status = nfserrno(PTR_ERR(argp->tname));
491 dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n",
492 SVCFH_fmt(&argp->ffh), argp->flen, argp->fname,
493 argp->tlen, argp->tname);
495 fh_init(&newfh, NFS_FHSIZE);
496 resp->status = nfsd_symlink(rqstp, &argp->ffh, argp->fname, argp->flen,
497 argp->tname, &newfh);
507 * Make directory. This operation is not idempotent.
508 * N.B. After this call resp->fh needs an fh_put
511 nfsd_proc_mkdir(struct svc_rqst *rqstp)
513 struct nfsd_createargs *argp = rqstp->rq_argp;
514 struct nfsd_diropres *resp = rqstp->rq_resp;
516 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
518 if (resp->fh.fh_dentry) {
520 "nfsd_proc_mkdir: response already verified??\n");
523 argp->attrs.ia_valid &= ~ATTR_SIZE;
524 fh_init(&resp->fh, NFS_FHSIZE);
525 resp->status = nfsd_create(rqstp, &argp->fh, argp->name, argp->len,
526 &argp->attrs, S_IFDIR, 0, &resp->fh);
528 if (resp->status != nfs_ok)
531 resp->status = fh_getattr(&resp->fh, &resp->stat);
540 nfsd_proc_rmdir(struct svc_rqst *rqstp)
542 struct nfsd_diropargs *argp = rqstp->rq_argp;
543 struct nfsd_stat *resp = rqstp->rq_resp;
545 dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
547 resp->status = nfsd_unlink(rqstp, &argp->fh, S_IFDIR,
548 argp->name, argp->len);
553 static void nfsd_init_dirlist_pages(struct svc_rqst *rqstp,
554 struct nfsd_readdirres *resp,
557 struct xdr_buf *buf = &resp->dirlist;
558 struct xdr_stream *xdr = &resp->xdr;
560 count = clamp(count, (u32)(XDR_UNIT * 2), svc_max_payload(rqstp));
562 memset(buf, 0, sizeof(*buf));
564 /* Reserve room for the NULL ptr & eof flag (-2 words) */
565 buf->buflen = count - XDR_UNIT * 2;
566 buf->pages = rqstp->rq_next_page;
567 rqstp->rq_next_page++;
569 /* This is xdr_init_encode(), but it assumes that
570 * the head kvec has already been consumed. */
571 xdr_set_scratch_buffer(xdr, NULL, 0);
573 xdr->page_ptr = buf->pages;
575 xdr->p = page_address(*buf->pages);
576 xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE);
581 * Read a portion of a directory.
584 nfsd_proc_readdir(struct svc_rqst *rqstp)
586 struct nfsd_readdirargs *argp = rqstp->rq_argp;
587 struct nfsd_readdirres *resp = rqstp->rq_resp;
590 dprintk("nfsd: READDIR %s %d bytes at %d\n",
591 SVCFH_fmt(&argp->fh),
592 argp->count, argp->cookie);
594 nfsd_init_dirlist_pages(rqstp, resp, argp->count);
596 resp->common.err = nfs_ok;
597 resp->cookie_offset = 0;
598 offset = argp->cookie;
599 resp->status = nfsd_readdir(rqstp, &argp->fh, &offset,
600 &resp->common, nfssvc_encode_entry);
601 nfssvc_encode_nfscookie(resp, offset);
608 * Get file system info
611 nfsd_proc_statfs(struct svc_rqst *rqstp)
613 struct nfsd_fhandle *argp = rqstp->rq_argp;
614 struct nfsd_statfsres *resp = rqstp->rq_resp;
616 dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp->fh));
618 resp->status = nfsd_statfs(rqstp, &argp->fh, &resp->stats,
619 NFSD_MAY_BYPASS_GSS_ON_ROOT);
625 * NFSv2 Server procedures.
626 * Only the results of non-idempotent operations are cached.
629 #define ST 1 /* status */
630 #define FH 8 /* filehandle */
631 #define AT 18 /* attributes */
633 static const struct svc_procedure nfsd_procedures2[18] = {
635 .pc_func = nfsd_proc_null,
636 .pc_decode = nfssvc_decode_voidarg,
637 .pc_encode = nfssvc_encode_voidres,
638 .pc_argsize = sizeof(struct nfsd_voidargs),
639 .pc_ressize = sizeof(struct nfsd_voidres),
640 .pc_cachetype = RC_NOCACHE,
644 [NFSPROC_GETATTR] = {
645 .pc_func = nfsd_proc_getattr,
646 .pc_decode = nfssvc_decode_fhandleargs,
647 .pc_encode = nfssvc_encode_attrstatres,
648 .pc_release = nfssvc_release_attrstat,
649 .pc_argsize = sizeof(struct nfsd_fhandle),
650 .pc_ressize = sizeof(struct nfsd_attrstat),
651 .pc_cachetype = RC_NOCACHE,
652 .pc_xdrressize = ST+AT,
653 .pc_name = "GETATTR",
655 [NFSPROC_SETATTR] = {
656 .pc_func = nfsd_proc_setattr,
657 .pc_decode = nfssvc_decode_sattrargs,
658 .pc_encode = nfssvc_encode_attrstatres,
659 .pc_release = nfssvc_release_attrstat,
660 .pc_argsize = sizeof(struct nfsd_sattrargs),
661 .pc_ressize = sizeof(struct nfsd_attrstat),
662 .pc_cachetype = RC_REPLBUFF,
663 .pc_xdrressize = ST+AT,
664 .pc_name = "SETATTR",
667 .pc_func = nfsd_proc_root,
668 .pc_decode = nfssvc_decode_voidarg,
669 .pc_encode = nfssvc_encode_voidres,
670 .pc_argsize = sizeof(struct nfsd_voidargs),
671 .pc_ressize = sizeof(struct nfsd_voidres),
672 .pc_cachetype = RC_NOCACHE,
677 .pc_func = nfsd_proc_lookup,
678 .pc_decode = nfssvc_decode_diropargs,
679 .pc_encode = nfssvc_encode_diropres,
680 .pc_release = nfssvc_release_diropres,
681 .pc_argsize = sizeof(struct nfsd_diropargs),
682 .pc_ressize = sizeof(struct nfsd_diropres),
683 .pc_cachetype = RC_NOCACHE,
684 .pc_xdrressize = ST+FH+AT,
687 [NFSPROC_READLINK] = {
688 .pc_func = nfsd_proc_readlink,
689 .pc_decode = nfssvc_decode_fhandleargs,
690 .pc_encode = nfssvc_encode_readlinkres,
691 .pc_argsize = sizeof(struct nfsd_fhandle),
692 .pc_ressize = sizeof(struct nfsd_readlinkres),
693 .pc_cachetype = RC_NOCACHE,
694 .pc_xdrressize = ST+1+NFS_MAXPATHLEN/4,
695 .pc_name = "READLINK",
698 .pc_func = nfsd_proc_read,
699 .pc_decode = nfssvc_decode_readargs,
700 .pc_encode = nfssvc_encode_readres,
701 .pc_release = nfssvc_release_readres,
702 .pc_argsize = sizeof(struct nfsd_readargs),
703 .pc_ressize = sizeof(struct nfsd_readres),
704 .pc_cachetype = RC_NOCACHE,
705 .pc_xdrressize = ST+AT+1+NFSSVC_MAXBLKSIZE_V2/4,
708 [NFSPROC_WRITECACHE] = {
709 .pc_func = nfsd_proc_writecache,
710 .pc_decode = nfssvc_decode_voidarg,
711 .pc_encode = nfssvc_encode_voidres,
712 .pc_argsize = sizeof(struct nfsd_voidargs),
713 .pc_ressize = sizeof(struct nfsd_voidres),
714 .pc_cachetype = RC_NOCACHE,
716 .pc_name = "WRITECACHE",
719 .pc_func = nfsd_proc_write,
720 .pc_decode = nfssvc_decode_writeargs,
721 .pc_encode = nfssvc_encode_attrstatres,
722 .pc_release = nfssvc_release_attrstat,
723 .pc_argsize = sizeof(struct nfsd_writeargs),
724 .pc_ressize = sizeof(struct nfsd_attrstat),
725 .pc_cachetype = RC_REPLBUFF,
726 .pc_xdrressize = ST+AT,
730 .pc_func = nfsd_proc_create,
731 .pc_decode = nfssvc_decode_createargs,
732 .pc_encode = nfssvc_encode_diropres,
733 .pc_release = nfssvc_release_diropres,
734 .pc_argsize = sizeof(struct nfsd_createargs),
735 .pc_ressize = sizeof(struct nfsd_diropres),
736 .pc_cachetype = RC_REPLBUFF,
737 .pc_xdrressize = ST+FH+AT,
741 .pc_func = nfsd_proc_remove,
742 .pc_decode = nfssvc_decode_diropargs,
743 .pc_encode = nfssvc_encode_statres,
744 .pc_argsize = sizeof(struct nfsd_diropargs),
745 .pc_ressize = sizeof(struct nfsd_stat),
746 .pc_cachetype = RC_REPLSTAT,
751 .pc_func = nfsd_proc_rename,
752 .pc_decode = nfssvc_decode_renameargs,
753 .pc_encode = nfssvc_encode_statres,
754 .pc_argsize = sizeof(struct nfsd_renameargs),
755 .pc_ressize = sizeof(struct nfsd_stat),
756 .pc_cachetype = RC_REPLSTAT,
761 .pc_func = nfsd_proc_link,
762 .pc_decode = nfssvc_decode_linkargs,
763 .pc_encode = nfssvc_encode_statres,
764 .pc_argsize = sizeof(struct nfsd_linkargs),
765 .pc_ressize = sizeof(struct nfsd_stat),
766 .pc_cachetype = RC_REPLSTAT,
770 [NFSPROC_SYMLINK] = {
771 .pc_func = nfsd_proc_symlink,
772 .pc_decode = nfssvc_decode_symlinkargs,
773 .pc_encode = nfssvc_encode_statres,
774 .pc_argsize = sizeof(struct nfsd_symlinkargs),
775 .pc_ressize = sizeof(struct nfsd_stat),
776 .pc_cachetype = RC_REPLSTAT,
778 .pc_name = "SYMLINK",
781 .pc_func = nfsd_proc_mkdir,
782 .pc_decode = nfssvc_decode_createargs,
783 .pc_encode = nfssvc_encode_diropres,
784 .pc_release = nfssvc_release_diropres,
785 .pc_argsize = sizeof(struct nfsd_createargs),
786 .pc_ressize = sizeof(struct nfsd_diropres),
787 .pc_cachetype = RC_REPLBUFF,
788 .pc_xdrressize = ST+FH+AT,
792 .pc_func = nfsd_proc_rmdir,
793 .pc_decode = nfssvc_decode_diropargs,
794 .pc_encode = nfssvc_encode_statres,
795 .pc_argsize = sizeof(struct nfsd_diropargs),
796 .pc_ressize = sizeof(struct nfsd_stat),
797 .pc_cachetype = RC_REPLSTAT,
801 [NFSPROC_READDIR] = {
802 .pc_func = nfsd_proc_readdir,
803 .pc_decode = nfssvc_decode_readdirargs,
804 .pc_encode = nfssvc_encode_readdirres,
805 .pc_argsize = sizeof(struct nfsd_readdirargs),
806 .pc_ressize = sizeof(struct nfsd_readdirres),
807 .pc_cachetype = RC_NOCACHE,
808 .pc_name = "READDIR",
811 .pc_func = nfsd_proc_statfs,
812 .pc_decode = nfssvc_decode_fhandleargs,
813 .pc_encode = nfssvc_encode_statfsres,
814 .pc_argsize = sizeof(struct nfsd_fhandle),
815 .pc_ressize = sizeof(struct nfsd_statfsres),
816 .pc_cachetype = RC_NOCACHE,
817 .pc_xdrressize = ST+5,
823 static unsigned int nfsd_count2[ARRAY_SIZE(nfsd_procedures2)];
824 const struct svc_version nfsd_version2 = {
827 .vs_proc = nfsd_procedures2,
828 .vs_count = nfsd_count2,
829 .vs_dispatch = nfsd_dispatch,
830 .vs_xdrsize = NFS2_SVC_XDRSIZE,
834 * Map errnos to NFS errnos.
844 { nfserr_perm, -EPERM },
845 { nfserr_noent, -ENOENT },
847 { nfserr_nxio, -ENXIO },
848 { nfserr_fbig, -E2BIG },
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, -EUCLEAN },
878 { nfserr_perm, -ENOKEY },
879 { nfserr_no_grace, -ENOGRACE},
883 for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) {
884 if (nfs_errtbl[i].syserr == errno)
885 return nfs_errtbl[i].nfserr;
887 WARN_ONCE(1, "nfsd: non-standard errno: %d\n", errno);