2 * Copyright (c) 2007-2009 Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * Copyright (C) 2005 Csaba Henk.
32 * All rights reserved.
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
43 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 #include "fuse_kernel.h"
60 #define FUSE_DEFAULT_DAEMON_TIMEOUT 60 /* s */
61 #define FUSE_MIN_DAEMON_TIMEOUT 0 /* s */
62 #define FUSE_MAX_DAEMON_TIMEOUT 600 /* s */
64 #ifndef FUSE_FREEBSD_VERSION
65 #define FUSE_FREEBSD_VERSION "0.4.4"
68 /* Mapping versions to features */
70 #define FUSE_KERNELABI_GEQ(maj, min) \
71 (FUSE_KERNEL_VERSION > (maj) || (FUSE_KERNEL_VERSION == (maj) && FUSE_KERNEL_MINOR_VERSION >= (min)))
74 * Appearance of new FUSE operations is not always in par with version
75 * numbering... At least, 7.3 is a sufficient condition for having
76 * FUSE_{ACCESS,CREATE}.
78 #if FUSE_KERNELABI_GEQ(7, 3)
79 #ifndef FUSE_HAS_ACCESS
80 #define FUSE_HAS_ACCESS 1
82 #ifndef FUSE_HAS_CREATE
83 #define FUSE_HAS_CREATE 1
85 #else /* FUSE_KERNELABI_GEQ(7, 3) */
86 #ifndef FUSE_HAS_ACCESS
87 #define FUSE_HAS_ACCESS 0
89 #ifndef FUSE_HAS_CREATE
90 #define FUSE_HAS_CREATE 0
94 #if FUSE_KERNELABI_GEQ(7, 7)
95 #ifndef FUSE_HAS_GETLK
96 #define FUSE_HAS_GETLK 1
98 #ifndef FUSE_HAS_SETLK
99 #define FUSE_HAS_SETLK 1
101 #ifndef FUSE_HAS_SETLKW
102 #define FUSE_HAS_SETLKW 1
104 #ifndef FUSE_HAS_INTERRUPT
105 #define FUSE_HAS_INTERRUPT 1
107 #else /* FUSE_KERNELABI_GEQ(7, 7) */
108 #ifndef FUSE_HAS_GETLK
109 #define FUSE_HAS_GETLK 0
111 #ifndef FUSE_HAS_SETLK
112 #define FUSE_HAS_SETLK 0
114 #ifndef FUSE_HAS_SETLKW
115 #define FUSE_HAS_SETLKW 0
117 #ifndef FUSE_HAS_INTERRUPT
118 #define FUSE_HAS_INTERRUPT 0
122 #if FUSE_KERNELABI_GEQ(7, 8)
123 #ifndef FUSE_HAS_FLUSH_RELEASE
124 #define FUSE_HAS_FLUSH_RELEASE 1
126 * "DESTROY" came in the middle of the 7.8 era,
127 * so this is not completely exact...
129 #ifndef FUSE_HAS_DESTROY
130 #define FUSE_HAS_DESTROY 1
133 #else /* FUSE_KERNELABI_GEQ(7, 8) */
134 #ifndef FUSE_HAS_FLUSH_RELEASE
135 #define FUSE_HAS_FLUSH_RELEASE 0
136 #ifndef FUSE_HAS_DESTROY
137 #define FUSE_HAS_DESTROY 0
144 SYSCTL_DECL(_vfs_fuse);
148 extern struct mtx fuse_mtx;
149 #define FUSE_LOCK() fuse_lck_mtx_lock(fuse_mtx)
150 #define FUSE_UNLOCK() fuse_lck_mtx_unlock(fuse_mtx)
152 #define RECTIFY_TDCR(td, cred) \
157 (cred) = (td)->td_ucred; \
160 /* Debug related stuff */
162 #ifndef FUSE_DEBUG_DEVICE
163 #define FUSE_DEBUG_DEVICE 0
166 #ifndef FUSE_DEBUG_FILE
167 #define FUSE_DEBUG_FILE 0
170 #ifndef FUSE_DEBUG_INTERNAL
171 #define FUSE_DEBUG_INTERNAL 0
174 #ifndef FUSE_DEBUG_IO
175 #define FUSE_DEBUG_IO 0
178 #ifndef FUSE_DEBUG_IPC
179 #define FUSE_DEBUG_IPC 0
182 #ifndef FUSE_DEBUG_LOCK
183 #define FUSE_DEBUG_LOCK 0
186 #ifndef FUSE_DEBUG_VFSOPS
187 #define FUSE_DEBUG_VFSOPS 0
190 #ifndef FUSE_DEBUG_VNOPS
191 #define FUSE_DEBUG_VNOPS 0
198 #define DEBUGX(cond, fmt, ...) do { \
200 printf("%s: " fmt, __func__, ## __VA_ARGS__); \
203 #define fuse_lck_mtx_lock(mtx) do { \
204 DEBUGX(FUSE_DEBUG_LOCK, "0: lock(%s): %s@%d by %d\n", \
205 __STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
207 DEBUGX(FUSE_DEBUG_LOCK, "1: lock(%s): %s@%d by %d\n", \
208 __STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
211 #define fuse_lck_mtx_unlock(mtx) do { \
212 DEBUGX(FUSE_DEBUG_LOCK, "0: unlock(%s): %s@%d by %d\n", \
213 __STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
214 mtx_unlock(&(mtx)); \
215 DEBUGX(FUSE_DEBUG_LOCK, "1: unlock(%s): %s@%d by %d\n", \
216 __STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
219 void fuse_ipc_init(void);
220 void fuse_ipc_destroy(void);
222 int fuse_device_init(void);
223 void fuse_device_destroy(void);