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 <afsconfig.h>
18 #include "afs/param.h"
23 #if !defined(AFS_DUX40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_OBSD_ENV)
24 #include "afs/sysincludes.h" /* Standard vendor system headers */
25 #include "afsincludes.h" /* Afs-based standard headers */
26 #include "afs/afs_stats.h" /* statistics */
27 #include "afs/afs_cbqueue.h"
28 #include "afs/nfsclient.h"
29 #include "afs/afs_osidnlc.h"
33 int afs_fid_vnodeoverflow = 0, afs_fid_uniqueoverflow = 0;
38 * afs_fid can return two flavors of NFS fid, depending on if submounts are
39 * allowed. The reason for this is that we can't guarantee that we found all
40 * the entry points any OS might use to get the fid for the NFS mountd.
41 * Hence we return a "magic" fid for all but /afs. If it goes through the
42 * translator code, it will get transformed into a SmallFid that we recognize.
43 * So, if submounts are disallowed, and an NFS client tries a submount, it will
44 * get a fid which we don't recognize and the mount will either fail or we
45 * will ignore subsequent requests for that mount.
47 * The Alpha fid is organized differently than for other platforms. Their
48 * intention was to have the data portion of the fid aligned on a 4 byte
49 * boundary. To do so, the fid is organized as:
53 * The len field is the length of the entire fid, from reserved through data.
54 * This length is used by fid_copy to include copying the reserved field.
55 * Alpha's zero the reserved field before handing us the fid, but they use
56 * it in fid_cmp. We use the reserved field to store the 16 bits of the Vnode.
58 * Note that the SmallFid only allows for 8 bits of the cell index and
59 * 16 bits of the vnode.
63 int afs_iauth_initd = 0;
64 #define USE_SMALLFID(C) (afs_iauth_initd && AFS_NFSXLATORREQ(C))
68 extern int afs_NFSRootOnly; /* 1 => only allow NFS mounts of /afs. */
71 #if !defined(AFS_DEC_ENV) && !defined(AFS_ATHENA_ENV)
73 afs_fid(OSI_VC_ARG(avc), fidpp, credp)
76 afs_fid(OSI_VC_ARG(avc), fidpp)
77 #endif /* AFS_AIX41_ENV */
79 #if defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN54_ENV)
87 register struct cell *tcell;
88 extern struct vcache *afs_globalVp;
89 int SizeOfSmallFid = SIZEOF_SMALLFID;
98 if (afs_NFSRootOnly && (avc == afs_globalVp))
100 if (!afs_NFSRootOnly || rootvp
102 || USE_SMALLFID(credp)
105 tcell = afs_GetCell(avc->fid.Cell, READ_LOCK);
106 Sfid.Volume = avc->fid.Fid.Volume;
107 Sfid.Vnode = avc->fid.Fid.Vnode;
109 ((tcell->cellIndex << 24) + (avc->fid.Fid.Unique & 0xffffff));
110 afs_PutCell(tcell, READ_LOCK);
111 if (avc->fid.Fid.Vnode > 0xffff)
112 afs_fid_vnodeoverflow++;
113 if (avc->fid.Fid.Unique > 0xffffff)
114 afs_fid_uniqueoverflow++;
116 #if defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64))
117 addr[1] = (long)AFS_XLATOR_MAGIC << 48;
118 #else /* defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64) */
119 addr[1] = AFS_XLATOR_MAGIC;
120 SizeOfSmallFid = sizeof(addr);
121 #endif /* defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64) */
123 #ifndef AFS_AIX41_ENV
124 /* No post processing, so don't hold ref count. */
125 VN_HOLD(AFSTOV(avc));
128 #if defined(AFS_AIX_ENV) || defined(AFS_SUN54_ENV)
129 /* Use the fid pointer passed to us. */
130 fidpp->fid_len = SizeOfSmallFid;
132 if (afs_NFSRootOnly) {
135 || USE_SMALLFID(credp)
138 memcpy(fidpp->fid_data, (caddr_t) & Sfid, SizeOfSmallFid);
140 memcpy(fidpp->fid_data, (caddr_t) addr, SizeOfSmallFid);
143 memcpy(fidpp->fid_data, (caddr_t) & Sfid, SizeOfSmallFid);
146 /* malloc a fid pointer ourselves. */
147 *fidpp = (struct fid *)AFS_KALLOC(SizeOfSmallFid + 2);
148 (*fidpp)->fid_len = SizeOfSmallFid;
149 if (afs_NFSRootOnly) {
151 memcpy((*fidpp)->fid_data, (char *)&Sfid, SizeOfSmallFid);
153 memcpy((*fidpp)->fid_data, (char *)addr, SizeOfSmallFid);
156 memcpy((*fidpp)->fid_data, (char *)&Sfid, SizeOfSmallFid);
164 #endif /* !AFS_DUX40_ENV && !AFS_LINUX20_ENV */