1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 #ifdef HAVE_CONFIG_H
37 #include <config.h>
38 #else
39 #include <xfs/xfs_config.h>
40 #endif
41
42 #ifndef RCSID
43 #define RCSID(x)
44 #endif
45
46 #ifdef __osf__
47
48 #ifdef __GNUC__
49 #define asm __foo_asm
50 #endif
51 #include <sys/types.h>
52 #include <sys/errno.h>
53 #include <sys/uio.h>
54 #include <machine/cpu.h>
55 #include <sys/conf.h>
56 #include <sys/sysconfig.h>
57 #include <sys/file.h>
58 #include <sys/malloc.h>
59 #include <sys/poll.h>
60 #include <sys/ioctl.h>
61 #include <sys/fcntl.h>
62 #include <sys/vfs_proto.h>
63 #include <io/common/devdriver.h>
64 #include <vm/vm_page.h>
65 #include <vm/vm_vppage.h>
66 #include <vm/vm_ubc.h>
67
68 typedef short int16_t;
69 typedef unsigned short uint16_t;
70 typedef int int32_t;
71 typedef unsigned int uint32_t;
72
73 #define VT_AFS VT_ADDON
74 #define MOUNT_NNPFS MOUNT_PC
75
76 typedef struct nameidata xfs_componentname;
77
78
79 #if 0
80 #define componentname nameidata
81 #endif
82
83 #define cn_nameptr ni_ptr
84 #define cn_namelen ni_namelen
85 #define cn_hash ni_hash
86 #define cn_cred ni_cred
87 #define cn_nameiop ni_nameiop
88 #define cn_flags ni_flags
89
90 #define mnt_stat m_stat
91 #define mnt_flag m_flag
92
93 #define NDINIT(ndp, op, flags, segflg, namep, p) \
94 (ndp)->ni_nameiop = (op) | (flags); \
95 (ndp)->ni_segflg = segflg; \
96 (ndp)->ni_dirp = namep;
97
98 #define LOCKLEAF 0
99
100 #define FFLAGS(mode) ((mode) - FOPEN)
101
102
103
104 #define vput(VP) vrele(VP)
105
106 #define xfs_uio_to_proc(uiop) (u.u_procp)
107 #define xfs_cnp_to_proc(cnp) (u.u_procp)
108 #define xfs_proc_to_cred(p) ((p)->p_rcred)
109 #define xfs_proc_to_euid(p) ((p)->p_rcred->cr_uid)
110
111 #define xfs_curproc() (u.u_procp)
112
113 #define xfs_vop_read VOP_READ
114 #define xfs_vop_write VOP_WRITE
115 #define xfs_vop_getattr(t, attr, cred, proc, error) VOP_GETATTR((t), (attr), (cred), (error))
116 #define xfs_vop_access(dvp, mode, cred, proc, error) VOP_ACCESS((dvp), (mode), (cred), (error))
117
118 struct vop_generic_args;
119
120 typedef u_long va_size_t;
121
122 #else
123
124 typedef struct componentname xfs_componentname;
125
126 #include <sys/types.h>
127 #include <sys/param.h>
128 #include <sys/time.h>
129 #include <sys/proc.h>
130 #include <sys/filedesc.h>
131 #include <sys/kernel.h>
132 #ifdef HAVE_SYS_MODULE_H
133 #include <sys/module.h>
134 #endif
135 #include <sys/systm.h>
136 #include <sys/fcntl.h>
137 #ifdef HAVE_SYS_SYSPROTO_H
138 #include <sys/sysproto.h>
139 #endif
140 #include <sys/conf.h>
141 #include <sys/mount.h>
142 #include <sys/exec.h>
143 #ifdef HAVE_SYS_SYSENT_H
144 #include <sys/sysent.h>
145 #endif
146 #ifdef HAVE_SYS_LKM_H
147 #include <sys/lkm.h>
148 #endif
149 #ifdef HAVE_SYS_LOCK_H
150 #include <sys/lock.h>
151 #endif
152 #ifdef HAVE_SYS_MUTEX_H
153 #include <sys/mutex.h>
154 #endif
155 #include <sys/vnode.h>
156 #include <sys/errno.h>
157 #include <sys/file.h>
158 #include <sys/namei.h>
159 #include <sys/dirent.h>
160 #include <sys/ucred.h>
161 #include <sys/selinfo.h>
162 #include <sys/uio.h>
163 #ifdef HAVE_SYS_POLL_H
164 #include <sys/poll.h>
165 #endif
166 #ifdef HAVE_SYS_SIGNALVAR_H
167 #include <sys/signalvar.h>
168 #endif
169 #ifdef HAVE_SYS_INTTYPES_H
170 #include <sys/inttypes.h>
171 #endif
172 #include <sys/syscall.h>
173 #include <sys/queue.h>
174 #include <sys/malloc.h>
175 #ifdef HAVE_SYS_SYSCALLARGS_H
176 #include <sys/syscallargs.h>
177 #endif
178 #ifdef HAVE_SYS_ATTR_H
179 #include <sys/attr.h>
180 #endif
181
182 #ifdef HAVE_MISCFS_GENFS_GENFS_H
183 #include <miscfs/genfs/genfs.h>
184 #endif
185 #ifdef HAVE_MISCFS_SYNCFS_SYNCFS_H
186 #include <miscfs/syncfs/syncfs.h>
187 #endif
188 #ifndef HAVE_KERNEL_UVM_ONLY
189 #ifdef HAVE_VM_VM_H
190 #include <vm/vm.h>
191 #endif
192 #ifdef HAVE_VM_VM_EXTERN_H
193 #include <vm/vm_extern.h>
194 #endif
195 #ifdef HAVE_VM_VM_ZONE_H
196 #include <vm/vm_zone.h>
197 #endif
198 #ifdef HAVE_VM_VM_OBJECT_H
199 #include <vm/vm_object.h>
200 #endif
201 #endif
202 #ifdef HAVE_UVM_UVM_EXTERN_H
203 #include <uvm/uvm_extern.h>
204 #endif
205 #ifdef HAVE_VM_UMA_H
206 #include <vm/uma.h>
207 #endif
208
209 #if defined(__APPLE__)
210 #include <machine/machine_routines.h>
211 #include <mach/machine/vm_types.h>
212 #include <sys/ubc.h>
213 void cache_purge(struct vnode *);
214 int cache_lookup(struct vnode *, struct vnode **, struct componentname *);
215 void cache_enter(struct vnode *, struct vnode *, struct componentname *);
216 void cache_purgevfs(struct mount *);
217 #endif
218
219 #define xfs_vop_read(t, uio, ioflag, cred, error) (error) = VOP_READ((t), (uio), (ioflag), (cred))
220 #define xfs_vop_write(t, uio, ioflag, cred, error) (error) = VOP_WRITE((t), (uio), (ioflag), (cred))
221 #define xfs_vop_getattr(t, attr, cred, proc, error) (error) = VOP_GETATTR((t), (attr), (cred), (proc))
222 #define xfs_vop_access(dvp, mode, cred, proc, error) (error) = VOP_ACCESS((dvp), (mode), (cred), (proc))
223
224 typedef u_quad_t va_size_t;
225
226 #endif
227
228 #ifdef __FreeBSD_version
229 #if __FreeBSD_version < 400000
230 # error This version is unsupported
231 #elif __FreeBSD_version < 440001 || (__FreeBSD_version >= 500000 && __FreeBSD_version < 500023)
232 typedef struct proc d_thread_t;
233 #elif __FreeBSD_version == 500023
234 # define HAVE_FREEBSD_THREAD
235 typedef struct thread d_thread_t;
236 #elif __FreeBSD_version >= 500024
237 # define HAVE_FREEBSD_THREAD
238 #endif
239 typedef d_thread_t syscall_d_thread_t;
240 #define syscall_thread_to_thread(x) (x)
241 #else
242 #if defined(__NetBSD__) && __NetBSD_Version__ >= 106130000
243 typedef struct lwp syscall_d_thread_t;
244 #define syscall_thread_to_thread(x) ((x)->l_proc)
245 #else
246 typedef struct proc syscall_d_thread_t;
247 #define syscall_thread_to_thread(x) (x)
248 #endif
249 typedef struct proc d_thread_t;
250 #endif
251
252 #ifdef VV_ROOT
253 #define NNPFS_MAKE_VROOT(v) ((v)->v_vflag |= VV_ROOT)
254 #else
255 #define NNPFS_MAKE_VROOT(v) ((v)->v_flag |= VROOT)
256 #endif
257
258 #if defined(__NetBSD__) && __NetBSD_Version__ >= 105280000
259 #include <miscfs/genfs/genfs.h>
260 #include <miscfs/genfs/genfs_node.h>
261
262 struct genfs_ops xfs_genfsops;
263 #endif
264
265
266 #if defined(HAVE_FREEBSD_THREAD)
267 #define xfs_uio_to_thread(uiop) ((uiop)->uio_td)
268 #define xfs_cnp_to_thread(cnp) ((cnp)->cn_thread)
269 #define xfs_thread_to_cred(td) ((td)->td_proc->p_ucred)
270 #define xfs_thread_to_euid(td) ((td)->td_proc->p_ucred->cr_uid)
271 #else
272 #define xfs_uio_to_proc(uiop) ((uiop)->uio_procp)
273 #define xfs_cnp_to_proc(cnp) ((cnp)->cn_proc)
274 #define xfs_proc_to_cred(p) ((p)->p_ucred)
275 #define xfs_proc_to_euid(p) ((p)->p_ucred->cr_uid)
276 #endif
277
278 #if defined(__FreeBSD_version) && __FreeBSD_version >= 500043
279 extern const char *VT_AFS;
280 #endif
281
282 #if defined(__FreeBSD__)
283 typedef void * xfs_malloc_type;
284 #elif defined(__NetBSD__) && __NetBSD_Version__ >= 106140000
285 typedef struct malloc_type * xfs_malloc_type;
286 #else
287 typedef int xfs_malloc_type;
288 #endif
289
290 #ifdef __APPLE__
291 #define xfs_curproc() (current_proc())
292 #else
293 #if defined(HAVE_FREEBSD_THREAD)
294 #define xfs_curthread() (curthread)
295 #else
296 #define xfs_curproc() (curproc)
297 #endif
298 #endif
299
300 #ifdef __osf__
301 #define xfs_pushdirty(vp, cred, p)
302 #else
303 void xfs_pushdirty(struct vnode *, struct ucred *, d_thread_t *);
304 #endif
305
306
307 #if defined(HAVE_UINTPTR_T)
308 #define xfs_uintptr_t uintptr_t
309 #else
310 #if defined(_LP64) || defined(alpha) || defined(__alpha__) || defined(__sparc64__) || defined(__sparcv9__)
311 #define xfs_uintptr_t unsigned long long
312 #else
313 #define xfs_uintptr_t unsigned long
314 #endif
315 #endif
316
317
318
319
320
321 #ifndef SCARG
322 #if defined(__FreeBSD_version) && __FreeBSD_version > 500042
323 #define SCARG(a, b) ((a)->b)
324 #define syscallarg(x) x
325 #else
326 #define SCARG(a, b) ((a)->b.datum)
327 #define syscallarg(x) union { x datum; register_t pad; }
328 #endif
329 #endif
330
331 #ifndef syscallarg
332 #define syscallarg(x) x
333 #endif
334
335 #ifndef HAVE_REGISTER_T
336 typedef int register_t;
337 #endif
338
339
340 #ifndef M_WAITOK
341 #define M_WAITOK 0
342 #endif
343
344 #if defined(HAVE_DEF_STRUCT_SETGROUPS_ARGS)
345 #define xfs_setgroups_args setgroups_args
346 #elif defined(HAVE_DEF_STRUCT_SYS_SETGROUPS_ARGS)
347 #define xfs_setgroups_args sys_setgroups_args
348 #elif __osf__
349 struct xfs_setgroups_args {
350 syscallarg(int) gidsetsize;
351 syscallarg(gid_t) *gidset;
352 };
353 #elif defined(__APPLE__)
354 struct xfs_setgroups_args{
355 syscallarg(u_int) gidsetsize;
356 syscallarg(gid_t) *gidset;
357 };
358 #else
359 #error what is you setgroups named ?
360 #endif
361
362
363 #ifdef HAVE_KERNEL_VFS_GETVFS
364 #define xfs_vfs_getvfs vfs_getvfs
365 #else
366 #define xfs_vfs_getvfs getvfs
367 #endif
368
369 #ifdef HAVE_FOUR_ARGUMENT_VFS_OBJECT_CREATE
370 #define xfs_vfs_object_create(vp,proc,ucred) vfs_object_create(vp,proc,ucred,TRUE)
371 #else
372 #define xfs_vfs_object_create(vp,proc,ucred) vfs_object_create(vp,proc,ucred)
373 #endif
374
375 #if defined(UVM) || (defined(__NetBSD__) && __NetBSD_Version__ >= 105280000)
376 #define xfs_set_vp_size(vp, sz) uvm_vnp_setsize(vp, sz)
377 #elif HAVE_KERNEL_VNODE_PAGER_SETSIZE
378 #define xfs_set_vp_size(vp, sz) vnode_pager_setsize(vp, sz)
379 #elif defined(__APPLE__)
380 #define xfs_set_vp_size(vp, sz) ubc_setsize(vp, sz)
381 #else
382 #define xfs_set_vp_size(vp, sz)
383 #endif
384
385
386 #ifdef LOCKLEAF
387 #define NNPFS_LOCKLEAF LOCKLEAF
388 #else
389 #define NNPFS_LOCKLEAF 0
390 #endif
391
392 #ifdef NEED_VGONEL_PROTO
393 void vgonel (struct vnode *vp, d_thread_t *p);
394 #endif
395
396 #ifdef NEED_ISSIGNAL_PROTO
397 int issignal (d_thread_t *);
398 #endif
399
400 #ifdef NEED_STRNCMP_PROTO
401 int strncmp (const char *, const char *, size_t);
402 #endif
403
404 #ifdef NEED_VN_WRITECHK_PROTO
405 int vn_writechk (struct vnode *);
406 #endif
407
408 #ifdef NEED_UBC_PUSHDIRTY_PROTO
409 int ubc_pushdirty (struct vnode *);
410 #endif
411
412 #include <xfs/xfs_syscalls.h>
413
414
415
416
417
418
419
420 #define NNPFS_VOP_DEF(n) \
421 struct vop_##n##_args; \
422 int xfs_##n(struct vop_##n##_args *);
423
424 #include "xfs/xfs_vopdefs.h"