/* #include <kern/sched_prim.h> */
/* #include <sys/unix_defs.h> */
+#ifndef AFS_FBSD50_ENV
#define getpid() curproc
+#endif
extern struct simplelock afs_rxglobal_lock;
/*
#define AFS_UCRED ucred
#define AFS_PROC struct proc
+#ifdef AFS_FBSD50_ENV
+#define osi_curcred() (curthread->td_ucred)
+#else
+#define osi_curcred() (curproc->p_cred->pc_ucred)
+#endif
#define afs_bufferpages bufpages
#define osi_vnhold(avc,r) do { VN_HOLD((struct vnode *)(avc)); } while (0)
-#define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
- vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid), curproc)
#undef gop_lookupname
#define gop_lookupname osi_lookupname
#undef afs_suser
#ifdef KERNEL
-extern struct proc * afs_global_owner;
extern struct lock afs_global_lock;
+
+#if defined(AFS_FBSD50_ENV)
+#define VT_AFS "afs"
+#define VROOT VV_ROOT
+#define v_flag v_vflag
+#define afs_suser() (!suser(curthread))
+#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)
+
+#else /* FBSD50 */
+
+#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;
#define AFS_GLOCK() \
do { \
osi_Assert(curproc); \
lockmgr(&afs_global_lock, LK_RELEASE, 0, curproc); \
} while(0)
#define ISAFS_GLOCK() (afs_global_owner == curproc && curproc)
+#endif /* FBSD50 */
+
#define AFS_RXGLOCK()
#define AFS_RXGUNLOCK()
#define ISAFS_RXGLOCK() 1