summaryrefslogtreecommitdiff
blob: cf4cf44411962232de3068c7b33326f011771352 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
Taken from FreeBSD Ports

cat sysutils/fusefs-kmod/files/patch-* > fuse4bsd-0.3.9_pre20080208-ports.patch


--- fuse_module/Makefile.orig	2008-02-05 08:25:57.000000000 +0300
+++ fuse_module/Makefile	2009-01-14 00:29:13.000000000 +0300
@@ -1,3 +1,5 @@
+.undef KERNCONF
+
 .include "../Makefile.common"
 
 SRCS = fuse_main.c    \
@@ -22,7 +24,8 @@
 
 .if defined(KERNCONF)
 KERNCONF1!= echo ${KERNCONF} | sed -e 's/ .*//g'
-KERNCONFDIR= /usr/obj/usr/src/sys/${KERNCONF1}
+KRNLOBJDIR!=	make -C /usr/src -f /usr/src/Makefile.inc1 -V KRNLOBJDIR
+KERNCONFDIR= ${KRNLOBJDIR}/${KERNCONF1}
 .endif
 
 .if defined(KERNCONFDIR)
--- fuse_module/fuse.h.orig	2008-02-05 00:25:57.000000000 -0500
+++ fuse_module/fuse.h	2009-05-13 18:40:19.000000000 -0400
@@ -25,6 +25,22 @@
 #endif
 #endif
 
+#ifndef VFSOPS_TAKES_THREAD
+#if __FreeBSD_version >= 800087
+#define VFSOPS_TAKES_THREAD 0
+#else
+#define VFSOPS_TAKES_THREAD 1
+#endif
+#endif
+
+#ifndef VOP_ACCESS_TAKES_ACCMODE_T
+#if __FreeBSD_version >= 800052
+#define VOP_ACCESS_TAKES_ACCMODE_T 1
+#else
+#define VOP_ACCESS_TAKES_ACCMODE_T 0
+#endif
+#endif
+
 #ifndef VOP_OPEN_TAKES_FP
 #if __FreeBSD_version >= 700044
 #define VOP_OPEN_TAKES_FP 1
@@ -49,6 +65,14 @@
 #endif
 #endif
 
