2 * nfsproc2.c Process version 2 NFS requests.
3 * linux/fs/nfsd/nfs2proc.c
5 * Process version 2 NFS requests.
7 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
10 #include <linux/linkage.h>
11 #include <linux/time.h>
12 #include <linux/errno.h>
14 #include <linux/stat.h>
15 #include <linux/fcntl.h>
16 #include <linux/net.h>
18 #include <linux/namei.h>
19 #include <linux/unistd.h>
20 #include <linux/slab.h>
22 #include <linux/sunrpc/clnt.h>
23 #include <linux/sunrpc/svc.h>
24 #include <linux/nfsd/nfsd.h>
25 #include <linux/nfsd/cache.h>
26 #include <linux/nfsd/xdr.h>
29 typedef struct svc_rqst svc_rqst
;
30 typedef struct svc_buf svc_buf
;
32 #define NFSDDBG_FACILITY NFSDDBG_PROC
36 nfsd_proc_null(struct svc_rqst
*rqstp
, void *argp
, void *resp
)
42 nfsd_return_attrs(__be32 err
, struct nfsd_attrstat
*resp
)
45 return nfserrno(vfs_getattr(resp
->fh
.fh_export
->ex_path
.mnt
,
50 nfsd_return_dirop(__be32 err
, struct nfsd_diropres
*resp
)
53 return nfserrno(vfs_getattr(resp
->fh
.fh_export
->ex_path
.mnt
,
58 * Get a file's attributes
59 * N.B. After this call resp->fh needs an fh_put
62 nfsd_proc_getattr(struct svc_rqst
*rqstp
, struct nfsd_fhandle
*argp
,
63 struct nfsd_attrstat
*resp
)
66 dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp
->fh
));
68 fh_copy(&resp
->fh
, &argp
->fh
);
69 nfserr
= fh_verify(rqstp
, &resp
->fh
, 0,
70 NFSD_MAY_NOP
| NFSD_MAY_BYPASS_GSS_ON_ROOT
);
71 return nfsd_return_attrs(nfserr
, resp
);
75 * Set a file's attributes
76 * N.B. After this call resp->fh needs an fh_put
79 nfsd_proc_setattr(struct svc_rqst
*rqstp
, struct nfsd_sattrargs
*argp
,
80 struct nfsd_attrstat
*resp
)
83 dprintk("nfsd: SETATTR %s, valid=%x, size=%ld\n",
85 argp
->attrs
.ia_valid
, (long) argp
->attrs
.ia_size
);
87 fh_copy(&resp
->fh
, &argp
->fh
);
88 nfserr
= nfsd_setattr(rqstp
, &resp
->fh
, &argp
->attrs
,0, (time_t)0);
89 return nfsd_return_attrs(nfserr
, resp
);
93 * Look up a path name component
94 * Note: the dentry in the resp->fh may be negative if the file
96 * N.B. After this call resp->fh needs an fh_put
99 nfsd_proc_lookup(struct svc_rqst
*rqstp
, struct nfsd_diropargs
*argp
,
100 struct nfsd_diropres
*resp
)
104 dprintk("nfsd: LOOKUP %s %.*s\n",
105 SVCFH_fmt(&argp
->fh
), argp
->len
, argp
->name
);
107 fh_init(&resp
->fh
, NFS_FHSIZE
);
108 nfserr
= nfsd_lookup(rqstp
, &argp
->fh
, argp
->name
, argp
->len
,
112 return nfsd_return_dirop(nfserr
, resp
);
119 nfsd_proc_readlink(struct svc_rqst
*rqstp
, struct nfsd_readlinkargs
*argp
,
120 struct nfsd_readlinkres
*resp
)
124 dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp
->fh
));
126 /* Read the symlink. */
127 resp
->len
= NFS_MAXPATHLEN
;
128 nfserr
= nfsd_readlink(rqstp
, &argp
->fh
, argp
->buffer
, &resp
->len
);
135 * Read a portion of a file.
136 * N.B. After this call resp->fh needs an fh_put
139 nfsd_proc_read(struct svc_rqst
*rqstp
, struct nfsd_readargs
*argp
,
140 struct nfsd_readres
*resp
)
144 dprintk("nfsd: READ %s %d bytes at %d\n",
145 SVCFH_fmt(&argp
->fh
),
146 argp
->count
, argp
->offset
);
148 /* Obtain buffer pointer for payload. 19 is 1 word for
149 * status, 17 words for fattr, and 1 word for the byte count.
152 if (NFSSVC_MAXBLKSIZE_V2
< argp
->count
) {
153 char buf
[RPC_MAX_ADDRBUFLEN
];
155 "oversized read request from %s (%d bytes)\n",
156 svc_print_addr(rqstp
, buf
, sizeof(buf
)),
158 argp
->count
= NFSSVC_MAXBLKSIZE_V2
;
160 svc_reserve_auth(rqstp
, (19<<2) + argp
->count
+ 4);
162 resp
->count
= argp
->count
;
163 nfserr
= nfsd_read(rqstp
, fh_copy(&resp
->fh
, &argp
->fh
), NULL
,
165 rqstp
->rq_vec
, argp
->vlen
,
168 if (nfserr
) return nfserr
;
169 return nfserrno(vfs_getattr(resp
->fh
.fh_export
->ex_path
.mnt
,
175 * Write data to a file
176 * N.B. After this call resp->fh needs an fh_put
179 nfsd_proc_write(struct svc_rqst
*rqstp
, struct nfsd_writeargs
*argp
,
180 struct nfsd_attrstat
*resp
)
184 unsigned long cnt
= argp
->len
;
186 dprintk("nfsd: WRITE %s %d bytes at %d\n",
187 SVCFH_fmt(&argp
->fh
),
188 argp
->len
, argp
->offset
);
190 nfserr
= nfsd_write(rqstp
, fh_copy(&resp
->fh
, &argp
->fh
), NULL
,
192 rqstp
->rq_vec
, argp
->vlen
,
195 return nfsd_return_attrs(nfserr
, resp
);
199 * CREATE processing is complicated. The keyword here is `overloaded.'
200 * The parent directory is kept locked between the check for existence
201 * and the actual create() call in compliance with VFS protocols.
202 * N.B. After this call _both_ argp->fh and resp->fh need an fh_put
205 nfsd_proc_create(struct svc_rqst
*rqstp
, struct nfsd_createargs
*argp
,
206 struct nfsd_diropres
*resp
)
208 svc_fh
*dirfhp
= &argp
->fh
;
209 svc_fh
*newfhp
= &resp
->fh
;
210 struct iattr
*attr
= &argp
->attrs
;
212 struct dentry
*dchild
;
215 dev_t rdev
= 0, wanted
= new_decode_dev(attr
->ia_size
);
217 dprintk("nfsd: CREATE %s %.*s\n",
218 SVCFH_fmt(dirfhp
), argp
->len
, argp
->name
);
220 /* First verify the parent file handle */
221 nfserr
= fh_verify(rqstp
, dirfhp
, S_IFDIR
, NFSD_MAY_EXEC
);
223 goto done
; /* must fh_put dirfhp even on error */
225 /* Check for NFSD_MAY_WRITE in nfsd_create if necessary */
227 nfserr
= nfserr_acces
;
230 nfserr
= nfserr_exist
;
231 if (isdotent(argp
->name
, argp
->len
))
233 fh_lock_nested(dirfhp
, I_MUTEX_PARENT
);
234 dchild
= lookup_one_len(argp
->name
, dirfhp
->fh_dentry
, argp
->len
);
235 if (IS_ERR(dchild
)) {
236 nfserr
= nfserrno(PTR_ERR(dchild
));
239 fh_init(newfhp
, NFS_FHSIZE
);
240 nfserr
= fh_compose(newfhp
, dirfhp
->fh_export
, dchild
, dirfhp
);
241 if (!nfserr
&& !dchild
->d_inode
)
242 nfserr
= nfserr_noent
;
245 if (nfserr
!= nfserr_noent
)
248 * If the new file handle wasn't verified, we can't tell
249 * whether the file exists or not. Time to bail ...
251 nfserr
= nfserr_acces
;
252 if (!newfhp
->fh_dentry
) {
254 "nfsd_proc_create: file handle not verified\n");
259 inode
= newfhp
->fh_dentry
->d_inode
;
261 /* Unfudge the mode bits */
262 if (attr
->ia_valid
& ATTR_MODE
) {
263 type
= attr
->ia_mode
& S_IFMT
;
264 mode
= attr
->ia_mode
& ~S_IFMT
;
266 /* no type, so if target exists, assume same as that,
267 * else assume a file */
269 type
= inode
->i_mode
& S_IFMT
;
273 /* reserve rdev for later checking */
274 rdev
= inode
->i_rdev
;
275 attr
->ia_valid
|= ATTR_SIZE
;
279 /* this is probably a permission check..
280 * at least IRIX implements perm checking on
281 * echo thing > device-special-file-or-pipe
282 * by doing a CREATE with type==0
284 nfserr
= nfsd_permission(rqstp
,
287 NFSD_MAY_WRITE
|NFSD_MAY_LOCAL_ACCESS
);
288 if (nfserr
&& nfserr
!= nfserr_rofs
)
295 type
= inode
->i_mode
& S_IFMT
;
296 mode
= inode
->i_mode
& ~S_IFMT
;
302 attr
->ia_valid
|= ATTR_MODE
;
303 attr
->ia_mode
= mode
;
305 /* Special treatment for non-regular files according to the
306 * gospel of sun micro
308 if (type
!= S_IFREG
) {
310 if (type
!= S_IFBLK
&& type
!= S_IFCHR
) {
312 } else if (type
== S_IFCHR
&& !(attr
->ia_valid
& ATTR_SIZE
)) {
313 /* If you think you've seen the worst, grok this. */
316 /* Okay, char or block special */
322 /* we've used the SIZE information, so discard it */
323 attr
->ia_valid
&= ~ATTR_SIZE
;
325 /* Make sure the type and device matches */
326 nfserr
= nfserr_exist
;
327 if (inode
&& type
!= (inode
->i_mode
& S_IFMT
))
333 /* File doesn't exist. Create it and set attrs */
334 nfserr
= nfsd_create(rqstp
, dirfhp
, argp
->name
, argp
->len
,
335 attr
, type
, rdev
, newfhp
);
336 } else if (type
== S_IFREG
) {
337 dprintk("nfsd: existing %s, valid=%x, size=%ld\n",
338 argp
->name
, attr
->ia_valid
, (long) attr
->ia_size
);
339 /* File already exists. We ignore all attributes except
340 * size, so that creat() behaves exactly like
341 * open(..., O_CREAT|O_TRUNC|O_WRONLY).
343 attr
->ia_valid
&= ATTR_SIZE
;
345 nfserr
= nfsd_setattr(rqstp
, newfhp
, attr
, 0, (time_t)0);
349 /* We don't really need to unlock, as fh_put does it. */
354 return nfsd_return_dirop(nfserr
, resp
);
358 nfsd_proc_remove(struct svc_rqst
*rqstp
, struct nfsd_diropargs
*argp
,
363 dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp
->fh
),
364 argp
->len
, argp
->name
);
366 /* Unlink. -SIFDIR means file must not be a directory */
367 nfserr
= nfsd_unlink(rqstp
, &argp
->fh
, -S_IFDIR
, argp
->name
, argp
->len
);
373 nfsd_proc_rename(struct svc_rqst
*rqstp
, struct nfsd_renameargs
*argp
,
378 dprintk("nfsd: RENAME %s %.*s -> \n",
379 SVCFH_fmt(&argp
->ffh
), argp
->flen
, argp
->fname
);
380 dprintk("nfsd: -> %s %.*s\n",
381 SVCFH_fmt(&argp
->tfh
), argp
->tlen
, argp
->tname
);
383 nfserr
= nfsd_rename(rqstp
, &argp
->ffh
, argp
->fname
, argp
->flen
,
384 &argp
->tfh
, argp
->tname
, argp
->tlen
);
391 nfsd_proc_link(struct svc_rqst
*rqstp
, struct nfsd_linkargs
*argp
,
396 dprintk("nfsd: LINK %s ->\n",
397 SVCFH_fmt(&argp
->ffh
));
398 dprintk("nfsd: %s %.*s\n",
399 SVCFH_fmt(&argp
->tfh
),
403 nfserr
= nfsd_link(rqstp
, &argp
->tfh
, argp
->tname
, argp
->tlen
,
411 nfsd_proc_symlink(struct svc_rqst
*rqstp
, struct nfsd_symlinkargs
*argp
,
417 dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n",
418 SVCFH_fmt(&argp
->ffh
), argp
->flen
, argp
->fname
,
419 argp
->tlen
, argp
->tname
);
421 fh_init(&newfh
, NFS_FHSIZE
);
423 * Create the link, look up new file and set attrs.
425 nfserr
= nfsd_symlink(rqstp
, &argp
->ffh
, argp
->fname
, argp
->flen
,
426 argp
->tname
, argp
->tlen
,
427 &newfh
, &argp
->attrs
);
436 * Make directory. This operation is not idempotent.
437 * N.B. After this call resp->fh needs an fh_put
440 nfsd_proc_mkdir(struct svc_rqst
*rqstp
, struct nfsd_createargs
*argp
,
441 struct nfsd_diropres
*resp
)
445 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp
->fh
), argp
->len
, argp
->name
);
447 if (resp
->fh
.fh_dentry
) {
449 "nfsd_proc_mkdir: response already verified??\n");
452 argp
->attrs
.ia_valid
&= ~ATTR_SIZE
;
453 fh_init(&resp
->fh
, NFS_FHSIZE
);
454 nfserr
= nfsd_create(rqstp
, &argp
->fh
, argp
->name
, argp
->len
,
455 &argp
->attrs
, S_IFDIR
, 0, &resp
->fh
);
457 return nfsd_return_dirop(nfserr
, resp
);
464 nfsd_proc_rmdir(struct svc_rqst
*rqstp
, struct nfsd_diropargs
*argp
,
469 dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp
->fh
), argp
->len
, argp
->name
);
471 nfserr
= nfsd_unlink(rqstp
, &argp
->fh
, S_IFDIR
, argp
->name
, argp
->len
);
477 * Read a portion of a directory.
480 nfsd_proc_readdir(struct svc_rqst
*rqstp
, struct nfsd_readdirargs
*argp
,
481 struct nfsd_readdirres
*resp
)
487 dprintk("nfsd: READDIR %s %d bytes at %d\n",
488 SVCFH_fmt(&argp
->fh
),
489 argp
->count
, argp
->cookie
);
491 /* Shrink to the client read size */
492 count
= (argp
->count
>> 2) - 2;
494 /* Make sure we've room for the NULL ptr & eof flag */
499 resp
->buffer
= argp
->buffer
;
501 resp
->buflen
= count
;
502 resp
->common
.err
= nfs_ok
;
503 /* Read directory and encode entries on the fly */
504 offset
= argp
->cookie
;
505 nfserr
= nfsd_readdir(rqstp
, &argp
->fh
, &offset
,
506 &resp
->common
, nfssvc_encode_entry
);
508 resp
->count
= resp
->buffer
- argp
->buffer
;
510 *resp
->offset
= htonl(offset
);
517 * Get file system info
520 nfsd_proc_statfs(struct svc_rqst
* rqstp
, struct nfsd_fhandle
*argp
,
521 struct nfsd_statfsres
*resp
)
525 dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp
->fh
));
527 nfserr
= nfsd_statfs(rqstp
, &argp
->fh
, &resp
->stats
,
528 NFSD_MAY_BYPASS_GSS_ON_ROOT
);
534 * NFSv2 Server procedures.
535 * Only the results of non-idempotent operations are cached.
537 struct nfsd_void
{ int dummy
; };
539 #define ST 1 /* status */
540 #define FH 8 /* filehandle */
541 #define AT 18 /* attributes */
543 static struct svc_procedure nfsd_procedures2
[18] = {
545 .pc_func
= (svc_procfunc
) nfsd_proc_null
,
546 .pc_decode
= (kxdrproc_t
) nfssvc_decode_void
,
547 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
548 .pc_argsize
= sizeof(struct nfsd_void
),
549 .pc_ressize
= sizeof(struct nfsd_void
),
550 .pc_cachetype
= RC_NOCACHE
,
553 [NFSPROC_GETATTR
] = {
554 .pc_func
= (svc_procfunc
) nfsd_proc_getattr
,
555 .pc_decode
= (kxdrproc_t
) nfssvc_decode_fhandle
,
556 .pc_encode
= (kxdrproc_t
) nfssvc_encode_attrstat
,
557 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
558 .pc_argsize
= sizeof(struct nfsd_fhandle
),
559 .pc_ressize
= sizeof(struct nfsd_attrstat
),
560 .pc_cachetype
= RC_NOCACHE
,
561 .pc_xdrressize
= ST
+AT
,
563 [NFSPROC_SETATTR
] = {
564 .pc_func
= (svc_procfunc
) nfsd_proc_setattr
,
565 .pc_decode
= (kxdrproc_t
) nfssvc_decode_sattrargs
,
566 .pc_encode
= (kxdrproc_t
) nfssvc_encode_attrstat
,
567 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
568 .pc_argsize
= sizeof(struct nfsd_sattrargs
),
569 .pc_ressize
= sizeof(struct nfsd_attrstat
),
570 .pc_cachetype
= RC_REPLBUFF
,
571 .pc_xdrressize
= ST
+AT
,
574 .pc_decode
= (kxdrproc_t
) nfssvc_decode_void
,
575 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
576 .pc_argsize
= sizeof(struct nfsd_void
),
577 .pc_ressize
= sizeof(struct nfsd_void
),
578 .pc_cachetype
= RC_NOCACHE
,
582 .pc_func
= (svc_procfunc
) nfsd_proc_lookup
,
583 .pc_decode
= (kxdrproc_t
) nfssvc_decode_diropargs
,
584 .pc_encode
= (kxdrproc_t
) nfssvc_encode_diropres
,
585 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
586 .pc_argsize
= sizeof(struct nfsd_diropargs
),
587 .pc_ressize
= sizeof(struct nfsd_diropres
),
588 .pc_cachetype
= RC_NOCACHE
,
589 .pc_xdrressize
= ST
+FH
+AT
,
591 [NFSPROC_READLINK
] = {
592 .pc_func
= (svc_procfunc
) nfsd_proc_readlink
,
593 .pc_decode
= (kxdrproc_t
) nfssvc_decode_readlinkargs
,
594 .pc_encode
= (kxdrproc_t
) nfssvc_encode_readlinkres
,
595 .pc_argsize
= sizeof(struct nfsd_readlinkargs
),
596 .pc_ressize
= sizeof(struct nfsd_readlinkres
),
597 .pc_cachetype
= RC_NOCACHE
,
598 .pc_xdrressize
= ST
+1+NFS_MAXPATHLEN
/4,
601 .pc_func
= (svc_procfunc
) nfsd_proc_read
,
602 .pc_decode
= (kxdrproc_t
) nfssvc_decode_readargs
,
603 .pc_encode
= (kxdrproc_t
) nfssvc_encode_readres
,
604 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
605 .pc_argsize
= sizeof(struct nfsd_readargs
),
606 .pc_ressize
= sizeof(struct nfsd_readres
),
607 .pc_cachetype
= RC_NOCACHE
,
608 .pc_xdrressize
= ST
+AT
+1+NFSSVC_MAXBLKSIZE_V2
/4,
610 [NFSPROC_WRITECACHE
] = {
611 .pc_decode
= (kxdrproc_t
) nfssvc_decode_void
,
612 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
613 .pc_argsize
= sizeof(struct nfsd_void
),
614 .pc_ressize
= sizeof(struct nfsd_void
),
615 .pc_cachetype
= RC_NOCACHE
,
619 .pc_func
= (svc_procfunc
) nfsd_proc_write
,
620 .pc_decode
= (kxdrproc_t
) nfssvc_decode_writeargs
,
621 .pc_encode
= (kxdrproc_t
) nfssvc_encode_attrstat
,
622 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
623 .pc_argsize
= sizeof(struct nfsd_writeargs
),
624 .pc_ressize
= sizeof(struct nfsd_attrstat
),
625 .pc_cachetype
= RC_REPLBUFF
,
626 .pc_xdrressize
= ST
+AT
,
629 .pc_func
= (svc_procfunc
) nfsd_proc_create
,
630 .pc_decode
= (kxdrproc_t
) nfssvc_decode_createargs
,
631 .pc_encode
= (kxdrproc_t
) nfssvc_encode_diropres
,
632 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
633 .pc_argsize
= sizeof(struct nfsd_createargs
),
634 .pc_ressize
= sizeof(struct nfsd_diropres
),
635 .pc_cachetype
= RC_REPLBUFF
,
636 .pc_xdrressize
= ST
+FH
+AT
,
639 .pc_func
= (svc_procfunc
) nfsd_proc_remove
,
640 .pc_decode
= (kxdrproc_t
) nfssvc_decode_diropargs
,
641 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
642 .pc_argsize
= sizeof(struct nfsd_diropargs
),
643 .pc_ressize
= sizeof(struct nfsd_void
),
644 .pc_cachetype
= RC_REPLSTAT
,
648 .pc_func
= (svc_procfunc
) nfsd_proc_rename
,
649 .pc_decode
= (kxdrproc_t
) nfssvc_decode_renameargs
,
650 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
651 .pc_argsize
= sizeof(struct nfsd_renameargs
),
652 .pc_ressize
= sizeof(struct nfsd_void
),
653 .pc_cachetype
= RC_REPLSTAT
,
657 .pc_func
= (svc_procfunc
) nfsd_proc_link
,
658 .pc_decode
= (kxdrproc_t
) nfssvc_decode_linkargs
,
659 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
660 .pc_argsize
= sizeof(struct nfsd_linkargs
),
661 .pc_ressize
= sizeof(struct nfsd_void
),
662 .pc_cachetype
= RC_REPLSTAT
,
665 [NFSPROC_SYMLINK
] = {
666 .pc_func
= (svc_procfunc
) nfsd_proc_symlink
,
667 .pc_decode
= (kxdrproc_t
) nfssvc_decode_symlinkargs
,
668 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
669 .pc_argsize
= sizeof(struct nfsd_symlinkargs
),
670 .pc_ressize
= sizeof(struct nfsd_void
),
671 .pc_cachetype
= RC_REPLSTAT
,
675 .pc_func
= (svc_procfunc
) nfsd_proc_mkdir
,
676 .pc_decode
= (kxdrproc_t
) nfssvc_decode_createargs
,
677 .pc_encode
= (kxdrproc_t
) nfssvc_encode_diropres
,
678 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
679 .pc_argsize
= sizeof(struct nfsd_createargs
),
680 .pc_ressize
= sizeof(struct nfsd_diropres
),
681 .pc_cachetype
= RC_REPLBUFF
,
682 .pc_xdrressize
= ST
+FH
+AT
,
685 .pc_func
= (svc_procfunc
) nfsd_proc_rmdir
,
686 .pc_decode
= (kxdrproc_t
) nfssvc_decode_diropargs
,
687 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
688 .pc_argsize
= sizeof(struct nfsd_diropargs
),
689 .pc_ressize
= sizeof(struct nfsd_void
),
690 .pc_cachetype
= RC_REPLSTAT
,
693 [NFSPROC_READDIR
] = {
694 .pc_func
= (svc_procfunc
) nfsd_proc_readdir
,
695 .pc_decode
= (kxdrproc_t
) nfssvc_decode_readdirargs
,
696 .pc_encode
= (kxdrproc_t
) nfssvc_encode_readdirres
,
697 .pc_argsize
= sizeof(struct nfsd_readdirargs
),
698 .pc_ressize
= sizeof(struct nfsd_readdirres
),
699 .pc_cachetype
= RC_NOCACHE
,
702 .pc_func
= (svc_procfunc
) nfsd_proc_statfs
,
703 .pc_decode
= (kxdrproc_t
) nfssvc_decode_fhandle
,
704 .pc_encode
= (kxdrproc_t
) nfssvc_encode_statfsres
,
705 .pc_argsize
= sizeof(struct nfsd_fhandle
),
706 .pc_ressize
= sizeof(struct nfsd_statfsres
),
707 .pc_cachetype
= RC_NOCACHE
,
708 .pc_xdrressize
= ST
+5,
713 struct svc_version nfsd_version2
= {
716 .vs_proc
= nfsd_procedures2
,
717 .vs_dispatch
= nfsd_dispatch
,
718 .vs_xdrsize
= NFS2_SVC_XDRSIZE
,
722 * Map errnos to NFS errnos.
732 { nfserr_perm
, -EPERM
},
733 { nfserr_noent
, -ENOENT
},
735 { nfserr_nxio
, -ENXIO
},
736 { nfserr_acces
, -EACCES
},
737 { nfserr_exist
, -EEXIST
},
738 { nfserr_xdev
, -EXDEV
},
739 { nfserr_mlink
, -EMLINK
},
740 { nfserr_nodev
, -ENODEV
},
741 { nfserr_notdir
, -ENOTDIR
},
742 { nfserr_isdir
, -EISDIR
},
743 { nfserr_inval
, -EINVAL
},
744 { nfserr_fbig
, -EFBIG
},
745 { nfserr_nospc
, -ENOSPC
},
746 { nfserr_rofs
, -EROFS
},
747 { nfserr_mlink
, -EMLINK
},
748 { nfserr_nametoolong
, -ENAMETOOLONG
},
749 { nfserr_notempty
, -ENOTEMPTY
},
751 { nfserr_dquot
, -EDQUOT
},
753 { nfserr_stale
, -ESTALE
},
754 { nfserr_jukebox
, -ETIMEDOUT
},
755 { nfserr_jukebox
, -ERESTARTSYS
},
756 { nfserr_dropit
, -EAGAIN
},
757 { nfserr_dropit
, -ENOMEM
},
758 { nfserr_badname
, -ESRCH
},
759 { nfserr_io
, -ETXTBSY
},
760 { nfserr_notsupp
, -EOPNOTSUPP
},
761 { nfserr_toosmall
, -ETOOSMALL
},
762 { nfserr_serverfault
, -ESERVERFAULT
},
766 for (i
= 0; i
< ARRAY_SIZE(nfs_errtbl
); i
++) {
767 if (nfs_errtbl
[i
].syserr
== errno
)
768 return nfs_errtbl
[i
].nfserr
;
770 printk (KERN_INFO
"nfsd: non-standard errno: %d\n", errno
);