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
;
184 dprintk("nfsd: READ %s %d bytes at %d\n",
185 SVCFH_fmt(&argp
->fh
),
186 argp
->count
, argp
->offset
);
188 /* Obtain buffer pointer for payload. 19 is 1 word for
189 * status, 17 words for fattr, and 1 word for the byte count.
192 if (NFSSVC_MAXBLKSIZE_V2
< argp
->count
) {
193 char buf
[RPC_MAX_ADDRBUFLEN
];
195 "oversized read request from %s (%d bytes)\n",
196 svc_print_addr(rqstp
, buf
, sizeof(buf
)),
198 argp
->count
= NFSSVC_MAXBLKSIZE_V2
;
200 svc_reserve_auth(rqstp
, (19<<2) + argp
->count
+ 4);
202 resp
->count
= argp
->count
;
203 nfserr
= nfsd_read(rqstp
, fh_copy(&resp
->fh
, &argp
->fh
),
205 rqstp
->rq_vec
, argp
->vlen
,
209 if (nfserr
) return nfserr
;
210 return fh_getattr(&resp
->fh
, &resp
->stat
);
215 nfsd_proc_writecache(struct svc_rqst
*rqstp
)
221 * Write data to a file
222 * N.B. After this call resp->fh needs an fh_put
225 nfsd_proc_write(struct svc_rqst
*rqstp
)
227 struct nfsd_writeargs
*argp
= rqstp
->rq_argp
;
228 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
, rqstp
->rq_arg
.pages
,
241 nfserr
= nfsd_write(rqstp
, fh_copy(&resp
->fh
, &argp
->fh
),
242 argp
->offset
, rqstp
->rq_vec
, nvecs
,
243 &cnt
, NFS_DATA_SYNC
);
244 return nfsd_return_attrs(nfserr
, resp
);
248 * CREATE processing is complicated. The keyword here is `overloaded.'
249 * The parent directory is kept locked between the check for existence
250 * and the actual create() call in compliance with VFS protocols.
251 * N.B. After this call _both_ argp->fh and resp->fh need an fh_put
254 nfsd_proc_create(struct svc_rqst
*rqstp
)
256 struct nfsd_createargs
*argp
= rqstp
->rq_argp
;
257 struct nfsd_diropres
*resp
= rqstp
->rq_resp
;
258 svc_fh
*dirfhp
= &argp
->fh
;
259 svc_fh
*newfhp
= &resp
->fh
;
260 struct iattr
*attr
= &argp
->attrs
;
262 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 nfserr
= fh_verify(rqstp
, dirfhp
, S_IFDIR
, NFSD_MAY_EXEC
);
274 goto done
; /* must fh_put dirfhp even on error */
276 /* Check for NFSD_MAY_WRITE in nfsd_create if necessary */
278 nfserr
= nfserr_exist
;
279 if (isdotent(argp
->name
, argp
->len
))
281 hosterr
= fh_want_write(dirfhp
);
283 nfserr
= 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 nfserr
= nfserrno(PTR_ERR(dchild
));
293 fh_init(newfhp
, NFS_FHSIZE
);
294 nfserr
= fh_compose(newfhp
, dirfhp
->fh_export
, dchild
, dirfhp
);
295 if (!nfserr
&& d_really_is_negative(dchild
))
296 nfserr
= nfserr_noent
;
299 if (nfserr
!= 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 nfserr
= 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 nfserr
= nfsd_permission(rqstp
,
341 NFSD_MAY_WRITE
|NFSD_MAY_LOCAL_ACCESS
);
342 if (nfserr
&& nfserr
!= 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 nfserr
= nfserr_exist
;
379 if (inode
&& type
!= (inode
->i_mode
& S_IFMT
))
385 /* File doesn't exist. Create it and set attrs */
386 nfserr
= nfsd_create_locked(rqstp
, dirfhp
, argp
->name
,
387 argp
->len
, attr
, type
, rdev
, newfhp
);
388 } else if (type
== S_IFREG
) {
389 dprintk("nfsd: existing %s, valid=%x, size=%ld\n",
390 argp
->name
, attr
->ia_valid
, (long) attr
->ia_size
);
391 /* File already exists. We ignore all attributes except
392 * size, so that creat() behaves exactly like
393 * open(..., O_CREAT|O_TRUNC|O_WRONLY).
395 attr
->ia_valid
&= ATTR_SIZE
;
397 nfserr
= nfsd_setattr(rqstp
, newfhp
, attr
, 0, (time_t)0);
401 /* We don't really need to unlock, as fh_put does it. */
403 fh_drop_write(dirfhp
);
406 return nfsd_return_dirop(nfserr
, resp
);
410 nfsd_proc_remove(struct svc_rqst
*rqstp
)
412 struct nfsd_diropargs
*argp
= rqstp
->rq_argp
;
415 dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp
->fh
),
416 argp
->len
, argp
->name
);
418 /* Unlink. -SIFDIR means file must not be a directory */
419 nfserr
= nfsd_unlink(rqstp
, &argp
->fh
, -S_IFDIR
, argp
->name
, argp
->len
);
425 nfsd_proc_rename(struct svc_rqst
*rqstp
)
427 struct nfsd_renameargs
*argp
= rqstp
->rq_argp
;
430 dprintk("nfsd: RENAME %s %.*s -> \n",
431 SVCFH_fmt(&argp
->ffh
), argp
->flen
, argp
->fname
);
432 dprintk("nfsd: -> %s %.*s\n",
433 SVCFH_fmt(&argp
->tfh
), argp
->tlen
, argp
->tname
);
435 nfserr
= nfsd_rename(rqstp
, &argp
->ffh
, argp
->fname
, argp
->flen
,
436 &argp
->tfh
, argp
->tname
, argp
->tlen
);
443 nfsd_proc_link(struct svc_rqst
*rqstp
)
445 struct nfsd_linkargs
*argp
= rqstp
->rq_argp
;
448 dprintk("nfsd: LINK %s ->\n",
449 SVCFH_fmt(&argp
->ffh
));
450 dprintk("nfsd: %s %.*s\n",
451 SVCFH_fmt(&argp
->tfh
),
455 nfserr
= nfsd_link(rqstp
, &argp
->tfh
, argp
->tname
, argp
->tlen
,
463 nfsd_proc_symlink(struct svc_rqst
*rqstp
)
465 struct nfsd_symlinkargs
*argp
= rqstp
->rq_argp
;
469 if (argp
->tlen
> NFS_MAXPATHLEN
)
470 return nfserr_nametoolong
;
472 argp
->tname
= svc_fill_symlink_pathname(rqstp
, &argp
->first
,
473 page_address(rqstp
->rq_arg
.pages
[0]),
475 if (IS_ERR(argp
->tname
))
476 return nfserrno(PTR_ERR(argp
->tname
));
478 dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n",
479 SVCFH_fmt(&argp
->ffh
), argp
->flen
, argp
->fname
,
480 argp
->tlen
, argp
->tname
);
482 fh_init(&newfh
, NFS_FHSIZE
);
483 nfserr
= nfsd_symlink(rqstp
, &argp
->ffh
, argp
->fname
, argp
->flen
,
484 argp
->tname
, &newfh
);
493 * Make directory. This operation is not idempotent.
494 * N.B. After this call resp->fh needs an fh_put
497 nfsd_proc_mkdir(struct svc_rqst
*rqstp
)
499 struct nfsd_createargs
*argp
= rqstp
->rq_argp
;
500 struct nfsd_diropres
*resp
= rqstp
->rq_resp
;
503 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp
->fh
), argp
->len
, argp
->name
);
505 if (resp
->fh
.fh_dentry
) {
507 "nfsd_proc_mkdir: response already verified??\n");
510 argp
->attrs
.ia_valid
&= ~ATTR_SIZE
;
511 fh_init(&resp
->fh
, NFS_FHSIZE
);
512 nfserr
= nfsd_create(rqstp
, &argp
->fh
, argp
->name
, argp
->len
,
513 &argp
->attrs
, S_IFDIR
, 0, &resp
->fh
);
515 return nfsd_return_dirop(nfserr
, resp
);
522 nfsd_proc_rmdir(struct svc_rqst
*rqstp
)
524 struct nfsd_diropargs
*argp
= rqstp
->rq_argp
;
527 dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp
->fh
), argp
->len
, argp
->name
);
529 nfserr
= nfsd_unlink(rqstp
, &argp
->fh
, S_IFDIR
, argp
->name
, argp
->len
);
535 * Read a portion of a directory.
538 nfsd_proc_readdir(struct svc_rqst
*rqstp
)
540 struct nfsd_readdirargs
*argp
= rqstp
->rq_argp
;
541 struct nfsd_readdirres
*resp
= rqstp
->rq_resp
;
546 dprintk("nfsd: READDIR %s %d bytes at %d\n",
547 SVCFH_fmt(&argp
->fh
),
548 argp
->count
, argp
->cookie
);
550 /* Shrink to the client read size */
551 count
= (argp
->count
>> 2) - 2;
553 /* Make sure we've room for the NULL ptr & eof flag */
558 resp
->buffer
= argp
->buffer
;
560 resp
->buflen
= count
;
561 resp
->common
.err
= nfs_ok
;
562 /* Read directory and encode entries on the fly */
563 offset
= argp
->cookie
;
564 nfserr
= nfsd_readdir(rqstp
, &argp
->fh
, &offset
,
565 &resp
->common
, nfssvc_encode_entry
);
567 resp
->count
= resp
->buffer
- argp
->buffer
;
569 *resp
->offset
= htonl(offset
);
576 * Get file system info
579 nfsd_proc_statfs(struct svc_rqst
*rqstp
)
581 struct nfsd_fhandle
*argp
= rqstp
->rq_argp
;
582 struct nfsd_statfsres
*resp
= rqstp
->rq_resp
;
585 dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp
->fh
));
587 nfserr
= nfsd_statfs(rqstp
, &argp
->fh
, &resp
->stats
,
588 NFSD_MAY_BYPASS_GSS_ON_ROOT
);
594 * NFSv2 Server procedures.
595 * Only the results of non-idempotent operations are cached.
597 struct nfsd_void
{ int dummy
; };
599 #define ST 1 /* status */
600 #define FH 8 /* filehandle */
601 #define AT 18 /* attributes */
603 static const struct svc_procedure nfsd_procedures2
[18] = {
605 .pc_func
= nfsd_proc_null
,
606 .pc_decode
= nfssvc_decode_void
,
607 .pc_encode
= nfssvc_encode_void
,
608 .pc_argsize
= sizeof(struct nfsd_void
),
609 .pc_ressize
= sizeof(struct nfsd_void
),
610 .pc_cachetype
= RC_NOCACHE
,
613 [NFSPROC_GETATTR
] = {
614 .pc_func
= nfsd_proc_getattr
,
615 .pc_decode
= nfssvc_decode_fhandle
,
616 .pc_encode
= nfssvc_encode_attrstat
,
617 .pc_release
= nfssvc_release_fhandle
,
618 .pc_argsize
= sizeof(struct nfsd_fhandle
),
619 .pc_ressize
= sizeof(struct nfsd_attrstat
),
620 .pc_cachetype
= RC_NOCACHE
,
621 .pc_xdrressize
= ST
+AT
,
623 [NFSPROC_SETATTR
] = {
624 .pc_func
= nfsd_proc_setattr
,
625 .pc_decode
= nfssvc_decode_sattrargs
,
626 .pc_encode
= nfssvc_encode_attrstat
,
627 .pc_release
= nfssvc_release_fhandle
,
628 .pc_argsize
= sizeof(struct nfsd_sattrargs
),
629 .pc_ressize
= sizeof(struct nfsd_attrstat
),
630 .pc_cachetype
= RC_REPLBUFF
,
631 .pc_xdrressize
= ST
+AT
,
634 .pc_func
= nfsd_proc_root
,
635 .pc_decode
= nfssvc_decode_void
,
636 .pc_encode
= nfssvc_encode_void
,
637 .pc_argsize
= sizeof(struct nfsd_void
),
638 .pc_ressize
= sizeof(struct nfsd_void
),
639 .pc_cachetype
= RC_NOCACHE
,
643 .pc_func
= nfsd_proc_lookup
,
644 .pc_decode
= nfssvc_decode_diropargs
,
645 .pc_encode
= nfssvc_encode_diropres
,
646 .pc_release
= nfssvc_release_fhandle
,
647 .pc_argsize
= sizeof(struct nfsd_diropargs
),
648 .pc_ressize
= sizeof(struct nfsd_diropres
),
649 .pc_cachetype
= RC_NOCACHE
,
650 .pc_xdrressize
= ST
+FH
+AT
,
652 [NFSPROC_READLINK
] = {
653 .pc_func
= nfsd_proc_readlink
,
654 .pc_decode
= nfssvc_decode_readlinkargs
,
655 .pc_encode
= nfssvc_encode_readlinkres
,
656 .pc_argsize
= sizeof(struct nfsd_readlinkargs
),
657 .pc_ressize
= sizeof(struct nfsd_readlinkres
),
658 .pc_cachetype
= RC_NOCACHE
,
659 .pc_xdrressize
= ST
+1+NFS_MAXPATHLEN
/4,
662 .pc_func
= nfsd_proc_read
,
663 .pc_decode
= nfssvc_decode_readargs
,
664 .pc_encode
= nfssvc_encode_readres
,
665 .pc_release
= nfssvc_release_fhandle
,
666 .pc_argsize
= sizeof(struct nfsd_readargs
),
667 .pc_ressize
= sizeof(struct nfsd_readres
),
668 .pc_cachetype
= RC_NOCACHE
,
669 .pc_xdrressize
= ST
+AT
+1+NFSSVC_MAXBLKSIZE_V2
/4,
671 [NFSPROC_WRITECACHE
] = {
672 .pc_func
= nfsd_proc_writecache
,
673 .pc_decode
= nfssvc_decode_void
,
674 .pc_encode
= nfssvc_encode_void
,
675 .pc_argsize
= sizeof(struct nfsd_void
),
676 .pc_ressize
= sizeof(struct nfsd_void
),
677 .pc_cachetype
= RC_NOCACHE
,
681 .pc_func
= nfsd_proc_write
,
682 .pc_decode
= nfssvc_decode_writeargs
,
683 .pc_encode
= nfssvc_encode_attrstat
,
684 .pc_release
= nfssvc_release_fhandle
,
685 .pc_argsize
= sizeof(struct nfsd_writeargs
),
686 .pc_ressize
= sizeof(struct nfsd_attrstat
),
687 .pc_cachetype
= RC_REPLBUFF
,
688 .pc_xdrressize
= ST
+AT
,
691 .pc_func
= nfsd_proc_create
,
692 .pc_decode
= nfssvc_decode_createargs
,
693 .pc_encode
= nfssvc_encode_diropres
,
694 .pc_release
= nfssvc_release_fhandle
,
695 .pc_argsize
= sizeof(struct nfsd_createargs
),
696 .pc_ressize
= sizeof(struct nfsd_diropres
),
697 .pc_cachetype
= RC_REPLBUFF
,
698 .pc_xdrressize
= ST
+FH
+AT
,
701 .pc_func
= nfsd_proc_remove
,
702 .pc_decode
= nfssvc_decode_diropargs
,
703 .pc_encode
= nfssvc_encode_void
,
704 .pc_argsize
= sizeof(struct nfsd_diropargs
),
705 .pc_ressize
= sizeof(struct nfsd_void
),
706 .pc_cachetype
= RC_REPLSTAT
,
710 .pc_func
= nfsd_proc_rename
,
711 .pc_decode
= nfssvc_decode_renameargs
,
712 .pc_encode
= nfssvc_encode_void
,
713 .pc_argsize
= sizeof(struct nfsd_renameargs
),
714 .pc_ressize
= sizeof(struct nfsd_void
),
715 .pc_cachetype
= RC_REPLSTAT
,
719 .pc_func
= nfsd_proc_link
,
720 .pc_decode
= nfssvc_decode_linkargs
,
721 .pc_encode
= nfssvc_encode_void
,
722 .pc_argsize
= sizeof(struct nfsd_linkargs
),
723 .pc_ressize
= sizeof(struct nfsd_void
),
724 .pc_cachetype
= RC_REPLSTAT
,
727 [NFSPROC_SYMLINK
] = {
728 .pc_func
= nfsd_proc_symlink
,
729 .pc_decode
= nfssvc_decode_symlinkargs
,
730 .pc_encode
= nfssvc_encode_void
,
731 .pc_argsize
= sizeof(struct nfsd_symlinkargs
),
732 .pc_ressize
= sizeof(struct nfsd_void
),
733 .pc_cachetype
= RC_REPLSTAT
,
737 .pc_func
= nfsd_proc_mkdir
,
738 .pc_decode
= nfssvc_decode_createargs
,
739 .pc_encode
= nfssvc_encode_diropres
,
740 .pc_release
= nfssvc_release_fhandle
,
741 .pc_argsize
= sizeof(struct nfsd_createargs
),
742 .pc_ressize
= sizeof(struct nfsd_diropres
),
743 .pc_cachetype
= RC_REPLBUFF
,
744 .pc_xdrressize
= ST
+FH
+AT
,
747 .pc_func
= nfsd_proc_rmdir
,
748 .pc_decode
= nfssvc_decode_diropargs
,
749 .pc_encode
= nfssvc_encode_void
,
750 .pc_argsize
= sizeof(struct nfsd_diropargs
),
751 .pc_ressize
= sizeof(struct nfsd_void
),
752 .pc_cachetype
= RC_REPLSTAT
,
755 [NFSPROC_READDIR
] = {
756 .pc_func
= nfsd_proc_readdir
,
757 .pc_decode
= nfssvc_decode_readdirargs
,
758 .pc_encode
= nfssvc_encode_readdirres
,
759 .pc_argsize
= sizeof(struct nfsd_readdirargs
),
760 .pc_ressize
= sizeof(struct nfsd_readdirres
),
761 .pc_cachetype
= RC_NOCACHE
,
764 .pc_func
= nfsd_proc_statfs
,
765 .pc_decode
= nfssvc_decode_fhandle
,
766 .pc_encode
= nfssvc_encode_statfsres
,
767 .pc_argsize
= sizeof(struct nfsd_fhandle
),
768 .pc_ressize
= sizeof(struct nfsd_statfsres
),
769 .pc_cachetype
= RC_NOCACHE
,
770 .pc_xdrressize
= ST
+5,
775 static unsigned int nfsd_count2
[ARRAY_SIZE(nfsd_procedures2
)];
776 const struct svc_version nfsd_version2
= {
779 .vs_proc
= nfsd_procedures2
,
780 .vs_count
= nfsd_count2
,
781 .vs_dispatch
= nfsd_dispatch
,
782 .vs_xdrsize
= NFS2_SVC_XDRSIZE
,
786 * Map errnos to NFS errnos.
796 { nfserr_perm
, -EPERM
},
797 { nfserr_noent
, -ENOENT
},
799 { nfserr_nxio
, -ENXIO
},
800 { nfserr_fbig
, -E2BIG
},
801 { nfserr_acces
, -EACCES
},
802 { nfserr_exist
, -EEXIST
},
803 { nfserr_xdev
, -EXDEV
},
804 { nfserr_mlink
, -EMLINK
},
805 { nfserr_nodev
, -ENODEV
},
806 { nfserr_notdir
, -ENOTDIR
},
807 { nfserr_isdir
, -EISDIR
},
808 { nfserr_inval
, -EINVAL
},
809 { nfserr_fbig
, -EFBIG
},
810 { nfserr_nospc
, -ENOSPC
},
811 { nfserr_rofs
, -EROFS
},
812 { nfserr_mlink
, -EMLINK
},
813 { nfserr_nametoolong
, -ENAMETOOLONG
},
814 { nfserr_notempty
, -ENOTEMPTY
},
816 { nfserr_dquot
, -EDQUOT
},
818 { nfserr_stale
, -ESTALE
},
819 { nfserr_jukebox
, -ETIMEDOUT
},
820 { nfserr_jukebox
, -ERESTARTSYS
},
821 { nfserr_jukebox
, -EAGAIN
},
822 { nfserr_jukebox
, -EWOULDBLOCK
},
823 { nfserr_jukebox
, -ENOMEM
},
824 { nfserr_io
, -ETXTBSY
},
825 { nfserr_notsupp
, -EOPNOTSUPP
},
826 { nfserr_toosmall
, -ETOOSMALL
},
827 { nfserr_serverfault
, -ESERVERFAULT
},
828 { nfserr_serverfault
, -ENFILE
},
829 { nfserr_io
, -EUCLEAN
},
830 { nfserr_perm
, -ENOKEY
},
834 for (i
= 0; i
< ARRAY_SIZE(nfs_errtbl
); i
++) {
835 if (nfs_errtbl
[i
].syserr
== errno
)
836 return nfs_errtbl
[i
].nfserr
;
838 WARN_ONCE(1, "nfsd: non-standard errno: %d\n", errno
);