OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/afs/SOLARIS/osi_machdep.h
00001 /*
00002  * Copyright 2000, International Business Machines Corporation and others.
00003  * All Rights Reserved.
00004  *
00005  * This software has been released under the terms of the IBM Public
00006  * License.  For details, see the LICENSE file in the top-level source
00007  * directory or online at http://www.openafs.org/dl/license10.html
00008  */
00009 
00010 /*
00011  * Solaris OSI header file. Extends afs_osi.h.
00012  *
00013  * afs_osi.h includes this file, which is the only way this file should
00014  * be included in a source file. This file can redefine macros declared in
00015  * afs_osi.h.
00016  */
00017 
00018 #ifndef _OSI_MACHDEP_H_
00019 #define _OSI_MACHDEP_H_
00020 
00021 #ifdef AFS_SUN5_64BIT_ENV
00022 #include <sys/model.h>          /* for get_udatamodel() */
00023 #endif
00024 
00025 #define getpid()                curproc->p_pid
00026 
00032 #define NFSSRV          "/kernel/misc/nfssrv"
00033 #define NFSSRV_V9       "/kernel/misc/sparcv9/nfssrv"
00034 #define NFSSRV_AMD64    "/kernel/misc/amd64/nfssrv"
00035 
00036 typedef struct cred afs_ucred_t;
00037 typedef struct proc afs_proc_t;
00038 
00039 /*
00040  * Time related macros
00041  */
00042 #define afs_hz      hz
00043 #ifdef AFS_SUN59_ENV
00044 #define osi_Time() local_osi_Time()
00045 extern void gethrestime(timespec_t *);
00046 static int
00047 local_osi_Time()
00048 {
00049     timespec_t start;
00050     gethrestime(&start);
00051     return start.tv_sec;
00052 }
00053 #else
00054 #define osi_Time() (hrestime.tv_sec)
00055 #endif
00056 
00057 #define osi_vnhold(avc, r)  do {    \
00058     struct vnode *vp = AFSTOV(avc); \
00059     uint_t prevcount;               \
00060                                     \
00061     mutex_enter(&vp->v_lock);       \
00062     prevcount = vp->v_count++;      \
00063     mutex_exit(&vp->v_lock);        \
00064                                     \
00065     if (prevcount == 0) {           \
00066         VFS_HOLD(afs_globalVFS);    \
00067     }                               \
00068 } while(0)
00069 
00070 #define gop_rdwr(rw,gp,base,len,offset,segflg,ioflag,ulimit,cr,aresid) \
00071   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(ioflag),(ulimit),(cr),(aresid))
00072 #define gop_lookupname(fnamep,segflg,followlink,compvpp) \
00073   lookupname((fnamep),(segflg),(followlink),NULL,(compvpp))
00074 #define gop_lookupname_user(fnamep,segflg,followlink,compvpp) \
00075   lookupname((fnamep),(segflg),(followlink),NULL,(compvpp))
00076 
00077 
00078 #if defined(AFS_SUN510_ENV)
00079 #define afs_suser(x)        afs_osi_suser(x)
00080 #else
00081 #define afs_suser(x)        suser(x)
00082 #endif
00083 
00084 /*
00085  * Global lock support.
00086  */
00087 #include <sys/mutex.h>
00088 extern kmutex_t afs_global_lock;
00089 
00090 #define AFS_GLOCK()     mutex_enter(&afs_global_lock);
00091 #define AFS_GUNLOCK()   mutex_exit(&afs_global_lock);
00092 #define ISAFS_GLOCK()   mutex_owned(&afs_global_lock)
00093 #define osi_InitGlock() \
00094         mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL);
00095 
00096 
00097 /* Associate the Berkley signal equivalent lock types to System V's */
00098 #define LOCK_SH 1               /* F_RDLCK */
00099 #define LOCK_EX 2               /* F_WRLCK */
00100 #define LOCK_NB 4               /* XXX */
00101 #define LOCK_UN 8               /* F_UNLCK */
00102 
00103 #ifndef IO_APPEND
00104 #define IO_APPEND       FAPPEND
00105 #endif
00106 
00107 #ifndef IO_SYNC
00108 #define IO_SYNC         FSYNC
00109 #endif
00110 
00111 /*
00112 ** Macro returns 1 if file is larger than 2GB; else returns 0
00113 */
00114 #undef AfsLargeFileUio
00115 #define AfsLargeFileUio(uio)       ( (uio)->_uio_offset._p._u ? 1 : 0 )
00116 #undef AfsLargeFileSize
00117 #define AfsLargeFileSize(pos, off) ( ((offset_t)(pos)+(offset_t)(off) > (offset_t)0x7fffffff)?1:0)
00118 
00119 #if defined(AFS_SUN510_ENV)
00120 #include "h/sunddi.h"
00121 extern ddi_taskq_t *afs_taskq;
00122 extern krwlock_t afsifinfo_lock;
00123 
00124 /* this should be in rx/SOLARIS/rx_knet.c accessed via accessor functions,
00125    eventually */
00126 #include "net/if.h"
00127 /* Global interface info struct */
00128 struct afs_ifinfo {
00129   char        ifname[LIFNAMSIZ];
00130   ipaddr_t    ipaddr;
00131   ipaddr_t    netmask;
00132   uint_t      mtu;
00133   uint64_t    flags;
00134   int         metric;
00135   ipaddr_t    dstaddr;
00136 };
00137 #endif /* AFS_SUN510_ENV */
00138 
00139 #define osi_procname(procname, size) strncpy(procname, PTOU(ttoproc(curthread))->u_comm, size)
00140 
00141 #endif /* _OSI_MACHDEP_H_ */
 All Data Structures Files Functions Variables