macos104-not-yet-20050511
[openafs.git] / src / afs / afs_osi.h
index b29f9cd..b2ba0cc 100644 (file)
 #include "h/types.h"
 #include "h/param.h"
 
+#ifdef AFS_FBSD50_ENV
+#include <sys/condvar.h>
+#endif
+
 #ifdef AFS_LINUX20_ENV
 #ifndef _LINUX_CODA_FS_I
 #define _LINUX_CODA_FS_I
 #define _CODA_HEADER_
-struct coda_inode_info {};
+struct coda_inode_info {
+};
 #endif
 #ifndef _LINUX_XFS_FS_I
 #define _LINUX_XFS_FS_I
-struct xfs_inode_info {};
+struct xfs_inode_info {
+};
 #endif
 #include "h/fs.h"
 #include "h/mm.h"
@@ -34,44 +40,59 @@ struct osi_socket {
 };
 
 struct osi_stat {
-    afs_int32 size;        /* file size in bytes */
-    afs_int32 blksize;   /* optimal transfer size in bytes */
-    afs_int32 mtime;       /* modification date */
-    afs_int32 atime;       /* access time */
+    afs_int32 size;            /* file size in bytes */
+    afs_int32 blksize;         /* optimal transfer size in bytes */
+    afs_int32 mtime;           /* modification date */
+    afs_int32 atime;           /* access time */
 };
 
 struct osi_file {
-    afs_int32 size;            /* file size in bytes XXX Must be first field XXX */
+    afs_int32 size;            /* file size in bytes XXX Must be first field XXX */
+#ifdef AFS_LINUX24_ENV
+    struct file *filp;         /* May need this if we really open the file. */
+#else
 #ifdef AFS_LINUX22_ENV
-    struct dentry dentry; /* merely to hold the pointer to the inode. */
-    struct file file; /* May need this if we really open the file. */
+    struct dentry dentry;      /* merely to hold the pointer to the inode. */
+    struct file file;          /* May need this if we really open the file. */
 #else
     struct vnode *vnode;
 #endif
+#endif
 #if    defined(AFS_HPUX102_ENV)
     k_off_t offset;
 #else
+#if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
+    afs_offs_t offset;
+#else
     afs_int32 offset;
 #endif
-    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 */
+#endif
+    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)
-    int fd;            /* file descriptor for user space files */
-#endif /* defined(UKERNEL) */
+    int fd;                    /* file descriptor for user space files */
+#endif                         /* defined(UKERNEL) */
 };
 
 struct osi_dev {
-#ifdef AFS_OBSD_ENV
+#if defined(AFS_XBSD_ENV)
     struct mount *mp;
     struct vnode *held_vnode;
+#elif defined(AFS_AIX42_ENV)
+    dev_t dev;
 #else
     afs_int32 dev;
 #endif
 };
 
 struct afs_osi_WaitHandle {
-    caddr_t proc;      /* process waiting */
+#ifdef AFS_FBSD50_ENV
+    struct cv wh_condvar;
+    int wh_inited;             /* XXX */
+#else
+    caddr_t proc;              /* process waiting */
+#endif
 };
 
 #define        osi_SetFileProc(x,p)    ((x)->proc=(p))
