2 * This software has been released under the terms of the IBM Public
3 * License. For details, see the LICENSE file in the top-level source
4 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include "afs/param.h"
14 /* Ugly Ugly Ugly but precludes conflicting XDR macros; We want kernel xdr */
15 #define __XDR_INCLUDE__
17 #include "afs/sysincludes.h" /* Standard vendor system headers */
18 #if defined(AFS_SUN5_ENV) && !defined(AFS_NONFSTRANS)
19 #include "rpc/types.h"
21 #include "rpc/auth_unix.h"
22 #include "rpc/auth_des.h"
23 #include "sys/tiuser.h"
27 #include "nfs/export.h"
28 /* Solaris 11.1 defines areq to areq_u.areq (and auid to areq_u.auid), for
29 * shortcut accessors to the nfsauth_arg structure. Since we dare to use the
30 * names areq and auid as parameter names in a lot of functions, work around
31 * this by undefining it. */
39 #include "nfs/nfs_clnt.h"
40 #include "nfs/nfs_acl.h"
41 #include "afs/afsincludes.h"
42 #include "afs/afs_stats.h"
43 #include "afs/exporter.h"
45 static int xlatorinit_v2_done = 0;
46 static int xlatorinit_v3_done = 0;
47 extern int afs_nobody;
48 extern int afs_NFSRootOnly;
52 xdrproc_t dis_xdrargs;
53 xdrproc_t dis_fastxdrargs;
56 xdrproc_t dis_fastxdrres;
58 void (*dis_resfree) ();
60 fhandle_t(*dis_getfh) ();
63 struct afs_nfs_disp_tbl {
67 struct afs_nfs2_resp {
72 #if defined(AFS_SUN510_ENV)
78 struct afs_nfs_disp_tbl afs_rfs_disp_tbl[RFS_NPROC];
79 struct afs_nfs_disp_tbl afs_acl_disp_tbl[ACL2_NPROC];
82 is_afs_fh(fhandle_t * fhp)
84 if ((fhp->fh_fsid.val[0] == AFS_VFSMAGIC)
85 && (fhp->fh_fsid.val[1] == AFS_VFSFSID))
91 nfs2_to_afs_call(int which, caddr_t * args, fhandle_t ** fhpp,
99 afs_Trace1(afs_iclSetp, CM_TRACE_NFSIN, ICL_TYPE_INT32, which);
100 *fh2pp = (fhandle_t *) 0;
105 fhp1 = (fhandle_t *) args;
109 struct nfssaargs *sargs = (struct nfssaargs *)args;
110 fhp1 = (fhandle_t *) & sargs->saa_fh;
115 struct nfsdiropargs *sargs = (struct nfsdiropargs *)args;
116 fhp1 = sargs->da_fhandle;
121 struct nfsreadargs *sargs = (struct nfsreadargs *)args;
122 fhp1 = (fhandle_t *) & sargs->ra_fhandle;
127 struct nfswriteargs *sargs = (struct nfswriteargs *)args;
128 fhp1 = (fhandle_t *) & sargs->wa_fhandle;
133 struct nfscreatargs *sargs = (struct nfscreatargs *)args;
134 fhp1 = sargs->ca_da.da_fhandle;
139 struct nfsdiropargs *sargs = (struct nfsdiropargs *)args;
140 fhp1 = sargs->da_fhandle;
145 struct nfsrnmargs *sargs = (struct nfsrnmargs *)args;
146 fhp1 = sargs->rna_from.da_fhandle;
147 fhp2 = sargs->rna_to.da_fhandle;
152 struct nfslinkargs *sargs = (struct nfslinkargs *)args;
153 fhp1 = sargs->la_from;
154 fhp2 = sargs->la_to.da_fhandle;
159 struct nfsslargs *sargs = (struct nfsslargs *)args;
160 fhp1 = sargs->sla_from.da_fhandle;
165 struct nfscreatargs *sargs = (struct nfscreatargs *)args;
166 fhp1 = sargs->ca_da.da_fhandle;
171 struct nfsdiropargs *sargs = (struct nfsdiropargs *)args;
172 fhp1 = sargs->da_fhandle;
177 struct nfsrddirargs *sargs = (struct nfsrddirargs *)args;
178 fhp1 = (fhandle_t *) & sargs->rda_fh;
185 /* Ok if arg 1 is in AFS or if 2 args and arg 2 is in AFS */
186 if (fhp1 && is_afs_fh(fhp1)) {
192 if (fhp2 && is_afs_fh(fhp2)) {
201 acl2_to_afs_call(int which, caddr_t * args, fhandle_t ** fhpp)
210 case ACLPROC2_GETACL:
212 struct GETACL2args *sargs = (struct GETACL2args *)args;
216 case ACLPROC2_SETACL:
218 struct SETACL2args *sargs = (struct SETACL2args *)args;
222 case ACLPROC2_GETATTR:
224 struct GETATTR2args *sargs = (struct GETATTR2args *)args;
228 case ACLPROC2_ACCESS:
230 struct ACCESS2args *sargs = (struct ACCESS2args *)args;
234 #if defined(AFS_SUN510_ENV)
235 case ACLPROC2_GETXATTRDIR:
237 struct GETXATTRDIR2args *sargs = (struct GETXATTRDIR2args *)args;
246 if (fhp && is_afs_fh(fhp)) {
255 afs_nfs2_dispatcher(int type, afs_int32 which, char *argp,
256 struct exportinfo *exp, struct svc_req *rp,
261 afs_int32 client = 0;
263 fhandle_t *fh = (fhandle_t *) argp;
264 fhandle_t *fh2 = (fhandle_t *) 0;
266 if (!xlatorinit_v2_done)
269 sa = (struct sockaddr *)svc_getrpccaller(rp->rq_xprt)->buf;
270 if (sa->sa_family == AF_INET)
271 client = ((struct sockaddr_in *)sa)->sin_addr.s_addr;
277 code = (client && nfs2_to_afs_call(which, argp, &fh, &fh2));
280 code = (client && acl2_to_afs_call(which, argp, &fh));
287 struct afs_exporter *out = 0;
290 struct SmallFid Sfid;
292 memcpy((char *)&Sfid, fh->fh_data, SIZEOF_SMALLFID);
294 afs_Trace2(afs_iclSetp, CM_TRACE_NFSIN1, ICL_TYPE_POINTER, client,
295 ICL_TYPE_FID, &Sfid);
300 afs_nobody = exp->exi_export.ex_anon;
304 afs_nfsclient_reqhandler((struct afs_exporter *)0, &crp, client,
319 afs_nfs2_smallfidder(struct nfsdiropres *dr)
321 fhandle_t *fhp = (fhandle_t *) & dr->dr_fhandle;
325 #if defined(AFS_SUN5_64BIT_ENV)
326 /* See also afs_fid() */
327 memcpy((char *)addr, fhp->fh_data, SIZEOF_SMALLFID);
328 addr[1] = (addr[1] >> 48) & 0xffff;
330 memcpy((char *)addr, fhp->fh_data, 2 * sizeof(long));
334 vcp = VTOAFS((struct vnode *)addr[0]);
336 if (addr[1] == AFS_XLATOR_MAGIC) {
337 if (dr->dr_status == NFS_OK) {
338 struct SmallFid Sfid;
341 /* Make up and copy out a SmallFid */
342 tcell = afs_GetCell(vcp->f.fid.Cell, READ_LOCK);
343 Sfid.Volume = vcp->f.fid.Fid.Volume;
345 ((tcell->cellIndex << 24) | (vcp->f.fid.Fid.Unique & 0xffffff));
346 afs_PutCell(tcell, READ_LOCK);
347 Sfid.Vnode = (u_short) (vcp->f.fid.Fid.Vnode & 0xffff);
348 fhp->fh_len = SIZEOF_SMALLFID;
349 memcpy(dr->dr_fhandle.fh_data, (char *)&Sfid, fhp->fh_len);
351 afs_Trace3(afs_iclSetp, CM_TRACE_NFSOUT, ICL_TYPE_INT32, 0,
352 ICL_TYPE_POINTER, vcp, ICL_TYPE_FID, &Sfid);
355 /* If we have a ref, release it */
356 if (vcp->vrefCount >= 1)
357 AFS_RELE(AFSTOV(vcp));
363 afs_nfs2_noaccess(struct afs_nfs2_resp *resp)
365 resp->status = NFSERR_ACCES;
369 afs_nfs2_null(char *args, char *xp, char *exp, char *rp, char *crp)
374 afs_nfs2_root(char *args, char *xp, char *exp, char *rp, char *crp)
379 afs_nfs2_writecache(char *args, char *xp, char *exp, char *rp, char *crp)
384 afs_nfs2_getattr(char *args, char *xp, char *exp, char *rp, char *crp)
387 afs_ucred_t *svcred = curthread->t_cred;
388 curthread->t_cred = (afs_ucred_t *)crp;
389 call = afs_nfs2_dispatcher(0, RFS_GETATTR, (char *)args, exp, rp, crp);
391 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
393 (*afs_rfs_disp_tbl[RFS_GETATTR].orig_proc) (args, xp, exp, rp, crp);
394 curthread->t_cred = svcred;
399 afs_nfs2_setattr(char *args, char *xp, char *exp, char *rp, char *crp)
402 afs_ucred_t *svcred = curthread->t_cred;
403 curthread->t_cred = (afs_ucred_t *)crp;
404 call = afs_nfs2_dispatcher(0, RFS_SETATTR, (char *)args, exp, rp, crp);
406 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
408 (*afs_rfs_disp_tbl[RFS_SETATTR].orig_proc) (args, xp, exp, rp, crp);
409 curthread->t_cred = svcred;
414 afs_nfs2_lookup(char *args, char *xp, char *exp, char *rp, char *crp)
417 afs_ucred_t *svcred = curthread->t_cred;
418 curthread->t_cred = (afs_ucred_t *)crp;
419 call = afs_nfs2_dispatcher(0, RFS_LOOKUP, (char *)args, exp, rp, crp);
421 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
423 (*afs_rfs_disp_tbl[RFS_LOOKUP].orig_proc) (args, xp, exp, rp, crp);
424 if (afs_NFSRootOnly && call)
425 afs_nfs2_smallfidder(xp);
427 curthread->t_cred = svcred;
432 afs_nfs2_readlink(char *args, char *xp, char *exp, char *rp, char *crp)
435 afs_ucred_t *svcred = curthread->t_cred;
436 curthread->t_cred = (afs_ucred_t *)crp;
437 call = afs_nfs2_dispatcher(0, RFS_READLINK, (char *)args, exp, rp, crp);
439 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
441 (*afs_rfs_disp_tbl[RFS_READLINK].orig_proc) (args, xp, exp, rp, crp);
442 curthread->t_cred = svcred;
447 afs_nfs2_read(char *args, char *xp, char *exp, char *rp, char *crp)
450 afs_ucred_t *svcred = curthread->t_cred;
451 curthread->t_cred = (afs_ucred_t *)crp;
452 call = afs_nfs2_dispatcher(0, RFS_READ, (char *)args, exp, rp, crp);
454 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
456 (*afs_rfs_disp_tbl[RFS_READ].orig_proc) (args, xp, exp, rp, crp);
457 curthread->t_cred = svcred;
462 afs_nfs2_write(char *args, char *xp, char *exp, char *rp, char *crp)
465 afs_ucred_t *svcred = curthread->t_cred;
466 curthread->t_cred = (afs_ucred_t *)crp;
467 call = afs_nfs2_dispatcher(0, RFS_WRITE, (char *)args, exp, rp, crp);
469 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
471 (*afs_rfs_disp_tbl[RFS_WRITE].orig_proc) (args, xp, exp, rp, crp);
472 curthread->t_cred = svcred;
477 afs_nfs2_create(char *args, char *xp, char *exp, char *rp, char *crp)
480 afs_ucred_t *svcred = curthread->t_cred;
481 curthread->t_cred = (afs_ucred_t *)crp;
482 call = afs_nfs2_dispatcher(0, RFS_CREATE, (char *)args, exp, rp, crp);
484 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
486 (*afs_rfs_disp_tbl[RFS_CREATE].orig_proc) (args, xp, exp, rp, crp);
487 if (afs_NFSRootOnly && call)
488 afs_nfs2_smallfidder(xp);
490 curthread->t_cred = svcred;
495 afs_nfs2_remove(char *args, char *xp, char *exp, char *rp, char *crp)
498 afs_ucred_t *svcred = curthread->t_cred;
499 curthread->t_cred = (afs_ucred_t *)crp;
500 call = afs_nfs2_dispatcher(0, RFS_REMOVE, (char *)args, exp, rp, crp);
502 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
504 (*afs_rfs_disp_tbl[RFS_REMOVE].orig_proc) (args, xp, exp, rp, crp);
505 curthread->t_cred = svcred;
510 afs_nfs2_rename(char *args, char *xp, char *exp, char *rp, char *crp)
513 afs_ucred_t *svcred = curthread->t_cred;
514 curthread->t_cred = (afs_ucred_t *)crp;
515 call = afs_nfs2_dispatcher(0, RFS_RENAME, (char *)args, exp, rp, crp);
517 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
519 (*afs_rfs_disp_tbl[RFS_RENAME].orig_proc) (args, xp, exp, rp, crp);
520 curthread->t_cred = svcred;
525 afs_nfs2_link(char *args, char *xp, char *exp, char *rp, char *crp)
528 afs_ucred_t *svcred = curthread->t_cred;
529 curthread->t_cred = (afs_ucred_t *)crp;
530 call = afs_nfs2_dispatcher(0, RFS_LINK, (char *)args, exp, rp, crp);
532 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
534 (*afs_rfs_disp_tbl[RFS_LINK].orig_proc) (args, xp, exp, rp, crp);
535 curthread->t_cred = svcred;
540 afs_nfs2_symlink(char *args, char *xp, char *exp, char *rp, char *crp)
543 afs_ucred_t *svcred = curthread->t_cred;
544 curthread->t_cred = (afs_ucred_t *)crp;
545 call = afs_nfs2_dispatcher(0, RFS_SYMLINK, (char *)args, exp, rp, crp);
547 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
549 (*afs_rfs_disp_tbl[RFS_SYMLINK].orig_proc) (args, xp, exp, rp, crp);
550 curthread->t_cred = svcred;
555 afs_nfs2_mkdir(char *args, char *xp, char *exp, char *rp, char *crp)
558 afs_ucred_t *svcred = curthread->t_cred;
559 curthread->t_cred = (afs_ucred_t *)crp;
560 call = afs_nfs2_dispatcher(0, RFS_MKDIR, (char *)args, exp, rp, crp);
562 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
564 (*afs_rfs_disp_tbl[RFS_MKDIR].orig_proc) (args, xp, exp, rp, crp);
565 if (afs_NFSRootOnly && call)
566 afs_nfs2_smallfidder(xp);
568 curthread->t_cred = svcred;
573 afs_nfs2_rmdir(char *args, char *xp, char *exp, char *rp, char *crp)
576 afs_ucred_t *svcred = curthread->t_cred;
577 curthread->t_cred = (afs_ucred_t *)crp;
578 call = afs_nfs2_dispatcher(0, RFS_RMDIR, (char *)args, exp, rp, crp);
580 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
582 (*afs_rfs_disp_tbl[RFS_RMDIR].orig_proc) (args, xp, exp, rp, crp);
583 curthread->t_cred = svcred;
588 afs_nfs2_readdir(char *args, char *xp, char *exp, char *rp, char *crp)
591 afs_ucred_t *svcred = curthread->t_cred;
592 curthread->t_cred = (afs_ucred_t *)crp;
593 call = afs_nfs2_dispatcher(0, RFS_READDIR, (char *)args, exp, rp, crp);
595 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
597 (*afs_rfs_disp_tbl[RFS_READDIR].orig_proc) (args, xp, exp, rp, crp);
598 curthread->t_cred = svcred;
603 afs_nfs2_statfs(char *args, char *xp, char *exp, char *rp, char *crp)
606 afs_ucred_t *svcred = curthread->t_cred;
607 curthread->t_cred = (afs_ucred_t *)crp;
608 call = afs_nfs2_dispatcher(0, RFS_STATFS, (char *)args, exp, rp, crp);
610 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
612 (*afs_rfs_disp_tbl[RFS_STATFS].orig_proc) (args, xp, exp, rp, crp);
613 curthread->t_cred = svcred;
617 struct afs_nfs_disp_tbl afs_rfs_disp_tbl[RFS_NPROC] = {
625 {afs_nfs2_writecache},
639 afs_acl2_getacl(char *args, char *xp, char *exp, char *rp, char *crp)
642 afs_ucred_t *svcred = curthread->t_cred;
643 curthread->t_cred = (afs_ucred_t *)crp;
645 afs_nfs2_dispatcher(1, ACLPROC2_GETACL, (char *)args, exp, rp, crp);
647 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
649 (*afs_acl_disp_tbl[ACLPROC2_GETACL].orig_proc) (args, xp, exp, rp,
651 curthread->t_cred = svcred;
656 afs_acl2_setacl(char *args, char *xp, char *exp, char *rp, char *crp)
659 afs_ucred_t *svcred = curthread->t_cred;
660 curthread->t_cred = (afs_ucred_t *)crp;
662 afs_nfs2_dispatcher(1, ACLPROC2_SETACL, (char *)args, exp, rp, crp);
664 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
666 (*afs_acl_disp_tbl[ACLPROC2_SETACL].orig_proc) (args, xp, exp, rp,
668 curthread->t_cred = svcred;
673 afs_acl2_getattr(char *args, char *xp, char *exp, char *rp, char *crp)
676 afs_ucred_t *svcred = curthread->t_cred;
677 curthread->t_cred = (afs_ucred_t *)crp;
679 afs_nfs2_dispatcher(1, ACLPROC2_GETATTR, (char *)args, exp, rp, crp);
681 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
683 (*afs_acl_disp_tbl[ACLPROC2_GETATTR].orig_proc) (args, xp, exp, rp,
685 curthread->t_cred = svcred;
690 afs_acl2_access(char *args, char *xp, char *exp, char *rp, char *crp)
693 afs_ucred_t *svcred = curthread->t_cred;
694 curthread->t_cred = (afs_ucred_t *)crp;
696 afs_nfs2_dispatcher(1, ACLPROC2_ACCESS, (char *)args, exp, rp, crp);
698 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
700 (*afs_acl_disp_tbl[ACLPROC2_ACCESS].orig_proc) (args, xp, exp, rp,
702 curthread->t_cred = svcred;
706 #if defined(AFS_SUN510_ENV)
708 afs_acl2_getxattrdir(char *args, char *xp, char *exp, char *rp, char *crp)
711 afs_ucred_t *svcred = curthread->t_cred;
712 curthread->t_cred = (afs_ucred_t *)crp;
714 afs_nfs2_dispatcher(1, ACLPROC2_GETXATTRDIR, (char *)args, exp, rp, crp);
716 afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
718 (*afs_acl_disp_tbl[ACLPROC2_GETXATTRDIR].orig_proc) (args, xp, exp, rp,
720 curthread->t_cred = svcred;
725 struct afs_nfs_disp_tbl afs_acl_disp_tbl[ACL2_NPROC] = {
731 #if defined(AFS_SUN510_ENV)
732 {afs_acl2_getxattrdir}
736 /* Munge the dispatch tables to link us in first */
738 afs_xlatorinit_v2(struct rfs_disp_tbl *_rfs_tbl,
739 struct rfs_disp_tbl *_acl_tbl)
743 if (xlatorinit_v2_done++)
746 for (i = 0; i < RFS_NPROC; i++) {
747 afs_rfs_disp_tbl[i].orig_proc = _rfs_tbl[i].dis_proc;
748 _rfs_tbl[i].dis_proc = afs_rfs_disp_tbl[i].afs_proc;
751 for (i = 0; i < 5; i++) {
752 afs_acl_disp_tbl[i].orig_proc = _acl_tbl[i].dis_proc;
753 _acl_tbl[i].dis_proc = afs_acl_disp_tbl[i].afs_proc;
758 #define RFS3_NPROC 22
762 #if defined(AFS_SUN510_ENV)
769 struct afs_nfs_disp_tbl afs_rfs3_disp_tbl[RFS3_NPROC];
770 struct afs_nfs_disp_tbl afs_acl3_disp_tbl[ACL3_NPROC];
772 struct afs_nfs3_resp {
776 typedef struct afs_nfs3_resp afs_nfs3_resp;
779 is_afs_fh3(nfs_fh3 * fhp)
781 if ((fhp->fh3_fsid.val[0] == AFS_VFSMAGIC)
782 && (fhp->fh3_fsid.val[1] == AFS_VFSFSID))
788 afs_nfs3_noaccess(struct afs_nfs3_resp *resp)
790 resp->status = NFS3ERR_ACCES;
795 afs_nfs3_notsupp(struct afs_nfs3_resp *resp)
797 resp->status = NFS3ERR_NOTSUPP;
802 nfs3_to_afs_call(int which, caddr_t * args, nfs_fh3 ** fhpp, nfs_fh3 ** fh2pp)
809 afs_Trace1(afs_iclSetp, CM_TRACE_NFS3IN, ICL_TYPE_INT32, which);
810 *fh2pp = (nfs_fh3 *) 0;
812 case NFSPROC3_GETATTR:
814 GETATTR3args *arg = (GETATTR3args *) args;
815 fhp1 = (nfs_fh3 *) & arg->object;
818 case NFSPROC3_SETATTR:
820 SETATTR3args *arg = (SETATTR3args *) args;
821 fhp1 = (nfs_fh3 *) & arg->object;
824 case NFSPROC3_LOOKUP:
826 LOOKUP3args *arg = (LOOKUP3args *) args;
827 fhp1 = (nfs_fh3 *) arg->what.dirp;
830 case NFSPROC3_ACCESS:
832 ACCESS3args *arg = (ACCESS3args *) args;
833 fhp1 = (nfs_fh3 *) & arg->object;
836 case NFSPROC3_READLINK:
838 READLINK3args *arg = (READLINK3args *) args;
839 fhp1 = (nfs_fh3 *) & arg->symlink;
844 READ3args *arg = (READ3args *) args;
845 fhp1 = (nfs_fh3 *) & arg->file;
850 WRITE3args *arg = (WRITE3args *) args;
851 fhp1 = (nfs_fh3 *) & arg->file;
854 case NFSPROC3_CREATE:
856 CREATE3args *arg = (CREATE3args *) args;
857 fhp1 = (nfs_fh3 *) arg->where.dirp;
862 MKDIR3args *arg = (MKDIR3args *) args;
863 fhp1 = (nfs_fh3 *) arg->where.dirp;
866 case NFSPROC3_SYMLINK:
868 SYMLINK3args *arg = (SYMLINK3args *) args;
869 fhp1 = (nfs_fh3 *) arg->where.dirp;
874 MKNOD3args *arg = (MKNOD3args *) args;
875 fhp1 = (nfs_fh3 *) arg->where.dirp;
878 case NFSPROC3_REMOVE:
880 REMOVE3args *arg = (REMOVE3args *) args;
881 fhp1 = (nfs_fh3 *) arg->object.dirp;
886 RMDIR3args *arg = (RMDIR3args *) args;
887 fhp1 = (nfs_fh3 *) arg->object.dirp;
890 case NFSPROC3_RENAME:
892 RENAME3args *arg = (RENAME3args *) args;
893 fhp1 = (nfs_fh3 *) arg->from.dirp;
894 fhp2 = (nfs_fh3 *) arg->to.dirp;
899 LINK3args *arg = (LINK3args *) args;
900 fhp1 = (nfs_fh3 *) & arg->file;
901 fhp2 = (nfs_fh3 *) arg->link.dirp;
904 case NFSPROC3_READDIR:
906 READDIR3args *arg = (READDIR3args *) args;
907 fhp1 = (nfs_fh3 *) & arg->dir;
910 case NFSPROC3_READDIRPLUS:
912 READDIRPLUS3args *arg = (READDIRPLUS3args *) args;
913 fhp1 = (nfs_fh3 *) & arg->dir;
916 case NFSPROC3_FSSTAT:
918 FSSTAT3args *arg = (FSSTAT3args *) args;
919 fhp1 = (nfs_fh3 *) & arg->fsroot;
922 case NFSPROC3_FSINFO:
924 FSINFO3args *arg = (FSINFO3args *) args;
925 fhp1 = (nfs_fh3 *) & arg->fsroot;
928 case NFSPROC3_PATHCONF:
930 PATHCONF3args *arg = (PATHCONF3args *) args;
931 fhp1 = (nfs_fh3 *) & arg->object;
934 case NFSPROC3_COMMIT:
936 COMMIT3args *arg = (COMMIT3args *) args;
937 fhp1 = (nfs_fh3 *) & arg->file;
944 if (fhp1 && is_afs_fh3(fhp1)) {
950 if (fhp2 && is_afs_fh3(fhp2)) {
959 acl3_to_afs_call(int which, caddr_t * args, nfs_fh3 ** fhpp)
964 case ACLPROC3_GETACL:
966 struct GETACL3args *sargs = (struct GETACL3args *)args;
970 case ACLPROC3_SETACL:
972 struct SETACL3args *sargs = (struct SETACL3args *)args;
976 #if defined(AFS_SUN510_ENV)
977 case ACLPROC3_GETXATTRDIR:
979 struct GETXATTRDIR3args *sargs = (struct GETXATTRDIR3args *)args;
988 if (fhp && is_afs_fh3(fhp)) {
997 afs_nfs3_dispatcher(int type, afs_int32 which, char *argp,
998 struct exportinfo *exp, struct svc_req *rp,
1003 afs_int32 client = 0;
1004 struct sockaddr *sa;
1005 nfs_fh3 *fh = (nfs_fh3 *) argp;
1006 nfs_fh3 *fh2 = (nfs_fh3 *) 0;
1008 if (!xlatorinit_v3_done)
1011 sa = (struct sockaddr *)svc_getrpccaller(rp->rq_xprt)->buf;
1015 if (sa->sa_family == AF_INET)
1016 client = ((struct sockaddr_in *)sa)->sin_addr.s_addr;
1022 code = (client && nfs3_to_afs_call(which, argp, &fh, &fh2));
1025 code = (client && acl3_to_afs_call(which, argp, &fh));
1032 struct afs_exporter *out = 0;
1034 static int once = 0;
1035 struct SmallFid Sfid;
1037 memcpy((char *)&Sfid, fh->fh3_data, SIZEOF_SMALLFID);
1039 afs_Trace2(afs_iclSetp, CM_TRACE_NFS3IN1, ICL_TYPE_INT32, client,
1040 ICL_TYPE_FID, &Sfid);
1044 afs_nobody = exp->exi_export.ex_anon;
1048 afs_nfsclient_reqhandler((struct afs_exporter *)0, &crp, client,
1064 afs_nfs3_smallfidder(struct nfs_fh3 *fhp, int status)
1069 #if defined(AFS_SUN5_64BIT_ENV)
1070 /* See also afs_fid() */
1071 memcpy((char *)addr, fhp->fh3_data, 10);
1072 addr[1] = (addr[1] >> 48) & 0xffff;
1074 memcpy((char *)addr, fhp->fh3_data, 2 * sizeof(long));
1078 vcp = VTOAFS((struct vnode *)addr[0]);
1080 /* See also afs_osi_vget */
1081 if (addr[1] == AFS_XLATOR_MAGIC) {
1082 if (status == NFS_OK) {
1083 struct SmallFid Sfid;
1086 /* Make up and copy out a SmallFid */
1087 tcell = afs_GetCell(vcp->f.fid.Cell, READ_LOCK);
1088 Sfid.Volume = vcp->f.fid.Fid.Volume;
1089 Sfid.CellAndUnique =
1090 ((tcell->cellIndex << 24) | (vcp->f.fid.Fid.Unique & 0xffffff));
1091 afs_PutCell(tcell, READ_LOCK);
1092 Sfid.Vnode = (u_short) (vcp->f.fid.Fid.Vnode & 0xffff);
1093 fhp->fh3_len = SIZEOF_SMALLFID;
1094 memcpy(fhp->fh3_data, (char *)&Sfid, fhp->fh3_len);
1096 afs_Trace3(afs_iclSetp, CM_TRACE_NFS3OUT, ICL_TYPE_INT32, status,
1097 ICL_TYPE_POINTER, vcp, ICL_TYPE_FID, &Sfid);
1100 /* If we have a ref, release it */
1101 if (vcp->vrefCount >= 1)
1102 AFS_RELE(AFSTOV(vcp));
1108 afs_nfs3_getattr(char *args, char *xp, char *exp, char *rp, char *crp)
1111 afs_nfs3_resp dummy;
1112 afs_ucred_t *svcred = curthread->t_cred;
1113 curthread->t_cred = (afs_ucred_t *)crp;
1115 afs_nfs3_dispatcher(0, NFSPROC3_GETATTR, (char *)args, exp, rp, crp);
1117 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1119 (*afs_rfs3_disp_tbl[NFSPROC3_GETATTR].orig_proc) (args, xp, exp, rp,
1121 curthread->t_cred = svcred;
1126 afs_nfs3_setattr(char *args, char *xp, char *exp, char *rp, char *crp)
1129 afs_nfs3_resp dummy;
1130 afs_ucred_t *svcred = curthread->t_cred;
1131 curthread->t_cred = (afs_ucred_t *)crp;
1133 afs_nfs3_dispatcher(0, NFSPROC3_SETATTR, (char *)args, exp, rp, crp);
1135 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1137 (*afs_rfs3_disp_tbl[NFSPROC3_SETATTR].orig_proc) (args, xp, exp, rp,
1139 curthread->t_cred = svcred;
1144 afs_nfs3_lookup(char *args, char *xp, char *exp, char *rp, char *crp)
1147 afs_nfs3_resp dummy;
1148 afs_ucred_t *svcred = curthread->t_cred;
1149 curthread->t_cred = (afs_ucred_t *)crp;
1151 afs_nfs3_dispatcher(0, NFSPROC3_LOOKUP, (char *)args, exp, rp, crp);
1153 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1155 (*afs_rfs3_disp_tbl[NFSPROC3_LOOKUP].orig_proc) (args, xp, exp, rp,
1157 if (afs_NFSRootOnly && call) {
1158 LOOKUP3res *resp = (LOOKUP3res *) xp;
1159 afs_nfs3_smallfidder(&resp->resok.object, resp->status);
1162 curthread->t_cred = svcred;
1167 afs_nfs3_access(char *args, char *xp, char *exp, char *rp, char *crp)
1170 afs_nfs3_resp dummy;
1171 afs_ucred_t *svcred = curthread->t_cred;
1172 curthread->t_cred = (afs_ucred_t *)crp;
1174 afs_nfs3_dispatcher(0, NFSPROC3_ACCESS, (char *)args, exp, rp, crp);
1176 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1178 (*afs_rfs3_disp_tbl[NFSPROC3_ACCESS].orig_proc) (args, xp, exp, rp,
1180 curthread->t_cred = svcred;
1185 afs_nfs3_readlink(char *args, char *xp, char *exp, char *rp, char *crp)
1188 afs_nfs3_resp dummy;
1189 afs_ucred_t *svcred = curthread->t_cred;
1190 curthread->t_cred = (afs_ucred_t *)crp;
1192 afs_nfs3_dispatcher(0, NFSPROC3_READLINK, (char *)args, exp, rp,
1195 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1197 (*afs_rfs3_disp_tbl[NFSPROC3_READLINK].orig_proc) (args, xp, exp, rp,
1199 curthread->t_cred = svcred;
1204 afs_nfs3_read(char *args, char *xp, char *exp, char *rp, char *crp)
1207 afs_nfs3_resp dummy;
1208 afs_ucred_t *svcred = curthread->t_cred;
1209 curthread->t_cred = (afs_ucred_t *)crp;
1210 call = afs_nfs3_dispatcher(0, NFSPROC3_READ, (char *)args, exp, rp, crp);
1212 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1214 (*afs_rfs3_disp_tbl[NFSPROC3_READ].orig_proc) (args, xp, exp, rp,
1216 curthread->t_cred = svcred;
1221 afs_nfs3_write(char *args, char *xp, char *exp, char *rp, char *crp)
1224 afs_nfs3_resp dummy;
1225 afs_ucred_t *svcred = curthread->t_cred;
1226 curthread->t_cred = (afs_ucred_t *)crp;
1228 afs_nfs3_dispatcher(0, NFSPROC3_WRITE, (char *)args, exp, rp, crp);
1230 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1232 (*afs_rfs3_disp_tbl[NFSPROC3_WRITE].orig_proc) (args, xp, exp, rp,
1234 curthread->t_cred = svcred;
1239 afs_nfs3_create(char *args, char *xp, char *exp, char *rp, char *crp)
1242 afs_nfs3_resp dummy;
1243 afs_ucred_t *svcred = curthread->t_cred;
1244 curthread->t_cred = (afs_ucred_t *)crp;
1246 afs_nfs3_dispatcher(0, NFSPROC3_CREATE, (char *)args, exp, rp, crp);
1248 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1250 (*afs_rfs3_disp_tbl[NFSPROC3_CREATE].orig_proc) (args, xp, exp, rp,
1252 if (afs_NFSRootOnly && call) {
1253 CREATE3res *resp = (CREATE3res *) xp;
1254 afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status);
1257 curthread->t_cred = svcred;
1262 afs_nfs3_mkdir(char *args, char *xp, char *exp, char *rp, char *crp)
1265 afs_nfs3_resp dummy;
1266 afs_ucred_t *svcred = curthread->t_cred;
1267 curthread->t_cred = (afs_ucred_t *)crp;
1269 afs_nfs3_dispatcher(0, NFSPROC3_MKDIR, (char *)args, exp, rp, crp);
1271 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1273 (*afs_rfs3_disp_tbl[NFSPROC3_MKDIR].orig_proc) (args, xp, exp, rp,
1275 if (afs_NFSRootOnly && call) {
1276 MKDIR3res *resp = (MKDIR3res *) xp;
1277 afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status);
1280 curthread->t_cred = svcred;
1285 afs_nfs3_symlink(char *args, char *xp, char *exp, char *rp, char *crp)
1288 afs_nfs3_resp dummy;
1289 afs_ucred_t *svcred = curthread->t_cred;
1290 curthread->t_cred = (afs_ucred_t *)crp;
1292 afs_nfs3_dispatcher(0, NFSPROC3_SYMLINK, (char *)args, exp, rp, crp);
1294 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1296 (*afs_rfs3_disp_tbl[NFSPROC3_SYMLINK].orig_proc) (args, xp, exp, rp,
1298 if (afs_NFSRootOnly && call) {
1299 SYMLINK3res *resp = (SYMLINK3res *) xp;
1300 afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status);
1303 curthread->t_cred = svcred;
1308 afs_nfs3_mknod(char *args, char *xp, char *exp, char *rp, char *crp)
1311 afs_nfs3_resp dummy;
1312 afs_ucred_t *svcred = curthread->t_cred;
1313 curthread->t_cred = (afs_ucred_t *)crp;
1315 afs_nfs3_dispatcher(0, NFSPROC3_MKNOD, (char *)args, exp, rp, crp);
1317 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1319 (*afs_rfs3_disp_tbl[NFSPROC3_MKNOD].orig_proc) (args, xp, exp, rp,
1321 if (afs_NFSRootOnly && call) {
1322 MKNOD3res *resp = (MKNOD3res *) xp;
1323 afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status);
1326 curthread->t_cred = svcred;
1331 afs_nfs3_remove(char *args, char *xp, char *exp, char *rp, char *crp)
1334 afs_nfs3_resp dummy;
1335 afs_ucred_t *svcred = curthread->t_cred;
1336 curthread->t_cred = (afs_ucred_t *)crp;
1338 afs_nfs3_dispatcher(0, NFSPROC3_REMOVE, (char *)args, exp, rp, crp);
1340 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1342 (*afs_rfs3_disp_tbl[NFSPROC3_REMOVE].orig_proc) (args, xp, exp, rp,
1344 curthread->t_cred = svcred;
1349 afs_nfs3_rmdir(char *args, char *xp, char *exp, char *rp, char *crp)
1352 afs_nfs3_resp dummy;
1353 afs_ucred_t *svcred = curthread->t_cred;
1354 curthread->t_cred = (afs_ucred_t *)crp;
1356 afs_nfs3_dispatcher(0, NFSPROC3_RMDIR, (char *)args, exp, rp, crp);
1358 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1360 (*afs_rfs3_disp_tbl[NFSPROC3_RMDIR].orig_proc) (args, xp, exp, rp,
1362 curthread->t_cred = svcred;
1367 afs_nfs3_rename(char *args, char *xp, char *exp, char *rp, char *crp)
1370 afs_nfs3_resp dummy;
1371 afs_ucred_t *svcred = curthread->t_cred;
1372 curthread->t_cred = (afs_ucred_t *)crp;
1374 afs_nfs3_dispatcher(0, NFSPROC3_RENAME, (char *)args, exp, rp, crp);
1376 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1378 (*afs_rfs3_disp_tbl[NFSPROC3_RENAME].orig_proc) (args, xp, exp, rp,
1380 curthread->t_cred = svcred;
1385 afs_nfs3_link(char *args, char *xp, char *exp, char *rp, char *crp)
1388 afs_nfs3_resp dummy;
1389 afs_ucred_t *svcred = curthread->t_cred;
1390 curthread->t_cred = (afs_ucred_t *)crp;
1391 call = afs_nfs3_dispatcher(0, NFSPROC3_LINK, (char *)args, exp, rp, crp);
1393 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1395 (*afs_rfs3_disp_tbl[NFSPROC3_LINK].orig_proc) (args, xp, exp, rp,
1397 curthread->t_cred = svcred;
1402 afs_nfs3_readdir(char *args, char *xp, char *exp, char *rp, char *crp)
1405 afs_nfs3_resp dummy;
1406 afs_ucred_t *svcred = curthread->t_cred;
1407 curthread->t_cred = (afs_ucred_t *)crp;
1409 afs_nfs3_dispatcher(0, NFSPROC3_READDIR, (char *)args, exp, rp, crp);
1411 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1413 (*afs_rfs3_disp_tbl[NFSPROC3_READDIR].orig_proc) (args, xp, exp, rp,
1415 curthread->t_cred = svcred;
1420 afs_nfs3_readdirplus(char *args, char *xp, char *exp, char *rp, char *crp)
1423 afs_nfs3_resp dummy;
1424 afs_ucred_t *svcred = curthread->t_cred;
1425 curthread->t_cred = (afs_ucred_t *)crp;
1427 afs_nfs3_dispatcher(0, NFSPROC3_READDIRPLUS, (char *)args, exp, rp,
1430 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1432 afs_nfs3_notsupp((struct afs_nfs3_resp *)xp);
1434 (*afs_rfs3_disp_tbl[NFSPROC3_READDIRPLUS].orig_proc) (args, xp, exp,
1436 curthread->t_cred = svcred;
1441 afs_nfs3_fsstat(char *args, char *xp, char *exp, char *rp, char *crp)
1444 afs_nfs3_resp dummy;
1445 afs_ucred_t *svcred = curthread->t_cred;
1446 curthread->t_cred = (afs_ucred_t *)crp;
1448 afs_nfs3_dispatcher(0, NFSPROC3_FSSTAT, (char *)args, exp, rp, crp);
1450 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1452 (*afs_rfs3_disp_tbl[NFSPROC3_FSSTAT].orig_proc) (args, xp, exp, rp,
1454 curthread->t_cred = svcred;
1459 afs_nfs3_fsinfo(char *args, char *xp, char *exp, char *rp, char *crp)
1462 afs_nfs3_resp dummy;
1463 afs_ucred_t *svcred = curthread->t_cred;
1464 curthread->t_cred = (afs_ucred_t *)crp;
1466 afs_nfs3_dispatcher(0, NFSPROC3_FSINFO, (char *)args, exp, rp, crp);
1468 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1470 (*afs_rfs3_disp_tbl[NFSPROC3_FSINFO].orig_proc) (args, xp, exp, rp,
1472 curthread->t_cred = svcred;
1477 afs_nfs3_pathconf(char *args, char *xp, char *exp, char *rp, char *crp)
1480 afs_nfs3_resp dummy;
1481 afs_ucred_t *svcred = curthread->t_cred;
1482 curthread->t_cred = (afs_ucred_t *)crp;
1484 afs_nfs3_dispatcher(0, NFSPROC3_PATHCONF, (char *)args, exp, rp,
1487 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1489 (*afs_rfs3_disp_tbl[NFSPROC3_PATHCONF].orig_proc) (args, xp, exp, rp,
1491 curthread->t_cred = svcred;
1496 afs_nfs3_commit(char *args, char *xp, char *exp, char *rp, char *crp)
1499 afs_nfs3_resp dummy;
1500 afs_ucred_t *svcred = curthread->t_cred;
1501 curthread->t_cred = (afs_ucred_t *)crp;
1503 afs_nfs3_dispatcher(0, NFSPROC3_COMMIT, (char *)args, exp, rp, crp);
1505 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1507 (*afs_rfs3_disp_tbl[NFSPROC3_COMMIT].orig_proc) (args, xp, exp, rp,
1509 curthread->t_cred = svcred;
1513 struct afs_nfs_disp_tbl afs_rfs3_disp_tbl[22] = {
1519 {afs_nfs3_readlink},
1531 {afs_nfs3_readdirplus},
1534 {afs_nfs3_pathconf},
1539 afs_acl3_getacl(char *args, char *xp, char *exp, char *rp, char *crp)
1542 afs_ucred_t *svcred = curthread->t_cred;
1543 curthread->t_cred = (afs_ucred_t *)crp;
1545 afs_nfs3_dispatcher(1, ACLPROC3_GETACL, (char *)args, exp, rp, crp);
1547 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1549 (*afs_acl3_disp_tbl[ACLPROC3_GETACL].orig_proc) (args, xp, exp, rp,
1551 curthread->t_cred = svcred;
1556 afs_acl3_setacl(char *args, char *xp, char *exp, char *rp, char *crp)
1559 afs_ucred_t *svcred = curthread->t_cred;
1560 curthread->t_cred = (afs_ucred_t *)crp;
1562 afs_nfs3_dispatcher(1, ACLPROC3_SETACL, (char *)args, exp, rp, crp);
1564 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1566 (*afs_acl3_disp_tbl[ACLPROC3_SETACL].orig_proc) (args, xp, exp, rp,
1568 curthread->t_cred = svcred;
1572 #if defined(AFS_SUN510_ENV)
1574 afs_acl3_getxattrdir(char *args, char *xp, char *exp, char *rp, char *crp)
1577 afs_ucred_t *svcred = curthread->t_cred;
1578 curthread->t_cred = (afs_ucred_t *)crp;
1580 afs_nfs3_dispatcher(1, ACLPROC3_GETXATTRDIR, (char *)args, exp, rp, crp);
1582 afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
1584 (*afs_acl3_disp_tbl[ACLPROC3_GETXATTRDIR].orig_proc) (args, xp, exp, rp,
1586 curthread->t_cred = svcred;
1591 struct afs_nfs_disp_tbl afs_acl3_disp_tbl[ACL3_NPROC] = {
1595 #if defined(AFS_SUN510_ENV)
1596 {afs_acl3_getxattrdir},
1600 /* Munge the dispatch tables to link us in first */
1602 afs_xlatorinit_v3(struct rfs_disp_tbl *_rfs_tbl,
1603 struct rfs_disp_tbl *_acl_tbl)
1607 if (xlatorinit_v3_done++)
1610 for (i = 0; i < 22; i++) {
1611 afs_rfs3_disp_tbl[i].orig_proc = _rfs_tbl[i].dis_proc;
1612 _rfs_tbl[i].dis_proc = afs_rfs3_disp_tbl[i].afs_proc;
1615 for (i = 0; i < 3; i++) {
1616 afs_acl3_disp_tbl[i].orig_proc = _acl_tbl[i].dis_proc;
1617 _acl_tbl[i].dis_proc = afs_acl3_disp_tbl[i].afs_proc;
1620 #endif /* !defined(AFS_NONFSTRANS) */