SOLARIS: let xlator load if amd64/nfssrv is loaded
[openafs.git] / src / afs / SOLARIS / osi_machdep.h
index b2731ae..ca25455 100644 (file)
   */
 #define NFSSRV                 "/kernel/misc/nfssrv"
 #define NFSSRV_V9      "/kernel/misc/sparcv9/nfssrv"
+#define NFSSRV_AMD64   "/kernel/misc/amd64/nfssrv"
 
-#define AFS_UCRED cred
-#define AFS_PROC struct proc
+typedef struct cred afs_ucred_t;
+typedef struct proc afs_proc_t;
 
 /* 
  * Time related macros
@@ -56,14 +57,37 @@ local_osi_Time()
 #undef afs_osi_Alloc_NoSleep
 extern void *afs_osi_Alloc_NoSleep(size_t size);
 
-#define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
+#ifdef AFS_SUN58_ENV
+# define osi_vnhold(avc, r)  do {    \
+    struct vnode *vp = AFSTOV(avc); \
+    uint_t prevcount;               \
+                                    \
+    mutex_enter(&vp->v_lock);       \
+    prevcount = vp->v_count++;      \
+    mutex_exit(&vp->v_lock);        \
+                                    \
+    if (prevcount == 0) {           \
+       VFS_HOLD(afs_globalVFS);    \
+    }                               \
+} while(0)
+#else /* !AFS_SUN58_ENV */
+# define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
+#endif /* !AFS_SUN58_ENV */
+
 #define gop_rdwr(rw,gp,base,len,offset,segflg,ioflag,ulimit,cr,aresid) \
   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(ioflag),(ulimit),(cr),(aresid))
+#define gop_lookupname(fnamep,segflg,followlink,compvpp) \
+  lookupname((fnamep),(segflg),(followlink),NULL,(compvpp))
+#define gop_lookupname_user(fnamep,segflg,followlink,compvpp) \
+  lookupname((fnamep),(segflg),(followlink),NULL,(compvpp))
 
-#define        afs_suser(x)        suser(x)
 
+#if defined(AFS_SUN510_ENV)
+#define afs_suser(x)        afs_osi_suser(x)
+#else
+#define afs_suser(x)        suser(x)
+#endif
 
-#ifdef KERNEL
 /*
  * Global lock support. 
  */
@@ -73,6 +97,8 @@ extern kmutex_t afs_global_lock;
 #define AFS_GLOCK()    mutex_enter(&afs_global_lock);
 #define AFS_GUNLOCK()  mutex_exit(&afs_global_lock);
 #define ISAFS_GLOCK()  mutex_owned(&afs_global_lock)
+#define osi_InitGlock() \
+       mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL);
 #endif
 
 
@@ -100,4 +126,25 @@ extern kmutex_t afs_global_lock;
 #define AfsLargeFileSize(pos, off) ( ((offset_t)(pos)+(offset_t)(off) > (offset_t)0x7fffffff)?1:0)
 #endif
 
+#if defined(AFS_SUN510_ENV)
+#include "h/sunddi.h"
+extern ddi_taskq_t *afs_taskq;
+extern krwlock_t afsifinfo_lock;
+
+/* this should be in rx/SOLARIS/rx_knet.c accessed via accessor functions,
+   eventually */
+#include "net/if.h"
+/* Global interface info struct */
+struct afs_ifinfo {
+  char        ifname[LIFNAMSIZ];
+  ipaddr_t    ipaddr;
+  ipaddr_t    netmask;
+  uint_t      mtu;
+  uint64_t    flags;
+  int         metric;
+  ipaddr_t    dstaddr;
+};
+
+#define osi_procname(procname, size) strncpy(procname, PTOU(ttoproc(curthread))->u_comm, size)
+
 #endif /* _OSI_MACHDEP_H_ */