+#ifndef VOP_GETATTR_TAKES_THREAD
+#if __FreeBSD_version >= 800046
+#define VOP_GETATTR_TAKES_THREAD 0
+#else
+#define VOP_GETATTR_TAKES_THREAD 1
+#endif
+#endif
+
 #ifndef USE_PRIVILEGE_API
 /*
  * __FreeBSD_version bump was omitted for introduction of
--- fuse_module/fuse_dev.c
+++ fuse_module/fuse_dev.c
@@ -52,8 +52,13 @@
 	.d_read = fusedev_read,
 	.d_write = fusedev_write,
 	.d_version = D_VERSION,
+#ifndef D_NEEDMINOR
+#define D_NEEDMINOR 0
+#endif
 #if ! DO_GIANT_MANUALLY
-	.d_flags = D_NEEDGIANT,
+	.d_flags = D_NEEDMINOR|D_NEEDGIANT,
+#else
+	.d_flags = D_NEEDMINOR,
 #endif
 };
 
@@ -548,7 +553,12 @@
 	/* find any existing device, or allocate new unit number */
 	i = clone_create(&fuseclones, &fuse_cdevsw, &unit, dev, 0);
 	if (i) {
-		*dev = make_dev(&fuse_cdevsw, unit2minor(unit),
+		*dev = make_dev(&fuse_cdevsw,
+#if __FreeBSD_version < 800062
+				unit2minor(unit),
+#else /* __FreeBSD_version >= 800062 */
+				unit,
+#endif /* __FreeBSD_version < 800062 */
 			        UID_ROOT, GID_OPERATOR,
 		                S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP,
                                 "fuse%d", unit);
--- fuse_module/fuse_io.c.orig	2008-02-05 00:25:57.000000000 -0500
+++ fuse_module/fuse_io.c	2009-07-13 09:31:24.000000000 -0400
@@ -35,6 +35,10 @@
 #include <vm/vnode_pager.h>
 #include <vm/vm_object.h>
 
+#if (__FreeBSD_version >= 800000)
+#define vfs_bio_set_validclean vfs_bio_set_valid
+#endif
+
 #include "fuse.h"
 #include "fuse_session.h"
 #include "fuse_vnode.h"
@@ -157,7 +161,11 @@
 		goto out;
 
 	if (uio->uio_rw == UIO_WRITE && fp->f_flag & O_APPEND) {
-		if ((err = VOP_GETATTR(vp, &va, cred, td)))
+		if ((err = VOP_GETATTR(vp, &va, cred
+#if VOP_GETATTR_TAKES_THREAD
+		    , td
+#endif
+		    )))
 			goto out;
 		uio->uio_offset = va.va_size;
 	} else if ((flags & FOF_OFFSET) == 0)
@@ -227,7 +235,7 @@
 		return (0);
 
 	biosize = vp->v_mount->mnt_stat.f_iosize;
-	bcount = min(MAXBSIZE, biosize);
+	bcount = MIN(MAXBSIZE, biosize);
 
 	DEBUG2G("entering loop\n");
 	do {
@@ -352,7 +360,7 @@
 		fri = fdi.indata;
 		fri->fh = fufh->fh_id;
 		fri->offset = uio->uio_offset;
-		fri->size = min(uio->uio_resid,
+		fri->size = MIN(uio->uio_resid,
 		                fusefs_get_data(vp->v_mount)->max_read);
 	
 		DEBUG2G("fri->fh %llu, fri->offset %d, fri->size %d\n",
@@ -399,7 +407,7 @@
 	while (uio->uio_resid > 0) {
 		int transfersize;
 
-		chunksize = min(iov->iov_len, nmax);
+		chunksize = MIN(iov->iov_len, nmax);
 
 		if (uio->uio_rw == UIO_READ) {
 			struct fuse_read_in *fri;
@@ -464,7 +472,7 @@
 {
 		int err;
 
-		if ((err = uiomove(buf, min(reqsize, bufsize), uio)))
+		if ((err = uiomove(buf, MIN(reqsize, bufsize), uio)))
 			return (err);
 
 		if (bufsize < reqsize)
@@ -502,7 +510,7 @@
 	}
 
 	while (uio->uio_resid > 0) {
-		chunksize = min(uio->uio_resid,
+		chunksize = MIN(uio->uio_resid,
 		                fusefs_get_data(vp->v_mount)->max_write);
 
 		fdi.iosize = sizeof(*fwi) + chunksize;
@@ -569,7 +577,7 @@
 	do {
 		lbn = uio->uio_offset / biosize;
 		on = uio->uio_offset & (biosize-1);
-		n = min((unsigned)(biosize - on), uio->uio_resid);
+		n = MIN((unsigned)(biosize - on), uio->uio_resid);
 		
 		DEBUG2G("lbn %d, on %d, n %d, uio offset %d, uio resid %d\n",
 		        (int)lbn, on, n, (int)uio->uio_offset, uio->uio_resid);
@@ -739,8 +747,8 @@
 		 */
 		if (n) {
 			if (bp->b_dirtyend > 0) {
-				bp->b_dirtyoff = min(on, bp->b_dirtyoff);
-				bp->b_dirtyend = max((on + n), bp->b_dirtyend);
+				bp->b_dirtyoff = MIN(on, bp->b_dirtyoff);
+				bp->b_dirtyend = MAX((on + n), bp->b_dirtyend);
 			} else {
 				bp->b_dirtyoff = on;
 				bp->b_dirtyend = on + n;
@@ -823,7 +831,11 @@
 #if FUSELIB_CONFORM_BIOREAD
 		struct vattr va;
 
-		if ((err = VOP_GETATTR(vp, &va, cred, curthread)))
+		if ((err = VOP_GETATTR(vp, &va, cred
+#if VOP_GETATTR_TAKES_THREAD
+		    , curthread
+#endif
+		    )))
 			goto out;
 #endif
 
@@ -831,7 +843,7 @@
 		bp->b_resid = bp->b_bcount;
 		while (bp->b_resid > 0) {
 			DEBUG2G("starting bio with resid %ld\n", bp->b_resid);	
-			chunksize = min(bp->b_resid,
+			chunksize = MIN(bp->b_resid,
 			                fusefs_get_data(vp->v_mount)->max_read);
 			fdi.iosize = sizeof(*fri);
 			if (! op)
@@ -842,8 +854,8 @@
 			fri->fh = fufh->fh_id;
 			fri->offset = ((off_t)bp->b_blkno) * biosize + ioff;
 #if FUSELIB_CONFORM_BIOREAD
-			chunksize = min(chunksize,
-			                min(fri->offset + bp->b_resid,
+			chunksize = MIN(chunksize,
+			                MIN(fri->offset + bp->b_resid,
 			                    va.va_size) - fri->offset);
 			if (chunksize == 0) {
 				respsize = -1;
@@ -901,7 +913,7 @@
 
 		bufdat = bp->b_data + bp->b_dirtyoff;
 		while (bp->b_dirtyend > bp->b_dirtyoff) {
-			chunksize = min(bp->b_dirtyend - bp->b_dirtyoff,
+			chunksize = MIN(bp->b_dirtyend - bp->b_dirtyoff,
 			                fusefs_get_data(vp->v_mount)->max_write);
 	
 			fdi.iosize = sizeof(*fwi);
--- fuse_module/fuse_main.c.00	2010-08-15 14:40:29.000000000 +0400
+++ fuse_module/fuse_main.c	2010-08-15 15:56:56.000000000 +0400
@@ -108,6 +108,9 @@
 	switch (what) {
 	case MOD_LOAD:                /* kldload */
 
+#if __FreeBSD_version > 800009
+	        fuse_fileops.fo_truncate = vnops.fo_truncate;
+#endif
 		fuse_fileops.fo_ioctl    = vnops.fo_ioctl;
 		fuse_fileops.fo_poll     = vnops.fo_poll;
 		fuse_fileops.fo_kqfilter = vnops.fo_kqfilter;


--- fuse_module/fuse_vfsops.c.orig	2008-02-05 00:25:57.000000000 -0500
+++ fuse_module/fuse_vfsops.c	2009-05-13 18:54:01.000000000 -0400
@@ -18,6 +18,7 @@
 #include <sys/namei.h>
 #include <sys/mount.h>
 #include <sys/sysctl.h>
+#include <sys/fcntl.h>
 
 #include "fuse.h"
 #include "fuse_session.h"
@@ -213,8 +214,14 @@
  * Mount system call
  */
 static int
+#if VFSOPS_TAKES_THREAD
 fuse_mount(struct mount *mp, struct thread *td)
 {
+#else
+fuse_mount(struct mount *mp)
+{
+	struct thread *td = curthread;
+#endif
 	int err = 0;
 	size_t len;
 	char *fspec, *subtype = NULL;
@@ -529,8 +536,14 @@
  * Unmount system call
  */
 static int
+#if VFSOPS_TAKES_THREAD
 fuse_unmount(struct mount *mp, int mntflags, struct thread *td)
 {
+#else
+fuse_unmount(struct mount *mp, int mntflags)
+{
+	struct thread *td = curthread;
+#endif
 	int flags = 0, err = 0;
 	struct fuse_data *data;
 	struct fuse_secondary_data *fsdat = NULL;
@@ -633,8 +646,14 @@
 
 /* stolen from portalfs */
 static int
+#if VFSOPS_TAKES_THREAD
 fuse_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td)
 {
+#else
+fuse_root(struct mount *mp, int flags, struct vnode **vpp)
+{
+	struct thread *td = curthread;
+#endif
 	/*
 	 * Return locked reference to root.
 	 */
@@ -650,7 +669,11 @@
 		data = fsdat->master;
 		sx_slock(&data->mhierlock);
 		if (data->mpri == FM_PRIMARY)
-			err = fuse_root(data->mp, flags, vpp, td);
+			err = fuse_root(data->mp, flags, vpp
+#if VFSOPS_TAKES_THREAD
+			    , td
+#endif
+			    );
 		else
 			err = ENXIO;
 		sx_sunlock(&data->mhierlock);
@@ -667,7 +690,11 @@
 	if (vp->v_type == VNON) {
 		struct vattr va;
 
-		(void)VOP_GETATTR(vp, &va, td->td_ucred, td);
+		(void)VOP_GETATTR(vp, &va, td->td_ucred
+#if VOP_GETATTR_TAKES_THREAD
+		    , td
+#endif
+		);
 	}
 	*vpp = vp;
 #if _DEBUG2G
@@ -678,8 +705,14 @@
 }
 
 static int
+#if VFSOPS_TAKES_THREAD
 fuse_statfs(struct mount *mp, struct statfs *sbp, struct thread *td)
 {
+#else
+fuse_statfs(struct mount *mp, struct statfs *sbp)
+{
+	struct thread *td = curthread;
+#endif
 	struct fuse_dispatcher fdi;
 	struct fuse_statfs_out *fsfo;
 	struct fuse_data *data;
@@ -696,7 +729,11 @@
 
 		sx_slock(&data->mhierlock);
 		if (data->mpri == FM_PRIMARY)
-			err = fuse_statfs(data->mp, sbp, td);
+			err = fuse_statfs(data->mp, sbp
+#if VFSOPS_TAKES_THREAD
+			    , td
+#endif
+			    );
 		else
 			err = ENXIO;
 		sx_sunlock(&data->mhierlock);
@@ -794,7 +831,11 @@
 	if (nodeid == FUSE_ROOT_ID) {
 		if (parentid != FUSE_NULL_ID)
 			return (ENOENT);
-		err = VFS_ROOT(mp, myflags, vpp, td);
+		err = VFS_ROOT(mp, myflags, vpp
+#if VFSOPS_TAKES_THREAD
+		    , td
+#endif
+		    );
 		if (err)
 			return (err);
 		KASSERT(*vpp, ("we neither err'd nor found the root node"));
--- ./fuse_module/fuse_vnops.c.orig	2012-09-19 06:04:10.512413490 +0200
+++ ./fuse_module/fuse_vnops.c	2012-09-19 06:20:44.949613892 +0200
@@ -799,8 +799,11 @@
 	struct vnode *vp = ap->a_vp;
 	struct vattr *vap = ap->a_vap;
 	struct ucred *cred = ap->a_cred;
+#if VOP_GETATTR_TAKES_THREAD
 	struct thread *td = ap->a_td;
-
+#else
+	struct thread *td = curthread;
+#endif
 	struct fuse_dispatcher fdi;
 	struct timespec uptsp;
 	int err = 0;
@@ -871,7 +874,11 @@
 fuse_access(ap)
 	struct vop_access_args /* {
 		struct vnode *a_vp;
+#if VOP_ACCESS_TAKES_ACCMODE_T
+		accmode_t a_accmode;
+#else
 		int a_mode;
+#endif
 		struct ucred *a_cred;
 		struct thread *a_td;
 	} */ *ap;
@@ -886,7 +893,13 @@
 	else
 		facp.facc_flags |= FACCESS_DO_ACCESS;
 
-	return fuse_access_i(vp, ap->a_mode, ap->a_cred, ap->a_td, &facp);
+	return fuse_access_i(vp,
+#if VOP_ACCESS_TAKES_ACCMODE_T
+	    ap->a_accmode,
+#else
+	    ap->a_mode,
+#endif
+	    ap->a_cred, ap->a_td, &facp);
 }
 
 /*
@@ -946,7 +959,11 @@
 		/* We are to do the check in-kernel */
 
 		if (! (facp->facc_flags & FACCESS_VA_VALID)) {
-			err = VOP_GETATTR(vp, VTOVA(vp), cred, td);
+			err = VOP_GETATTR(vp, VTOVA(vp), cred
+#if VOP_GETATTR_TAKES_THREAD
+			    , td
+#endif
+			    );
 			if (err)
 				return (err);
 			facp->facc_flags |= FACCESS_VA_VALID;
@@ -1544,7 +1561,7 @@
 	struct fuse_vnode_data *fvdat = VTOFUD(vp);
 	uint64_t parentid = fvdat->parent_nid;
 	struct componentname *cnp = fvdat->germcnp;
-	struct fuse_open_in *foi;
+	struct fuse_create_in *foi;
 	struct fuse_entry_out *feo;
 	struct fuse_mknod_in fmni;
 	int err;
@@ -1929,7 +1946,11 @@
 		 * It will not invalidate pages which are dirty, locked, under
 		 * writeback or mapped into pagetables.") 
 		 */
+#if VOP_GETATTR_TAKES_THREAD
 		err = vinvalbuf(vp, 0, td, PCATCH, 0);
+#else
+		err = vinvalbuf(vp, 0, PCATCH, 0);
+#endif
 		fufh->flags |= FOPEN_KEEP_CACHE;
 	}
 
@@ -3005,8 +3026,11 @@
 	struct vattr *vap = ap->a_vap;
 	struct vnode *vp = ap->a_vp;
 	struct ucred *cred = ap->a_cred;
+#if VOP_GETATTR_TAKES_THREAD
 	struct thread *td = ap->a_td;
-
+#else
+	struct thread *td = curthread;
+#endif
 	int err = 0;
 	struct fuse_dispatcher fdi;
 	struct fuse_setattr_in *fsai;
--- mount_fusefs/mount_fusefs.c	2008-02-05 07:25:57.000000000 +0200
+++ mount_fusefs/mount_fusefs.c	2012-01-07 21:07:35.000000000 +0200
@@ -44,6 +44,7 @@
 #include <getopt.h>
 #include <libgen.h>
 #include <limits.h>
+#include <osreldate.h>
 #include <paths.h>
 
 #include "fuse4bsd.h"
@@ -312,7 +313,12 @@
 	 * Resolve the mountpoint with realpath(3) and remove unnecessary
 	 * slashes from the devicename if there are any.
 	 */
+#if __FreeBSD_version >= 1000005
+	if (checkpath(dir, mntpath) != 0)
+		err(1, "%s", mntpath);
+#else
 	(void)checkpath(dir, mntpath);
+#endif
 	(void)rmslashes(dev, dev);
 
 	if (strcmp(dev, "auto") == 0)