2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
12 * FBSD OSI header file. Extends afs_osi.h.
14 * afs_osi.h includes this file, which is the only way this file should
15 * be included in a source file. This file can redefine macros declared in
19 #ifndef _OSI_MACHDEP_H_
20 #define _OSI_MACHDEP_H_
24 #if defined(AFS_FBSD50_ENV)
25 #include <sys/mutex.h>
27 #include <sys/vnode.h>
28 #if defined(AFS_FBSD80_ENV)
35 #define osi_Time() time_second
38 typedef struct ucred afs_ucred_t;
39 typedef struct proc afs_proc_t;
41 #define afs_bufferpages bufpages
43 #define iodone biodone
49 #define osi_vnhold(avc,r) vref(AFSTOV(avc))
51 #define vType(vc) AFSTOV(vc)->v_type
52 #define vSetVfsp(vc, vfsp) AFSTOV(vc)->v_mount = (vfsp)
53 #define vSetType(vc, type) AFSTOV(vc)->v_type = (type)
54 #if defined(AFS_FBSD60_ENV) && defined(KERNEL)
55 extern struct vop_vector afs_vnodeops;
56 # define IsAfsVnode(v) ((v)->v_op == &afs_vnodeops)
58 extern int (**afs_vnodeop_p) ();
59 # define IsAfsVnode(v) ((v)->v_op == afs_vnodeop_p)
61 #define SetAfsVnode(v) /* nothing; done in getnewvnode() */
63 #if defined(AFS_FBSD80_ENV)
64 #define osi_vinvalbuf(vp, flags, slpflag, slptimeo) \
65 vinvalbuf((vp), (flags), (slpflag), (slptimeo))
67 #define osi_vinvalbuf(vp, flags, slpflag, slptimeo) \
68 vinvalbuf((vp), (flags), (curthread), (slpflag), (slptimeo))
72 #define gop_lookupname osi_lookupname
74 #undef gop_lookupname_user
75 #define gop_lookupname_user osi_lookupname
77 #define afs_strcat(s1, s2) strcat((s1), (s2))
80 extern void *osi_fbsd_alloc(size_t size, int dropglobal);
81 extern void osi_fbsd_free(void *p);
83 #undef afs_osi_Alloc_NoSleep
84 #define afs_osi_Alloc_NoSleep(size) osi_fbsd_alloc((size), 0)
92 #define VN_RELE(vp) vrele(vp)
94 #define VN_HOLD(vp) VREF(vp)
97 #if defined(AFS_FBSD80_ENV)
98 /* OpenAFS-specific privileges negotiated for FreeBSD, thanks due to
100 #define osi_suser_client_settings(x) (!priv_check(curthread, PRIV_AFS_ADMIN))
101 #define osi_suser_afs_daemon(x) (!priv_check(curthread, PRIV_AFS_DAEMON))
102 #define afs_suser(x) (osi_suser_client_settings((x)) && osi_suser_afs_daemon((x)))
104 #define afs_suser(x) (!suser(curthread))
109 #define VROOT VV_ROOT
110 #define v_flag v_vflag
111 #define osi_curcred() (curthread->td_ucred)
112 #define osi_getpid() (curthread->td_proc->p_pid)
113 #define simple_lock(x) mtx_lock(x)
114 #define simple_unlock(x) mtx_unlock(x)
115 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
116 vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(cred),(aresid), curthread)
117 extern struct mtx afs_global_mtx;
118 extern struct thread *afs_global_owner;
119 #define AFS_GLOCK() \
121 mtx_assert(&afs_global_mtx, (MA_NOTOWNED)); \
122 mtx_lock(&afs_global_mtx); \
123 mtx_assert(&afs_global_mtx, (MA_OWNED|MA_NOTRECURSED)); \
125 #define AFS_GUNLOCK() \
127 mtx_assert(&afs_global_mtx, (MA_OWNED|MA_NOTRECURSED)); \
128 mtx_unlock(&afs_global_mtx); \
130 #define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx))
131 # if defined(AFS_FBSD80_ENV) && defined(WITNESS)
132 # define osi_InitGlock() \
134 memset(&afs_global_mtx, 0, sizeof(struct mtx)); \
135 mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF); \
136 afs_global_owner = 0; \
139 # define osi_InitGlock() \
141 mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF); \
142 afs_global_owner = 0; \
147 #define SPLVAR int splvar
149 #define NETPRI splvar=splnet()
151 #define USERPRI splx(splvar)
153 #define osi_procname(procname, size) strncpy(procname, curproc->p_comm, size)
155 #endif /* _OSI_MACHDEP_H_ */