openbsd-20021108
[openafs.git] / src / afs / afs_osi.h
index bae946e..32a284a 100644 (file)
@@ -10,9 +10,8 @@
 #ifndef _AFS_OSI_
 #define _AFS_OSI_
 
-#include "../afs/param.h"
-#include "../h/types.h"
-#include "../h/param.h"
+#include "h/types.h"
+#include "h/param.h"
 
 #ifdef AFS_LINUX20_ENV
 #ifndef _LINUX_CODA_FS_I
@@ -24,8 +23,8 @@ struct coda_inode_info {};
 #define _LINUX_XFS_FS_I
 struct xfs_inode_info {};
 #endif
-#include "../h/fs.h"
-#include "../h/mm.h"
+#include "h/fs.h"
+#include "h/mm.h"
 #endif
 
 
@@ -54,7 +53,7 @@ struct osi_file {
 #else
     afs_int32 offset;
 #endif
-    int        (*proc)();      /* proc, which, if not null, is called on writes */
+    int        (*proc)(struct osi_file *afile, afs_int32 code);        /* proc, which, if not null, is called on writes */
     char *rock;                /* rock passed to proc */
     ino_t inum;         /* guarantee validity of hint */
 #if defined(UKERNEL)
@@ -63,7 +62,12 @@ struct osi_file {
 };
 
 struct osi_dev {
+#ifdef AFS_OBSD_ENV
+    struct mount *mp;
+    struct vnode *held_vnode;
+#else
     afs_int32 dev;
+#endif
 };
 
 struct afs_osi_WaitHandle {
@@ -89,27 +93,17 @@ struct afs_osi_WaitHandle {
 
 
 #define        osi_NPACKETS    20              /* number of cluster pkts to alloc */
-extern struct osi_socket *osi_NewSocket();
-
 
 /*
  * Alloc declarations.
  */
-extern void *afs_osi_Alloc(size_t size);
-extern void  afs_osi_Free(void *x, size_t size);
 #define afs_osi_Alloc_NoSleep afs_osi_Alloc
 
-extern void *osi_AllocSmallSpace(size_t size);
-extern void  osi_FreeSmallSpace(void *x);
-extern void *osi_AllocMediumSpace(size_t size);
-extern void  osi_FreeMediumSpace(void *x);
-extern void *osi_AllocLargeSpace(size_t size);
-extern void  osi_FreeLargeSpace(void *x);
-
 /*
  * Vnode related macros
  */
-#ifdef AFS_DARWIN_ENV
+#ifndef AFS_OBSD_ENV
+#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
 extern int (**afs_vnodeop_p)();
 #define IsAfsVnode(vc)      ((vc)->v_op == afs_vnodeop_p)
 #define SetAfsVnode(vc)     (vc)->v_op = afs_vnodeop_p
@@ -121,15 +115,18 @@ extern struct vnodeops *afs_ops;
 #define        vType(vc)           (vc)->v.v_type
 #define        vSetType(vc,type)   (vc)->v.v_type = (type)
 #define        vSetVfsp(vc,vfsp)   (vc)->v.v_vfsp = (vfsp)
+#endif
 
 #ifdef AFS_SGI65_ENV
 #define        gop_lookupname(fnamep,segflg,followlink,dirvpp,compvpp) \
              lookupname((fnamep),(segflg),(followlink),(dirvpp),(compvpp),\
                        NULL)
 #else
+#ifndef AFS_OBSD_ENV
 #define        gop_lookupname(fnamep,segflg,followlink,dirvpp,compvpp) \
              lookupname((fnamep),(segflg),(followlink),(dirvpp),(compvpp))
 #endif
+#endif
 
 /*
  * In IRIX 6.5 we cannot have DEBUG turned on since certain
@@ -190,11 +187,19 @@ typedef struct timeval osi_timeval_t;
 
 #ifdef AFS_GLOBAL_SUNLOCK
 #define AFS_ASSERT_GLOCK() \
-    (ISAFS_GLOCK() || (osi_Panic("afs global lock not held"), 0))
+    (ISAFS_GLOCK() || (osi_Panic("afs global lock not held at %s:%d\n", __FILE__, __LINE__), 0))
 #define AFS_ASSERT_RXGLOCK() \
-    (ISAFS_RXGLOCK() || (osi_Panic("rx global lock not held"), 0))
+    (ISAFS_RXGLOCK() || (osi_Panic("rx global lock not held at %s:%d\n", __FILE__, __LINE__), 0))
 #endif /* AFS_GLOBAL_SUNLOCK */
 
+#ifdef RX_ENABLE_LOCKS
+#define RX_AFS_GLOCK()         AFS_GLOCK()
+#define RX_AFS_GUNLOCK()       AFS_GUNLOCK()
+#else
+#define RX_AFS_GLOCK()
+#define RX_AFS_GUNLOCK()
+#endif
+
 
 
 #ifndef KERNEL
@@ -220,6 +225,7 @@ typedef struct timeval osi_timeval_t;
 #define USERPRI
 #endif
 
+#ifndef AFS_OBSD_ENV
 /*
  * vnode/vcache ref count manipulation
  */
@@ -228,6 +234,8 @@ typedef struct timeval osi_timeval_t;
 #else /* defined(UKERNEL) */
 #define AFS_RELE(vp) do { AFS_GUNLOCK(); VN_RELE(vp); AFS_GLOCK(); } while (0)
 #endif /* defined(UKERNEL) */
+#endif
+
 /*
  * For some reason we do bare refcount manipulation in some places, for some
  * platforms.  The assumption is apparently that either we wouldn't call
@@ -236,14 +244,14 @@ typedef struct timeval osi_timeval_t;
  * (Also, of course, the vnode is assumed to be one of ours.  Can't use this
  * macro for V-file vnodes.)
  */
-#ifdef AFS_DARWIN_ENV
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 /* Bare refcount manipulation would probably work on this platform, but just
    calling VREF does not */
 #define AFS_FAST_HOLD(vp) osi_vnhold((vp),0)
 #else
 #define AFS_FAST_HOLD(vp) VN_HOLD(&(vp)->v)
 #endif
-#define AFS_FAST_RELE(vp) AFS_RELE(&(vp)->v)
+#define AFS_FAST_RELE(vp) AFS_RELE(AFSTOV(vp))
 
 /*
  * MP safe versions of routines to copy memory between user space
@@ -282,7 +290,7 @@ typedef struct timeval osi_timeval_t;
                AFS_GLOCK();                                    \
        } while(0)
 
-#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)                       \
        do {                                                    \
            int haveGlock = ISAFS_GLOCK();                      \
@@ -293,7 +301,7 @@ typedef struct timeval osi_timeval_t;
            if (haveGlock)                                      \
                AFS_GLOCK();                                    \
        } while(0)
-#else /* AFS_OSF_ENV */
+#else
 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)                       \
        do {                                                    \
            int haveGlock = ISAFS_GLOCK();                      \
@@ -303,7 +311,7 @@ typedef struct timeval osi_timeval_t;
            if (haveGlock)                                      \
                AFS_GLOCK();                                    \
        } while(0)
-#endif /* AFS_OSF_ENV */
+#endif
 
 #else /* AFS_GLOBAL_SUNLOCK */
 
@@ -322,18 +330,18 @@ typedef struct timeval osi_timeval_t;
            CODE = copyout((SRC),(DST),(LEN));                  \
        } while(0)
 
-#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)                       \
        do {                                                    \
            (UIO)->uio_rw = (RW);                               \
            CODE = uiomove((SRC),(LEN),(UIO));                  \
        } while(0)
-#else /* AFS_OSF_ENV */
+#else /* AFS_OSF_ENV || AFS_FBSD_ENV */
 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)                       \
        do {                                                    \
            CODE = uiomove((SRC),(LEN),(RW),(UIO));             \
        } while(0)
