convert-vcache-casts-to-macros-20020325
[openafs.git] / src / afs / FBSD / osi_vnodeops.c
index f5d85e2..c48f1c2 100644 (file)
@@ -140,7 +140,7 @@ struct vop_lookup_args /* {
     if (flags & ISDOTDOT) 
        VOP_UNLOCK(dvp, 0, p);
     AFS_GLOCK();
-    error = afs_lookup((struct vcache *)dvp, name, &vcp, cnp->cn_cred);
+    error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
     AFS_GUNLOCK();
     if (error) {
         if (flags & ISDOTDOT) 
@@ -154,7 +154,7 @@ struct vop_lookup_args /* {
        *ap->a_vpp = 0;
        return (error);
     }
-    vp = (struct vnode *)vcp;  /* always get a node if no error */
+    vp = AFSTOV(vcp);  /* always get a node if no error */
 
     /* The parent directory comes in locked.  We unlock it on return
        unless the caller wants it left locked.
@@ -205,7 +205,7 @@ afs_vop_create(ap)
     p=cnp->cn_proc;
 
     AFS_GLOCK();
-    error = afs_create((struct vcache *)dvp, name, ap->a_vap, ap->a_vap->va_vaflags & VA_EXCLUSIVE? EXCL : NONEXCL,
+    error = afs_create(VTOAFS(dvp), name, ap->a_vap, ap->a_vap->va_vaflags & VA_EXCLUSIVE? EXCL : NONEXCL,
                       ap->a_vap->va_mode, &vcp,
                       cnp->cn_cred);
     AFS_GUNLOCK();
@@ -215,8 +215,8 @@ afs_vop_create(ap)
     }
 
     if (vcp) {
-       *ap->a_vpp = (struct vnode *)vcp;
-       vn_lock((struct vnode *)vcp, LK_EXCLUSIVE| LK_RETRY, p);
+       *ap->a_vpp = AFSTOV(vcp);
+       vn_lock(AFSTOV(vcp), LK_EXCLUSIVE| LK_RETRY, p);
     }
     else *ap->a_vpp = 0;
 
@@ -267,12 +267,12 @@ afs_vop_open(ap)
 {
     int error;
     int bad;
-    struct vcache *vc = (struct vcache *)ap->a_vp;
+    struct vcache *vc = VTOAFS(ap->a_vp);
     bad=0;
     AFS_GLOCK();
     error = afs_open(&vc, ap->a_mode, ap->a_cred);
 #ifdef DIAGNOSTIC
-    if ((struct vnode *)vc != ap->a_vp)
+    if (AFSTOV(vc) != ap->a_vp)
        panic("AFS open changed vnode!");
 #endif
     afs_BozonLock(&vc->pvnLock, vc);
@@ -316,7 +316,7 @@ afs_vop_access(ap)
 {
     int code;
     AFS_GLOCK();
-    code=afs_access((struct vcache *)ap->a_vp, ap->a_mode, ap->a_cred);
+    code=afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred);
     AFS_GUNLOCK();
     return code;
 }
@@ -331,7 +331,7 @@ afs_vop_getattr(ap)
 {
     int code;
     AFS_GLOCK();
-    code=afs_getattr((struct vcache *)ap->a_vp, ap->a_vap, ap->a_cred);
+    code=afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
     AFS_GUNLOCK();
     return code;
 }
@@ -346,7 +346,7 @@ afs_vop_setattr(ap)
 {
     int code;
     AFS_GLOCK();
-    code=afs_setattr((struct vcache *)ap->a_vp, ap->a_vap, ap->a_cred);
+    code=afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
     AFS_GUNLOCK();
     return code;
 }int
@@ -360,7 +360,7 @@ afs_vop_read(ap)
 } */ *ap;
 {
     int code;
-    struct vcache *avc=(struct vcache *)ap->a_vp;
+    struct vcache *avc=VTOAFS(ap->a_vp);
     AFS_GLOCK();
     afs_BozonLock(&avc->pvnLock, avc);
     osi_FlushPages(avc);        /* hold bozon lock, but not basic vnode lock */
@@ -385,7 +385,7 @@ afs_vop_getpages(ap)
     struct iovec iov;
     struct buf *bp;
     vm_offset_t kva;
-    struct vcache *avc=(struct vcache *)ap->a_vp;
+    struct vcache *avc=VTOAFS(ap->a_vp);
 
     if (avc->v.v_object == NULL) {
         printf("afs_getpages: called with non-merged cache vnode??\n");
@@ -500,11 +500,11 @@ afs_vop_write(ap)
        } */ *ap;
 {
     int code;
-    struct vcache *avc=(struct vcache *)ap->a_vp;
+    struct vcache *avc=VTOAFS(ap->a_vp);
     AFS_GLOCK();
     afs_BozonLock(&avc->pvnLock, avc);
     osi_FlushPages(avc);        /* hold bozon lock, but not basic vnode lock */
-    code=afs_write((struct vcache *)ap->a_vp, ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
+    code=afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
     afs_BozonUnlock(&avc->pvnLock, avc);
     AFS_GUNLOCK();
     return code;
@@ -527,7 +527,7 @@ afs_vop_putpages(ap)
     struct iovec iov;
     struct buf *bp;
     vm_offset_t kva;
-    struct vcache *avc=(struct vcache *)ap->a_vp;
+    struct vcache *avc=VTOAFS(ap->a_vp);
 
     if (avc->v.v_object == NULL) {
         printf("afs_putpages: called with non-merged cache vnode??\n");
@@ -586,7 +586,7 @@ afs_vop_ioctl(ap)
                struct proc *a_p;
        } */ *ap;
 {
-    struct vcache *tvc = (struct vcache *)ap->a_vp;
+    struct vcache *tvc = VTOAFS(ap->a_vp);
     struct afs_ioctl data;
     int error = 0;
   
@@ -655,9 +655,9 @@ afs_vop_fsync(ap)
     AFS_GLOCK();
     /*vflushbuf(vp, wait);*/
     if (ap->a_cred)
-      error=afs_fsync((struct vcache *)vp, ap->a_cred);
+      error=afs_fsync(VTOAFS(vp), ap->a_cred);
     else
-      error=afs_fsync((struct vcache *)vp, &afs_osi_cred);
+      error=afs_fsync(VTOAFS(vp), &afs_osi_cred);
     AFS_GUNLOCK();
     return error;
 }
@@ -676,7 +676,7 @@ afs_vop_remove(ap)
 
     GETNAME();
     AFS_GLOCK();
-    error =  afs_remove((struct vcache *)dvp, name, cnp->cn_cred);
+    error =  afs_remove(VTOAFS(dvp), name, cnp->cn_cred);
     AFS_GUNLOCK();
     cache_purge(vp);
     DROPNAME();
@@ -710,7 +710,7 @@ afs_vop_link(ap)
        goto out;
     }
     AFS_GLOCK();
-    error = afs_link((struct vcache *)vp, (struct vcache *)dvp, name, cnp->cn_cred);
+    error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
     AFS_GUNLOCK();
     if (dvp != vp)
        VOP_UNLOCK(vp,0, p);
@@ -811,7 +811,7 @@ abortit:
 
     AFS_GLOCK();
     /* XXX use "from" or "to" creds? NFS uses "to" creds */
-    error = afs_rename((struct vcache *)fdvp, fname, (struct vcache *)tdvp, tname, tcnp->cn_cred);
+    error = afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred);
     AFS_GUNLOCK();
 
     FREE(fname, M_TEMP);
@@ -849,7 +849,7 @@ afs_vop_mkdir(ap)
        panic("afs_vop_mkdir: no name");
 #endif
     AFS_GLOCK();
-    error = afs_mkdir((struct vcache *)dvp, name, vap, &vcp, cnp->cn_cred);
+    error = afs_mkdir(VTOAFS(dvp), name, vap, &vcp, cnp->cn_cred);
     AFS_GUNLOCK();
     if (error) {
        vput(dvp);
@@ -857,8 +857,8 @@ afs_vop_mkdir(ap)
        return(error);
     }
     if (vcp) {
-       *ap->a_vpp = (struct vnode *)vcp;
-       vn_lock((struct vnode *)vcp, LK_EXCLUSIVE|LK_RETRY, p);
+       *ap->a_vpp = AFSTOV(vcp);
+       vn_lock(AFSTOV(vcp), LK_EXCLUSIVE|LK_RETRY, p);
     } else
        *ap->a_vpp = 0;
     DROPNAME();
@@ -879,7 +879,7 @@ afs_vop_rmdir(ap)
 
     GETNAME();
     AFS_GLOCK();
-    error = afs_rmdir((struct vcache *)dvp, name, cnp->cn_cred);
+    error = afs_rmdir(VTOAFS(dvp), name, cnp->cn_cred);
     AFS_GUNLOCK();
     DROPNAME();
     return error;
@@ -901,7 +901,7 @@ afs_vop_symlink(ap)
 
     GETNAME();
     AFS_GLOCK();
-    error = afs_symlink((struct vcache *)dvp, name, ap->a_vap, ap->a_target,
+    error = afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target,
                        cnp->cn_cred);
     AFS_GUNLOCK();
     DROPNAME();
@@ -925,7 +925,7 @@ afs_vop_readdir(ap)
           ap->a_ncookies); */
     off=ap->a_uio->uio_offset;
     AFS_GLOCK();
