macos104-not-yet-20050513
[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_DARWIN80_ENV)
97     VATTR_RETURN(attrs, va_fsid, vfs_statfs(vnode_mount(AFSTOV(avc)))->f_fsid.val[0]);
98 #elif defined(AFS_DARWIN70_ENV)
99     attrs->va_fsid = avc->v->v_mount->mnt_stat.f_fsid.val[0];
100 #else /* ! AFS_DARWIN70_ENV */
101     attrs->va_fsid = 1;
102 #endif 
103     if (avc->mvstat == 2) {
104         tvp = afs_GetVolume(&avc->fid, 0, READ_LOCK);
105         /* The mount point's vnode. */
106         if (tvp) {
107             attrs->va_nodeid =
108                 tvp->mtpoint.Fid.Vnode + (tvp->mtpoint.Fid.Volume << 16);
109             if (FidCmp(&afs_rootFid, &avc->fid) && !attrs->va_nodeid)
110                 attrs->va_nodeid = 2;
111             afs_PutVolume(tvp, READ_LOCK);
112         } else
113             attrs->va_nodeid = 2;
114     } else
115         attrs->va_nodeid = avc->fid.Fid.Vnode + (avc->fid.Fid.Volume << 16);
116     attrs->va_nodeid &= 0x7fffffff;     /* Saber C hates negative inode #s! */
117     attrs->va_nlink = fakedir ? 100 : avc->m.LinkCount;
118     attrs->va_size = fakedir ? 4096 : avc->m.Length;
119     attrs->va_atime.tv_sec = attrs->va_mtime.tv_sec = attrs->va_ctime.tv_sec =
120         fakedir ? 0 : (int)avc->m.Date;
121     /* set microseconds to be dataversion # so that we approximate NFS-style
122      * use of mtime as a dataversion #.  We take it mod 512K because
123      * microseconds *must* be less than a million, and 512K is the biggest
124      * power of 2 less than such.  DataVersions are typically pretty small
125      * anyway, so the difference between 512K and 1000000 shouldn't matter
126      * much, and "&" is a lot faster than "%".
127      */
128 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
129     /* nfs on these systems puts an 0 in nsec and stores the nfs usec (aka 
130      * dataversion) in va_gen */
131
132     attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec =
133         attrs->va_ctime.tv_nsec = 0;
134     attrs->va_gen = hgetlo(avc->m.DataVersion);
135 #elif defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_OBSD_ENV)
136     attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec =
137         attrs->va_ctime.tv_nsec =
138         (hgetlo(avc->m.DataVersion) & 0x7ffff) * 1000;
139 #else
140     attrs->va_atime.tv_usec = attrs->va_mtime.tv_usec =
141         attrs->va_ctime.tv_usec = (hgetlo(avc->m.DataVersion) & 0x7ffff);
142 #endif
143 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) || defined(AFS_OSF_ENV)
144     attrs->va_flags = 0;
145 #endif
146 #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV)
147     attrs->va_blksize = PAGESIZE;       /* XXX Was 8192 XXX */
148 #else
149     attrs->va_blocksize = PAGESIZE;     /* XXX Was 8192 XXX */
150 #endif
151     attrs->va_rdev = 1;
152 #if defined(AFS_HPUX110_ENV)
153     if (afs_globalVFS)
154         attrs->va_fstype = afs_globalVFS->vfs_mtype;
155 #endif
156
157     /*
158      * Below return 0 (and not 1) blocks if the file is zero length. This conforms
159      * better with the other filesystems that do return 0.      
160      */
161 #ifdef AFS_HPUX_ENV
162     attrs->va_blocks = (attrs->va_size ? ((attrs->va_size + 1023) >> 10) : 0);
163 #elif defined(AFS_SGI_ENV)
164     attrs->va_blocks = BTOBB(attrs->va_size);
165 #elif defined(AFS_XBSD_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
166     attrs->va_bytes = (attrs->va_size ? (attrs->va_size + 1023) : 1024);
167 #ifdef  va_bytes_rsv
168     attrs->va_bytes_rsv = -1;
169 #endif
170 #else
171     attrs->va_blocks =
172         (attrs->va_size ? ((attrs->va_size + 1023) >> 10) << 1 : 0);
173 #endif
174
175 #ifdef AFS_LINUX22_ENV
176     /* And linux has its own stash as well. */
177     vattr2inode(AFSTOV(avc), attrs);
178 #endif
179     return 0;
180 }
181
182
183
184 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
185 int
186 afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, int flags,
187             struct AFS_UCRED *acred)
188 #else
189 int
190 afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, struct AFS_UCRED *acred)
191 #endif
192 {
193     afs_int32 code;
194     struct vrequest treq;
195     extern struct unixuser *afs_FindUser();
196     struct unixuser *au;
197     int inited = 0;
198     OSI_VC_CONVERT(avc);
199
200     AFS_STATCNT(afs_getattr);
201     afs_Trace2(afs_iclSetp, CM_TRACE_GETATTR, ICL_TYPE_POINTER, avc,
202                ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length));
203
204     if (afs_fakestat_enable && avc->mvstat == 1) {
205         struct afs_fakestat_state fakestat;
206
207         code = afs_InitReq(&treq, acred);
208         if (code)
209             return code;
210         afs_InitFakeStat(&fakestat);
211         code = afs_TryEvalFakeStat(&avc, &fakestat, &treq);
212         if (code) {
213             afs_PutFakeStat(&fakestat);
214             return code;
215         }
216
217         code = afs_CopyOutAttrs(avc, attrs);
218         afs_PutFakeStat(&fakestat);
219         return code;
220     }
221 #if defined(AFS_SUN5_ENV)
222     if (flags & ATTR_HINT) {
223         code = afs_CopyOutAttrs(avc, attrs);
224         return code;
225     }
226 #endif
227 #if defined(AFS_DARWIN_ENV)
228     if (avc->states & CUBCinit) {
229         code = afs_CopyOutAttrs(avc, attrs);
230         return code;
231     }
232 #endif
233
234 #ifdef AFS_BOZONLOCK_ENV
235     afs_BozonLock(&avc->pvnLock, avc);
236 #endif
237
238     if (afs_shuttingdown)
239         return EIO;
240
241     if (!(avc->states & CStatd)) {
242         if (!(code = afs_InitReq(&treq, acred))) {
243             code = afs_VerifyVCache2(avc, &treq);
244             inited = 1;
245         }
246     } else
247         code = 0;
248
249 #ifdef AFS_BOZONLOCK_ENV
250     if (code == 0)
251         osi_FlushPages(avc, acred);
252     afs_BozonUnlock(&avc->pvnLock, avc);
253 #endif
254
255
256     if (code == 0) {
257         osi_FlushText(avc);     /* only needed to flush text if text locked last time */
258         code = afs_CopyOutAttrs(avc, attrs);
259
260         if (afs_nfsexporter) {
261             if (!inited) {
262                 if ((code = afs_InitReq(&treq, acred)))
263                     return code;
264                 inited = 1;
265             }
266             if (AFS_NFSXLATORREQ(acred)) {
267                 if ((vType(avc) != VDIR)
268                     && !afs_AccessOK(avc, PRSFS_READ, &treq,
269                                      CHECK_MODE_BITS |
270                                      CMB_ALLOW_EXEC_AS_READ)) {
271                     return EACCES;
272                 }
273             }
274             if ((au = afs_FindUser(treq.uid, -1, READ_LOCK))) {
275                 register struct afs_exporter *exporter = au->exporter;
276
277                 if (exporter && !(afs_nfsexporter->exp_states & EXP_UNIXMODE)) {
278                     unsigned int ubits;
279                     /*
280                      *  If the remote user wishes to enforce default Unix mode semantics,
281                      *  like in the nfs exporter case, we OR in the user bits
282                      *  into the group and other bits. We need to do this
283                      *  because there is no RFS_ACCESS call and thus nfs
284                      *  clients implement nfs_access by interpreting the 
285                      *  mode bits in the traditional way, which of course
286                      *  loses with afs.
287                      */
288                     ubits = (attrs->va_mode & 0700) >> 6;
289                     attrs->va_mode = attrs->va_mode | ubits | (ubits << 3);
290                     /* If it's the root of AFS, replace the inode number with the
291                      * inode number of the mounted on directory; otherwise this 
292                      * confuses getwd()... */
293 #ifdef AFS_LINUX22_ENV
294                     if (avc == afs_globalVp) {
295                         struct inode *ip = avc->v.i_sb->s_root->d_inode;
296                         attrs->va_nodeid = ip->i_ino;
297                     }
298 #else
299                     if (vnode_isvroot(AFSTOV(avc))) {
300                         struct vnode *vp = AFSTOV(avc);
301
302 #ifdef AFS_DARWIN80_ENV
303                         /* XXX vp = vnode_mount(vp)->mnt_vnodecovered; */
304                         vp = 0;
305 #else
306                         vp = vp->v_vfsp->vfs_vnodecovered;
307                         if (vp) {       /* Ignore weird failures */
308 #ifdef AFS_SGI62_ENV
309                             attrs->va_nodeid = VnodeToIno(vp);
310 #else
311                             struct inode *ip;
312
313                             ip = (struct inode *)VTOI(vp);
314                             if (ip)     /* Ignore weird failures */
315                                 attrs->va_nodeid = ip->i_number;
316 #endif
317                         }
318 #endif
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 }