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