Bring FBSD 7.X client back to life
[openafs.git] / src / afs / FBSD / osi_machdep.h
index 4c04884..2865120 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 
 #include <sys/lock.h>
 #include <sys/time.h>
-#if defined(AFS_FBSD50_ENV)
 #include <sys/mutex.h>
-#endif
 #include <sys/vnode.h>
 #if defined(AFS_FBSD80_ENV)
 #include <sys/priv.h>
 #endif
 
-/* 
+/*
  * Time related macros
  */
 #define osi_Time()     time_second
@@ -43,8 +41,10 @@ typedef struct proc afs_proc_t;
 #define iodone biodone
 #endif
 
+#ifdef AFS_FBSD80_ENV
 #define VSUID           S_ISUID
 #define VSGID           S_ISGID
+#endif
 
 #define osi_vnhold(avc,r)      vref(AFSTOV(avc))
 
@@ -66,6 +66,7 @@ extern int (**afs_vnodeop_p) ();
 #else
 #define osi_vinvalbuf(vp, flags, slpflag, slptimeo) \
   vinvalbuf((vp), (flags), (curthread), (slpflag), (slptimeo))
+#define osi_curproc() (curthread)
 #endif
 
 #undef gop_lookupname
@@ -76,7 +77,10 @@ extern int (**afs_vnodeop_p) ();
 
 #define afs_strcat(s1, s2)     strcat((s1), (s2))
 
-#undef afs_osi_Alloc_NoSleep
+/* malloc */
+extern void *osi_fbsd_alloc(size_t size, int dropglobal);
+extern void osi_fbsd_free(void *p);
+
 #define afs_osi_Alloc_NoSleep(size) osi_fbsd_alloc((size), 0)
 
 #ifdef AFS_FBSD80_ENV
@@ -96,18 +100,16 @@ extern int (**afs_vnodeop_p) ();
 #define osi_suser_client_settings(x)   (!priv_check(curthread, PRIV_AFS_ADMIN))
 #define osi_suser_afs_daemon(x)   (!priv_check(curthread, PRIV_AFS_DAEMON))
 #define afs_suser(x) (osi_suser_client_settings((x)) && osi_suser_afs_daemon((x)))
-#elif defined(AFS_FBSD50_ENV)
-#define afs_suser(x)   (!suser(curthread))
 #else
-#define afs_suser(x)   (!suser(curproc))
+#define afs_suser(x)   (!suser(curthread))
 #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 osi_curproc()   (curthread)
 #define osi_getpid()   (curthread->td_proc->p_pid)
 #define simple_lock(x) mtx_lock(x)
 #define simple_unlock(x) mtx_unlock(x)
@@ -115,8 +117,17 @@ extern int (**afs_vnodeop_p) ();
   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(cred),(aresid), curthread)
 extern struct mtx afs_global_mtx;
 extern struct thread *afs_global_owner;
-#define AFS_GLOCK() mtx_lock(&afs_global_mtx)
-#define AFS_GUNLOCK() mtx_unlock(&afs_global_mtx)
+#define AFS_GLOCK() \
+    do { \
+       mtx_assert(&afs_global_mtx, (MA_NOTOWNED)); \
+       mtx_lock(&afs_global_mtx); \
+       mtx_assert(&afs_global_mtx, (MA_OWNED|MA_NOTRECURSED)); \
+    } while (0)
+#define AFS_GUNLOCK() \
+    do { \
+       mtx_assert(&afs_global_mtx, (MA_OWNED|MA_NOTRECURSED)); \
+       mtx_unlock(&afs_global_mtx); \
+    } while (0)
 #define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx))
 # if defined(AFS_FBSD80_ENV) && defined(WITNESS)
 #  define osi_InitGlock() \
@@ -132,40 +143,14 @@ extern struct thread *afs_global_owner;
        afs_global_owner = 0; \
     } while (0)
 # endif
-#else /* FBSD50 */
-extern struct lock afs_global_lock;
-#define osi_curcred()  (curproc->p_cred->pc_ucred)
-#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;
-#define AFS_GLOCK() \
-    do { \
-        osi_Assert(curproc); \
-       lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, curproc); \
-        osi_Assert(afs_global_owner == 0); \
-       afs_global_owner = curproc; \
-    } while (0)
-#define AFS_GUNLOCK() \
-    do { \
-        osi_Assert(curproc); \
-       osi_Assert(afs_global_owner == curproc); \
-        afs_global_owner = 0; \
-        lockmgr(&afs_global_lock, LK_RELEASE, 0, curproc); \
-    } while(0)
-#define ISAFS_GLOCK() (afs_global_owner == curproc && curproc)
-#define osi_InitGlock() \
-    do { \
-       lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); \
-       afs_global_owner = 0; \
-    } while (0)
-#endif /* FBSD50 */
 
 #undef SPLVAR
-#define SPLVAR int splvar
+#define SPLVAR
 #undef NETPRI
-#define NETPRI splvar=splnet()
+#define NETPRI
 #undef USERPRI
-#define USERPRI splx(splvar)
+#define USERPRI
+
+#define osi_procname(procname, size) strncpy(procname, curproc->p_comm, size)
 
 #endif /* _OSI_MACHDEP_H_ */