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(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_readlinkargs
*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
->status
= nfsd_readlink(rqstp
, &argp
->fh
, argp
->buffer
, &resp
->len
);
166 * Read a portion of a file.
167 * N.B. After this call resp->fh needs an fh_put
170 nfsd_proc_read(struct svc_rqst
*rqstp
)
172 struct nfsd_readargs
*argp
= rqstp
->rq_argp
;
173 struct nfsd_readres
*resp
= rqstp
->rq_resp
;
176 dprintk("nfsd: READ %s %d bytes at %d\n",
177 SVCFH_fmt(&argp
->fh
),
178 argp
->count
, argp
->offset
);
180 /* Obtain buffer pointer for payload. 19 is 1 word for
181 * status, 17 words for fattr, and 1 word for the byte count.
184 if (NFSSVC_MAXBLKSIZE_V2
< argp
->count
) {
185 char buf
[RPC_MAX_ADDRBUFLEN
];
187 "oversized read request from %s (%d bytes)\n",
188 svc_print_addr(rqstp
, buf
, sizeof(buf
)),
190 argp
->count
= NFSSVC_MAXBLKSIZE_V2
;
192 svc_reserve_auth(rqstp
, (19<<2) + argp
->count
+ 4);
194 resp
->count
= argp
->count
;
195 resp
->status
= nfsd_read(rqstp
, fh_copy(&resp
->fh
, &argp
->fh
),
197 rqstp
->rq_vec
, argp
->vlen
,
200 if (resp
->status
== nfs_ok
)
201 resp
->status
= fh_getattr(&resp
->fh
, &resp
->stat
);
202 else if (resp
->status
== nfserr_jukebox
)
203 return rpc_drop_reply
;
209 nfsd_proc_writecache(struct svc_rqst
*rqstp
)
215 * Write data to a file
216 * N.B. After this call resp->fh needs an fh_put
219 nfsd_proc_write(struct svc_rqst
*rqstp
)
221 struct nfsd_writeargs
*argp
= rqstp
->rq_argp
;
222 struct nfsd_attrstat
*resp
= rqstp
->rq_resp
;
223 unsigned long cnt
= argp
->len
;
226 dprintk("nfsd: WRITE %s %d bytes at %d\n",
227 SVCFH_fmt(&argp
->fh
),
228 argp
->len
, argp
->offset
);
230 nvecs
= svc_fill_write_vector(rqstp
, rqstp
->rq_arg
.pages
,
233 resp
->status
= nfserr_io
;
237 resp
->status
= nfsd_write(rqstp
, fh_copy(&resp
->fh
, &argp
->fh
),
238 argp
->offset
, rqstp
->rq_vec
, nvecs
,
239 &cnt
, NFS_DATA_SYNC
, NULL
);
240 if (resp
->status
== nfs_ok
)
241 resp
->status
= fh_getattr(&resp
->fh
, &resp
->stat
);
242 else if (resp
->status
== nfserr_jukebox
)
243 return rpc_drop_reply
;
249 * CREATE processing is complicated. The keyword here is `overloaded.'
250 * The parent directory is kept locked between the check for existence
251 * and the actual create() call in compliance with VFS protocols.
252 * N.B. After this call _both_ argp->fh and resp->fh need an fh_put
255 nfsd_proc_create(struct svc_rqst
*rqstp
)
257 struct nfsd_createargs
*argp
= rqstp
->rq_argp
;
258 struct nfsd_diropres
*resp
= rqstp
->rq_resp
;
259 svc_fh
*dirfhp
= &argp
->fh
;
260 svc_fh
*newfhp
= &resp
->fh
;
261 struct iattr
*attr
= &argp
->attrs
;
263 struct dentry
*dchild
;
266 dev_t rdev
= 0, wanted
= new_decode_dev(attr
->ia_size
);
268 dprintk("nfsd: CREATE %s %.*s\n",
269 SVCFH_fmt(dirfhp
), argp
->len
, argp
->name
);
271 /* First verify the parent file handle */
272 resp
->status
= fh_verify(rqstp
, dirfhp
, S_IFDIR
, NFSD_MAY_EXEC
);
273 if (resp
->status
!= nfs_ok
)
274 goto done
; /* must fh_put dirfhp even on error */
276 /* Check for NFSD_MAY_WRITE in nfsd_create if necessary */
278 resp
->status
= nfserr_exist
;
279 if (isdotent(argp
->name
, argp
->len
))
281 hosterr
= fh_want_write(dirfhp
);
283 resp
->status
= nfserrno(hosterr
);
287 fh_lock_nested(dirfhp
, I_MUTEX_PARENT
);
288 dchild
= lookup_one_len(argp
->name
, dirfhp
->fh_dentry
, argp
->len
);
289 if (IS_ERR(dchild
)) {
290 resp
->status
= nfserrno(PTR_ERR(dchild
));
293 fh_init(newfhp
, NFS_FHSIZE
);
294 resp
->status
= fh_compose(newfhp
, dirfhp
->fh_export
, dchild
, dirfhp
);
295 if (!resp
->status
&& d_really_is_negative(dchild
))
296 resp
->status
= nfserr_noent
;
299 if (resp
->status
!= nfserr_noent
)
302 * If the new file handle wasn't verified, we can't tell
303 * whether the file exists or not. Time to bail ...
305 resp
->status
= nfserr_acces
;
306 if (!newfhp
->fh_dentry
) {
308 "nfsd_proc_create: file handle not verified\n");
313 inode
= d_inode(newfhp
->fh_dentry
);
315 /* Unfudge the mode bits */
316 if (attr
->ia_valid
& ATTR_MODE
) {
317 type
= attr
->ia_mode
& S_IFMT
;
318 mode
= attr
->ia_mode
& ~S_IFMT
;
320 /* no type, so if target exists, assume same as that,
321 * else assume a file */
323 type
= inode
->i_mode
& S_IFMT
;
327 /* reserve rdev for later checking */
328 rdev
= inode
->i_rdev
;
329 attr
->ia_valid
|= ATTR_SIZE
;
333 /* this is probably a permission check..
334 * at least IRIX implements perm checking on
335 * echo thing > device-special-file-or-pipe
336 * by doing a CREATE with type==0
338 resp
->status
= nfsd_permission(rqstp
,
341 NFSD_MAY_WRITE
|NFSD_MAY_LOCAL_ACCESS
);
342 if (resp
->status
&& resp
->status
!= nfserr_rofs
)
349 type
= inode
->i_mode
& S_IFMT
;
350 mode
= inode
->i_mode
& ~S_IFMT
;
356 attr
->ia_valid
|= ATTR_MODE
;
357 attr
->ia_mode
= mode
;
359 /* Special treatment for non-regular files according to the
360 * gospel of sun micro
362 if (type
!= S_IFREG
) {
363 if (type
!= S_IFBLK
&& type
!= S_IFCHR
) {
365 } else if (type
== S_IFCHR
&& !(attr
->ia_valid
& ATTR_SIZE
)) {
366 /* If you think you've seen the worst, grok this. */
369 /* Okay, char or block special */
374 /* we've used the SIZE information, so discard it */
375 attr
->ia_valid
&= ~ATTR_SIZE
;
377 /* Make sure the type and device matches */
378 resp
->status
= nfserr_exist
;
379 if (inode
&& type
!= (inode
->i_mode
& S_IFMT
))
383 resp
->status
= nfs_ok
;
385 /* File doesn't exist. Create it and set attrs */
386 resp
->status
= nfsd_create_locked(rqstp
, dirfhp
, argp
->name
,
387 argp
->len
, attr
, type
, rdev
,
389 } else if (type
== S_IFREG
) {
390 dprintk("nfsd: existing %s, valid=%x, size=%ld\n",
391 argp
->name
, attr
->ia_valid
, (long) attr
->ia_size
);
392 /* File already exists. We ignore all attributes except
393 * size, so that creat() behaves exactly like
394 * open(..., O_CREAT|O_TRUNC|O_WRONLY).
396 attr
->ia_valid
&= ATTR_SIZE
;
398 resp
->status
= nfsd_setattr(rqstp
, newfhp
, attr
, 0,
403 /* We don't really need to unlock, as fh_put does it. */
405 fh_drop_write(dirfhp
);
408 if (resp
->status
!= nfs_ok
)
410 resp
->status
= fh_getattr(&resp
->fh
, &resp
->stat
);
416 nfsd_proc_remove(struct svc_rqst
*rqstp
)
418 struct nfsd_diropargs
*argp
= rqstp
->rq_argp
;
419 struct nfsd_stat
*resp
= rqstp
->rq_resp
;
421 dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp
->fh
),
422 argp
->len
, argp
->name
);
424 /* Unlink. -SIFDIR means file must not be a directory */
425 resp
->status
= nfsd_unlink(rqstp
, &argp
->fh
, -S_IFDIR
,
426 argp
->name
, argp
->len
);
432 nfsd_proc_rename(struct svc_rqst
*rqstp
)
434 struct nfsd_renameargs
*argp
= rqstp
->rq_argp
;
435 struct nfsd_stat
*resp
= rqstp
->rq_resp
;
437 dprintk("nfsd: RENAME %s %.*s -> \n",
438 SVCFH_fmt(&argp
->ffh
), argp
->flen
, argp
->fname
);
439 dprintk("nfsd: -> %s %.*s\n",
440 SVCFH_fmt(&argp
->tfh
), argp
->tlen
, argp
->tname
);
442 resp
->status
= nfsd_rename(rqstp
, &argp
->ffh
, argp
->fname
, argp
->flen
,
443 &argp
->tfh
, argp
->tname
, argp
->tlen
);
450 nfsd_proc_link(struct svc_rqst
*rqstp
)
452 struct nfsd_linkargs
*argp
= rqstp
->rq_argp
;
453 struct nfsd_stat
*resp
= rqstp
->rq_resp
;
455 dprintk("nfsd: LINK %s ->\n",
456 SVCFH_fmt(&argp
->ffh
));
457 dprintk("nfsd: %s %.*s\n",
458 SVCFH_fmt(&argp
->tfh
),
462 resp
->status
= nfsd_link(rqstp
, &argp
->tfh
, argp
->tname
, argp
->tlen
,
470 nfsd_proc_symlink(struct svc_rqst
*rqstp
)
472 struct nfsd_symlinkargs
*argp
= rqstp
->rq_argp
;
473 struct nfsd_stat
*resp
= rqstp
->rq_resp
;
476 if (argp
->tlen
> NFS_MAXPATHLEN
) {
477 resp
->status
= nfserr_nametoolong
;
481 argp
->tname
= svc_fill_symlink_pathname(rqstp
, &argp
->first
,
482 page_address(rqstp
->rq_arg
.pages
[0]),
484 if (IS_ERR(argp
->tname
)) {
485 resp
->status
= nfserrno(PTR_ERR(argp
->tname
));
489 dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n",
490 SVCFH_fmt(&argp
->ffh
), argp
->flen
, argp
->fname
,
491 argp
->tlen
, argp
->tname
);
493 fh_init(&newfh
, NFS_FHSIZE
);
494 resp
->status
= nfsd_symlink(rqstp
, &argp
->ffh
, argp
->fname
, argp
->flen
,
495 argp
->tname
, &newfh
);
505 * Make directory. This operation is not idempotent.
506 * N.B. After this call resp->fh needs an fh_put
509 nfsd_proc_mkdir(struct svc_rqst
*rqstp
)
511 struct nfsd_createargs
*argp
= rqstp
->rq_argp
;
512 struct nfsd_diropres
*resp
= rqstp
->rq_resp
;
514 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp
->fh
), argp
->len
, argp
->name
);
516 if (resp
->fh
.fh_dentry
) {
518 "nfsd_proc_mkdir: response already verified??\n");
521 argp
->attrs
.ia_valid
&= ~ATTR_SIZE
;
522 fh_init(&resp
->fh
, NFS_FHSIZE
);
523 resp
->status
= nfsd_create(rqstp
, &argp
->fh
, argp
->name
, argp
->len
,
524 &argp
->attrs
, S_IFDIR
, 0, &resp
->fh
);
526 if (resp
->status
!= nfs_ok
)
529 resp
->status
= fh_getattr(&resp
->fh
, &resp
->stat
);
538 nfsd_proc_rmdir(struct svc_rqst
*rqstp
)
540 struct nfsd_diropargs
*argp
= rqstp
->rq_argp
;
541 struct nfsd_stat
*resp
= rqstp
->rq_resp
;
543 dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp
->fh
), argp
->len
, argp
->name
);
545 resp
->status
= nfsd_unlink(rqstp
, &argp
->fh
, S_IFDIR
,
546 argp
->name
, argp
->len
);
552 * Read a portion of a directory.
555 nfsd_proc_readdir(struct svc_rqst
*rqstp
)
557 struct nfsd_readdirargs
*argp
= rqstp
->rq_argp
;
558 struct nfsd_readdirres
*resp
= rqstp
->rq_resp
;
562 dprintk("nfsd: READDIR %s %d bytes at %d\n",
563 SVCFH_fmt(&argp
->fh
),
564 argp
->count
, argp
->cookie
);
566 /* Shrink to the client read size */
567 count
= (argp
->count
>> 2) - 2;
569 /* Make sure we've room for the NULL ptr & eof flag */
574 resp
->buffer
= argp
->buffer
;
576 resp
->buflen
= count
;
577 resp
->common
.err
= nfs_ok
;
578 /* Read directory and encode entries on the fly */
579 offset
= argp
->cookie
;
580 resp
->status
= nfsd_readdir(rqstp
, &argp
->fh
, &offset
,
581 &resp
->common
, nfssvc_encode_entry
);
583 resp
->count
= resp
->buffer
- argp
->buffer
;
585 *resp
->offset
= htonl(offset
);
592 * Get file system info
595 nfsd_proc_statfs(struct svc_rqst
*rqstp
)
597 struct nfsd_fhandle
*argp
= rqstp
->rq_argp
;
598 struct nfsd_statfsres
*resp
= rqstp
->rq_resp
;
600 dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp
->fh
));
602 resp
->status
= nfsd_statfs(rqstp
, &argp
->fh
, &resp
->stats
,
603 NFSD_MAY_BYPASS_GSS_ON_ROOT
);
609 * NFSv2 Server procedures.
610 * Only the results of non-idempotent operations are cached.
613 #define ST 1 /* status */
614 #define FH 8 /* filehandle */
615 #define AT 18 /* attributes */
617 static const struct svc_procedure nfsd_procedures2
[18] = {
619 .pc_func
= nfsd_proc_null
,
620 .pc_decode
= nfssvc_decode_voidarg
,
621 .pc_encode
= nfssvc_encode_voidres
,
622 .pc_argsize
= sizeof(struct nfsd_voidargs
),
623 .pc_ressize
= sizeof(struct nfsd_voidres
),
624 .pc_cachetype
= RC_NOCACHE
,
627 [NFSPROC_GETATTR
] = {
628 .pc_func
= nfsd_proc_getattr
,
629 .pc_decode
= nfssvc_decode_fhandle
,
630 .pc_encode
= nfssvc_encode_attrstat
,
631 .pc_release
= nfssvc_release_attrstat
,
632 .pc_argsize
= sizeof(struct nfsd_fhandle
),
633 .pc_ressize
= sizeof(struct nfsd_attrstat
),
634 .pc_cachetype
= RC_NOCACHE
,
635 .pc_xdrressize
= ST
+AT
,
637 [NFSPROC_SETATTR
] = {
638 .pc_func
= nfsd_proc_setattr
,
639 .pc_decode
= nfssvc_decode_sattrargs
,
640 .pc_encode
= nfssvc_encode_attrstat
,
641 .pc_release
= nfssvc_release_attrstat
,
642 .pc_argsize
= sizeof(struct nfsd_sattrargs
),
643 .pc_ressize
= sizeof(struct nfsd_attrstat
),
644 .pc_cachetype
= RC_REPLBUFF
,
645 .pc_xdrressize
= ST
+AT
,
648 .pc_func
= nfsd_proc_root
,
649 .pc_decode
= nfssvc_decode_voidarg
,
650 .pc_encode
= nfssvc_encode_voidres
,
651 .pc_argsize
= sizeof(struct nfsd_voidargs
),
652 .pc_ressize
= sizeof(struct nfsd_voidres
),
653 .pc_cachetype
= RC_NOCACHE
,
657 .pc_func
= nfsd_proc_lookup
,
658 .pc_decode
= nfssvc_decode_diropargs
,
659 .pc_encode
= nfssvc_encode_diropres
,
660 .pc_release
= nfssvc_release_diropres
,
661 .pc_argsize
= sizeof(struct nfsd_diropargs
),
662 .pc_ressize
= sizeof(struct nfsd_diropres
),
663 .pc_cachetype
= RC_NOCACHE
,
664 .pc_xdrressize
= ST
+FH
+AT
,
666 [NFSPROC_READLINK
] = {
667 .pc_func
= nfsd_proc_readlink
,
668 .pc_decode
= nfssvc_decode_readlinkargs
,
669 .pc_encode
= nfssvc_encode_readlinkres
,
670 .pc_argsize
= sizeof(struct nfsd_readlinkargs
),
671 .pc_ressize
= sizeof(struct nfsd_readlinkres
),
672 .pc_cachetype
= RC_NOCACHE
,
673 .pc_xdrressize
= ST
+1+NFS_MAXPATHLEN
/4,
676 .pc_func
= nfsd_proc_read
,
677 .pc_decode
= nfssvc_decode_readargs
,
678 .pc_encode
= nfssvc_encode_readres
,
679 .pc_release
= nfssvc_release_readres
,
680 .pc_argsize
= sizeof(struct nfsd_readargs
),
681 .pc_ressize
= sizeof(struct nfsd_readres
),
682 .pc_cachetype
= RC_NOCACHE
,
683 .pc_xdrressize
= ST
+AT
+1+NFSSVC_MAXBLKSIZE_V2
/4,
685 [NFSPROC_WRITECACHE
] = {
686 .pc_func
= nfsd_proc_writecache
,
687 .pc_decode
= nfssvc_decode_voidarg
,
688 .pc_encode
= nfssvc_encode_voidres
,
689 .pc_argsize
= sizeof(struct nfsd_voidargs
),
690 .pc_ressize
= sizeof(struct nfsd_voidres
),
691 .pc_cachetype
= RC_NOCACHE
,
695 .pc_func
= nfsd_proc_write
,
696 .pc_decode
= nfssvc_decode_writeargs
,
697 .pc_encode
= nfssvc_encode_attrstat
,
698 .pc_release
= nfssvc_release_attrstat
,
699 .pc_argsize
= sizeof(struct nfsd_writeargs
),
700 .pc_ressize
= sizeof(struct nfsd_attrstat
),
701 .pc_cachetype
= RC_REPLBUFF
,
702 .pc_xdrressize
= ST
+AT
,
705 .pc_func
= nfsd_proc_create
,
706 .pc_decode
= nfssvc_decode_createargs
,
707 .pc_encode
= nfssvc_encode_diropres
,
708 .pc_release
= nfssvc_release_diropres
,
709 .pc_argsize
= sizeof(struct nfsd_createargs
),
710 .pc_ressize
= sizeof(struct nfsd_diropres
),
711 .pc_cachetype
= RC_REPLBUFF
,
712 .pc_xdrressize
= ST
+FH
+AT
,
715 .pc_func
= nfsd_proc_remove
,
716 .pc_decode
= nfssvc_decode_diropargs
,
717 .pc_encode
= nfssvc_encode_stat
,
718 .pc_argsize
= sizeof(struct nfsd_diropargs
),
719 .pc_ressize
= sizeof(struct nfsd_stat
),
720 .pc_cachetype
= RC_REPLSTAT
,
724 .pc_func
= nfsd_proc_rename
,
725 .pc_decode
= nfssvc_decode_renameargs
,
726 .pc_encode
= nfssvc_encode_stat
,
727 .pc_argsize
= sizeof(struct nfsd_renameargs
),
728 .pc_ressize
= sizeof(struct nfsd_stat
),
729 .pc_cachetype
= RC_REPLSTAT
,
733 .pc_func
= nfsd_proc_link
,
734 .pc_decode
= nfssvc_decode_linkargs
,
735 .pc_encode
= nfssvc_encode_stat
,
736 .pc_argsize
= sizeof(struct nfsd_linkargs
),
737 .pc_ressize
= sizeof(struct nfsd_stat
),
738 .pc_cachetype
= RC_REPLSTAT
,
741 [NFSPROC_SYMLINK
] = {
742 .pc_func
= nfsd_proc_symlink
,
743 .pc_decode
= nfssvc_decode_symlinkargs
,
744 .pc_encode
= nfssvc_encode_stat
,
745 .pc_argsize
= sizeof(struct nfsd_symlinkargs
),
746 .pc_ressize
= sizeof(struct nfsd_stat
),
747 .pc_cachetype
= RC_REPLSTAT
,
751 .pc_func
= nfsd_proc_mkdir
,
752 .pc_decode
= nfssvc_decode_createargs
,
753 .pc_encode
= nfssvc_encode_diropres
,
754 .pc_release
= nfssvc_release_diropres
,
755 .pc_argsize
= sizeof(struct nfsd_createargs
),
756 .pc_ressize
= sizeof(struct nfsd_diropres
),
757 .pc_cachetype
= RC_REPLBUFF
,
758 .pc_xdrressize
= ST
+FH
+AT
,
761 .pc_func
= nfsd_proc_rmdir
,
762 .pc_decode
= nfssvc_decode_diropargs
,
763 .pc_encode
= nfssvc_encode_stat
,
764 .pc_argsize
= sizeof(struct nfsd_diropargs
),
765 .pc_ressize
= sizeof(struct nfsd_stat
),
766 .pc_cachetype
= RC_REPLSTAT
,
769 [NFSPROC_READDIR
] = {
770 .pc_func
= nfsd_proc_readdir
,
771 .pc_decode
= nfssvc_decode_readdirargs
,
772 .pc_encode
= nfssvc_encode_readdirres
,
773 .pc_argsize
= sizeof(struct nfsd_readdirargs
),
774 .pc_ressize
= sizeof(struct nfsd_readdirres
),
775 .pc_cachetype
= RC_NOCACHE
,
778 .pc_func
= nfsd_proc_statfs
,
779 .pc_decode
= nfssvc_decode_fhandle
,
780 .pc_encode
= nfssvc_encode_statfsres
,
781 .pc_argsize
= sizeof(struct nfsd_fhandle
),
782 .pc_ressize
= sizeof(struct nfsd_statfsres
),
783 .pc_cachetype
= RC_NOCACHE
,
784 .pc_xdrressize
= ST
+5,
789 static unsigned int nfsd_count2
[ARRAY_SIZE(nfsd_procedures2
)];
790 const struct svc_version nfsd_version2
= {
793 .vs_proc
= nfsd_procedures2
,
794 .vs_count
= nfsd_count2
,
795 .vs_dispatch
= nfsd_dispatch
,
796 .vs_xdrsize
= NFS2_SVC_XDRSIZE
,
800 * Map errnos to NFS errnos.
810 { nfserr_perm
, -EPERM
},
811 { nfserr_noent
, -ENOENT
},
813 { nfserr_nxio
, -ENXIO
},
814 { nfserr_fbig
, -E2BIG
},
815 { nfserr_acces
, -EACCES
},
816 { nfserr_exist
, -EEXIST
},
817 { nfserr_xdev
, -EXDEV
},
818 { nfserr_mlink
, -EMLINK
},
819 { nfserr_nodev
, -ENODEV
},
820 { nfserr_notdir
, -ENOTDIR
},
821 { nfserr_isdir
, -EISDIR
},
822 { nfserr_inval
, -EINVAL
},
823 { nfserr_fbig
, -EFBIG
},
824 { nfserr_nospc
, -ENOSPC
},
825 { nfserr_rofs
, -EROFS
},
826 { nfserr_mlink
, -EMLINK
},
827 { nfserr_nametoolong
, -ENAMETOOLONG
},
828 { nfserr_notempty
, -ENOTEMPTY
},
830 { nfserr_dquot
, -EDQUOT
},
832 { nfserr_stale
, -ESTALE
},
833 { nfserr_jukebox
, -ETIMEDOUT
},
834 { nfserr_jukebox
, -ERESTARTSYS
},
835 { nfserr_jukebox
, -EAGAIN
},
836 { nfserr_jukebox
, -EWOULDBLOCK
},
837 { nfserr_jukebox
, -ENOMEM
},
838 { nfserr_io
, -ETXTBSY
},
839 { nfserr_notsupp
, -EOPNOTSUPP
},
840 { nfserr_toosmall
, -ETOOSMALL
},
841 { nfserr_serverfault
, -ESERVERFAULT
},
842 { nfserr_serverfault
, -ENFILE
},
843 { nfserr_io
, -EUCLEAN
},
844 { nfserr_perm
, -ENOKEY
},
848 for (i
= 0; i
< ARRAY_SIZE(nfs_errtbl
); i
++) {
849 if (nfs_errtbl
[i
].syserr
== errno
)
850 return nfs_errtbl
[i
].nfserr
;
852 WARN_ONCE(1, "nfsd: non-standard errno: %d\n", errno
);