OpenAFS
OpenAFS distributed network file system
|
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 * FBSD 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 #include <sys/lock.h> 00023 #include <sys/time.h> 00024 #include <sys/mutex.h> 00025 #include <sys/vnode.h> 00026 #if defined(AFS_FBSD80_ENV) 00027 #include <sys/priv.h> 00028 #endif 00029 00030 /* 00031 * Time related macros 00032 */ 00033 #define osi_Time() time_second 00034 #define afs_hz hz 00035 00036 typedef struct ucred afs_ucred_t; 00037 typedef struct proc afs_proc_t; 00038 00039 #define afs_bufferpages bufpages 00040 #ifndef iodone 00041 #define iodone biodone 00042 #endif 00043 00044 #ifdef AFS_FBSD80_ENV 00045 #define VSUID S_ISUID 00046 #define VSGID S_ISGID 00047 #endif 00048 00049 #define osi_vnhold(avc,r) vref(AFSTOV(avc)) 00050 00051 #define vType(vc) AFSTOV(vc)->v_type 00052 #define vSetVfsp(vc, vfsp) AFSTOV(vc)->v_mount = (vfsp) 00053 #define vSetType(vc, type) AFSTOV(vc)->v_type = (type) 00054 #if defined(AFS_FBSD60_ENV) && defined(KERNEL) 00055 extern struct vop_vector afs_vnodeops; 00056 # define IsAfsVnode(v) ((v)->v_op == &afs_vnodeops) 00057 #else 00058 extern int (**afs_vnodeop_p) (); 00059 # define IsAfsVnode(v) ((v)->v_op == afs_vnodeop_p) 00060 #endif 00061 #define SetAfsVnode(v) /* nothing; done in getnewvnode() */ 00062 00063 #if defined(AFS_FBSD80_ENV) 00064 #define osi_vinvalbuf(vp, flags, slpflag, slptimeo) \ 00065 vinvalbuf((vp), (flags), (slpflag), (slptimeo)) 00066 #else 00067 #define osi_vinvalbuf(vp, flags, slpflag, slptimeo) \ 00068 vinvalbuf((vp), (flags), (curthread), (slpflag), (slptimeo)) 00069 #define osi_curproc() (curthread) 00070 #endif 00071 00072 #undef gop_lookupname 00073 #define gop_lookupname osi_lookupname 00074 00075 #undef gop_lookupname_user 00076 #define gop_lookupname_user osi_lookupname 00077 00078 #define afs_strcat(s1, s2) strcat((s1), (s2)) 00079 00080 /* malloc */ 00081 extern void *osi_fbsd_alloc(size_t size, int dropglobal); 00082 extern void osi_fbsd_free(void *p); 00083 00084 #define afs_osi_Alloc_NoSleep(size) osi_fbsd_alloc((size), 0) 00085 00086 #ifdef AFS_FBSD80_ENV 00087 #define VN_RELE(vp) \ 00088 do { \ 00089 vrele(vp); \ 00090 } while(0); 00091 #else 00092 #define VN_RELE(vp) vrele(vp) 00093 #endif 00094 #define VN_HOLD(vp) VREF(vp) 00095 00096 #undef afs_suser 00097 #if defined(AFS_FBSD80_ENV) 00098 /* OpenAFS-specific privileges negotiated for FreeBSD, thanks due to 00099 * Ben Kaduk */ 00100 #define osi_suser_client_settings(x) (!priv_check(curthread, PRIV_AFS_ADMIN)) 00101 #define osi_suser_afs_daemon(x) (!priv_check(curthread, PRIV_AFS_DAEMON)) 00102 #define afs_suser(x) (osi_suser_client_settings((x)) && osi_suser_afs_daemon((x))) 00103 #else 00104 #define afs_suser(x) (!suser(curthread)) 00105 #endif 00106 00107 #undef osi_getpid 00108 #define VT_AFS "afs" 00109 #define VROOT VV_ROOT 00110 #define v_flag v_vflag 00111 #define osi_curcred() (curthread->td_ucred) 00112 #define osi_curproc() (curthread) 00113 #define osi_getpid() (curthread->td_proc->p_pid) 00114 #define simple_lock(x) mtx_lock(x) 00115 #define simple_unlock(x) mtx_unlock(x) 00116 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \ 00117 vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(cred),(aresid), curthread) 00118 extern struct mtx afs_global_mtx; 00119 extern struct thread *afs_global_owner; 00120 #define AFS_GLOCK() \ 00121 do { \ 00122 mtx_assert(&afs_global_mtx, (MA_NOTOWNED)); \ 00123 mtx_lock(&afs_global_mtx); \ 00124 mtx_assert(&afs_global_mtx, (MA_OWNED|MA_NOTRECURSED)); \ 00125 } while (0) 00126 #define AFS_GUNLOCK() \ 00127 do { \ 00128 mtx_assert(&afs_global_mtx, (MA_OWNED|MA_NOTRECURSED)); \ 00129 mtx_unlock(&afs_global_mtx); \ 00130 } while (0) 00131 #define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx)) 00132 # if defined(AFS_FBSD80_ENV) && defined(WITNESS) 00133 # define osi_InitGlock() \ 00134 do { \ 00135 memset(&afs_global_mtx, 0, sizeof(struct mtx)); \ 00136 mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF); \ 00137 afs_global_owner = 0; \ 00138 } while(0) 00139 # else 00140 # define osi_InitGlock() \ 00141 do { \ 00142 mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF); \ 00143 afs_global_owner = 0; \ 00144 } while (0) 00145 # endif 00146 00147 #undef SPLVAR 00148 #define SPLVAR 00149 #undef NETPRI 00150 #define NETPRI 00151 #undef USERPRI 00152 #define USERPRI 00153 00154 #define osi_procname(procname, size) strncpy(procname, curproc->p_comm, size) 00155 00156 #endif /* _OSI_MACHDEP_H_ */