@@ -87,12 +108,12 @@ struct afs_osi_WaitHandle {
 #endif
 
 
-#define AFSOP_STOP_RXEVENT   214 /* stop rx event deamon */
-#define AFSOP_STOP_COMPLETE  215 /* afs has been shutdown */
-#define AFSOP_STOP_RXK_LISTENER   217 /* stop rx listener daemon */
+#define AFSOP_STOP_RXEVENT   214       /* stop rx event deamon */
+#define AFSOP_STOP_COMPLETE  215       /* afs has been shutdown */
+#define AFSOP_STOP_RXK_LISTENER   217  /* stop rx listener daemon */
 
 
-#define        osi_NPACKETS    20              /* number of cluster pkts to alloc */
+#define        osi_NPACKETS    20      /* number of cluster pkts to alloc */
 
 /*
  * Alloc declarations.
@@ -102,30 +123,33 @@ struct afs_osi_WaitHandle {
 /*
  * Vnode related macros
  */
-#ifndef AFS_OBSD_ENV
+#if defined(AFS_DARWIN80_ENV)
+#define vType(vc)               vnode_vtype(AFSTOV(vc))
+#else
 #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
+#define vSetVfsp(vc, vfsp)      AFSTOV(vc)->v_mount = (vfsp)
+#define vSetType(vc, type)      AFSTOV(vc)->v_type = (type)
+#define vType(vc)               AFSTOV(vc)->v_type
+extern int (**afs_vnodeop_p) ();
+#define IsAfsVnode(v)      ((v)->v_op == afs_vnodeop_p)
+#define SetAfsVnode(v)     /* nothing; done in getnewvnode() */
 #else
-extern struct vnodeops *afs_ops;
-#define        IsAfsVnode(vc)      ((vc)->v_op == afs_ops)
-#define        SetAfsVnode(vc)     (vc)->v_op = afs_ops
-#endif
 #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)
+extern struct vnodeops *afs_ops;
+#define        IsAfsVnode(v)       ((v)->v_op == afs_ops)
+#define        SetAfsVnode(v)      (v)->v_op = afs_ops
+#endif
 #endif
 
 #ifdef AFS_SGI65_ENV
-#define        gop_lookupname(fnamep,segflg,followlink,dirvpp,compvpp) \
-             lookupname((fnamep),(segflg),(followlink),(dirvpp),(compvpp),\
+#define        gop_lookupname(fnamep,segflg,followlink,compvpp) \
+             lookupname((fnamep),(segflg),(followlink),NULL,(compvpp),\
                        NULL)
 #else
-#ifndef AFS_OBSD_ENV
-#define        gop_lookupname(fnamep,segflg,followlink,dirvpp,compvpp) \
-             lookupname((fnamep),(segflg),(followlink),(dirvpp),(compvpp))
-#endif
+#define        gop_lookupname(fnamep,segflg,followlink,compvpp) \
+             lookupname((fnamep),(segflg),(followlink),NULL,(compvpp))
 #endif
 
 /*
@@ -139,7 +163,7 @@ extern struct vnodeops *afs_ops;
  */
 #if !defined(AFS_SGI65_ENV)
 #ifndef        DEBUG
-#define        DEBUG   1       /* Default is to enable debugging/logging */
+#define        DEBUG   1               /* Default is to enable debugging/logging */
 #endif
 #endif
 
@@ -157,7 +181,7 @@ extern struct vnodeops *afs_ops;
   */
 
 
-#if defined(AFS_HPUX_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_LINUX_64BIT_KERNEL) || (defined(AFS_SGI61_ENV) && defined(KERNEL) && defined(_K64U64))
+#if defined(AFS_HPUX_ENV) || (defined(AFS_SUN57_ENV) && !defined(AFS_SUN510_ENV)) || defined(AFS_LINUX_64BIT_KERNEL) || (defined(AFS_SGI61_ENV) && defined(KERNEL) && defined(_K64U64))
 typedef struct {
     afs_int32 tv_sec;
     afs_int32 tv_usec;
@@ -166,14 +190,7 @@ typedef struct {
 typedef struct timeval osi_timeval_t;
 #endif /* AFS_SGI61_ENV */
 
-/*
- * The following three routines provide the fid routines used by the buffer
- * and directory packages.
- */
-#define dirp_Zap(afid)    (*(afid) = -1)
-#define dirp_Eq(afid, bfid) (*(afid) == *(bfid))
-#define dirp_Cpy(dfid,sfid) (*(dfid) = *(sfid))
-
+#define osi_getpid()           getpid()
 
 /*
  * osi_ThreadUnique() should yield a value that can be found in ps
@@ -193,8 +210,6 @@ typedef struct timeval osi_timeval_t;
 #ifdef AFS_GLOBAL_SUNLOCK
 #define AFS_ASSERT_GLOCK() \
     (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 at %s:%d\n", __FILE__, __LINE__), 0))
 #endif /* AFS_GLOBAL_SUNLOCK */
 
 #ifdef RX_ENABLE_LOCKS
@@ -212,10 +227,6 @@ typedef struct timeval osi_timeval_t;
 #define AFS_GUNLOCK()
 #define ISAFS_GLOCK() 1
 #define AFS_ASSERT_GLOCK()
-#define AFS_RXGLOCK()
-#define AFS_RXGUNLOCK()
-#define ISAFS_RXGLOCK() 1
-#define AFS_ASSERT_RXGLOCK()
 #endif
 
 /* On an MP that uses multithreading, splnet is not sufficient to provide
@@ -230,7 +241,6 @@ typedef struct timeval osi_timeval_t;
 #define USERPRI
 #endif
 
-#ifndef AFS_OBSD_ENV
 /*
  * vnode/vcache ref count manipulation
  */
@@ -239,7 +249,6 @@ 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
@@ -295,6 +304,18 @@ typedef struct timeval osi_timeval_t;
                AFS_GLOCK();                                    \
        } while(0)
 
+#if defined(AFS_DARWIN80_ENV)
+#define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)                       \
+       do {                                                    \
+           int haveGlock = ISAFS_GLOCK();                      \
+           if (haveGlock)                                      \
+               AFS_GUNLOCK();                                  \
+           uio_setrw((UIO),(RW));                              \
+           CODE = uiomove((SRC),(LEN),(UIO));                  \
+           if (haveGlock)                                      \
+               AFS_GLOCK();                                    \
+       } while(0)
+#else
 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)                       \
        do {                                                    \
@@ -317,6 +338,7 @@ typedef struct timeval osi_timeval_t;
                AFS_GLOCK();                                    \
        } while(0)
 #endif
+#endif /* AFS_DARWIN80_ENV */
 
 #else /* AFS_GLOBAL_SUNLOCK */
 
@@ -335,6 +357,13 @@ typedef struct timeval osi_timeval_t;
            CODE = copyout((SRC),(DST),(LEN));                  \
        } while(0)
 
+#if defined(AFS_DARWIN80_ENV)
+#define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)                       \
+       do {                                                    \
+           uio_setrw((UIO),(RW));                              \
+           CODE = uiomove((SRC),(LEN),(UIO));                  \
+       } while(0)
+#else /* AFS_OSF_ENV || AFS_FBSD_ENV */
 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 #define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE)                       \
        do {                                                    \
@@ -347,9 +376,19 @@ typedef struct timeval osi_timeval_t;
            CODE = uiomove((SRC),(LEN),(RW),(UIO));             \
        } while(0)
 #endif /* AFS_OSF_ENV || AFS_FBSD_ENV */
+#endif /* AFS_DARWIN80_ENV */
 
 #endif /* AFS_GLOBAL_SUNLOCK */
 
+#ifdef AFS_DARWIN80_ENV
+#define AFS_UIO_OFFSET(uio) uio_offset(uio)
+#define AFS_UIO_RESID(uio) uio_resid(uio)
+#else
+#define AFS_UIO_OFFSET(uio) (uio)->uio_offset
+#define AFS_UIO_RESID(uio) (uio)->uio_resid
+#endif
+
+
 /*
  * encapsulation of kernel data structure accesses
  */
@@ -386,7 +425,7 @@ typedef struct timeval osi_timeval_t;
 /* 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;
+extern struct AFS_UCRED afs_osi_cred, *afs_osi_credp;
 
 #ifndef osi_curcred
 #define osi_curcred() (u.u_cred)