-    error= afs_readdir((struct vcache *)ap->a_vp, ap->a_uio, ap->a_cred,
+    error= afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred,
                       ap->a_eofflag);
     AFS_GUNLOCK();
     if (!error && ap->a_ncookies != NULL) {
@@ -971,7 +971,7 @@ afs_vop_readlink(ap)
     int error;
 /*    printf("readlink %x\n", ap->a_vp);*/
     AFS_GLOCK();
-    error= afs_readlink((struct vcache *)ap->a_vp, ap->a_uio, ap->a_cred);
+    error= afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred);
     AFS_GUNLOCK();
     return error;
 }
@@ -991,7 +991,7 @@ afs_vop_inactive(ap)
        vprint("afs_vop_inactive(): pushing active", vp);
 
     AFS_GLOCK();
-    afs_InactiveVCache((struct vcache *)vp, 0);   /* decrs ref counts */
+    afs_InactiveVCache(VTOAFS(vp), 0);   /* decrs ref counts */
     AFS_GUNLOCK();
     VOP_UNLOCK(vp, 0, ap->a_p);
     return 0;
@@ -1011,7 +1011,7 @@ afs_vop_reclaim(ap)
 
 #if 0 
     AFS_GLOCK();
-    error = afs_FlushVCache((struct vcache *)vp, &sl); /* tosses our stuff from vnode */
+    error = afs_FlushVCache(VTOAFS(vp), &sl); /* tosses our stuff from vnode */
     AFS_GUNLOCK();
     ubc_unlink(vp);
     if (!error && vp->v_data)
