2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
14 * afs_vptofh (DUX) is now in DUX/osi_vfsops.c
17 #include "../afs/param.h" /* Should be always first */
18 #if !defined(AFS_DUX40_ENV) && !defined(AFS_LINUX20_ENV)
19 #include "../afs/sysincludes.h" /* Standard vendor system headers */
20 #include "../afs/afsincludes.h" /* Afs-based standard headers */
21 #include "../afs/afs_stats.h" /* statistics */
22 #include "../afs/afs_cbqueue.h"
23 #include "../afs/nfsclient.h"
24 #include "../afs/afs_osidnlc.h"
28 int afs_fid_vnodeoverflow=0, afs_fid_uniqueoverflow=0;
33 * afs_fid can return two flavors of NFS fid, depending on if submounts are
34 * allowed. The reason for this is that we can't guarantee that we found all
35 * the entry points any OS might use to get the fid for the NFS mountd.
36 * Hence we return a "magic" fid for all but /afs. If it goes through the
37 * translator code, it will get transformed into a SmallFid that we recognize.
38 * So, if submounts are disallowed, and an NFS client tries a submount, it will
39 * get a fid which we don't recognize and the mount will either fail or we
40 * will ignore subsequent requests for that mount.
42 * The Alpha fid is organized differently than for other platforms. Their
43 * intention was to have the data portion of the fid aligned on a 4 byte
44 * boundary. To do so, the fid is organized as:
48 * The len field is the length of the entire fid, from reserved through data.
49 * This length is used by fid_copy to include copying the reserved field.
50 * Alpha's zero the reserved field before handing us the fid, but they use
51 * it in fid_cmp. We use the reserved field to store the 16 bits of the Vnode.
53 * Note that the SmallFid only allows for 8 bits of the cell index and
54 * 16 bits of the vnode.
58 int afs_iauth_initd = 0;
59 #define USE_SMALLFID(C) (afs_iauth_initd && AFS_NFSXLATORREQ(C))
63 extern int afs_NFSRootOnly; /* 1 => only allow NFS mounts of /afs. */
64 #if !defined(AFS_DEC_ENV) && !defined(AFS_ATHENA_ENV)
66 afs_fid(OSI_VC_ARG(avc), fidpp, credp)
69 afs_fid(OSI_VC_ARG(avc), fidpp)
70 #endif /* AFS_AIX41_ENV */
72 #if defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN54_ENV)
80 register struct cell *tcell;
81 extern struct vcache *afs_globalVp;
82 int SizeOfSmallFid = SIZEOF_SMALLFID;
88 if (afs_shuttingdown) return EIO;
90 if (afs_NFSRootOnly && (avc == afs_globalVp)) rootvp = 1;
91 if (!afs_NFSRootOnly || rootvp
93 || USE_SMALLFID(credp)
96 tcell = afs_GetCell(avc->fid.Cell, READ_LOCK);
97 Sfid.Volume = avc->fid.Fid.Volume;
98 Sfid.Vnode = avc->fid.Fid.Vnode;
99 Sfid.CellAndUnique = ((tcell->cellIndex << 24) +
100 (avc->fid.Fid.Unique & 0xffffff));
101 afs_PutCell(tcell, READ_LOCK);
102 if (avc->fid.Fid.Vnode > 0xffff)
103 afs_fid_vnodeoverflow++;
104 if (avc->fid.Fid.Unique > 0xffffff)
105 afs_fid_uniqueoverflow++;
107 #if defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64))
108 addr[1] = (long)AFS_XLATOR_MAGIC << 48 ;
109 #else /* defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64) */
110 addr[1] = AFS_XLATOR_MAGIC;
111 SizeOfSmallFid = sizeof(addr);
112 #endif /* defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64) */
114 #ifndef AFS_AIX41_ENV
115 /* No post processing, so don't hold ref count. */
116 VN_HOLD((struct vnode *)avc);
119 #if defined(AFS_AIX_ENV) || defined(AFS_SUN54_ENV)
120 /* Use the fid pointer passed to us. */
121 fidpp->fid_len = SizeOfSmallFid;
123 if (afs_NFSRootOnly) {
126 || USE_SMALLFID(credp)
129 bcopy((caddr_t)&Sfid, fidpp->fid_data, SizeOfSmallFid);
131 bcopy((caddr_t)addr, fidpp->fid_data, SizeOfSmallFid);
134 bcopy((caddr_t)&Sfid, fidpp->fid_data, SizeOfSmallFid);
137 /* malloc a fid pointer ourselves. */
138 *fidpp = (struct fid *) AFS_KALLOC(SizeOfSmallFid+2);
139 (*fidpp)->fid_len = SizeOfSmallFid;
140 if (afs_NFSRootOnly) {
142 bcopy((char *)&Sfid, (*fidpp)->fid_data, SizeOfSmallFid);
144 bcopy((char *)addr, (*fidpp)->fid_data, SizeOfSmallFid);
147 bcopy((char *)&Sfid, (*fidpp)->fid_data, SizeOfSmallFid);
155 #endif /* !AFS_DUX40_ENV && !AFS_LINUX20_ENV */