openbsd-20021119
[openafs.git] / src / afs / VNOPS / afs_vnop_symlink.c
index d626f30..5e9e597 100644 (file)
  */
 
 #include <afsconfig.h>
-#include "../afs/param.h"
+#include "afs/param.h"
 
 RCSID("$Header$");
 
-#include "../afs/sysincludes.h"        /* Standard vendor system headers */
-#include "../afs/afsincludes.h"        /* Afs-based standard headers */
-#include "../afs/afs_stats.h" /* statistics */
-#include "../afs/afs_cbqueue.h"
-#include "../afs/nfsclient.h"
-#include "../afs/afs_osidnlc.h"
+#include "afs/sysincludes.h"   /* Standard vendor system headers */
+#include "afsincludes.h"       /* Afs-based standard headers */
+#include "afs/afs_stats.h" /* statistics */
+#include "afs/afs_cbqueue.h"
+#include "afs/nfsclient.h"
+#include "afs/afs_osidnlc.h"
 
 extern afs_rwlock_t afs_xvcache;
 extern afs_rwlock_t afs_xcbhash;
@@ -40,6 +40,7 @@ extern afs_rwlock_t afs_xcbhash;
 
 
 /* don't set CDirty in here because RPC is called synchronously */
+int
 afs_symlink
 #ifdef AFS_OSF_ENV
   (ndp, attrs, atargetName)
@@ -57,7 +58,7 @@ afs_symlink
     struct vattr *attrs;
     struct AFS_UCRED *acred; {
 #endif
-    afs_uint32 now;
+    afs_uint32 now = 0;
     struct vrequest treq;
     afs_int32 code;
     struct conn *tc;
@@ -80,7 +81,7 @@ afs_symlink
     afs_Trace2(afs_iclSetp, CM_TRACE_SYMLINK, ICL_TYPE_POINTER, adp,
                 ICL_TYPE_STRING, aname);
 
-    if (code = afs_InitReq(&treq, acred))
+    if ((code = afs_InitReq(&treq, acred)))
        goto done2;
 
     afs_InitFakeStat(&fakestate);
@@ -125,7 +126,7 @@ afs_symlink
     tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1);
     volp = afs_FindVolume(&adp->fid, READ_LOCK); /*parent is also in same vol*/
     ObtainWriteLock(&adp->lock,156);
-    ObtainWriteLock(&tdc->lock, 636);
+    if (tdc) ObtainWriteLock(&tdc->lock, 636);
     ObtainSharedLock(&afs_xvcache,17);  /* prevent others from creating this entry */
     /* XXX Pay attention to afs_xvcache around the whole thing!! XXX */
     do {
@@ -135,32 +136,24 @@ afs_symlink
            XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SYMLINK);
            if (adp->states & CForeign) {
                now = osi_Time();
-#ifdef RX_ENABLE_LOCKS
-               AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+               RX_AFS_GUNLOCK();
                code = RXAFS_DFSSymlink(tc->id, (struct AFSFid *) &adp->fid.Fid, aname,
                                     atargetName, &InStatus, (struct AFSFid *) &newFid.Fid,
                                     &OutFidStatus, &OutDirStatus, &CallBack, &tsync);
-#ifdef RX_ENABLE_LOCKS
-               AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+               RX_AFS_GLOCK();
            } else {
-#ifdef RX_ENABLE_LOCKS
-               AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+               RX_AFS_GUNLOCK();
                code = RXAFS_Symlink(tc->id, (struct AFSFid *) &adp->fid.Fid, aname,
                                     atargetName, &InStatus, (struct AFSFid *) &newFid.Fid,
                                     &OutFidStatus, &OutDirStatus, &tsync);
-#ifdef RX_ENABLE_LOCKS
-               AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+               RX_AFS_GLOCK();
            }
           XSTATS_END_TIME;
        }
        else code = -1;
     } while 
        (afs_Analyze(tc, code, &adp->fid, &treq,
-                   AFS_STATS_FS_RPCIDX_SYMLINK, SHARED_LOCK, (struct cell *)0));
+                   AFS_STATS_FS_RPCIDX_SYMLINK, SHARED_LOCK, NULL));
 
     UpgradeSToWLock(&afs_xvcache,40);
     if (code) {
@@ -199,7 +192,7 @@ afs_symlink
     /* now we're done with parent dir, create the link's entry.  Note that
      * no one can get a pointer to the new cache entry until we release 
      * the xvcache lock. */
-    tvc = afs_NewVCache(&newFid, hostp, 1, WRITE_LOCK);
+    tvc = afs_NewVCache(&newFid, hostp);
     ObtainWriteLock(&tvc->lock,157);
     ObtainWriteLock(&afs_xcbhash, 500);
     tvc->states |= CStatd;             /* have valid info */
@@ -226,7 +219,7 @@ afs_symlink
     }
     ReleaseWriteLock(&tvc->lock);
     ReleaseWriteLock(&afs_xvcache);
-    afs_PutVCache(tvc, WRITE_LOCK);
+    afs_PutVCache(tvc);
     code = 0;
 done:
     afs_PutFakeStat(&fakestate);
@@ -240,10 +233,8 @@ done2:
     return code;
 }
 
-afs_MemHandleLink(avc, areq)
-     register struct vcache *avc;
-     struct vrequest *areq;
-  {
+int afs_MemHandleLink(register struct vcache *avc, struct vrequest *areq)
+{
       register struct dcache *tdc;
       register char *tp, *rbuf;
       afs_size_t offset, len;
@@ -289,21 +280,19 @@ afs_MemHandleLink(avc, areq)
       return 0;
   }
 
-afs_UFSHandleLink(avc, areq)
-    register struct vcache *avc;
-    struct vrequest *areq; 
+int afs_UFSHandleLink(register struct vcache *avc, struct vrequest *areq)
 {
     register struct dcache *tdc;
     register char *tp, *rbuf;
-    char *tfile;
+    void *tfile;
     afs_size_t offset, len;
     afs_int32 tlen, alen;
     register afs_int32 code;
 
-    /* two different formats, one for links protected 644, have a "." at the end
-       of the file name, which we turn into a null.  Others, protected 755,
-       we add a null to the end of */
-   AFS_STATCNT(afs_UFSHandleLink);
+    /* two different formats, one for links protected 644, have a "." at the
+       end of the file name, which we turn into a null.  Others, protected
+       755, we add a null to the end of */
+    AFS_STATCNT(afs_UFSHandleLink);
     if (!avc->linkData) {
        tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 0);
        afs_Trace3(afs_iclSetp, CM_TRACE_UFSLINK, ICL_TYPE_POINTER, avc,
@@ -341,6 +330,7 @@ afs_UFSHandleLink(avc, areq)
     return 0;
 }
 
+int
 afs_readlink(OSI_VC_ARG(avc), auio, acred)
     OSI_VC_DECL(avc);
     struct uio *auio;
@@ -354,7 +344,7 @@ afs_readlink(OSI_VC_ARG(avc), auio, acred)
 
     AFS_STATCNT(afs_readlink);
     afs_Trace1(afs_iclSetp, CM_TRACE_READLINK, ICL_TYPE_POINTER, avc);
-    if (code = afs_InitReq(&treq, acred)) return code;
+    if ((code = afs_InitReq(&treq, acred))) return code;
     afs_InitFakeStat(&fakestat);
     code = afs_EvalFakeStat(&avc, &fakestat, &treq);
     if (code) goto done;