1 | | diff --git a/Makefile.am b/Makefile.am |
2 | | index a80788b..99e1dc8 100644 |
3 | | --- a/Makefile.am |
4 | | +++ b/Makefile.am |
5 | | @@ -2,14 +2,14 @@ |
6 | | |
7 | | bin_PROGRAMS = sshfs |
8 | | |
9 | | -sshfs_SOURCES = sshfs.c cache.c cache.h |
10 | | +sshfs_SOURCES = sshfs.c cache.c cache.h compat/darwin_semaphore.h compat/darwin_semaphore.c |
11 | | if FUSE_OPT_COMPAT |
12 | | sshfs_SOURCES += compat/fuse_opt.c compat/fuse_opt.h |
13 | | endif |
14 | | |
15 | | sshfs_LDADD = $(SSHFS_LIBS) |
16 | | sshfs_CFLAGS = $(SSHFS_CFLAGS) |
17 | | -sshfs_CPPFLAGS = -D_REENTRANT -DFUSE_USE_VERSION=26 -DLIBDIR=\"$(libdir)\" |
18 | | +sshfs_CPPFLAGS = -D_REENTRANT -DFUSE_USE_VERSION=26 -DLIBDIR=\"$(libdir)\" -Icompat |
19 | | |
20 | | EXTRA_DIST = sshnodelay.c FAQ.txt |
21 | | CLEANFILES = sshnodelay.so |
22 | | diff --git a/compat/darwin_semaphore.c b/compat/darwin_semaphore.c |
23 | | new file mode 100644 |
24 | | index 0000000..e45fd9a |
25 | | --- /dev/null |
26 | | +++ b/compat/darwin_semaphore.c |
27 | | @@ -0,0 +1,229 @@ |
28 | | +/* |
29 | | + * Copyright (C) 2000,02 Free Software Foundation, Inc. |
30 | | + * This file is part of the GNU C Library. |
31 | | + * Written by Ga<EB>l Le Mignot <address@hidden> |
32 | | + * |
33 | | + * The GNU C Library is free software; you can redistribute it and/or |
34 | | + * modify it under the terms of the GNU Library General Public License as |
35 | | + * published by the Free Software Foundation; either version 2 of the |
36 | | + * License, or (at your option) any later version. |
37 | | + * |
38 | | + * The GNU C Library is distributed in the hope that it will be useful, |
39 | | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
40 | | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
41 | | + * Library General Public License for more details. |
42 | | + * |
43 | | + * You should have received a copy of the GNU Library General Public |
44 | | + * License along with the GNU C Library; see the file COPYING.LIB. If not, |
45 | | + * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
46 | | + * Boston, MA 02111-1307, USA. |
47 | | + */ |
48 | | + |
49 | | +#include "darwin_semaphore.h" |
50 | | + |
51 | | +#include <assert.h> |
52 | | +#include <errno.h> |
53 | | +#include <sys/types.h> |
54 | | + |
55 | | +#define __SEM_ID_NONE 0x0 |
56 | | +#define __SEM_ID_LOCAL 0xcafef00d |
57 | | + |
58 | | +/* http://www.opengroup.org/onlinepubs/007908799/xsh/sem_init.html */ |
59 | | +int |
60 | | +compat_sem_init(compat_sem_t *sem, int pshared, unsigned int value) |
61 | | +{ |
62 | | + if (pshared) { |
63 | | + errno = ENOSYS; |
64 | | + return -1; |
65 | | + } |
66 | | + |
67 | | + sem->id = __SEM_ID_NONE; |
68 | | + |
69 | | + if (pthread_cond_init(&sem->__data.local.count_cond, NULL)) { |
70 | | + goto cond_init_fail; |
71 | | + } |
72 | | + |
73 | | + if (pthread_mutex_init(&sem->__data.local.count_lock, NULL)) { |
74 | | + goto mutex_init_fail; |
75 | | + } |
76 | | + |
77 | | + sem->__data.local.count = value; |
78 | | + sem->id = __SEM_ID_LOCAL; |
79 | | + |
80 | | + return 0; |
81 | | + |
82 | | +mutex_init_fail: |
83 | | + |
84 | | + pthread_cond_destroy(&sem->__data.local.count_cond); |
85 | | + |
86 | | +cond_init_fail: |
87 | | + |
88 | | + return -1; |
89 | | +} |
90 | | + |
91 | | +/* http://www.opengroup.org/onlinepubs/007908799/xsh/sem_destroy.html */ |
92 | | +int |
93 | | +compat_sem_destroy(compat_sem_t *sem) |
94 | | +{ |
95 | | + int res = 0; |
96 | | + |
97 | | + pthread_mutex_lock(&sem->__data.local.count_lock); |
98 | | + |
99 | | + sem->id = __SEM_ID_NONE; |
100 | | + pthread_cond_broadcast(&sem->__data.local.count_cond); |
101 | | + |
102 | | + if (pthread_cond_destroy(&sem->__data.local.count_cond)) { |
103 | | + res = -1; |
104 | | + } |
105 | | + |
106 | | + pthread_mutex_unlock(&sem->__data.local.count_lock); |
107 | | + |
108 | | + if (pthread_mutex_destroy(&sem->__data.local.count_lock)) { |
109 | | + res = -1; |
110 | | + } |
111 | | + |
112 | | + return res; |
113 | | +} |
114 | | + |
115 | | +int |
116 | | +compat_sem_getvalue(compat_sem_t *sem, unsigned int *sval) |
117 | | +{ |
118 | | + int res = 0; |
119 | | + |
120 | | + pthread_mutex_lock(&sem->__data.local.count_lock); |
121 | | + |
122 | | + if (sem->id != __SEM_ID_LOCAL) { |
123 | | + res = -1; |
124 | | + errno = EINVAL; |
125 | | + } else { |
126 | | + *sval = sem->__data.local.count; |
127 | | + } |
128 | | + |
129 | | + pthread_mutex_unlock(&sem->__data.local.count_lock); |
130 | | + |
131 | | + return res; |
132 | | +} |
133 | | + |
134 | | +/* http://www.opengroup.org/onlinepubs/007908799/xsh/sem_post.html */ |
135 | | +int |
136 | | +compat_sem_post(compat_sem_t *sem) |
137 | | +{ |
138 | | + int res = 0; |
139 | | + |
140 | | + pthread_mutex_lock(&sem->__data.local.count_lock); |
141 | | + |
142 | | + if (sem->id != __SEM_ID_LOCAL) { |
143 | | + res = -1; |
144 | | + errno = EINVAL; |
145 | | + } else if (sem->__data.local.count < COMPAT_SEM_VALUE_MAX) { |
146 | | + sem->__data.local.count++; |
147 | | + if (sem->__data.local.count == 1) { |
148 | | + pthread_cond_signal(&sem->__data.local.count_cond); |
149 | | + } |
150 | | + } else { |
151 | | + errno = ERANGE; |
152 | | + res = -1; |
153 | | + } |
154 | | + |
155 | | + pthread_mutex_unlock(&sem->__data.local.count_lock); |
156 | | + |
157 | | + return res; |
158 | | +} |
159 | | + |
160 | | +/* http://www.opengroup.org/onlinepubs/009695399/functions/sem_timedwait.html */ |
161 | | +int |
162 | | +compat_sem_timedwait(compat_sem_t *sem, const struct timespec *abs_timeout) |
163 | | +{ |
164 | | + int res = 0; |
165 | | + |
166 | | + if (abs_timeout && |
167 | | + (abs_timeout->tv_nsec < 0 || abs_timeout->tv_nsec >= 1000000000)) { |
168 | | + errno = EINVAL; |
169 | | + return -1; |
170 | | + } |
171 | | + |
172 | | + pthread_cleanup_push((void(*)(void*))&pthread_mutex_unlock, |
173 | | + &sem->__data.local.count_lock); |
174 | | + |
175 | | + pthread_mutex_lock(&sem->__data.local.count_lock); |
176 | | + |
177 | | + if (sem->id != __SEM_ID_LOCAL) { |
178 | | + errno = EINVAL; |
179 | | + res = -1; |
180 | | + } else { |
181 | | + if (!sem->__data.local.count) { |
182 | | + res = pthread_cond_timedwait(&sem->__data.local.count_cond, |
183 | | + &sem->__data.local.count_lock, |
184 | | + abs_timeout); |
185 | | + } |
186 | | + if (res) { |
187 | | + assert(res == ETIMEDOUT); |
188 | | + res = -1; |
189 | | + errno = ETIMEDOUT; |
190 | | + } else if (sem->id != __SEM_ID_LOCAL) { |
191 | | + res = -1; |
192 | | + errno = EINVAL; |
193 | | + } else { |
194 | | + sem->__data.local.count--; |
195 | | + } |
196 | | + } |
197 | | + |
198 | | + pthread_cleanup_pop(1); |
199 | | + |
200 | | + return res; |
201 | | +} |
202 | | + |
203 | | +/* http://www.opengroup.org/onlinepubs/007908799/xsh/sem_trywait.html */ |
204 | | +int |
205 | | +compat_sem_trywait(compat_sem_t *sem) |
206 | | +{ |
207 | | + int res = 0; |
208 | | + |
209 | | + pthread_mutex_lock(&sem->__data.local.count_lock); |
210 | | + |
211 | | + if (sem->id != __SEM_ID_LOCAL) { |
212 | | + res = -1; |
213 | | + errno = EINVAL; |
214 | | + } else if (sem->__data.local.count) { |
215 | | + sem->__data.local.count--; |
216 | | + } else { |
217 | | + res = -1; |
218 | | + errno = EAGAIN; |
219 | | + } |
220 | | + |
221 | | + pthread_mutex_unlock (&sem->__data.local.count_lock); |
222 | | + |
223 | | + return res; |
224 | | +} |
225 | | + |
226 | | +/* http://www.opengroup.org/onlinepubs/007908799/xsh/sem_wait.html */ |
227 | | +int |
228 | | +compat_sem_wait(compat_sem_t *sem) |
229 | | +{ |
230 | | + int res = 0; |
231 | | + |
232 | | + pthread_cleanup_push((void(*)(void*))&pthread_mutex_unlock, |
233 | | + &sem->__data.local.count_lock); |
234 | | + |
235 | | + pthread_mutex_lock(&sem->__data.local.count_lock); |
236 | | + |
237 | | + if (sem->id != __SEM_ID_LOCAL) { |
238 | | + errno = EINVAL; |
239 | | + res = -1; |
240 | | + } else { |
241 | | + while (!sem->__data.local.count) { |
242 | | + pthread_cond_wait(&sem->__data.local.count_cond, |
243 | | + &sem->__data.local.count_lock); |
244 | | + } |
245 | | + if (sem->id != __SEM_ID_LOCAL) { |
246 | | + res = -1; |
247 | | + errno = EINVAL; |
248 | | + } else { |
249 | | + sem->__data.local.count--; |
250 | | + } |
251 | | + } |
252 | | + |
253 | | + pthread_cleanup_pop(1); |
254 | | + |
255 | | + return res; |
256 | | +} |
257 | | diff --git a/compat/darwin_semaphore.h b/compat/darwin_semaphore.h |
258 | | new file mode 100644 |
259 | | index 0000000..3f03e41 |
260 | | --- /dev/null |
261 | | +++ b/compat/darwin_semaphore.h |
262 | | @@ -0,0 +1,69 @@ |
263 | | +/* Copyright (C) 2000,02 Free Software Foundation, Inc. |
264 | | + This file is part of the GNU C Library. |
265 | | + Written by Gaël Le Mignot <address@hidden> |
266 | | + |
267 | | + The GNU C Library is free software; you can redistribute it and/or |
268 | | + modify it under the terms of the GNU Library General Public License as |
269 | | + published by the Free Software Foundation; either version 2 of the |
270 | | + License, or (at your option) any later version. |
271 | | + |
272 | | + The GNU C Library is distributed in the hope that it will be useful, |
273 | | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
274 | | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
275 | | + Library General Public License for more details. |
276 | | + |
277 | | + You should have received a copy of the GNU Library General Public |
278 | | + License along with the GNU C Library; see the file COPYING.LIB. If not, |
279 | | + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
280 | | + Boston, MA 02111-1307, USA. */ |
281 | | + |
282 | | +// This implementation is based on libsem http://lists.debian.org/debian-devel/2004/08/msg00612.html |
283 | | + |
284 | | +#ifndef _SEMAPHORE_H_ |
285 | | +#define _SEMAPHORE_H_ |
286 | | + |
287 | | +/* Caller must not include <semaphore.h> */ |
288 | | + |
289 | | +#include <pthread.h> |
290 | | + |
291 | | +struct __local_sem_t |
292 | | +{ |
293 | | + unsigned int count; |
294 | | + pthread_mutex_t count_lock; |
295 | | + pthread_cond_t count_cond; |
296 | | +}; |
297 | | + |
298 | | +typedef struct compat_sem { |
299 | | + unsigned int id; |
300 | | + union { |
301 | | + struct __local_sem_t local; |
302 | | + } __data; |
303 | | +} compat_sem_t; |
304 | | + |
305 | | +#define COMPAT_SEM_VALUE_MAX ((int32_t)32767) |
306 | | + |
307 | | +int compat_sem_init(compat_sem_t *sem, int pshared, unsigned int value); |
308 | | +int compat_sem_destroy(compat_sem_t *sem); |
309 | | +int compat_sem_getvalue(compat_sem_t *sem, unsigned int *value); |
310 | | +int compat_sem_post(compat_sem_t *sem); |
311 | | +int compat_sem_timedwait(compat_sem_t *sem, const struct timespec *abs_timeout); |
312 | | +int compat_sem_trywait(compat_sem_t *sem); |
313 | | +int compat_sem_wait(compat_sem_t *sem); |
314 | | + |
315 | | + |
316 | | +/* Redefine semaphores. Caller must not include <semaphore.h> */ |
317 | | + |
318 | | +typedef compat_sem_t sem_t; |
319 | | + |
320 | | +#define sem_init(s, p, v) compat_sem_init(s, p, v) |
321 | | +#define sem_destroy(s) compat_sem_destroy(s) |
322 | | +#define sem_getvalue(s, v) compat_sem_getvalue(s, v) |
323 | | +#define sem_post(s) compat_sem_post(s) |
324 | | +#define sem_timedwait(s, t) compat_sem_timedwait(s, t) |
325 | | +#define sem_trywait(s) compat_sem_trywait(s) |
326 | | +#define sem_wait(s) compat_sem_wait(s) |
327 | | + |
328 | | +#define SEM_VALUE_MAX COMPAT_SEM_VALUE_MAX |
329 | | + |
330 | | + |
331 | | +#endif /* semaphore.h */ |
332 | | diff --git a/sshfs.c b/sshfs.c |
333 | | index 8a8e858..9220b70 100644 |
334 | | --- a/sshfs.c.orig 2011-07-23 18:00:48.000000000 -0400 |
335 | | +++ a/sshfs.c 2011-07-23 19:28:43.000000000 -0400 |
336 | | @@ -19,12 +19,18 @@ |
337 | | #include <string.h> |
338 | | #include <stdint.h> |
339 | | #include <errno.h> |
340 | | -#if !(__FreeBSD__ >= 10) |
341 | | -#include <semaphore.h> |
342 | | +#ifdef __APPLE__ |
343 | | +/* OS X does not support named semaphores; need some sort of emulation */ |
344 | | +#if (__FreeBSD__ >= 10) |
345 | | +/* MacFUSE provides a semaphore emulation layer */ |
346 | | +#include <fuse_darwin.h> |
347 | | #else |
348 | | -#define MACFUSE_SSHFS_VERSION "2.2.0" |
349 | | -#include "fuse_darwin.h" |
350 | | -#endif |
351 | | +/* Fuse4X doesn't; use our own */ |
352 | | +#include "darwin_semaphore.h" |
353 | | +#endif /* (__FreeBSD__ >= 10) */ |
354 | | +#else |
355 | | +#include <semaphore.h> |
356 | | +#endif /* __APPLE__ */ |
357 | | #include <pthread.h> |
358 | | #include <netdb.h> |
359 | | #include <signal.h> |
360 | | @@ -39,7 +45,7 @@ |
361 | | #include <netinet/in.h> |
362 | | #include <netinet/tcp.h> |
363 | | #include <glib.h> |
364 | | -#if (__FreeBSD__ >= 10) |
365 | | +#ifdef __APPLE__ |
366 | | #include <libgen.h> |
367 | | #include <strings.h> |
368 | | #endif |
369 | | @@ -129,7 +135,7 @@ |
370 | | |
371 | | #define SSHNODELAY_SO "sshnodelay.so" |
372 | | |
373 | | -#if (__FreeBSD__ >= 10) |
374 | | +#ifdef __APPLE__ |
375 | | |
376 | | #ifndef LIBDIR |
377 | | #define LIBDIR "/usr/local/lib" |
378 | | @@ -188,7 +194,7 @@ |
379 | | int connver; |
380 | | int modifver; |
381 | | int refs; |
382 | | -#if (__FreeBSD__ >= 10) |
383 | | +#ifdef __APPLE__ |
384 | | pthread_mutex_t file_lock; |
385 | | #endif |
386 | | }; |
387 | | @@ -230,7 +236,7 @@ |
388 | | int server_version; |
389 | | unsigned remote_uid; |
390 | | unsigned local_uid; |
391 | | -#if (__FreeBSD__ >= 10) |
392 | | +#ifdef __APPLE__ |
393 | | unsigned remote_gid; |
394 | | unsigned local_gid; |
395 | | #endif |
396 | | @@ -667,7 +673,7 @@ |
397 | | } |
398 | | } |
399 | | |
400 | | -#if (__FreeBSD__ >= 10) |
401 | | +#ifdef __APPLE__ |
402 | | if (sshfs.remote_uid_detected) { |
403 | | if (uid == sshfs.remote_uid) |
404 | | uid = sshfs.local_uid; |
405 | | @@ -780,7 +786,7 @@ |
406 | | #ifdef SSH_NODELAY_WORKAROUND |
407 | | static int do_ssh_nodelay_workaround(void) |
408 | | { |
409 | | -#if (__FreeBSD__ >= 10) |
410 | | +#ifdef __APPLE__ |
411 | | char *oldpreload = getenv("DYLD_INSERT_LIBRARIES"); |
412 | | #else |
413 | | char *oldpreload = getenv("LD_PRELOAD"); |
414 | | @@ -789,7 +795,7 @@ |
415 | | char sopath[PATH_MAX]; |
416 | | int res; |
417 | | |
418 | | -#if (__FreeBSD__ >= 10) |
419 | | +#ifdef __APPLE__ |
420 | | char *sshfs_program_path_base = NULL; |
421 | | if (!sshfs_program_path[0]) { |
422 | | goto nobundle; |
423 | | @@ -831,7 +837,7 @@ |
424 | | return -1; |
425 | | } |
426 | | } |
427 | | -#if (__FreeBSD__ >= 10) |
428 | | +#ifdef __APPLE__ |
429 | | pathok: |
430 | | #endif |
431 | | |
432 | | @@ -840,7 +846,7 @@ |
433 | | oldpreload ? " " : "", |
434 | | sopath); |
435 | | |
436 | | -#if (__FreeBSD__ >= 10) |
437 | | +#ifdef __APPLE__ |
438 | | if (!newpreload || setenv("DYLD_INSERT_LIBRARIES", newpreload, 1) == -1) |
439 | | fprintf(stderr, "warning: failed set DYLD_INSERT_LIBRARIES for ssh nodelay workaround\n"); |
440 | | #else |
441 | | @@ -1541,7 +1547,7 @@ |
442 | | |
443 | | sshfs.remote_uid = stbuf.st_uid; |
444 | | sshfs.local_uid = getuid(); |
445 | | -#if (__FreeBSD__ >= 10) |
446 | | +#ifdef __APPLE__ |
447 | | sshfs.remote_gid = stbuf.st_gid; |
448 | | sshfs.local_gid = getgid(); |
449 | | #endif |
450 | | @@ -2139,7 +2145,7 @@ |
451 | | buf_init(&buf, 0); |
452 | | buf_add_path(&buf, path); |
453 | | buf_add_uint32(&buf, SSH_FILEXFER_ATTR_UIDGID); |
454 | | -#if (__FreeBSD__ >= 10) |
455 | | +#ifdef __APPLE__ |
456 | | if (sshfs.remote_uid_detected) { |
457 | | if (uid == sshfs.local_uid) |
458 | | uid = sshfs.remote_uid; |
459 | | @@ -2230,7 +2236,7 @@ |
460 | | sf = g_new0(struct sshfs_file, 1); |
461 | | list_init(&sf->write_reqs); |
462 | | pthread_cond_init(&sf->write_finished, NULL); |
463 | | -#if (__FreeBSD__ >= 10) |
464 | | +#ifdef __APPLE__ |
465 | | pthread_mutex_init(&sf->file_lock, NULL); |
466 | | #endif |
467 | | /* Assume random read after open */ |
468 | | @@ -2266,7 +2272,7 @@ |
469 | | } |
470 | | |
471 | | if (!err) { |
472 | | -#if (__FreeBSD__ >= 10) |
473 | | +#ifdef __APPLE__ |
474 | | if (cache_enabled) |
475 | | cache_add_attr(path, &stbuf, wrctr); |
476 | | #else |
477 | | @@ -2275,7 +2281,7 @@ |
478 | | buf_finish(&sf->handle); |
479 | | fi->fh = (unsigned long) sf; |
480 | | } else { |
481 | | -#if (__FreeBSD__ >= 10) |
482 | | +#ifdef __APPLE__ |
483 | | if (cache_enabled) |
484 | | cache_invalidate(path); |
485 | | #else |
486 | | @@ -2335,11 +2341,11 @@ |
487 | | |
488 | | static void sshfs_file_put(struct sshfs_file *sf) |
489 | | { |
490 | | -#if (__FreeBSD__ >= 10) |
491 | | +#ifdef __APPLE__ |
492 | | pthread_mutex_lock(&sf->file_lock); |
493 | | #endif |
494 | | sf->refs--; |
495 | | -#if (__FreeBSD__ >= 10) |
496 | | +#ifdef __APPLE__ |
497 | | if (!sf->refs) { |
498 | | pthread_mutex_unlock(&sf->file_lock); |
499 | | g_free(sf); |
500 | | @@ -2354,11 +2360,11 @@ |
501 | | |
502 | | static void sshfs_file_get(struct sshfs_file *sf) |
503 | | { |
504 | | -#if (__FreeBSD__ >= 10) |
505 | | +#ifdef __APPLE__ |
506 | | pthread_mutex_lock(&sf->file_lock); |
507 | | #endif |
508 | | sf->refs++; |
509 | | -#if (__FreeBSD__ >= 10) |
510 | | +#ifdef __APPLE__ |
511 | | pthread_mutex_unlock(&sf->file_lock); |
512 | | #endif |
513 | | } |
514 | | @@ -3050,12 +3056,7 @@ |
515 | | exit(1); |
516 | | |
517 | | case KEY_VERSION: |
518 | | -#if (__FreeBSD__ >= 10) |
519 | | - fprintf(stderr, "SSHFS version %s (MacFUSE SSHFS %s)\n", |
520 | | - PACKAGE_VERSION, MACFUSE_SSHFS_VERSION); |
521 | | -#else |
522 | | fprintf(stderr, "SSHFS version %s\n", PACKAGE_VERSION); |
523 | | -#endif |
524 | | #if FUSE_VERSION >= 25 |
525 | | fuse_opt_add_arg(outargs, "--version"); |
526 | | sshfs_fuse_main(outargs); |
527 | | @@ -3139,7 +3140,7 @@ |
528 | | perror("Failed to allocate locked page for password"); |
529 | | return -1; |
530 | | } |
531 | | -#if (__FreeBSD__ >= 10) |
532 | | +#ifdef __APPLE__ |
533 | | if (mlock(sshfs.password, size) != 0) { |
534 | | memset(sshfs.password, 0, size); |
535 | | munmap(sshfs.password, size); |
536 | | @@ -3147,7 +3148,7 @@ |
537 | | perror("Failed to allocate locked page for password"); |
538 | | return -1; |
539 | | } |
540 | | -#endif /* __FreeBSD__ >= 10 */ |
541 | | +#endif /* __APPLE__ */ |
542 | | |
543 | | /* Don't use fgets() because password might stay in memory */ |
544 | | for (n = 0; n < max_password; n++) { |
545 | | @@ -3279,13 +3280,13 @@ |
546 | | } |
547 | | #endif |
548 | | |
549 | | -#if (__FreeBSD__ >= 10) |
550 | | +#ifdef __APPLE__ |
551 | | int main(int argc, char *argv[], __unused char *envp[], char **exec_path) |
552 | | #else |
553 | | int main(int argc, char *argv[]) |
554 | | #endif |
555 | | { |
556 | | -#if (__FreeBSD__ >= 10) |
557 | | +#ifdef __APPLE__ |
558 | | if (!realpath(*exec_path, sshfs_program_path)) { |
559 | | memset(sshfs_program_path, 0, PATH_MAX); |
560 | | } |
561 | | @@ -3298,10 +3299,10 @@ |
562 | | const char *sftp_server; |
563 | | int libver; |
564 | | |
565 | | -#if (__FreeBSD__ >= 10) |
566 | | +#ifdef __APPLE__ |
567 | | /* Until this gets fixed somewhere else. */ |
568 | | g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE); |
569 | | -#endif /* __FreeBSD__ >= 10 */ |
570 | | +#endif /* __APPLE__ */ |
571 | | g_thread_init(NULL); |
572 | | |
573 | | sshfs.blksize = 4096; |
574 | | @@ -3309,11 +3310,11 @@ |
575 | | sshfs.max_write = 65536; |
576 | | sshfs.nodelay_workaround = 1; |
577 | | sshfs.nodelaysrv_workaround = 0; |
578 | | -#if (__FreeBSD__ >= 10) |
579 | | +#ifdef __APPLE__ |
580 | | sshfs.rename_workaround = 1; |
581 | | #else |
582 | | sshfs.rename_workaround = 0; |
583 | | -#endif /* __FreeBSD__ >= 10 */ |
584 | | +#endif /* __APPLE__ */ |
585 | | sshfs.truncate_workaround = 0; |
586 | | sshfs.buflimit_workaround = 1; |
587 | | sshfs.ssh_ver = 2; |
588 | | @@ -3326,7 +3327,7 @@ |
589 | | ssh_add_arg("-a"); |
590 | | ssh_add_arg("-oClearAllForwardings=yes"); |
591 | | |
592 | | -#if (__FreeBSD__ >= 10) |
593 | | +#ifdef __APPLE__ |
594 | | sshfs.detect_uid = 1; |
595 | | #endif |
596 | | |
597 | | --- sshfs-fuse-2.2/cache.h.orig 2011-07-23 19:42:35.000000000 -0400 |
598 | | +++ sshfs-fuse-2.2/cache.h 2011-07-23 19:48:15.000000000 -0400 |
599 | | @@ -28,6 +28,6 @@ |
600 | | void cache_invalidate(const char *path); |
601 | | uint64_t cache_get_write_ctr(void); |
602 | | |
603 | | -#if (__FreeBSD__ >= 10) |
604 | | +#ifdef __APPLE__ |
605 | | extern int cache_enabled; |
606 | | #endif |
607 | | --- sshfs-fuse-2.2/cache.c.orig 2011-07-23 19:42:33.000000000 -0400 |
608 | | +++ sshfs-fuse-2.2/cache.c 2011-07-23 19:47:52.000000000 -0400 |
609 | | @@ -559,7 +559,7 @@ |
610 | | cache.next_oper = oper; |
611 | | |
612 | | cache_unity_fill(oper, &cache_oper); |
613 | | -#if (__FreeBSD__ >= 10) |
614 | | +#ifdef __APPLE__ |
615 | | cache_enabled = cache.on; |
616 | | #endif |
617 | | if (cache.on) { |
618 | | @@ -597,6 +597,6 @@ |
619 | | return fuse_opt_parse(args, &cache, cache_opts, NULL); |
620 | | } |
621 | | |
622 | | -#if (__FreeBSD__ >= 10) |
623 | | +#ifdef __APPLE__ |
624 | | int cache_enabled; |
625 | | #endif |