98c8e8606c194d946c4a0be2011836efed095e68
[openafs.git] / src / afs / VNOPS / afs_vnop_attrs.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 /*
11  * afs_vnop_attrs.c - setattr and getattr vnodeops
12  *
13  * Implements:
14  * afs_CopyOutAttrs
15  * afs_getattr
16  * afs_VAttrToAS
17  * afs_setattr
18  *
19  */
20
21 #include <afsconfig.h>
22 #include "../afs/param.h"
23
24 RCSID("$Header$");
25
26 #include "../afs/sysincludes.h" /* Standard vendor system headers */
27 #include "../afs/afsincludes.h" /* Afs-based standard headers */
28 #include "../afs/afs_stats.h" /* statistics */
29 #include "../afs/afs_cbqueue.h"
30 #include "../afs/nfsclient.h"
31 #include "../afs/afs_osidnlc.h"
32
33 extern afs_rwlock_t afs_xcbhash;
34 struct afs_exporter *afs_nfsexporter;
35 extern struct vcache *afs_globalVp;
36
37 /* copy out attributes from cache entry */
38 int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs)
39 {
40     register struct volume *tvp;
41     register struct cell *tcell;
42     register afs_int32 i;
43     int fakedir = 0;
44
45     AFS_STATCNT(afs_CopyOutAttrs);
46     if (afs_fakestat_enable && avc->mvstat == 1)
47         fakedir = 1;
48 #if     defined(AFS_MACH_ENV )
49     attrs->va_mode = fakedir ? VDIR | 0755 : vType(avc) | (avc->m.Mode&~VFMT);
50 #else /* AFS_MACH_ENV */
51     attrs->va_type = fakedir ? VDIR : vType(avc);
52 #if defined(AFS_SGI_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV)
53     attrs->va_mode = fakedir ? 0755 : (mode_t)(avc->m.Mode & 0xffff);
54 #else
55     attrs->va_mode = fakedir ? VDIR | 0755 : avc->m.Mode;
56 #endif
57 #endif /* AFS_MACH_ENV */
58
59     if (avc->m.Mode & (VSUID|VSGID)) {
60         /* setuid or setgid, make sure we're allowed to run them from this cell */
61         tcell = afs_GetCell(avc->fid.Cell, 0);
62         if (tcell && (tcell->states & CNoSUID))
63             attrs->va_mode &= ~(VSUID|VSGID);
64     }
65     attrs->va_uid = fakedir ? 0 : avc->m.Owner;
66     attrs->va_gid = fakedir ? 0 : avc->m.Group;   /* yeah! */
67 #if     defined(AFS_SUN56_ENV)
68     attrs->va_fsid = avc->v.v_vfsp->vfs_fsid.val[0];
69 #else
70 #ifdef  AFS_SUN5_ENV
71     /* XXX We try making this match the vfs's dev field  XXX */
72     attrs->va_fsid = 1;
73 #else
74 #ifdef AFS_OSF_ENV
75     attrs->va_fsid = avc->v.v_mount->m_stat.f_fsid.val[0]; 
76 #else
77     attrs->va_fsid = 1;
78 #endif
79 #endif
80 #endif /* AFS_SUN56_ENV */
81     if (avc->mvstat == 2) {
82         tvp = afs_GetVolume(&avc->fid, 0, READ_LOCK);
83         /* The mount point's vnode. */
84         if (tvp) {
85             attrs->va_nodeid =
86                 tvp->mtpoint.Fid.Vnode + (tvp->mtpoint.Fid.Volume << 16);
87             if (FidCmp(&afs_rootFid, &avc->fid) && !attrs->va_nodeid)
88                 attrs->va_nodeid = 2;
89             afs_PutVolume(tvp, READ_LOCK);
90         }
91         else attrs->va_nodeid = 2;
92     }
93     else attrs->va_nodeid = avc->fid.Fid.Vnode + (avc->fid.Fid.Volume << 16);
94     attrs->va_nodeid &= 0x7fffffff;     /* Saber C hates negative inode #s! */
95     attrs->va_nlink = fakedir ? 100 : avc->m.LinkCount;
96     attrs->va_size = fakedir ? 4096 : avc->m.Length;
97     attrs->va_atime.tv_sec = attrs->va_mtime.tv_sec = attrs->va_ctime.tv_sec =
98         fakedir ? 0 : (int)avc->m.Date;
99     /* set microseconds to be dataversion # so that we approximate NFS-style
100      * use of mtime as a dataversion #.  We take it mod 512K because
101      * microseconds *must* be less than a million, and 512K is the biggest
102      * power of 2 less than such.  DataVersions are typically pretty small
103      * anyway, so the difference between 512K and 1000000 shouldn't matter
104      * much, and "&" is a lot faster than "%".
105      */
106 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
107     /* nfs on these systems puts an 0 in nsec and stores the nfs usec (aka 
108        dataversion) in va_gen */
109
110     attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec =
111         attrs->va_ctime.tv_nsec =0;
112     attrs->va_blocksize = PAGESIZE;             /* XXX Was 8192 XXX */
113     attrs->va_gen = hgetlo(avc->m.DataVersion);
114     attrs->va_flags = 0;
115 #else
116 #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) 
117     attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec =
118         attrs->va_ctime.tv_nsec =
119             (hgetlo(avc->m.DataVersion) & 0x7ffff) * 1000;
120 #if defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
121     attrs->va_blocksize = PAGESIZE;             /* XXX Was 8192 XXX */
122 #else
123     attrs->va_blksize = PAGESIZE;               /* XXX Was 8192 XXX */
124 #endif
125 #else
126     attrs->va_atime.tv_usec = attrs->va_mtime.tv_usec =
127         attrs->va_ctime.tv_usec =
128             (hgetlo(avc->m.DataVersion) & 0x7ffff);
129     attrs->va_blocksize = PAGESIZE;             /* XXX Was 8192 XXX */
130 #endif
131 #endif
132 #ifdef AFS_DEC_ENV
133     /* Have to use real device #s in Ultrix, since that's how FS type is
134      * encoded.  If rdev doesn't match Ultrix equivalent of statfs's rdev, then
135      * "df ." doesn't work.
136      */
137     if (afs_globalVFS && afs_globalVFS->vfs_data)
138         attrs->va_rdev = ((struct mount *)(afs_globalVFS->vfs_data))->m_dev;
139     else
140         attrs->va_rdev = 1;     /* better than nothing */
141 #else 
142     attrs->va_rdev = 1;
143 #endif
144     /*
145      * Below return 0 (and not 1) blocks if the file is zero length. This conforms
146      * better with the other filesystems that do return 0.      
147      */
148 #if   defined(AFS_OSF_ENV)
149 #ifdef  va_size_rsv
150     attrs->va_size_rsv = 0;
151 #endif
152 /* XXX do this */
153 /*    attrs->va_gen = avc->m.DataVersion;*/
154     attrs->va_flags = 0;
155 #endif  /* AFS_OSF_ENV || AFS_DARWIN_ENV */
156
157 #if !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
158 #if !defined(AFS_HPUX_ENV)
159 #ifdef  AFS_SUN5_ENV
160     attrs->va_nblocks = (attrs->va_size? ((attrs->va_size + 1023)>>10) << 1 : 0);
161 #else
162 #if defined(AFS_SGI_ENV)
163     attrs->va_blocks = BTOBB(attrs->va_size);
164 #else
165     attrs->va_blocks = (attrs->va_size? ((attrs->va_size + 1023)>>10) << 1 : 0);
166 #endif
167 #endif
168 #else /* !defined(AFS_HPUX_ENV) */
169     attrs->va_blocks = (attrs->va_size? ((attrs->va_size + 1023)>>10) : 0);
170 #endif /* !defined(AFS_HPUX_ENV) */
171 #else   /* ! AFS_OSF_ENV && !AFS_FBSD_ENV */
172     attrs->va_bytes = (attrs->va_size? (attrs->va_size + 1023) : 1024);
173 #ifdef  va_bytes_rsv
174     attrs->va_bytes_rsv = -1;
175 #endif
176 #endif  /* ! AFS_OSF_ENV */
177
178 #ifdef AFS_LINUX22_ENV
179     /* And linux has it's own stash as well. */
180     vattr2inode(AFSTOV(avc), attrs);
181 #endif
182 #ifdef notdef
183 #ifdef AFS_AIX51_ENV
184     afs_Trace2(afs_iclSetp, CM_TRACE_STATACLX, 
185                 ICL_TYPE_POINTER, attrs->va_acl, 
186                 ICL_TYPE_INT32, attrs->va_aclsiz);
187     if (attrs->va_acl && attrs->va_aclsiz >= 12) {
188         struct acl *ap;
189
190         ap = (struct acl *) attrs->va_acl;
191         ap->acl_len = 8;
192         ap->acl_mode = ACL_MODE;
193         ap->acl_rsvd = 0;
194         ap->u_access = 7;
195     }
196     /* temporary fix ? */
197     attrs->va_aclsiz = 1;
198 #endif
199 #endif
200     return 0;
201 }
202
203
204
205 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
206 int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, int flags, struct AFS_UCRED *acred)
207 #else
208 int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, struct AFS_UCRED *acred)
209 #endif
210 {
211     afs_int32 code;
212     struct vrequest treq;
213     extern struct unixuser *afs_FindUser();
214     struct unixuser *au;
215     int inited = 0;
216     OSI_VC_CONVERT(avc)
217
218     AFS_STATCNT(afs_getattr);
219     afs_Trace2(afs_iclSetp, CM_TRACE_GETATTR, ICL_TYPE_POINTER, avc, 
220                ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length));
221
222     if (afs_fakestat_enable && avc->mvstat == 1) {
223         struct afs_fakestat_state fakestat;
224
225         code = afs_InitReq(&treq, acred);
226         if (code) return code;
227         afs_InitFakeStat(&fakestat);
228         code = afs_TryEvalFakeStat(&avc, &fakestat, &treq);
229         if (code) {
230             afs_PutFakeStat(&fakestat);
231             return code;
232         }
233
234         code = afs_CopyOutAttrs(avc, attrs);
235         afs_PutFakeStat(&fakestat);
236         return code;
237     }
238
239 #if defined(AFS_SUN5_ENV)
240     if (flags & ATTR_HINT) {
241        code = afs_CopyOutAttrs(avc, attrs);
242        return code;
243     }
244 #endif
245 #if defined(AFS_DARWIN_ENV)
246     if (avc->states & CUBCinit) {
247        code = afs_CopyOutAttrs(avc, attrs);
248        return code;
249     }
250 #endif
251
252 #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
253     afs_BozonLock(&avc->pvnLock, avc);
254 #endif
255
256     if (afs_shuttingdown) return EIO;
257
258     if (!(avc->states & CStatd)) {
259       if (!(code = afs_InitReq(&treq, acred))) {
260         code = afs_VerifyVCache2(avc, &treq);
261         inited = 1;
262       }
263     }
264     else code = 0;
265
266 #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
267     if (code == 0) osi_FlushPages(avc, acred);
268     afs_BozonUnlock(&avc->pvnLock, avc);
269 #endif
270
271
272     if (code == 0) {
273         osi_FlushText(avc); /* only needed to flush text if text locked last time */
274         code = afs_CopyOutAttrs(avc, attrs);
275
276         if (afs_nfsexporter) {
277           if (!inited) {
278             if ((code = afs_InitReq(&treq, acred)))
279               return code;
280              inited = 1;
281           }
282           if (AFS_NFSXLATORREQ(acred)) {
283               if ((vType(avc) != VDIR) &&
284                   !afs_AccessOK(avc, PRSFS_READ, &treq,
285                                 CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) {
286                   return EACCES;
287               }
288               if (avc->mvstat == 2) {
289 #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
290                   attrs->va_mtime.tv_nsec += ((++avc->xlatordv) * 1000); 
291 #else
292                   attrs->va_mtime.tv_usec += ++avc->xlatordv; 
293 #endif
294               }
295           }
296           if ((au = afs_FindUser(treq.uid, -1, READ_LOCK))) {
297             register struct afs_exporter *exporter = au->exporter;
298
299             if (exporter && !(afs_nfsexporter->exp_states & EXP_UNIXMODE)) {
300                 unsigned int ubits;
301                 /*
302                  *  If the remote user wishes to enforce default Unix mode semantics,
303                  *  like in the nfs exporter case, we OR in the user bits
304                  *  into the group and other bits. We need to do this
305                  *  because there is no RFS_ACCESS call and thus nfs
306                  *  clients implement nfs_access by interpreting the 
307                  *  mode bits in the traditional way, which of course
308                  *  loses with afs.
309                  */
310                 ubits = (attrs->va_mode & 0700) >> 6;
311                 attrs->va_mode = attrs->va_mode | ubits | (ubits << 3);
312                 /* If it's the root of AFS, replace the inode number with the
313                  * inode number of the mounted on directory; otherwise this 
314                  * confuses getwd()... */
315 #ifdef AFS_LINUX22_ENV
316                 if (avc == afs_globalVp) {
317                     struct inode *ip = avc->v.i_sb->s_root->d_inode;
318                     attrs->va_nodeid = ip->i_ino;
319                 }
320 #else
321                 if (AFSTOV(avc)->v_flag & VROOT) {
322                     struct vnode *vp = AFSTOV(avc);
323
324                     vp = vp->v_vfsp->vfs_vnodecovered;
325                     if (vp) {   /* Ignore weird failures */
326 #ifdef AFS_SGI62_ENV
327                         attrs->va_nodeid = VnodeToIno(vp);
328 #else
329                         struct inode *ip;
330                         
331                         ip = (struct inode *) VTOI(vp);
332                         if (ip) /* Ignore weird failures */
333                             attrs->va_nodeid = ip->i_number;
334 #endif
335                     }
336                 }
337 #endif /* AFS_LINUX22_ENV */
338               }
339             afs_PutUser(au, READ_LOCK);
340           }
341         }
342     }
343     if (!code)
344       return 0;
345     code = afs_CheckCode(code, &treq, 14);
346     return code;
347 }
348
349 /* convert a Unix request into a status store request */
350 int afs_VAttrToAS(register struct vcache *avc, register struct vattr *av, 
351         register struct AFSStoreStatus *as)
352 {
353     register int mask;
354     mask = 0;
355     AFS_STATCNT(afs_VAttrToAS);
356 #if     defined(AFS_AIX_ENV)
357 /* Boy, was this machine dependent bogosity hard to swallow????.... */
358     if (av->va_mode != -1) {
359 #else
360 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
361     if (av->va_mask & AT_MODE) {
362 #else
363     if (av->va_mode != ((unsigned short)-1)) {
364 #endif
365 #endif
366         mask |= AFS_SETMODE;
367         as->UnixModeBits = av->va_mode & 0xffff;
368         if (avc->states & CForeign) {
369             ObtainWriteLock(&avc->lock,127);
370             afs_FreeAllAxs(&(avc->Access));
371             ReleaseWriteLock(&avc->lock);
372         }
373     }
374
375 #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
376     if (av->va_mask & AT_GID) {
377 #else
378 #if (defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV))
379 #if     defined(AFS_HPUX102_ENV)
380     if (av->va_gid != GID_NO_CHANGE) {
381 #else
382     if (av->va_gid != ((unsigned short)-1)) {
383 #endif
384 #else
385     if (av->va_gid != -1) {
386 #endif
387 #endif /* AFS_SUN5_ENV */
388         mask |= AFS_SETGROUP;
389         as->Group = av->va_gid;
390     }
391
392 #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
393     if (av->va_mask & AT_UID) {
394 #else
395 #if (defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV))
396 #if     defined(AFS_HPUX102_ENV)
397     if (av->va_uid != UID_NO_CHANGE) {
398 #else
399     if (av->va_uid != ((unsigned short)-1)) {
400 #endif
401 #else
402     if (av->va_uid != -1) {
403 #endif
404 #endif /* AFS_SUN5_ENV */
405         mask |= AFS_SETOWNER;
406         as->Owner = av->va_uid;
407     }
408 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
409     if (av->va_mask & AT_MTIME) {
410 #else
411     if (av->va_mtime.tv_sec != -1) {
412 #endif
413         mask |= AFS_SETMODTIME;
414 #ifndef AFS_SGI_ENV
415 #if     defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
416         if (av->va_mtime.tv_nsec == -1)
417 #else
418         if (av->va_mtime.tv_usec == -1)
419 #endif
420             as->ClientModTime = osi_Time();     /* special Sys V compat hack for Suns */
421         else
422 #endif
423             as->ClientModTime = av->va_mtime.tv_sec;
424     }
425     as->Mask = mask;
426     return 0;
427 }
428
429 /* We don't set CDirty bit in avc->states because setattr calls WriteVCache
430  * synchronously, therefore, it's not needed.
431  */
432 #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
433 int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, int flags, struct AFS_UCRED *acred)
434 #else
435 int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, struct AFS_UCRED *acred)
436 #endif
437 {
438     struct vrequest treq;
439     struct AFSStoreStatus astat;
440     register afs_int32 code;
441     struct afs_fakestat_state fakestate;
442     OSI_VC_CONVERT(avc)
443
444     AFS_STATCNT(afs_setattr);
445     afs_Trace2(afs_iclSetp, CM_TRACE_SETATTR, ICL_TYPE_POINTER, avc, 
446                ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length));
447     if ((code = afs_InitReq(&treq, acred))) return code;
448  
449     afs_InitFakeStat(&fakestate);
450     code = afs_EvalFakeStat(&avc, &fakestate, &treq);
451     if (code)
452         goto done;
453
454     if (avc->states & CRO) {
455         code=EROFS;
456         goto done;
457     }
458 #if defined(AFS_SGI_ENV)
459     /* ignore ATTR_LAZY calls - they are really only for keeping
460      * the access/mtime of mmaped files up to date
461      */
462     if (flags & ATTR_LAZY)
463         goto done;
464 #endif
465 #ifndef AFS_DEC_ENV
466     /* if file size has changed, we need write access, otherwise (e.g.
467      * chmod) give it a shot; if it fails, we'll discard the status
468      * info.
469      *
470      * Note that Ultrix actually defines ftruncate of a file you have open to
471      * be O.K., and does the proper access checks itself in the truncate
472      * path (unlike BSD or SUNOS), so we skip this check for Ultrix.
473      *
474      */
475 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
476     if (attrs->va_mask & AT_SIZE) {
477 #else
478 #ifdef  AFS_OSF_ENV
479     if (attrs->va_size != VNOVAL) {
480 #else
481 #ifdef  AFS_AIX41_ENV
482     if (attrs->va_size != -1) {
483 #else
484     if (attrs->va_size != ~0) {
485 #endif
486 #endif
487 #endif
488         if (!afs_AccessOK(avc, PRSFS_WRITE, &treq, DONT_CHECK_MODE_BITS)) {
489             code = EACCES;
490             goto done;
491         }
492     }
493 #endif
494
495     afs_VAttrToAS(avc, attrs, &astat);  /* interpret request */
496     code = 0;
497 #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
498     afs_BozonLock(&avc->pvnLock, avc);
499 #endif
500 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
501     if (AFS_NFSXLATORREQ(acred)) {
502         avc->execsOrWriters++;
503     }
504 #endif
505
506 #if defined(AFS_SGI_ENV)
507     AFS_RWLOCK((vnode_t *)avc, VRWLOCK_WRITE);
508 #endif
509 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
510     if (attrs->va_mask & AT_SIZE) {
511 #else
512 #if     defined(AFS_OSF_ENV)
513     if (attrs->va_size != VNOVAL) {
514 #else   /* AFS_OSF_ENV */
515     if (attrs->va_size != -1) {
516 #endif
517 #endif
518         afs_size_t tsize = attrs->va_size;
519         ObtainWriteLock(&avc->lock,128);
520         avc->states |= CDirty;
521         code = afs_TruncateAllSegments(avc, tsize, &treq, acred);
522         /* if date not explicitly set by this call, set it ourselves, since we
523          * changed the data */
524         if (!(astat.Mask & AFS_SETMODTIME)) {
525             astat.Mask |= AFS_SETMODTIME;
526             astat.ClientModTime = osi_Time();
527         }
528         if (code == 0) {
529           if ( ( (avc->execsOrWriters <= 0 ) && (avc->states & CCreating) == 0)
530                 || (  avc->execsOrWriters == 1 && AFS_NFSXLATORREQ(acred)) ) {
531             code = afs_StoreAllSegments(avc, &treq, AFS_ASYNC);
532             if (!code)
533               avc->states &= ~CDirty;
534           }
535         } else
536           avc->states &= ~CDirty;
537
538         ReleaseWriteLock(&avc->lock);
539         hzero(avc->flushDV);
540         osi_FlushText(avc);     /* do this after releasing all locks */
541 #ifdef AFS_DEC_ENV
542         /* in case we changed the size here, propagate it to gp->g_size */
543         afs_gfshack((struct gnode *)avc);
544 #endif
545     }
546     if (code == 0) {
547         ObtainSharedLock(&avc->lock,16);        /* lock entry */
548         code = afs_WriteVCache(avc, &astat, &treq);    /* send request */
549         ReleaseSharedLock(&avc->lock);  /* release lock */
550     }
551     if (code) {
552        ObtainWriteLock(&afs_xcbhash, 487);
553        afs_DequeueCallback(avc);
554        avc->states &= ~CStatd;      
555        ReleaseWriteLock(&afs_xcbhash);
556        if (avc->fid.Fid.Vnode & 1 || (vType(avc) == VDIR))
557            osi_dnlc_purgedp(avc);
558        /* error?  erase any changes we made to vcache entry */
559      }
560
561 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
562     if (AFS_NFSXLATORREQ(acred)) {
563         avc->execsOrWriters--;
564     }
565 #endif
566 #if defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV)
567     afs_BozonUnlock(&avc->pvnLock, avc);
568 #endif
569 #if defined(AFS_SGI_ENV)
570     AFS_RWUNLOCK((vnode_t *)avc, VRWLOCK_WRITE);
571 #endif
572 done:
573     afs_PutFakeStat(&fakestate);
574     code = afs_CheckCode(code, &treq, 15);
575     return code;
576 }