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