-#endif /* AFS_OSF_ENV */
+#endif /* AFS_OSF_ENV || AFS_FBSD_ENV */
 
 #endif /* AFS_GLOBAL_SUNLOCK */
 
@@ -365,34 +373,18 @@ typedef struct timeval osi_timeval_t;
 #define AfsLargeFileUio(uio)       0
 #define AfsLargeFileSize(pos, off) 0
 
-
-/* VM function prototypes.
- */
-#if defined(AFS_SUN5_ENV)
-extern int osi_VM_GetDownD();
-extern void osi_VM_PreTruncate();
-#endif
-#if defined(AFS_SGI_ENV)
-extern void osi_VM_FSyncInval();
-#endif
-extern int osi_VM_FlushVCache();
-extern void osi_VM_StoreAllSegments();
-extern void osi_VM_TryToSmush();
-extern void osi_VM_FlushPages();
-extern void osi_VM_Truncate();
-
-extern void osi_ReleaseVM();
-
 /* Now include system specific OSI header file. It will redefine macros
  * defined here as required by the OS.
  */
-#include "../afs/osi_machdep.h"
+#include "osi_machdep.h"
 
 /* Declare any structures which use these macros after the OSI implementation
  * has had the opportunity to redefine them.
  */
 extern struct AFS_UCRED afs_osi_cred;
 
-#endif /* _AFS_OSI_ */
-
+#ifndef osi_curcred
+#define osi_curcred() (u.u_cred)
+#endif
 
+#endif /* _AFS_OSI_ */