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, void *args, fhandle_t ** fhpp,
99 afs_Trace1(afs_iclSetp, CM_TRACE_NFSIN, ICL_TYPE_INT32, which);
109 struct nfssaargs *sargs = args;
110 fhp1 = (fhandle_t *) & sargs->saa_fh;
115 struct nfsdiropargs *sargs = args;
116 fhp1 = sargs->da_fhandle;
121 struct nfsreadargs *sargs = args;
122 fhp1 = (fhandle_t *) & sargs->ra_fhandle;
127 struct nfswriteargs *sargs = args;
128 fhp1 = (fhandle_t *) & sargs->wa_fhandle;
133 struct nfscreatargs *sargs = args;
134 fhp1 = sargs->ca_da.da_fhandle;
139 struct nfsdiropargs *sargs = args;
140 fhp1 = sargs->da_fhandle;
145 struct nfsrnmargs *sargs = args;
146 fhp1 = sargs->rna_from.da_fhandle;
147 fhp2 = sargs->rna_to.da_fhandle;
152 struct nfslinkargs *sargs = args;
153 fhp1 = sargs->la_from;
154 fhp2 = sargs->la_to.da_fhandle;
159 struct nfsslargs *sargs = args;
160 fhp1 = sargs->sla_from.da_fhandle;
165 struct nfscreatargs *sargs = args;
166 fhp1 = sargs->ca_da.da_fhandle;
171 struct nfsdiropargs *sargs = args;
172 fhp1 = sargs->da_fhandle;
177 struct nfsrddirargs *sargs = 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, void *args, fhandle_t ** fhpp)
210 case ACLPROC2_GETACL:
212 struct GETACL2args *sargs = args;
216 case ACLPROC2_SETACL:
218 struct SETACL2args *sargs = args;
222 case ACLPROC2_GETATTR:
224 struct GETATTR2args *sargs = args;
228 case ACLPROC2_ACCESS:
230 struct ACCESS2args *sargs = args;
234 #if defined(AFS_SUN510_ENV)
235 case ACLPROC2_GETXATTRDIR:
237 struct GETXATTRDIR2args *sargs = args;
246 if (fhp && is_afs_fh(fhp)) {
255 afs_nfs2_dispatcher(int type, afs_int32 which, void *argp,
256 struct exportinfo *exp, struct svc_req *rp,
261 afs_int32 client = 0;
263 fhandle_t *fh = argp;
264 fhandle_t *fh2 = NULL;
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(&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(NULL, &crp, client, &dummy, &out);
318 afs_nfs2_smallfidder(struct nfsdiropres *dr)
320 fhandle_t *fhp = (fhandle_t *) & dr->dr_fhandle;
324 #if defined(AFS_SUN5_64BIT_ENV)
325 /* See also afs_fid() */
326 memcpy(addr, fhp->fh_data, SIZEOF_SMALLFID);
327 addr[1] = (addr[1] >> 48) & 0xffff;
329 memcpy(addr, fhp->fh_data, 2 * sizeof(long));
333 vcp = VTOAFS((struct vnode *)addr[0]);
335 if (addr[1] == AFS_XLATOR_MAGIC) {
336 if (dr->dr_status == NFS_OK) {
337 struct SmallFid Sfid;
340 /* Make up and copy out a SmallFid */
341 tcell = afs_GetCell(vcp->f.fid.Cell, READ_LOCK);
342 Sfid.Volume = vcp->f.fid.Fid.Volume;
344 ((tcell->cellIndex << 24) | (vcp->f.fid.Fid.Unique & 0xffffff));
345 afs_PutCell(tcell, READ_LOCK);
346 Sfid.Vnode = (u_short) (vcp->f.fid.Fid.Vnode & 0xffff);
347 fhp->fh_len = SIZEOF_SMALLFID;
348 memcpy(dr->dr_fhandle.fh_data, &Sfid, fhp->fh_len);
350 afs_Trace3(afs_iclSetp, CM_TRACE_NFSOUT, ICL_TYPE_INT32, 0,
351 ICL_TYPE_POINTER, vcp, ICL_TYPE_FID, &Sfid);
354 /* If we have a ref, release it */
355 if (vcp->vrefCount >= 1)
356 AFS_RELE(AFSTOV(vcp));
362 afs_nfs2_noaccess(struct afs_nfs2_resp *resp)
364 resp->status = NFSERR_ACCES;
368 afs_nfs2_null(void *args, void *xp, void *exp, void *rp, void *crp)
373 afs_nfs2_root(void *args, void *xp, void *exp, void *rp, void *crp)
378 afs_nfs2_writecache(void *args, void *xp, void *exp, void *rp, void *crp)
383 afs_nfs2_getattr(void *args, void *xp, void *exp, void *rp, void *crp)
386 afs_ucred_t *svcred = curthread->t_cred;
387 curthread->t_cred = crp;
388 call = afs_nfs2_dispatcher(0, RFS_GETATTR, args, exp, rp, crp);
390 afs_nfs2_noaccess(xp);
392 (*afs_rfs_disp_tbl[RFS_GETATTR].orig_proc) (args, xp, exp, rp, crp);
393 curthread->t_cred = svcred;
398 afs_nfs2_setattr(void *args, void *xp, void *exp, void *rp, void *crp)
401 afs_ucred_t *svcred = curthread->t_cred;
402 curthread->t_cred = crp;
403 call = afs_nfs2_dispatcher(0, RFS_SETATTR, args, exp, rp, crp);
405 afs_nfs2_noaccess(xp);
407 (*afs_rfs_disp_tbl[RFS_SETATTR].orig_proc) (args, xp, exp, rp, crp);
408 curthread->t_cred = svcred;
413 afs_nfs2_lookup(void *args, void *xp, void *exp, void *rp, void *crp)
416 afs_ucred_t *svcred = curthread->t_cred;
417 curthread->t_cred = crp;
418 call = afs_nfs2_dispatcher(0, RFS_LOOKUP, args, exp, rp, crp);
420 afs_nfs2_noaccess(xp);
422 (*afs_rfs_disp_tbl[RFS_LOOKUP].orig_proc) (args, xp, exp, rp, crp);
423 if (afs_NFSRootOnly && call)
424 afs_nfs2_smallfidder(xp);
426 curthread->t_cred = svcred;
431 afs_nfs2_readlink(void *args, void *xp, void *exp, void *rp, void *crp)
434 afs_ucred_t *svcred = curthread->t_cred;
435 curthread->t_cred = crp;
436 call = afs_nfs2_dispatcher(0, RFS_READLINK, args, exp, rp, crp);
438 afs_nfs2_noaccess(xp);
440 (*afs_rfs_disp_tbl[RFS_READLINK].orig_proc) (args, xp, exp, rp, crp);
441 curthread->t_cred = svcred;
446 afs_nfs2_read(void *args, void *xp, void *exp, void *rp, void *crp)
449 afs_ucred_t *svcred = curthread->t_cred;
450 curthread->t_cred = crp;
451 call = afs_nfs2_dispatcher(0, RFS_READ, args, exp, rp, crp);
453 afs_nfs2_noaccess(xp);
455 (*afs_rfs_disp_tbl[RFS_READ].orig_proc) (args, xp, exp, rp, crp);
456 curthread->t_cred = svcred;
461 afs_nfs2_write(void *args, void *xp, void *exp, void *rp, void *crp)
464 afs_ucred_t *svcred = curthread->t_cred;
465 curthread->t_cred = crp;
466 call = afs_nfs2_dispatcher(0, RFS_WRITE, args, exp, rp, crp);
468 afs_nfs2_noaccess(xp);
470 (*afs_rfs_disp_tbl[RFS_WRITE].orig_proc) (args, xp, exp, rp, crp);
471 curthread->t_cred = svcred;
476 afs_nfs2_create(void *args, void *xp, void *exp, void *rp, void *crp)
479 afs_ucred_t *svcred = curthread->t_cred;
480 curthread->t_cred = crp;
481 call = afs_nfs2_dispatcher(0, RFS_CREATE, args, exp, rp, crp);
483 afs_nfs2_noaccess(xp);
485 (*afs_rfs_disp_tbl[RFS_CREATE].orig_proc) (args, xp, exp, rp, crp);
486 if (afs_NFSRootOnly && call)
487 afs_nfs2_smallfidder(xp);
489 curthread->t_cred = svcred;
494 afs_nfs2_remove(void *args, void *xp, void *exp, void *rp, void *crp)
497 afs_ucred_t *svcred = curthread->t_cred;
498 curthread->t_cred = crp;
499 call = afs_nfs2_dispatcher(0, RFS_REMOVE, args, exp, rp, crp);
501 afs_nfs2_noaccess(xp);
503 (*afs_rfs_disp_tbl[RFS_REMOVE].orig_proc) (args, xp, exp, rp, crp);
504 curthread->t_cred = svcred;
509 afs_nfs2_rename(void *args, void *xp, void *exp, void *rp, void *crp)
512 afs_ucred_t *svcred = curthread->t_cred;
513 curthread->t_cred = crp;
514 call = afs_nfs2_dispatcher(0, RFS_RENAME, args, exp, rp, crp);
516 afs_nfs2_noaccess(xp);
518 (*afs_rfs_disp_tbl[RFS_RENAME].orig_proc) (args, xp, exp, rp, crp);
519 curthread->t_cred = svcred;
524 afs_nfs2_link(void *args, void *xp, void *exp, void *rp, void *crp)
527 afs_ucred_t *svcred = curthread->t_cred;
528 curthread->t_cred = crp;
529 call = afs_nfs2_dispatcher(0, RFS_LINK, args, exp, rp, crp);
531 afs_nfs2_noaccess(xp);
533 (*afs_rfs_disp_tbl[RFS_LINK].orig_proc) (args, xp, exp, rp, crp);
534 curthread->t_cred = svcred;
539 afs_nfs2_symlink(void *args, void *xp, void *exp, void *rp, void *crp)
542 afs_ucred_t *svcred = curthread->t_cred;
543 curthread->t_cred = crp;
544 call = afs_nfs2_dispatcher(0, RFS_SYMLINK, args, exp, rp, crp);
546 afs_nfs2_noaccess(xp);
548 (*afs_rfs_disp_tbl[RFS_SYMLINK].orig_proc) (args, xp, exp, rp, crp);
549 curthread->t_cred = svcred;
554 afs_nfs2_mkdir(void *args, void *xp, void *exp, void *rp, void *crp)
557 afs_ucred_t *svcred = curthread->t_cred;
558 curthread->t_cred = crp;
559 call = afs_nfs2_dispatcher(0, RFS_MKDIR, args, exp, rp, crp);
561 afs_nfs2_noaccess(xp);
563 (*afs_rfs_disp_tbl[RFS_MKDIR].orig_proc) (args, xp, exp, rp, crp);
564 if (afs_NFSRootOnly && call)
565 afs_nfs2_smallfidder(xp);
567 curthread->t_cred = svcred;
572 afs_nfs2_rmdir(void *args, void *xp, void *exp, void *rp, void *crp)
575 afs_ucred_t *svcred = curthread->t_cred;
576 curthread->t_cred = crp;
577 call = afs_nfs2_dispatcher(0, RFS_RMDIR, args, exp, rp, crp);
579 afs_nfs2_noaccess(xp);
581 (*afs_rfs_disp_tbl[RFS_RMDIR].orig_proc) (args, xp, exp, rp, crp);
582 curthread->t_cred = svcred;
587 afs_nfs2_readdir(void *args, void *xp, void *exp, void *rp, void *crp)
590 afs_ucred_t *svcred = curthread->t_cred;
591 curthread->t_cred = crp;
592 call = afs_nfs2_dispatcher(0, RFS_READDIR, args, exp, rp, crp);
594 afs_nfs2_noaccess(xp);
596 (*afs_rfs_disp_tbl[RFS_READDIR].orig_proc) (args, xp, exp, rp, crp);
597 curthread->t_cred = svcred;
602 afs_nfs2_statfs(void *args, void *xp, void *exp, void *rp, void *crp)
605 afs_ucred_t *svcred = curthread->t_cred;
606 curthread->t_cred = crp;
607 call = afs_nfs2_dispatcher(0, RFS_STATFS, args, exp, rp, crp);
609 afs_nfs2_noaccess(xp);
611 (*afs_rfs_disp_tbl[RFS_STATFS].orig_proc) (args, xp, exp, rp, crp);
612 curthread->t_cred = svcred;
616 struct afs_nfs_disp_tbl afs_rfs_disp_tbl[RFS_NPROC] = {
624 {afs_nfs2_writecache},
638 afs_acl2_getacl(void *args, void *xp, void *exp, void *rp, void *crp)
641 afs_ucred_t *svcred = curthread->t_cred;
642 curthread->t_cred = crp;
644 afs_nfs2_dispatcher(1, ACLPROC2_GETACL, args, exp, rp, crp);
646 afs_nfs2_noaccess(xp);
648 (*afs_acl_disp_tbl[ACLPROC2_GETACL].orig_proc) (args, xp, exp, rp,
650 curthread->t_cred = svcred;
655 afs_acl2_setacl(void *args, void *xp, void *exp, void *rp, void *crp)
658 afs_ucred_t *svcred = curthread->t_cred;
659 curthread->t_cred = crp;
661 afs_nfs2_dispatcher(1, ACLPROC2_SETACL, args, exp, rp, crp);
663 afs_nfs2_noaccess(xp);
665 (*afs_acl_disp_tbl[ACLPROC2_SETACL].orig_proc) (args, xp, exp, rp,
667 curthread->t_cred = svcred;
672 afs_acl2_getattr(void *args, void *xp, void *exp, void *rp, void *crp)
675 afs_ucred_t *svcred = curthread->t_cred;
676 curthread->t_cred = crp;
678 afs_nfs2_dispatcher(1, ACLPROC2_GETATTR, args, exp, rp, crp);
680 afs_nfs2_noaccess(xp);
682 (*afs_acl_disp_tbl[ACLPROC2_GETATTR].orig_proc) (args, xp, exp, rp,
684 curthread->t_cred = svcred;
689 afs_acl2_access(void *args, void *xp, void *exp, void *rp, void *crp)
692 afs_ucred_t *svcred = curthread->t_cred;
693 curthread->t_cred = crp;
695 afs_nfs2_dispatcher(1, ACLPROC2_ACCESS, args, exp, rp, crp);
697 afs_nfs2_noaccess(xp);
699 (*afs_acl_disp_tbl[ACLPROC2_ACCESS].orig_proc) (args, xp, exp, rp,
701 curthread->t_cred = svcred;
705 #if defined(AFS_SUN510_ENV)
707 afs_acl2_getxattrdir(void *args, void *xp, void *exp, void *rp, void *crp)
710 afs_ucred_t *svcred = curthread->t_cred;
711 curthread->t_cred = crp;
713 afs_nfs2_dispatcher(1, ACLPROC2_GETXATTRDIR, args, exp, rp, crp);
715 afs_nfs2_noaccess(xp);
717 (*afs_acl_disp_tbl[ACLPROC2_GETXATTRDIR].orig_proc) (args, xp, exp, rp,
719 curthread->t_cred = svcred;
724 struct afs_nfs_disp_tbl afs_acl_disp_tbl[ACL2_NPROC] = {
730 #if defined(AFS_SUN510_ENV)
731 {afs_acl2_getxattrdir}
735 /* Munge the dispatch tables to link us in first */
737 afs_xlatorinit_v2(struct rfs_disp_tbl *_rfs_tbl,
738 struct rfs_disp_tbl *_acl_tbl)
742 if (xlatorinit_v2_done++)
745 for (i = 0; i < RFS_NPROC; i++) {
746 afs_rfs_disp_tbl[i].orig_proc = _rfs_tbl[i].dis_proc;
747 _rfs_tbl[i].dis_proc = afs_rfs_disp_tbl[i].afs_proc;
750 for (i = 0; i < 5; i++) {
751 afs_acl_disp_tbl[i].orig_proc = _acl_tbl[i].dis_proc;
752 _acl_tbl[i].dis_proc = afs_acl_disp_tbl[i].afs_proc;
757 #define RFS3_NPROC 22
761 #if defined(AFS_SUN510_ENV)
768 struct afs_nfs_disp_tbl afs_rfs3_disp_tbl[RFS3_NPROC];
769 struct afs_nfs_disp_tbl afs_acl3_disp_tbl[ACL3_NPROC];
771 struct afs_nfs3_resp {
775 typedef struct afs_nfs3_resp afs_nfs3_resp;
778 is_afs_fh3(nfs_fh3 * fhp)
780 if ((fhp->fh3_fsid.val[0] == AFS_VFSMAGIC)
781 && (fhp->fh3_fsid.val[1] == AFS_VFSFSID))
787 afs_nfs3_noaccess(struct afs_nfs3_resp *resp)
789 resp->status = NFS3ERR_ACCES;
794 afs_nfs3_notsupp(struct afs_nfs3_resp *resp)
796 resp->status = NFS3ERR_NOTSUPP;
801 nfs3_to_afs_call(int which, void *args, nfs_fh3 ** fhpp, nfs_fh3 ** fh2pp)
808 afs_Trace1(afs_iclSetp, CM_TRACE_NFS3IN, ICL_TYPE_INT32, which);
811 case NFSPROC3_GETATTR:
813 GETATTR3args *arg = args;
814 fhp1 = (nfs_fh3 *) & arg->object;
817 case NFSPROC3_SETATTR:
819 SETATTR3args *arg = args;
820 fhp1 = (nfs_fh3 *) & arg->object;
823 case NFSPROC3_LOOKUP:
825 LOOKUP3args *arg = args;
826 fhp1 = (nfs_fh3 *) arg->what.dirp;
829 case NFSPROC3_ACCESS:
831 ACCESS3args *arg = args;
832 fhp1 = (nfs_fh3 *) & arg->object;
835 case NFSPROC3_READLINK:
837 READLINK3args *arg = args;
838 fhp1 = (nfs_fh3 *) & arg->symlink;
843 READ3args *arg = args;
844 fhp1 = (nfs_fh3 *) & arg->file;
849 WRITE3args *arg = args;
850 fhp1 = (nfs_fh3 *) & arg->file;
853 case NFSPROC3_CREATE:
855 CREATE3args *arg = args;
856 fhp1 = (nfs_fh3 *) arg->where.dirp;
861 MKDIR3args *arg = args;
862 fhp1 = (nfs_fh3 *) arg->where.dirp;
865 case NFSPROC3_SYMLINK:
867 SYMLINK3args *arg = args;
868 fhp1 = (nfs_fh3 *) arg->where.dirp;
873 MKNOD3args *arg = args;
874 fhp1 = (nfs_fh3 *) arg->where.dirp;
877 case NFSPROC3_REMOVE:
879 REMOVE3args *arg = args;
880 fhp1 = (nfs_fh3 *) arg->object.dirp;
885 RMDIR3args *arg = args;
886 fhp1 = (nfs_fh3 *) arg->object.dirp;
889 case NFSPROC3_RENAME:
891 RENAME3args *arg = args;
892 fhp1 = (nfs_fh3 *) arg->from.dirp;
893 fhp2 = (nfs_fh3 *) arg->to.dirp;
898 LINK3args *arg = args;
899 fhp1 = (nfs_fh3 *) & arg->file;
900 fhp2 = (nfs_fh3 *) arg->link.dirp;
903 case NFSPROC3_READDIR:
905 READDIR3args *arg = args;
906 fhp1 = (nfs_fh3 *) & arg->dir;
909 case NFSPROC3_READDIRPLUS:
911 READDIRPLUS3args *arg = args;
912 fhp1 = (nfs_fh3 *) & arg->dir;
915 case NFSPROC3_FSSTAT:
917 FSSTAT3args *arg = args;
918 fhp1 = (nfs_fh3 *) & arg->fsroot;
921 case NFSPROC3_FSINFO:
923 FSINFO3args *arg = args;
924 fhp1 = (nfs_fh3 *) & arg->fsroot;
927 case NFSPROC3_PATHCONF:
929 PATHCONF3args *arg = args;
930 fhp1 = (nfs_fh3 *) & arg->object;
933 case NFSPROC3_COMMIT:
935 COMMIT3args *arg = args;
936 fhp1 = (nfs_fh3 *) & arg->file;
943 if (fhp1 && is_afs_fh3(fhp1)) {
949 if (fhp2 && is_afs_fh3(fhp2)) {
958 acl3_to_afs_call(int which, void *args, nfs_fh3 ** fhpp)
963 case ACLPROC3_GETACL:
965 struct GETACL3args *sargs = args;
969 case ACLPROC3_SETACL:
971 struct SETACL3args *sargs = args;
975 #if defined(AFS_SUN510_ENV)
976 case ACLPROC3_GETXATTRDIR:
978 struct GETXATTRDIR3args *sargs = args;
987 if (fhp && is_afs_fh3(fhp)) {
996 afs_nfs3_dispatcher(int type, afs_int32 which, void *argp,
997 struct exportinfo *exp, struct svc_req *rp,
1002 afs_int32 client = 0;
1003 struct sockaddr *sa;
1004 nfs_fh3 *fh = (nfs_fh3 *) argp;
1005 nfs_fh3 *fh2 = (nfs_fh3 *) 0;
1007 if (!xlatorinit_v3_done)
1010 sa = (struct sockaddr *)svc_getrpccaller(rp->rq_xprt)->buf;
1014 if (sa->sa_family == AF_INET)
1015 client = ((struct sockaddr_in *)sa)->sin_addr.s_addr;
1021 code = (client && nfs3_to_afs_call(which, argp, &fh, &fh2));
1024 code = (client && acl3_to_afs_call(which, argp, &fh));
1031 struct afs_exporter *out = 0;
1033 static int once = 0;
1034 struct SmallFid Sfid;
1036 memcpy(&Sfid, fh->fh3_data, SIZEOF_SMALLFID);
1038 afs_Trace2(afs_iclSetp, CM_TRACE_NFS3IN1, ICL_TYPE_INT32, client,
1039 ICL_TYPE_FID, &Sfid);
1043 afs_nobody = exp->exi_export.ex_anon;
1047 afs_nfsclient_reqhandler((struct afs_exporter *)0, &crp, client,
1063 afs_nfs3_smallfidder(struct nfs_fh3 *fhp, int status)
1068 #if defined(AFS_SUN5_64BIT_ENV)
1069 /* See also afs_fid() */
1070 memcpy(addr, fhp->fh3_data, 10);
1071 addr[1] = (addr[1] >> 48) & 0xffff;
1073 memcpy(addr, fhp->fh3_data, 2 * sizeof(long));
1077 vcp = VTOAFS((struct vnode *)addr[0]);
1079 /* See also afs_osi_vget */
1080 if (addr[1] == AFS_XLATOR_MAGIC) {
1081 if (status == NFS_OK) {
1082 struct SmallFid Sfid;
1085 /* Make up and copy out a SmallFid */
1086 tcell = afs_GetCell(vcp->f.fid.Cell, READ_LOCK);
1087 Sfid.Volume = vcp->f.fid.Fid.Volume;
1088 Sfid.CellAndUnique =
1089 ((tcell->cellIndex << 24) | (vcp->f.fid.Fid.Unique & 0xffffff));
1090 afs_PutCell(tcell, READ_LOCK);
1091 Sfid.Vnode = (u_short) (vcp->f.fid.Fid.Vnode & 0xffff);
1092 fhp->fh3_len = SIZEOF_SMALLFID;
1093 memcpy(fhp->fh3_data, &Sfid, fhp->fh3_len);
1095 afs_Trace3(afs_iclSetp, CM_TRACE_NFS3OUT, ICL_TYPE_INT32, status,
1096 ICL_TYPE_POINTER, vcp, ICL_TYPE_FID, &Sfid);
1099 /* If we have a ref, release it */
1100 if (vcp->vrefCount >= 1)
1101 AFS_RELE(AFSTOV(vcp));
1107 afs_nfs3_getattr(void *args, void *xp, void *exp, void *rp, void *crp)
1110 afs_nfs3_resp dummy;
1111 afs_ucred_t *svcred = curthread->t_cred;
1112 curthread->t_cred = crp;
1114 afs_nfs3_dispatcher(0, NFSPROC3_GETATTR, args, exp, rp, crp);
1116 afs_nfs3_noaccess(xp);
1118 (*afs_rfs3_disp_tbl[NFSPROC3_GETATTR].orig_proc) (args, xp, exp, rp,
1120 curthread->t_cred = svcred;
1125 afs_nfs3_setattr(void *args, void *xp, void *exp, void *rp, void *crp)
1128 afs_nfs3_resp dummy;
1129 afs_ucred_t *svcred = curthread->t_cred;
1130 curthread->t_cred = crp;
1132 afs_nfs3_dispatcher(0, NFSPROC3_SETATTR, args, exp, rp, crp);
1134 afs_nfs3_noaccess(xp);
1136 (*afs_rfs3_disp_tbl[NFSPROC3_SETATTR].orig_proc) (args, xp, exp, rp,
1138 curthread->t_cred = svcred;
1143 afs_nfs3_lookup(void *args, void *xp, void *exp, void *rp, void *crp)
1146 afs_nfs3_resp dummy;
1147 afs_ucred_t *svcred = curthread->t_cred;
1148 curthread->t_cred = crp;
1150 afs_nfs3_dispatcher(0, NFSPROC3_LOOKUP, args, exp, rp, crp);
1152 afs_nfs3_noaccess(xp);
1154 (*afs_rfs3_disp_tbl[NFSPROC3_LOOKUP].orig_proc) (args, xp, exp, rp,
1156 if (afs_NFSRootOnly && call) {
1157 LOOKUP3res *resp = xp;
1158 afs_nfs3_smallfidder(&resp->resok.object, resp->status);
1161 curthread->t_cred = svcred;
1166 afs_nfs3_access(void *args, void *xp, void *exp, void *rp, void *crp)
1169 afs_nfs3_resp dummy;
1170 afs_ucred_t *svcred = curthread->t_cred;
1171 curthread->t_cred = crp;
1173 afs_nfs3_dispatcher(0, NFSPROC3_ACCESS, args, exp, rp, crp);
1175 afs_nfs3_noaccess(xp);
1177 (*afs_rfs3_disp_tbl[NFSPROC3_ACCESS].orig_proc) (args, xp, exp, rp,
1179 curthread->t_cred = svcred;
1184 afs_nfs3_readlink(void *args, void *xp, void *exp, void *rp, void *crp)
1187 afs_nfs3_resp dummy;
1188 afs_ucred_t *svcred = curthread->t_cred;
1189 curthread->t_cred = crp;
1191 afs_nfs3_dispatcher(0, NFSPROC3_READLINK, args, exp, rp,
1194 afs_nfs3_noaccess(xp);
1196 (*afs_rfs3_disp_tbl[NFSPROC3_READLINK].orig_proc) (args, xp, exp, rp,
1198 curthread->t_cred = svcred;
1203 afs_nfs3_read(void *args, void *xp, void *exp, void *rp, void *crp)
1206 afs_nfs3_resp dummy;
1207 afs_ucred_t *svcred = curthread->t_cred;
1208 curthread->t_cred = crp;
1209 call = afs_nfs3_dispatcher(0, NFSPROC3_READ, args, exp, rp, crp);
1211 afs_nfs3_noaccess(xp);
1213 (*afs_rfs3_disp_tbl[NFSPROC3_READ].orig_proc) (args, xp, exp, rp,
1215 curthread->t_cred = svcred;
1220 afs_nfs3_write(void *args, void *xp, void *exp, void *rp, void *crp)
1223 afs_nfs3_resp dummy;
1224 afs_ucred_t *svcred = curthread->t_cred;
1225 curthread->t_cred = crp;
1227 afs_nfs3_dispatcher(0, NFSPROC3_WRITE, args, exp, rp, crp);
1229 afs_nfs3_noaccess(xp);
1231 (*afs_rfs3_disp_tbl[NFSPROC3_WRITE].orig_proc) (args, xp, exp, rp,
1233 curthread->t_cred = svcred;
1238 afs_nfs3_create(void *args, void *xp, void *exp, void *rp, void *crp)
1241 afs_nfs3_resp dummy;
1242 afs_ucred_t *svcred = curthread->t_cred;
1243 curthread->t_cred = crp;
1245 afs_nfs3_dispatcher(0, NFSPROC3_CREATE, args, exp, rp, crp);
1247 afs_nfs3_noaccess(xp);
1249 (*afs_rfs3_disp_tbl[NFSPROC3_CREATE].orig_proc) (args, xp, exp, rp,
1251 if (afs_NFSRootOnly && call) {
1252 CREATE3res *resp = (CREATE3res *) xp;
1253 afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status);
1256 curthread->t_cred = svcred;
1261 afs_nfs3_mkdir(void *args, void *xp, void *exp, void *rp, void *crp)
1264 afs_nfs3_resp dummy;
1265 afs_ucred_t *svcred = curthread->t_cred;
1266 curthread->t_cred = crp;
1268 afs_nfs3_dispatcher(0, NFSPROC3_MKDIR, args, exp, rp, crp);
1270 afs_nfs3_noaccess(xp);
1272 (*afs_rfs3_disp_tbl[NFSPROC3_MKDIR].orig_proc) (args, xp, exp, rp,
1274 if (afs_NFSRootOnly && call) {
1275 MKDIR3res *resp = (MKDIR3res *) xp;
1276 afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status);
1279 curthread->t_cred = svcred;
1284 afs_nfs3_symlink(void *args, void *xp, void *exp, void *rp, void *crp)
1287 afs_nfs3_resp dummy;
1288 afs_ucred_t *svcred = curthread->t_cred;
1289 curthread->t_cred = crp;
1291 afs_nfs3_dispatcher(0, NFSPROC3_SYMLINK, args, exp, rp, crp);
1293 afs_nfs3_noaccess(xp);
1295 (*afs_rfs3_disp_tbl[NFSPROC3_SYMLINK].orig_proc) (args, xp, exp, rp,
1297 if (afs_NFSRootOnly && call) {
1298 SYMLINK3res *resp = (SYMLINK3res *) xp;
1299 afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status);
1302 curthread->t_cred = svcred;
1307 afs_nfs3_mknod(void *args, void *xp, void *exp, void *rp, void *crp)
1310 afs_nfs3_resp dummy;
1311 afs_ucred_t *svcred = curthread->t_cred;
1312 curthread->t_cred = crp;
1314 afs_nfs3_dispatcher(0, NFSPROC3_MKNOD, args, exp, rp, crp);
1316 afs_nfs3_noaccess(xp);
1318 (*afs_rfs3_disp_tbl[NFSPROC3_MKNOD].orig_proc) (args, xp, exp, rp,
1320 if (afs_NFSRootOnly && call) {
1321 MKNOD3res *resp = xp;
1322 afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status);
1325 curthread->t_cred = svcred;
1330 afs_nfs3_remove(void *args, void *xp, void *exp, void *rp, void *crp)
1333 afs_nfs3_resp dummy;
1334 afs_ucred_t *svcred = curthread->t_cred;
1335 curthread->t_cred = crp;
1337 afs_nfs3_dispatcher(0, NFSPROC3_REMOVE, args, exp, rp, crp);
1339 afs_nfs3_noaccess(xp);
1341 (*afs_rfs3_disp_tbl[NFSPROC3_REMOVE].orig_proc) (args, xp, exp, rp,
1343 curthread->t_cred = svcred;
1348 afs_nfs3_rmdir(void *args, void *xp, void *exp, void *rp, void *crp)
1351 afs_nfs3_resp dummy;
1352 afs_ucred_t *svcred = curthread->t_cred;
1353 curthread->t_cred = crp;
1355 afs_nfs3_dispatcher(0, NFSPROC3_RMDIR, args, exp, rp, crp);
1357 afs_nfs3_noaccess(xp);
1359 (*afs_rfs3_disp_tbl[NFSPROC3_RMDIR].orig_proc) (args, xp, exp, rp,
1361 curthread->t_cred = svcred;
1366 afs_nfs3_rename(void *args, void *xp, void *exp, void *rp, void *crp)
1369 afs_nfs3_resp dummy;
1370 afs_ucred_t *svcred = curthread->t_cred;
1371 curthread->t_cred = crp;
1373 afs_nfs3_dispatcher(0, NFSPROC3_RENAME, args, exp, rp, crp);
1375 afs_nfs3_noaccess(xp);
1377 (*afs_rfs3_disp_tbl[NFSPROC3_RENAME].orig_proc) (args, xp, exp, rp,
1379 curthread->t_cred = svcred;
1384 afs_nfs3_link(void *args, void *xp, void *exp, void *rp, void *crp)
1387 afs_nfs3_resp dummy;
1388 afs_ucred_t *svcred = curthread->t_cred;
1389 curthread->t_cred = crp;
1390 call = afs_nfs3_dispatcher(0, NFSPROC3_LINK, args, exp, rp, crp);
1392 afs_nfs3_noaccess(xp);
1394 (*afs_rfs3_disp_tbl[NFSPROC3_LINK].orig_proc) (args, xp, exp, rp,
1396 curthread->t_cred = svcred;
1401 afs_nfs3_readdir(void *args, void *xp, void *exp, void *rp, void *crp)
1404 afs_nfs3_resp dummy;
1405 afs_ucred_t *svcred = curthread->t_cred;
1406 curthread->t_cred = crp;
1408 afs_nfs3_dispatcher(0, NFSPROC3_READDIR, args, exp, rp, crp);
1410 afs_nfs3_noaccess(xp);
1412 (*afs_rfs3_disp_tbl[NFSPROC3_READDIR].orig_proc) (args, xp, exp, rp,
1414 curthread->t_cred = svcred;
1419 afs_nfs3_readdirplus(void *args, void *xp, void *exp, void *rp, void *crp)
1422 afs_nfs3_resp dummy;
1423 afs_ucred_t *svcred = curthread->t_cred;
1424 curthread->t_cred = crp;
1426 afs_nfs3_dispatcher(0, NFSPROC3_READDIRPLUS, args, exp, rp,
1429 afs_nfs3_noaccess(xp);
1431 afs_nfs3_notsupp(xp);
1433 (*afs_rfs3_disp_tbl[NFSPROC3_READDIRPLUS].orig_proc) (args, xp, exp,
1435 curthread->t_cred = svcred;
1440 afs_nfs3_fsstat(void *args, void *xp, void *exp, void *rp, void *crp)
1443 afs_nfs3_resp dummy;
1444 afs_ucred_t *svcred = curthread->t_cred;
1445 curthread->t_cred = crp;
1447 afs_nfs3_dispatcher(0, NFSPROC3_FSSTAT, args, exp, rp, crp);
1449 afs_nfs3_noaccess(xp);
1451 (*afs_rfs3_disp_tbl[NFSPROC3_FSSTAT].orig_proc) (args, xp, exp, rp,
1453 curthread->t_cred = svcred;
1458 afs_nfs3_fsinfo(void *args, void *xp, void *exp, void *rp, void *crp)
1461 afs_nfs3_resp dummy;
1462 afs_ucred_t *svcred = curthread->t_cred;
1463 curthread->t_cred = crp;
1465 afs_nfs3_dispatcher(0, NFSPROC3_FSINFO, args, exp, rp, crp);
1467 afs_nfs3_noaccess(xp);
1469 (*afs_rfs3_disp_tbl[NFSPROC3_FSINFO].orig_proc) (args, xp, exp, rp,
1471 curthread->t_cred = svcred;
1476 afs_nfs3_pathconf(void *args, void *xp, void *exp, void *rp, void *crp)
1479 afs_nfs3_resp dummy;
1480 afs_ucred_t *svcred = curthread->t_cred;
1481 curthread->t_cred = crp;
1483 afs_nfs3_dispatcher(0, NFSPROC3_PATHCONF, args, exp, rp,
1486 afs_nfs3_noaccess(xp);
1488 (*afs_rfs3_disp_tbl[NFSPROC3_PATHCONF].orig_proc) (args, xp, exp, rp,
1490 curthread->t_cred = svcred;
1495 afs_nfs3_commit(void *args, void *xp, void *exp, void *rp, void *crp)
1498 afs_nfs3_resp dummy;
1499 afs_ucred_t *svcred = curthread->t_cred;
1500 curthread->t_cred = crp;
1502 afs_nfs3_dispatcher(0, NFSPROC3_COMMIT, args, exp, rp, crp);
1504 afs_nfs3_noaccess(xp);
1506 (*afs_rfs3_disp_tbl[NFSPROC3_COMMIT].orig_proc) (args, xp, exp, rp,
1508 curthread->t_cred = svcred;
1512 struct afs_nfs_disp_tbl afs_rfs3_disp_tbl[22] = {
1518 {afs_nfs3_readlink},
1530 {afs_nfs3_readdirplus},
1533 {afs_nfs3_pathconf},
1538 afs_acl3_getacl(void *args, void *xp, void *exp, void *rp, void *crp)
1541 afs_ucred_t *svcred = curthread->t_cred;
1542 curthread->t_cred = crp;
1544 afs_nfs3_dispatcher(1, ACLPROC3_GETACL, args, exp, rp, crp);
1546 afs_nfs3_noaccess(xp);
1548 (*afs_acl3_disp_tbl[ACLPROC3_GETACL].orig_proc) (args, xp, exp, rp,
1550 curthread->t_cred = svcred;
1555 afs_acl3_setacl(void *args, void *xp, void *exp, void *rp, void *crp)
1558 afs_ucred_t *svcred = curthread->t_cred;
1559 curthread->t_cred = crp;
1561 afs_nfs3_dispatcher(1, ACLPROC3_SETACL, args, exp, rp, crp);
1563 afs_nfs3_noaccess(xp);
1565 (*afs_acl3_disp_tbl[ACLPROC3_SETACL].orig_proc) (args, xp, exp, rp,
1567 curthread->t_cred = svcred;
1571 #if defined(AFS_SUN510_ENV)
1573 afs_acl3_getxattrdir(void *args, void *xp, void *exp, void *rp, void *crp)
1576 afs_ucred_t *svcred = curthread->t_cred;
1577 curthread->t_cred = crp;
1579 afs_nfs3_dispatcher(1, ACLPROC3_GETXATTRDIR, args, exp, rp, crp);
1581 afs_nfs3_noaccess(xp);
1583 (*afs_acl3_disp_tbl[ACLPROC3_GETXATTRDIR].orig_proc) (args, xp, exp, rp,
1585 curthread->t_cred = svcred;
1590 struct afs_nfs_disp_tbl afs_acl3_disp_tbl[ACL3_NPROC] = {
1594 #if defined(AFS_SUN510_ENV)
1595 {afs_acl3_getxattrdir},
1599 /* Munge the dispatch tables to link us in first */
1601 afs_xlatorinit_v3(struct rfs_disp_tbl *_rfs_tbl,
1602 struct rfs_disp_tbl *_acl_tbl)
1606 if (xlatorinit_v3_done++)
1609 for (i = 0; i < 22; i++) {
1610 afs_rfs3_disp_tbl[i].orig_proc = _rfs_tbl[i].dis_proc;
1611 _rfs_tbl[i].dis_proc = afs_rfs3_disp_tbl[i].afs_proc;
1614 for (i = 0; i < 3; i++) {
1615 afs_acl3_disp_tbl[i].orig_proc = _acl_tbl[i].dis_proc;
1616 _acl_tbl[i].dis_proc = afs_acl3_disp_tbl[i].afs_proc;
1619 #endif /* !defined(AFS_NONFSTRANS) */