@@ -1036,7 +1036,7 @@ afs_vop_lock(ap)
        } */ *ap;
 {
        register struct vnode *vp = ap->a_vp;
-       register struct vcache *avc = (struct vcache *)vp;
+       register struct vcache *avc = VTOAFS(vp);
 
        if (vp->v_tag == VT_NON)
                return (ENOENT);
@@ -1051,7 +1051,7 @@ afs_vop_unlock(ap)
        } */ *ap;
 {
     struct vnode *vp = ap->a_vp;
-    struct vcache *avc = (struct vcache *)vp;
+    struct vcache *avc = VTOAFS(vp);
     return (lockmgr(&avc->rwlock, ap->a_flags | LK_RELEASE,
             &vp->v_interlock, ap->a_p));
 
@@ -1102,7 +1102,7 @@ afs_vop_print(ap)
        } */ *ap;
 {
     register struct vnode *vp = ap->a_vp;
-    register struct vcache *vc = (struct vcache *)ap->a_vp;
+    register struct vcache *vc = VTOAFS(ap->a_vp);
     int s = vc->states;
     printf("tag %d, fid: %ld.%x.%x.%x, opens %d, writers %d", vp->v_tag, vc->fid.Cell,
           vc->fid.Fid.Volume, vc->fid.Fid.Vnode, vc->fid.Fid.Unique, vc->opens,
@@ -1118,7 +1118,7 @@ afs_vop_islocked(ap)
                struct vnode *a_vp;
        } */ *ap;
 {
-    struct vcache *vc = (struct vcache *)ap->a_vp;
+    struct vcache *vc = VTOAFS(ap->a_vp);
     return lockstatus(&vc->rwlock, ap->a_p);
 }
 
@@ -1140,7 +1140,7 @@ afs_vop_advlock(ap)
     struct ucred cr;
     cr=*p->p_cred->pc_ucred;
     AFS_GLOCK();
-    error= afs_lockctl((struct vcache *)ap->a_vp, ap->a_fl, ap->a_op, &cr,
+    error= afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, &cr,
                       (int) ap->a_id);
     AFS_GUNLOCK();
     return error;