#include <sys/lock.h>
#include <sys/time.h>
-/* #include <kern/sched_prim.h> */
-/* #include <sys/unix_defs.h> */
+#if defined(AFS_FBSD50_ENV)
+#include <sys/mutex.h>
+#endif
extern struct simplelock afs_rxglobal_lock;
#define iodone biodone
#endif
-#define osi_vnhold(avc,r) do { VN_HOLD((struct vnode *)(avc)); } while (0)
+#define osi_vnhold(avc,r) vref(AFSTOV(avc))
+#undef vSetVfsp
+#define vSetVfsp(vc, vfsp) AFSTOV(vc)->v_mount = (vfsp)
+#undef vSetType
+#define vSetType(vc, type) AFSTOV(vc)->v_type = (type)
+#undef vType
+#define vType(vc) AFSTOV(vc)->v_type
#undef gop_lookupname
#define gop_lookupname osi_lookupname
#define afs_strcat(s1, s2) strcat((s1), (s2))
#ifdef KERNEL
-extern struct lock afs_global_lock;
+#undef afs_osi_Alloc_NoSleep
+#define afs_osi_Alloc_NoSleep(size) osi_fbsd_alloc((size), 0)
+
+#define VN_RELE(vp) vrele(vp)
+#define VN_HOLD(vp) VREF(vp)
+
+#ifdef AFS_FBSD60_ENV
+#undef IsAfsVnode
+#define IsAfsVnode(v) ((v)->v_op == &afs_vnodeops)
+extern struct vop_vector afs_vnodeops;
+#endif
+
+#undef osi_getpid
#if defined(AFS_FBSD50_ENV)
#define VT_AFS "afs"
#define VROOT VV_ROOT
#define v_flag v_vflag
#define osi_curcred() (curthread->td_ucred)
-#define afs_suser() (!suser(curthread))
+#define afs_suser(x) (!suser(curthread))
+#define osi_getpid() (curthread->td_proc->p_pid)
#define simple_lock(x) mtx_lock(x)
#define simple_unlock(x) mtx_unlock(x)
#define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(cred),(aresid), curthread)
-extern struct thread * afs_global_owner;
-#define AFS_GLOCK() \
- do { \
- osi_Assert(curthread); \
- lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, curthread); \
- osi_Assert(afs_global_owner == 0); \
- afs_global_owner = curthread; \
- } while (0)
-#define AFS_GUNLOCK() \
- do { \
- osi_Assert(curthread); \
- osi_Assert(afs_global_owner == curthread); \
- afs_global_owner = 0; \
- lockmgr(&afs_global_lock, LK_RELEASE, 0, curthread); \
- } while(0)
-#define ISAFS_GLOCK() (afs_global_owner == curthread && curthread)
+extern struct mtx afs_global_mtx;
+#define AFS_GLOCK() mtx_lock(&afs_global_mtx)
+#define AFS_GUNLOCK() mtx_unlock(&afs_global_mtx)
+#define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx))
#else /* FBSD50 */
+extern struct lock afs_global_lock;
#define osi_curcred() (curproc->p_cred->pc_ucred)
-#define getpid() curproc
+#define afs_suser(x) (!suser(curproc))
+#define osi_getpid() (curproc->p_pid)
#define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid), curproc)
-extern struct proc * afs_global_owner;
+extern struct proc *afs_global_owner;
#define AFS_GLOCK() \
do { \
osi_Assert(curproc); \
#define ISAFS_GLOCK() (afs_global_owner == curproc && curproc)
#endif /* FBSD50 */
-#define AFS_RXGLOCK()
-#define AFS_RXGUNLOCK()
-#define ISAFS_RXGLOCK() 1
-
#undef SPLVAR
#define SPLVAR int splvar
#undef NETPRI