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"
21 #if !defined(AFS_DUX40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_OBSD_ENV)
22 #include "afs/sysincludes.h" /* Standard vendor system headers */
23 #include "afsincludes.h" /* Afs-based standard headers */
24 #include "afs/afs_stats.h" /* statistics */
25 #include "afs/afs_cbqueue.h"
26 #include "afs/nfsclient.h"
27 #include "afs/afs_osidnlc.h"
31 int afs_fid_vnodeoverflow = 0, afs_fid_uniqueoverflow = 0;
36 * afs_fid can return two flavors of NFS fid, depending on if submounts are
37 * allowed. The reason for this is that we can't guarantee that we found all
38 * the entry points any OS might use to get the fid for the NFS mountd.
39 * Hence we return a "magic" fid for all but /afs. If it goes through the
40 * translator code, it will get transformed into a SmallFid that we recognize.
41 * So, if submounts are disallowed, and an NFS client tries a submount, it will
42 * get a fid which we don't recognize and the mount will either fail or we
43 * will ignore subsequent requests for that mount.
45 * The Alpha fid is organized differently than for other platforms. Their
46 * intention was to have the data portion of the fid aligned on a 4 byte
47 * boundary. To do so, the fid is organized as:
51 * The len field is the length of the entire fid, from reserved through data.
52 * This length is used by fid_copy to include copying the reserved field.
53 * Alpha's zero the reserved field before handing us the fid, but they use
54 * it in fid_cmp. We use the reserved field to store the 16 bits of the Vnode.
56 * Note that the SmallFid only allows for 8 bits of the cell index and
57 * 16 bits of the vnode.
61 int afs_iauth_initd = 0;
62 #define USE_SMALLFID(C) (afs_iauth_initd && AFS_NFSXLATORREQ(C))
66 extern int afs_NFSRootOnly; /* 1 => only allow NFS mounts of /afs. */
68 #if !defined(AFS_ATHENA_ENV)
71 afs_fid(OSI_VC_DECL(avc), struct fid *fidpp, struct ucred *credp)
72 #elif defined(AFS_OSF_ENV) || defined(AFS_SUN54_ENV)
73 afs_fid(OSI_VC_DECL(avc), struct fid *fidpp)
75 afs_fid(OSI_VC_DECL(avc), struct fid **fidpp)
76 #endif /* AFS_AIX41_ENV */
80 register struct cell *tcell;
81 extern struct vcache *afs_globalVp;
82 int SizeOfSmallFid = SIZEOF_SMALLFID;
91 if (afs_NFSRootOnly && (avc == afs_globalVp))
93 if (!afs_NFSRootOnly || rootvp
95 || USE_SMALLFID(credp)
98 tcell = afs_GetCell(avc->f.fid.Cell, READ_LOCK);
99 Sfid.Volume = avc->f.fid.Fid.Volume;
100 Sfid.Vnode = avc->f.fid.Fid.Vnode;
102 ((tcell->cellIndex << 24) + (avc->f.fid.Fid.Unique & 0xffffff));
103 afs_PutCell(tcell, READ_LOCK);
104 if (avc->f.fid.Fid.Vnode > 0xffff)
105 afs_fid_vnodeoverflow++;
106 if (avc->f.fid.Fid.Unique > 0xffffff)
107 afs_fid_uniqueoverflow++;
109 #if defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64))
110 addr[1] = (long)AFS_XLATOR_MAGIC << 48;
111 #else /* defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64) */
112 addr[1] = AFS_XLATOR_MAGIC;
113 SizeOfSmallFid = sizeof(addr);
114 #endif /* defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64) */
116 #ifndef AFS_AIX41_ENV
117 /* No post processing, so don't hold ref count. */
118 VN_HOLD(AFSTOV(avc));
121 #if defined(AFS_AIX_ENV) || defined(AFS_SUN54_ENV)
122 /* Use the fid pointer passed to us. */
123 fidpp->fid_len = SizeOfSmallFid;
125 if (afs_NFSRootOnly) {
128 || USE_SMALLFID(credp)
131 memcpy(fidpp->fid_data, (caddr_t) & Sfid, SizeOfSmallFid);
133 memcpy(fidpp->fid_data, (caddr_t) addr, SizeOfSmallFid);
136 memcpy(fidpp->fid_data, (caddr_t) & Sfid, SizeOfSmallFid);
139 /* malloc a fid pointer ourselves. */
140 *fidpp = (struct fid *)AFS_KALLOC(SizeOfSmallFid + 2);
141 (*fidpp)->fid_len = SizeOfSmallFid;
142 if (afs_NFSRootOnly) {
144 memcpy((*fidpp)->fid_data, (char *)&Sfid, SizeOfSmallFid);
146 memcpy((*fidpp)->fid_data, (char *)addr, SizeOfSmallFid);
149 memcpy((*fidpp)->fid_data, (char *)&Sfid, SizeOfSmallFid);
157 #endif /* !AFS_DUX40_ENV && !AFS_LINUX20_ENV */