2 * Process version 2 NFS requests.
4 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
7 #include <linux/namei.h>
13 typedef struct svc_rqst svc_rqst
;
14 typedef struct svc_buf svc_buf
;
16 #define NFSDDBG_FACILITY NFSDDBG_PROC
20 nfsd_proc_null(struct svc_rqst
*rqstp
, void *argp
, void *resp
)
26 nfsd_return_attrs(__be32 err
, struct nfsd_attrstat
*resp
)
29 return fh_getattr(&resp
->fh
, &resp
->stat
);
32 nfsd_return_dirop(__be32 err
, struct nfsd_diropres
*resp
)
35 return fh_getattr(&resp
->fh
, &resp
->stat
);
38 * Get a file's attributes
39 * N.B. After this call resp->fh needs an fh_put
42 nfsd_proc_getattr(struct svc_rqst
*rqstp
, struct nfsd_fhandle
*argp
,
43 struct nfsd_attrstat
*resp
)
46 dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp
->fh
));
48 fh_copy(&resp
->fh
, &argp
->fh
);
49 nfserr
= fh_verify(rqstp
, &resp
->fh
, 0,
50 NFSD_MAY_NOP
| NFSD_MAY_BYPASS_GSS_ON_ROOT
);
51 return nfsd_return_attrs(nfserr
, resp
);
55 * Set a file's attributes
56 * N.B. After this call resp->fh needs an fh_put
59 nfsd_proc_setattr(struct svc_rqst
*rqstp
, struct nfsd_sattrargs
*argp
,
60 struct nfsd_attrstat
*resp
)
62 struct iattr
*iap
= &argp
->attrs
;
66 dprintk("nfsd: SETATTR %s, valid=%x, size=%ld\n",
68 argp
->attrs
.ia_valid
, (long) argp
->attrs
.ia_size
);
70 fhp
= fh_copy(&resp
->fh
, &argp
->fh
);
73 * NFSv2 does not differentiate between "set-[ac]time-to-now"
74 * which only requires access, and "set-[ac]time-to-X" which
76 * So if it looks like it might be "set both to the same time which
77 * is close to now", and if setattr_prepare fails, then we
78 * convert to "set to now" instead of "set to explicit time"
80 * We only call setattr_prepare as the last test as technically
81 * it is not an interface that we should be using.
83 #define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET)
84 #define MAX_TOUCH_TIME_ERROR (30*60)
85 if ((iap
->ia_valid
& BOTH_TIME_SET
) == BOTH_TIME_SET
&&
86 iap
->ia_mtime
.tv_sec
== iap
->ia_atime
.tv_sec
) {
90 * Now just make sure time is in the right ballpark.
91 * Solaris, at least, doesn't seem to care what the time
92 * request is. We require it be within 30 minutes of now.
94 time_t delta
= iap
->ia_atime
.tv_sec
- get_seconds();
96 nfserr
= fh_verify(rqstp
, fhp
, 0, NFSD_MAY_NOP
);
102 if (delta
< MAX_TOUCH_TIME_ERROR
&&
103 setattr_prepare(fhp
->fh_dentry
, iap
) != 0) {
105 * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME.
106 * This will cause notify_change to set these times
109 iap
->ia_valid
&= ~BOTH_TIME_SET
;
113 nfserr
= nfsd_setattr(rqstp
, fhp
, iap
, 0, (time_t)0);
115 return nfsd_return_attrs(nfserr
, resp
);
119 * Look up a path name component
120 * Note: the dentry in the resp->fh may be negative if the file
122 * N.B. After this call resp->fh needs an fh_put
125 nfsd_proc_lookup(struct svc_rqst
*rqstp
, struct nfsd_diropargs
*argp
,
126 struct nfsd_diropres
*resp
)
130 dprintk("nfsd: LOOKUP %s %.*s\n",
131 SVCFH_fmt(&argp
->fh
), argp
->len
, argp
->name
);
133 fh_init(&resp
->fh
, NFS_FHSIZE
);
134 nfserr
= nfsd_lookup(rqstp
, &argp
->fh
, argp
->name
, argp
->len
,
138 return nfsd_return_dirop(nfserr
, resp
);
145 nfsd_proc_readlink(struct svc_rqst
*rqstp
, struct nfsd_readlinkargs
*argp
,
146 struct nfsd_readlinkres
*resp
)
150 dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp
->fh
));
152 /* Read the symlink. */
153 resp
->len
= NFS_MAXPATHLEN
;
154 nfserr
= nfsd_readlink(rqstp
, &argp
->fh
, argp
->buffer
, &resp
->len
);
161 * Read a portion of a file.
162 * N.B. After this call resp->fh needs an fh_put
165 nfsd_proc_read(struct svc_rqst
*rqstp
, struct nfsd_readargs
*argp
,
166 struct nfsd_readres
*resp
)
170 dprintk("nfsd: READ %s %d bytes at %d\n",
171 SVCFH_fmt(&argp
->fh
),
172 argp
->count
, argp
->offset
);
174 /* Obtain buffer pointer for payload. 19 is 1 word for
175 * status, 17 words for fattr, and 1 word for the byte count.
178 if (NFSSVC_MAXBLKSIZE_V2
< argp
->count
) {
179 char buf
[RPC_MAX_ADDRBUFLEN
];
181 "oversized read request from %s (%d bytes)\n",
182 svc_print_addr(rqstp
, buf
, sizeof(buf
)),
184 argp
->count
= NFSSVC_MAXBLKSIZE_V2
;
186 svc_reserve_auth(rqstp
, (19<<2) + argp
->count
+ 4);
188 resp
->count
= argp
->count
;
189 nfserr
= nfsd_read(rqstp
, fh_copy(&resp
->fh
, &argp
->fh
),
191 rqstp
->rq_vec
, argp
->vlen
,
194 if (nfserr
) return nfserr
;
195 return fh_getattr(&resp
->fh
, &resp
->stat
);
199 * Write data to a file
200 * N.B. After this call resp->fh needs an fh_put
203 nfsd_proc_write(struct svc_rqst
*rqstp
, struct nfsd_writeargs
*argp
,
204 struct nfsd_attrstat
*resp
)
207 unsigned long cnt
= argp
->len
;
209 dprintk("nfsd: WRITE %s %d bytes at %d\n",
210 SVCFH_fmt(&argp
->fh
),
211 argp
->len
, argp
->offset
);
213 nfserr
= nfsd_write(rqstp
, fh_copy(&resp
->fh
, &argp
->fh
), argp
->offset
,
214 rqstp
->rq_vec
, argp
->vlen
, &cnt
, NFS_DATA_SYNC
);
215 return nfsd_return_attrs(nfserr
, resp
);
219 * CREATE processing is complicated. The keyword here is `overloaded.'
220 * The parent directory is kept locked between the check for existence
221 * and the actual create() call in compliance with VFS protocols.
222 * N.B. After this call _both_ argp->fh and resp->fh need an fh_put
225 nfsd_proc_create(struct svc_rqst
*rqstp
, struct nfsd_createargs
*argp
,
226 struct nfsd_diropres
*resp
)
228 svc_fh
*dirfhp
= &argp
->fh
;
229 svc_fh
*newfhp
= &resp
->fh
;
230 struct iattr
*attr
= &argp
->attrs
;
232 struct dentry
*dchild
;
236 dev_t rdev
= 0, wanted
= new_decode_dev(attr
->ia_size
);
238 dprintk("nfsd: CREATE %s %.*s\n",
239 SVCFH_fmt(dirfhp
), argp
->len
, argp
->name
);
241 /* First verify the parent file handle */
242 nfserr
= fh_verify(rqstp
, dirfhp
, S_IFDIR
, NFSD_MAY_EXEC
);
244 goto done
; /* must fh_put dirfhp even on error */
246 /* Check for NFSD_MAY_WRITE in nfsd_create if necessary */
248 nfserr
= nfserr_exist
;
249 if (isdotent(argp
->name
, argp
->len
))
251 hosterr
= fh_want_write(dirfhp
);
253 nfserr
= nfserrno(hosterr
);
257 fh_lock_nested(dirfhp
, I_MUTEX_PARENT
);
258 dchild
= lookup_one_len(argp
->name
, dirfhp
->fh_dentry
, argp
->len
);
259 if (IS_ERR(dchild
)) {
260 nfserr
= nfserrno(PTR_ERR(dchild
));
263 fh_init(newfhp
, NFS_FHSIZE
);
264 nfserr
= fh_compose(newfhp
, dirfhp
->fh_export
, dchild
, dirfhp
);
265 if (!nfserr
&& d_really_is_negative(dchild
))
266 nfserr
= nfserr_noent
;
269 if (nfserr
!= nfserr_noent
)
272 * If the new file handle wasn't verified, we can't tell
273 * whether the file exists or not. Time to bail ...
275 nfserr
= nfserr_acces
;
276 if (!newfhp
->fh_dentry
) {
278 "nfsd_proc_create: file handle not verified\n");
283 inode
= d_inode(newfhp
->fh_dentry
);
285 /* Unfudge the mode bits */
286 if (attr
->ia_valid
& ATTR_MODE
) {
287 type
= attr
->ia_mode
& S_IFMT
;
288 mode
= attr
->ia_mode
& ~S_IFMT
;
290 /* no type, so if target exists, assume same as that,
291 * else assume a file */
293 type
= inode
->i_mode
& S_IFMT
;
297 /* reserve rdev for later checking */
298 rdev
= inode
->i_rdev
;
299 attr
->ia_valid
|= ATTR_SIZE
;
303 /* this is probably a permission check..
304 * at least IRIX implements perm checking on
305 * echo thing > device-special-file-or-pipe
306 * by doing a CREATE with type==0
308 nfserr
= nfsd_permission(rqstp
,
311 NFSD_MAY_WRITE
|NFSD_MAY_LOCAL_ACCESS
);
312 if (nfserr
&& nfserr
!= nfserr_rofs
)
319 type
= inode
->i_mode
& S_IFMT
;
320 mode
= inode
->i_mode
& ~S_IFMT
;
326 attr
->ia_valid
|= ATTR_MODE
;
327 attr
->ia_mode
= mode
;
329 /* Special treatment for non-regular files according to the
330 * gospel of sun micro
332 if (type
!= S_IFREG
) {
333 if (type
!= S_IFBLK
&& type
!= S_IFCHR
) {
335 } else if (type
== S_IFCHR
&& !(attr
->ia_valid
& ATTR_SIZE
)) {
336 /* If you think you've seen the worst, grok this. */
339 /* Okay, char or block special */
344 /* we've used the SIZE information, so discard it */
345 attr
->ia_valid
&= ~ATTR_SIZE
;
347 /* Make sure the type and device matches */
348 nfserr
= nfserr_exist
;
349 if (inode
&& type
!= (inode
->i_mode
& S_IFMT
))
355 /* File doesn't exist. Create it and set attrs */
356 nfserr
= nfsd_create_locked(rqstp
, dirfhp
, argp
->name
,
357 argp
->len
, attr
, type
, rdev
, newfhp
);
358 } else if (type
== S_IFREG
) {
359 dprintk("nfsd: existing %s, valid=%x, size=%ld\n",
360 argp
->name
, attr
->ia_valid
, (long) attr
->ia_size
);
361 /* File already exists. We ignore all attributes except
362 * size, so that creat() behaves exactly like
363 * open(..., O_CREAT|O_TRUNC|O_WRONLY).
365 attr
->ia_valid
&= ATTR_SIZE
;
367 nfserr
= nfsd_setattr(rqstp
, newfhp
, attr
, 0, (time_t)0);
371 /* We don't really need to unlock, as fh_put does it. */
373 fh_drop_write(dirfhp
);
376 return nfsd_return_dirop(nfserr
, resp
);
380 nfsd_proc_remove(struct svc_rqst
*rqstp
, struct nfsd_diropargs
*argp
,
385 dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp
->fh
),
386 argp
->len
, argp
->name
);
388 /* Unlink. -SIFDIR means file must not be a directory */
389 nfserr
= nfsd_unlink(rqstp
, &argp
->fh
, -S_IFDIR
, argp
->name
, argp
->len
);
395 nfsd_proc_rename(struct svc_rqst
*rqstp
, struct nfsd_renameargs
*argp
,
400 dprintk("nfsd: RENAME %s %.*s -> \n",
401 SVCFH_fmt(&argp
->ffh
), argp
->flen
, argp
->fname
);
402 dprintk("nfsd: -> %s %.*s\n",
403 SVCFH_fmt(&argp
->tfh
), argp
->tlen
, argp
->tname
);
405 nfserr
= nfsd_rename(rqstp
, &argp
->ffh
, argp
->fname
, argp
->flen
,
406 &argp
->tfh
, argp
->tname
, argp
->tlen
);
413 nfsd_proc_link(struct svc_rqst
*rqstp
, struct nfsd_linkargs
*argp
,
418 dprintk("nfsd: LINK %s ->\n",
419 SVCFH_fmt(&argp
->ffh
));
420 dprintk("nfsd: %s %.*s\n",
421 SVCFH_fmt(&argp
->tfh
),
425 nfserr
= nfsd_link(rqstp
, &argp
->tfh
, argp
->tname
, argp
->tlen
,
433 nfsd_proc_symlink(struct svc_rqst
*rqstp
, struct nfsd_symlinkargs
*argp
,
439 dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n",
440 SVCFH_fmt(&argp
->ffh
), argp
->flen
, argp
->fname
,
441 argp
->tlen
, argp
->tname
);
443 fh_init(&newfh
, NFS_FHSIZE
);
445 * Crazy hack: the request fits in a page, and already-decoded
446 * attributes follow argp->tname, so it's safe to just write a
447 * null to ensure it's null-terminated:
449 argp
->tname
[argp
->tlen
] = '\0';
450 nfserr
= nfsd_symlink(rqstp
, &argp
->ffh
, argp
->fname
, argp
->flen
,
451 argp
->tname
, &newfh
);
459 * Make directory. This operation is not idempotent.
460 * N.B. After this call resp->fh needs an fh_put
463 nfsd_proc_mkdir(struct svc_rqst
*rqstp
, struct nfsd_createargs
*argp
,
464 struct nfsd_diropres
*resp
)
468 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp
->fh
), argp
->len
, argp
->name
);
470 if (resp
->fh
.fh_dentry
) {
472 "nfsd_proc_mkdir: response already verified??\n");
475 argp
->attrs
.ia_valid
&= ~ATTR_SIZE
;
476 fh_init(&resp
->fh
, NFS_FHSIZE
);
477 nfserr
= nfsd_create(rqstp
, &argp
->fh
, argp
->name
, argp
->len
,
478 &argp
->attrs
, S_IFDIR
, 0, &resp
->fh
);
480 return nfsd_return_dirop(nfserr
, resp
);
487 nfsd_proc_rmdir(struct svc_rqst
*rqstp
, struct nfsd_diropargs
*argp
,
492 dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp
->fh
), argp
->len
, argp
->name
);
494 nfserr
= nfsd_unlink(rqstp
, &argp
->fh
, S_IFDIR
, argp
->name
, argp
->len
);
500 * Read a portion of a directory.
503 nfsd_proc_readdir(struct svc_rqst
*rqstp
, struct nfsd_readdirargs
*argp
,
504 struct nfsd_readdirres
*resp
)
510 dprintk("nfsd: READDIR %s %d bytes at %d\n",
511 SVCFH_fmt(&argp
->fh
),
512 argp
->count
, argp
->cookie
);
514 /* Shrink to the client read size */
515 count
= (argp
->count
>> 2) - 2;
517 /* Make sure we've room for the NULL ptr & eof flag */
522 resp
->buffer
= argp
->buffer
;
524 resp
->buflen
= count
;
525 resp
->common
.err
= nfs_ok
;
526 /* Read directory and encode entries on the fly */
527 offset
= argp
->cookie
;
528 nfserr
= nfsd_readdir(rqstp
, &argp
->fh
, &offset
,
529 &resp
->common
, nfssvc_encode_entry
);
531 resp
->count
= resp
->buffer
- argp
->buffer
;
533 *resp
->offset
= htonl(offset
);
540 * Get file system info
543 nfsd_proc_statfs(struct svc_rqst
* rqstp
, struct nfsd_fhandle
*argp
,
544 struct nfsd_statfsres
*resp
)
548 dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp
->fh
));
550 nfserr
= nfsd_statfs(rqstp
, &argp
->fh
, &resp
->stats
,
551 NFSD_MAY_BYPASS_GSS_ON_ROOT
);
557 * NFSv2 Server procedures.
558 * Only the results of non-idempotent operations are cached.
560 struct nfsd_void
{ int dummy
; };
562 #define ST 1 /* status */
563 #define FH 8 /* filehandle */
564 #define AT 18 /* attributes */
566 static struct svc_procedure nfsd_procedures2
[18] = {
568 .pc_func
= (svc_procfunc
) nfsd_proc_null
,
569 .pc_decode
= (kxdrproc_t
) nfssvc_decode_void
,
570 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
571 .pc_argsize
= sizeof(struct nfsd_void
),
572 .pc_ressize
= sizeof(struct nfsd_void
),
573 .pc_cachetype
= RC_NOCACHE
,
576 [NFSPROC_GETATTR
] = {
577 .pc_func
= (svc_procfunc
) nfsd_proc_getattr
,
578 .pc_decode
= (kxdrproc_t
) nfssvc_decode_fhandle
,
579 .pc_encode
= (kxdrproc_t
) nfssvc_encode_attrstat
,
580 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
581 .pc_argsize
= sizeof(struct nfsd_fhandle
),
582 .pc_ressize
= sizeof(struct nfsd_attrstat
),
583 .pc_cachetype
= RC_NOCACHE
,
584 .pc_xdrressize
= ST
+AT
,
586 [NFSPROC_SETATTR
] = {
587 .pc_func
= (svc_procfunc
) nfsd_proc_setattr
,
588 .pc_decode
= (kxdrproc_t
) nfssvc_decode_sattrargs
,
589 .pc_encode
= (kxdrproc_t
) nfssvc_encode_attrstat
,
590 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
591 .pc_argsize
= sizeof(struct nfsd_sattrargs
),
592 .pc_ressize
= sizeof(struct nfsd_attrstat
),
593 .pc_cachetype
= RC_REPLBUFF
,
594 .pc_xdrressize
= ST
+AT
,
597 .pc_decode
= (kxdrproc_t
) nfssvc_decode_void
,
598 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
599 .pc_argsize
= sizeof(struct nfsd_void
),
600 .pc_ressize
= sizeof(struct nfsd_void
),
601 .pc_cachetype
= RC_NOCACHE
,
605 .pc_func
= (svc_procfunc
) nfsd_proc_lookup
,
606 .pc_decode
= (kxdrproc_t
) nfssvc_decode_diropargs
,
607 .pc_encode
= (kxdrproc_t
) nfssvc_encode_diropres
,
608 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
609 .pc_argsize
= sizeof(struct nfsd_diropargs
),
610 .pc_ressize
= sizeof(struct nfsd_diropres
),
611 .pc_cachetype
= RC_NOCACHE
,
612 .pc_xdrressize
= ST
+FH
+AT
,
614 [NFSPROC_READLINK
] = {
615 .pc_func
= (svc_procfunc
) nfsd_proc_readlink
,
616 .pc_decode
= (kxdrproc_t
) nfssvc_decode_readlinkargs
,
617 .pc_encode
= (kxdrproc_t
) nfssvc_encode_readlinkres
,
618 .pc_argsize
= sizeof(struct nfsd_readlinkargs
),
619 .pc_ressize
= sizeof(struct nfsd_readlinkres
),
620 .pc_cachetype
= RC_NOCACHE
,
621 .pc_xdrressize
= ST
+1+NFS_MAXPATHLEN
/4,
624 .pc_func
= (svc_procfunc
) nfsd_proc_read
,
625 .pc_decode
= (kxdrproc_t
) nfssvc_decode_readargs
,
626 .pc_encode
= (kxdrproc_t
) nfssvc_encode_readres
,
627 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
628 .pc_argsize
= sizeof(struct nfsd_readargs
),
629 .pc_ressize
= sizeof(struct nfsd_readres
),
630 .pc_cachetype
= RC_NOCACHE
,
631 .pc_xdrressize
= ST
+AT
+1+NFSSVC_MAXBLKSIZE_V2
/4,
633 [NFSPROC_WRITECACHE
] = {
634 .pc_decode
= (kxdrproc_t
) nfssvc_decode_void
,
635 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
636 .pc_argsize
= sizeof(struct nfsd_void
),
637 .pc_ressize
= sizeof(struct nfsd_void
),
638 .pc_cachetype
= RC_NOCACHE
,
642 .pc_func
= (svc_procfunc
) nfsd_proc_write
,
643 .pc_decode
= (kxdrproc_t
) nfssvc_decode_writeargs
,
644 .pc_encode
= (kxdrproc_t
) nfssvc_encode_attrstat
,
645 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
646 .pc_argsize
= sizeof(struct nfsd_writeargs
),
647 .pc_ressize
= sizeof(struct nfsd_attrstat
),
648 .pc_cachetype
= RC_REPLBUFF
,
649 .pc_xdrressize
= ST
+AT
,
652 .pc_func
= (svc_procfunc
) nfsd_proc_create
,
653 .pc_decode
= (kxdrproc_t
) nfssvc_decode_createargs
,
654 .pc_encode
= (kxdrproc_t
) nfssvc_encode_diropres
,
655 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
656 .pc_argsize
= sizeof(struct nfsd_createargs
),
657 .pc_ressize
= sizeof(struct nfsd_diropres
),
658 .pc_cachetype
= RC_REPLBUFF
,
659 .pc_xdrressize
= ST
+FH
+AT
,
662 .pc_func
= (svc_procfunc
) nfsd_proc_remove
,
663 .pc_decode
= (kxdrproc_t
) nfssvc_decode_diropargs
,
664 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
665 .pc_argsize
= sizeof(struct nfsd_diropargs
),
666 .pc_ressize
= sizeof(struct nfsd_void
),
667 .pc_cachetype
= RC_REPLSTAT
,
671 .pc_func
= (svc_procfunc
) nfsd_proc_rename
,
672 .pc_decode
= (kxdrproc_t
) nfssvc_decode_renameargs
,
673 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
674 .pc_argsize
= sizeof(struct nfsd_renameargs
),
675 .pc_ressize
= sizeof(struct nfsd_void
),
676 .pc_cachetype
= RC_REPLSTAT
,
680 .pc_func
= (svc_procfunc
) nfsd_proc_link
,
681 .pc_decode
= (kxdrproc_t
) nfssvc_decode_linkargs
,
682 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
683 .pc_argsize
= sizeof(struct nfsd_linkargs
),
684 .pc_ressize
= sizeof(struct nfsd_void
),
685 .pc_cachetype
= RC_REPLSTAT
,
688 [NFSPROC_SYMLINK
] = {
689 .pc_func
= (svc_procfunc
) nfsd_proc_symlink
,
690 .pc_decode
= (kxdrproc_t
) nfssvc_decode_symlinkargs
,
691 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
692 .pc_argsize
= sizeof(struct nfsd_symlinkargs
),
693 .pc_ressize
= sizeof(struct nfsd_void
),
694 .pc_cachetype
= RC_REPLSTAT
,
698 .pc_func
= (svc_procfunc
) nfsd_proc_mkdir
,
699 .pc_decode
= (kxdrproc_t
) nfssvc_decode_createargs
,
700 .pc_encode
= (kxdrproc_t
) nfssvc_encode_diropres
,
701 .pc_release
= (kxdrproc_t
) nfssvc_release_fhandle
,
702 .pc_argsize
= sizeof(struct nfsd_createargs
),
703 .pc_ressize
= sizeof(struct nfsd_diropres
),
704 .pc_cachetype
= RC_REPLBUFF
,
705 .pc_xdrressize
= ST
+FH
+AT
,
708 .pc_func
= (svc_procfunc
) nfsd_proc_rmdir
,
709 .pc_decode
= (kxdrproc_t
) nfssvc_decode_diropargs
,
710 .pc_encode
= (kxdrproc_t
) nfssvc_encode_void
,
711 .pc_argsize
= sizeof(struct nfsd_diropargs
),
712 .pc_ressize
= sizeof(struct nfsd_void
),
713 .pc_cachetype
= RC_REPLSTAT
,
716 [NFSPROC_READDIR
] = {
717 .pc_func
= (svc_procfunc
) nfsd_proc_readdir
,
718 .pc_decode
= (kxdrproc_t
) nfssvc_decode_readdirargs
,
719 .pc_encode
= (kxdrproc_t
) nfssvc_encode_readdirres
,
720 .pc_argsize
= sizeof(struct nfsd_readdirargs
),
721 .pc_ressize
= sizeof(struct nfsd_readdirres
),
722 .pc_cachetype
= RC_NOCACHE
,
725 .pc_func
= (svc_procfunc
) nfsd_proc_statfs
,
726 .pc_decode
= (kxdrproc_t
) nfssvc_decode_fhandle
,
727 .pc_encode
= (kxdrproc_t
) nfssvc_encode_statfsres
,
728 .pc_argsize
= sizeof(struct nfsd_fhandle
),
729 .pc_ressize
= sizeof(struct nfsd_statfsres
),
730 .pc_cachetype
= RC_NOCACHE
,
731 .pc_xdrressize
= ST
+5,
736 struct svc_version nfsd_version2
= {
739 .vs_proc
= nfsd_procedures2
,
740 .vs_dispatch
= nfsd_dispatch
,
741 .vs_xdrsize
= NFS2_SVC_XDRSIZE
,
745 * Map errnos to NFS errnos.
755 { nfserr_perm
, -EPERM
},
756 { nfserr_noent
, -ENOENT
},
758 { nfserr_nxio
, -ENXIO
},
759 { nfserr_fbig
, -E2BIG
},
760 { nfserr_acces
, -EACCES
},
761 { nfserr_exist
, -EEXIST
},
762 { nfserr_xdev
, -EXDEV
},
763 { nfserr_mlink
, -EMLINK
},
764 { nfserr_nodev
, -ENODEV
},
765 { nfserr_notdir
, -ENOTDIR
},
766 { nfserr_isdir
, -EISDIR
},
767 { nfserr_inval
, -EINVAL
},
768 { nfserr_fbig
, -EFBIG
},
769 { nfserr_nospc
, -ENOSPC
},
770 { nfserr_rofs
, -EROFS
},
771 { nfserr_mlink
, -EMLINK
},
772 { nfserr_nametoolong
, -ENAMETOOLONG
},
773 { nfserr_notempty
, -ENOTEMPTY
},
775 { nfserr_dquot
, -EDQUOT
},
777 { nfserr_stale
, -ESTALE
},
778 { nfserr_jukebox
, -ETIMEDOUT
},
779 { nfserr_jukebox
, -ERESTARTSYS
},
780 { nfserr_jukebox
, -EAGAIN
},
781 { nfserr_jukebox
, -EWOULDBLOCK
},
782 { nfserr_jukebox
, -ENOMEM
},
783 { nfserr_io
, -ETXTBSY
},
784 { nfserr_notsupp
, -EOPNOTSUPP
},
785 { nfserr_toosmall
, -ETOOSMALL
},
786 { nfserr_serverfault
, -ESERVERFAULT
},
787 { nfserr_serverfault
, -ENFILE
},
788 { nfserr_io
, -EUCLEAN
},
792 for (i
= 0; i
< ARRAY_SIZE(nfs_errtbl
); i
++) {
793 if (nfs_errtbl
[i
].syserr
== errno
)
794 return nfs_errtbl
[i
].nfserr
;
796 WARN_ONCE(1, "nfsd: non-standard errno: %d\n", errno
);