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