OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/afs/NBSD/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  *
00012  * NetBSD OSI header file. Extends afs_osi.h.
00013  *
00014  * afs_osi.h includes this file, which is the only way this file should
00015  * be included in a source file. This file can redefine macros declared in
00016  * afs_osi.h.
00017  */
00018 
00019 #ifndef _OSI_MACHDEP_H_
00020 #define _OSI_MACHDEP_H_
00021 
00022 #define RXK_LISTENER_ENV 1
00023 #define AFS_DIRENT 1
00024 
00025 #include <sys/lock.h>
00026 #if defined(AFS_NBSD50_ENV)
00027 #include <sys/kmem.h>
00028 #include <sys/specificdata.h>
00029 #include <sys/mutex.h>
00030 #include <sys/rwlock.h>
00031 #endif
00032 #include <sys/syscall.h>
00033 #include <sys/syscallargs.h>
00034 
00035 #if defined(AFS_NBSD50_ENV)
00036 # if !defined(DEF_CADDR_T)
00037 typedef char * caddr_t;
00038 #define DEF_CADDR_T
00039 # endif
00040 #endif
00041 
00042 /* vfs */
00043 #define osi_vfs         mount
00044 #define osi_vfs_bsize   mnt_stat.f_bsize
00045 #define osi_vfs_iosize  mnt_stat.f_iosize
00046 #define osi_vfs_fsid    mnt_stat.f_fsid
00047 #if 0
00048 #define vfs_bsize       mnt_stat.f_bsize
00049 #define vfs_fsid        mnt_stat.f_fsid
00050 #endif
00051 #define vfs_vnodecovered mnt_vnodecovered
00052 #define v_vfsp          v_mount
00053 
00054 /* vnode */
00055 #define VN_HOLD(vp)     (vget(vp, 0))
00056 #define VN_RELE(vp)     (vrele(vp))
00057 #define osi_vnhold(avc, r) (VN_HOLD(AFSTOV(avc)))
00058 
00059 #define va_nodeid       va_fileid
00060 
00061 /* syscall */
00062 struct afs_sysargs {
00063     syscallarg(long) syscall;
00064     syscallarg(long) parm1;
00065     syscallarg(long) parm2;
00066     syscallarg(long) parm3;
00067     syscallarg(long) parm4;
00068     syscallarg(long) parm5;
00069     syscallarg(long) parm6;
00070 };
00071 
00072 /* uio */
00073 #define afsio_iov       uio_iov
00074 #define afsio_iovcnt    uio_iovcnt
00075 #define afsio_offset    uio_offset
00076 #define afsio_resid     uio_resid
00077 #define afsio_seg       uio_segflg
00078 #define AFS_UIOSYS      UIO_SYSSPACE
00079 #define AFS_UIOUSER     UIO_USERSPACE
00080 
00081 /* proc */
00082 typedef struct lwp afs_proc_t;
00083 #define osi_curproc()   curlwp
00084 #define getpid()        (osi_curproc())->l_proc->p_pid
00085 #define osi_procname(procname, size) strncpy(procname, curproc->p_comm, size)
00086 
00087 typedef struct kauth_cred afs_ucred_t;
00088 #define osi_curcred()   (kauth_cred_get())
00089 #define afs_suser(x)    afs_osi_suser(osi_curcred())
00090 #define osi_crgetruid(acred) (kauth_cred_getuid(acred))
00091 #define osi_crgetrgid(acred) (kauth_cred_getgid(acred))
00092 #define osi_crngroups(acred) (kauth_cred_ngroups(acred))
00093 #define osi_proccred(aproc) ((aproc)->l_proc->p_cred)
00094 #define osi_crgroupbyid kauth_cred_group
00095 #define crdup kauth_cred_dup
00096 #define crhold kauth_cred_hold
00097 #define crfree kauth_cred_free
00098 
00099 #define afs_cr_gid osi_crgetrgid
00100 #define afs_cr_uid osi_crgetruid
00101 
00102 /* time */
00103 #define afs_hz          hz
00104 #define osi_GetTime(x)  getmicrotime(x)
00105 #define osi_Time()      time_second
00106 
00107 /* str */
00108 #define afs_strcasecmp(s1, s2)  strncasecmp((s1), (s2), 65535)
00109 #define afs_strcat(s1, s2)      strcat((s1), (s2))
00110 
00111 /* other */
00112 #define afs_bufferpages bufpages
00113 #ifndef iodone
00114 #define iodone biodone
00115 #endif
00116 #define printk          printf  /* for RX version of xdr_* */
00117 #define setgroups       sys_setgroups
00118 #define UVM
00119 
00120 /* This is not always in scope yet */
00121 struct vcache;
00122 
00123 extern int afs_nbsd_lookupname(const char *fnamep, enum uio_seg segflg,
00124                                int followlink, struct vnode **compvpp);
00125 extern void afs_nbsd_getnewvnode(struct vcache *tvc);
00126 
00127 #undef gop_lookupname
00128 #undef gop_lookupname_user
00129 #define osi_lookupname_user(fnamep, segflg, followlink, compvpp) \
00130         afs_nbsd_lookupname((fnamep), (segflg), (followlink), (compvpp))
00131 #define gop_lookupname_user osi_lookupname_user
00132 #define gop_lookupname osi_lookupname_user
00133 
00134 #ifdef KERNEL
00135 #ifdef AFS_GLOBAL_SUNLOCK
00136 
00137 #if defined(AFS_NBSD50_ENV)
00138 extern kmutex_t afs_global_mtx;
00139 #define AFS_GLOCK() \
00140     do { \
00141         mutex_enter(&afs_global_mtx); \
00142     } while (0)
00143 #define AFS_GUNLOCK() \
00144     do { \
00145         mutex_exit(&afs_global_mtx); \
00146     } while (0)
00147 #define ISAFS_GLOCK() (mutex_owned(&afs_global_mtx))
00148 #define osi_InitGlock() \
00149     do { \
00150         mutex_init(&afs_global_mtx, MUTEX_DEFAULT, IPL_NONE); \
00151     } while (0)
00152 #else /* !50 */
00153 extern struct lock afs_global_lock;
00154 #if defined(LOCKDEBUG)
00155 #define AFS_GLOCK() \
00156   do { \
00157       _lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL, __FILE__, __LINE__); \
00158   } while(0);
00159 #define AFS_GUNLOCK() \
00160   do { \
00161       _lockmgr(&afs_global_lock, LK_RELEASE, NULL, __FILE__, __LINE__); \
00162   } while(0);
00163 #else
00164 #define AFS_GLOCK() \
00165   do { \
00166     lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL); \
00167   } while(0);
00168 #define AFS_GUNLOCK() \
00169   do { \
00170     lockmgr(&afs_global_lock, LK_RELEASE, NULL); \
00171   } while(0);
00172 #endif /* LOCKDEBUG */
00173 #endif /* !50 */
00174 #else
00175 #define ISAFS_GLOCK() (lockstatus(&afs_global_lock) == LK_EXCLUSIVE)
00176 extern struct lock afs_global_lock;
00177 #define AFS_GLOCKP(p)
00178 #define AFS_GUNLOCKP(p)
00179 #define AFS_ASSERT_GLOCK()
00180 #define ISAFS_GLOCK() 1
00181 #endif /* !AFS_GLOBAL_SUNLOCK */
00182 
00183 #undef SPLVAR
00184 #define SPLVAR int splvar
00185 #undef NETPRI
00186 #define NETPRI splvar=splnet()
00187 #undef USERPRI
00188 #define USERPRI splx(splvar)
00189 #endif /* KERNEL */
00190 
00191 #if     !defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__) && !defined(IGNORE_STDS_H)
00192 enum vcexcl { NONEXCL, EXCL };
00193 
00194 #ifndef MIN
00195 #define MIN(A,B) ((A) < (B) ? (A) : (B))
00196 #endif
00197 #ifndef MAX
00198 #define MAX(A,B) ((A) > (B) ? (A) : (B))
00199 #endif
00200 
00201 #endif /* ASSEMBLER */
00202 
00203 /* vnodes */
00204 extern int (**afs_vnodeop_p) __P((void *));
00205 #define vType(vc)               AFSTOV(vc)->v_type
00206 #define vSetVfsp(vc, vfsp)      AFSTOV(vc)->v_mount = (vfsp)
00207 #define vSetType(vc, type)      AFSTOV(vc)->v_type = (type)
00208 #define IsAfsVnode(v)      ((v)->v_op == afs_vnodeop_p)
00209 #define SetAfsVnode(v)     /* nothing; done in getnewvnode() */
00210 
00211 extern int afs_debug;
00212 
00213 #define AFS_USE_NBSD_NAMECACHE 0
00214 
00215 #endif /* _OSI_MACHDEP_H_ */
 All Data Structures Files Functions Variables