Ticket #30440: diff_against_upstream_2.3.diff
File diff_against_upstream_2.3.diff, 30.3 KB (added by anatol (Anatol Pomozov), 13 years ago) |
---|
-
Makefile.am
diff --git a/Makefile.am b/Makefile.am index a80788b..99e1dc8 100644
a b 2 2 3 3 bin_PROGRAMS = sshfs 4 4 5 sshfs_SOURCES = sshfs.c cache.c cache.h 5 sshfs_SOURCES = sshfs.c cache.c cache.h compat/darwin_semaphore.h compat/darwin_semaphore.c 6 6 if FUSE_OPT_COMPAT 7 7 sshfs_SOURCES += compat/fuse_opt.c compat/fuse_opt.h 8 8 endif 9 9 10 10 sshfs_LDADD = $(SSHFS_LIBS) 11 11 sshfs_CFLAGS = $(SSHFS_CFLAGS) 12 sshfs_CPPFLAGS = -D_REENTRANT -DFUSE_USE_VERSION=26 -DLIBDIR=\"$(libdir)\" 12 sshfs_CPPFLAGS = -D_REENTRANT -DFUSE_USE_VERSION=26 -DLIBDIR=\"$(libdir)\" -Icompat 13 13 14 14 EXTRA_DIST = sshnodelay.c FAQ.txt 15 15 CLEANFILES = sshnodelay.so -
new file uild.rb
diff --git a/build.rb b/build.rb new file mode 100755 index 0000000..b7a1d85
- + 1 #!/usr/bin/env ruby 2 # Possible flags are: 3 # --debug this builds distribuition with debug flags enabled 4 # --root DIR install the binary into this directory. If this flag is not set - the script 5 # redeploys kext to local machine and restarts it 6 # --static build static sshfs binary, it dynamically links only with fuse4x library 7 # --clean clean before build 8 9 require 'fileutils' 10 11 CWD = File.dirname(__FILE__) 12 KEXT_DIR = '/System/Library/Extensions/' 13 Dir.chdir(CWD) 14 15 debug = ARGV.include?('--debug') 16 clean = ARGV.include?('--clean') 17 static = ARGV.include?('--static') 18 root_dir = ARGV.index('--root') ? ARGV[ARGV.index('--root') + 1] : nil 19 20 abort("root directory #{root_dir} does not exist") if ARGV.index('--root') and not File.exists?(root_dir) 21 22 system('git clean -xdf') if clean 23 24 unless File.exists?('Makefile') then 25 system("autoreconf -f -i -Wall,no-obsolete") or abort 26 system("./configure") or abort 27 end 28 29 tmp_dir = "/tmp/sshfsbuild-#{Process.pid}" 30 Dir.mkdir(tmp_dir) 31 32 ld_flags = '' 33 dylibs = %w(iconv gthread-2.0 glib-2.0 intl) 34 if static 35 # In case if we build the distribution we need statically link against 36 # macports libraries from the 'dylibs' list above. 37 # To do it - we trick the build system by adding temp path with static libraries. 38 for lib in dylibs do 39 `ln -s /opt/local/lib/lib#{lib}.a #{tmp_dir}/` 40 end 41 42 ld_flags = "LDFLAGS='-L#{tmp_dir} -framework CoreFoundation -framework CoreServices'" 43 end 44 45 system("make -s -j3 #{ld_flags}") or abort 46 47 cmd = 'sudo make install' 48 if root_dir 49 cmd = cmd + ' DESTDIR=' + root_dir 50 end 51 52 system(cmd) 53 54 FileUtils.rm_rf(tmp_dir) -
cache.c
diff --git a/cache.c b/cache.c index bb23f8f..5b635f2 100644
a b struct fuse_operations *cache_init(struct fuse_cache_operations *oper) 559 559 cache.next_oper = oper; 560 560 561 561 cache_unity_fill(oper, &cache_oper); 562 #ifdef __APPLE__ 563 cache_enabled = cache.on; 564 #endif 562 565 if (cache.on) { 563 566 cache_fill(oper, &cache_oper); 564 567 pthread_mutex_init(&cache.lock, NULL); … … int cache_parse_options(struct fuse_args *args) 593 596 594 597 return fuse_opt_parse(args, &cache, cache_opts, NULL); 595 598 } 599 600 #ifdef __APPLE__ 601 int cache_enabled; 602 #endif -
cache.h
diff --git a/cache.h b/cache.h index cec9ca4..8ca0989 100644
a b int cache_parse_options(struct fuse_args *args); 27 27 void cache_add_attr(const char *path, const struct stat *stbuf, uint64_t wrctr); 28 28 void cache_invalidate(const char *path); 29 29 uint64_t cache_get_write_ctr(void); 30 31 #ifdef __APPLE__ 32 extern int cache_enabled; 33 #endif -
new file compat/darwin_semaphore.c
diff --git a/compat/darwin_semaphore.c b/compat/darwin_semaphore.c new file mode 100644 index 0000000..e45fd9a
- + 1 /* 2 * Copyright (C) 2000,02 Free Software Foundation, Inc. 3 * This file is part of the GNU C Library. 4 * Written by Ga<EB>l Le Mignot <address@hidden> 5 * 6 * The GNU C Library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public License as 8 * published by the Free Software Foundation; either version 2 of the 9 * License, or (at your option) any later version. 10 * 11 * The GNU C Library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public 17 * License along with the GNU C Library; see the file COPYING.LIB. If not, 18 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 * Boston, MA 02111-1307, USA. 20 */ 21 22 #include "darwin_semaphore.h" 23 24 #include <assert.h> 25 #include <errno.h> 26 #include <sys/types.h> 27 28 #define __SEM_ID_NONE 0x0 29 #define __SEM_ID_LOCAL 0xcafef00d 30 31 /* http://www.opengroup.org/onlinepubs/007908799/xsh/sem_init.html */ 32 int 33 compat_sem_init(compat_sem_t *sem, int pshared, unsigned int value) 34 { 35 if (pshared) { 36 errno = ENOSYS; 37 return -1; 38 } 39 40 sem->id = __SEM_ID_NONE; 41 42 if (pthread_cond_init(&sem->__data.local.count_cond, NULL)) { 43 goto cond_init_fail; 44 } 45 46 if (pthread_mutex_init(&sem->__data.local.count_lock, NULL)) { 47 goto mutex_init_fail; 48 } 49 50 sem->__data.local.count = value; 51 sem->id = __SEM_ID_LOCAL; 52 53 return 0; 54 55 mutex_init_fail: 56 57 pthread_cond_destroy(&sem->__data.local.count_cond); 58 59 cond_init_fail: 60 61 return -1; 62 } 63 64 /* http://www.opengroup.org/onlinepubs/007908799/xsh/sem_destroy.html */ 65 int 66 compat_sem_destroy(compat_sem_t *sem) 67 { 68 int res = 0; 69 70 pthread_mutex_lock(&sem->__data.local.count_lock); 71 72 sem->id = __SEM_ID_NONE; 73 pthread_cond_broadcast(&sem->__data.local.count_cond); 74 75 if (pthread_cond_destroy(&sem->__data.local.count_cond)) { 76 res = -1; 77 } 78 79 pthread_mutex_unlock(&sem->__data.local.count_lock); 80 81 if (pthread_mutex_destroy(&sem->__data.local.count_lock)) { 82 res = -1; 83 } 84 85 return res; 86 } 87 88 int 89 compat_sem_getvalue(compat_sem_t *sem, unsigned int *sval) 90 { 91 int res = 0; 92 93 pthread_mutex_lock(&sem->__data.local.count_lock); 94 95 if (sem->id != __SEM_ID_LOCAL) { 96 res = -1; 97 errno = EINVAL; 98 } else { 99 *sval = sem->__data.local.count; 100 } 101 102 pthread_mutex_unlock(&sem->__data.local.count_lock); 103 104 return res; 105 } 106 107 /* http://www.opengroup.org/onlinepubs/007908799/xsh/sem_post.html */ 108 int 109 compat_sem_post(compat_sem_t *sem) 110 { 111 int res = 0; 112 113 pthread_mutex_lock(&sem->__data.local.count_lock); 114 115 if (sem->id != __SEM_ID_LOCAL) { 116 res = -1; 117 errno = EINVAL; 118 } else if (sem->__data.local.count < COMPAT_SEM_VALUE_MAX) { 119 sem->__data.local.count++; 120 if (sem->__data.local.count == 1) { 121 pthread_cond_signal(&sem->__data.local.count_cond); 122 } 123 } else { 124 errno = ERANGE; 125 res = -1; 126 } 127 128 pthread_mutex_unlock(&sem->__data.local.count_lock); 129 130 return res; 131 } 132 133 /* http://www.opengroup.org/onlinepubs/009695399/functions/sem_timedwait.html */ 134 int 135 compat_sem_timedwait(compat_sem_t *sem, const struct timespec *abs_timeout) 136 { 137 int res = 0; 138 139 if (abs_timeout && 140 (abs_timeout->tv_nsec < 0 || abs_timeout->tv_nsec >= 1000000000)) { 141 errno = EINVAL; 142 return -1; 143 } 144 145 pthread_cleanup_push((void(*)(void*))&pthread_mutex_unlock, 146 &sem->__data.local.count_lock); 147 148 pthread_mutex_lock(&sem->__data.local.count_lock); 149 150 if (sem->id != __SEM_ID_LOCAL) { 151 errno = EINVAL; 152 res = -1; 153 } else { 154 if (!sem->__data.local.count) { 155 res = pthread_cond_timedwait(&sem->__data.local.count_cond, 156 &sem->__data.local.count_lock, 157 abs_timeout); 158 } 159 if (res) { 160 assert(res == ETIMEDOUT); 161 res = -1; 162 errno = ETIMEDOUT; 163 } else if (sem->id != __SEM_ID_LOCAL) { 164 res = -1; 165 errno = EINVAL; 166 } else { 167 sem->__data.local.count--; 168 } 169 } 170 171 pthread_cleanup_pop(1); 172 173 return res; 174 } 175 176 /* http://www.opengroup.org/onlinepubs/007908799/xsh/sem_trywait.html */ 177 int 178 compat_sem_trywait(compat_sem_t *sem) 179 { 180 int res = 0; 181 182 pthread_mutex_lock(&sem->__data.local.count_lock); 183 184 if (sem->id != __SEM_ID_LOCAL) { 185 res = -1; 186 errno = EINVAL; 187 } else if (sem->__data.local.count) { 188 sem->__data.local.count--; 189 } else { 190 res = -1; 191 errno = EAGAIN; 192 } 193 194 pthread_mutex_unlock (&sem->__data.local.count_lock); 195 196 return res; 197 } 198 199 /* http://www.opengroup.org/onlinepubs/007908799/xsh/sem_wait.html */ 200 int 201 compat_sem_wait(compat_sem_t *sem) 202 { 203 int res = 0; 204 205 pthread_cleanup_push((void(*)(void*))&pthread_mutex_unlock, 206 &sem->__data.local.count_lock); 207 208 pthread_mutex_lock(&sem->__data.local.count_lock); 209 210 if (sem->id != __SEM_ID_LOCAL) { 211 errno = EINVAL; 212 res = -1; 213 } else { 214 while (!sem->__data.local.count) { 215 pthread_cond_wait(&sem->__data.local.count_cond, 216 &sem->__data.local.count_lock); 217 } 218 if (sem->id != __SEM_ID_LOCAL) { 219 res = -1; 220 errno = EINVAL; 221 } else { 222 sem->__data.local.count--; 223 } 224 } 225 226 pthread_cleanup_pop(1); 227 228 return res; 229 } -
new file compat/darwin_semaphore.h
diff --git a/compat/darwin_semaphore.h b/compat/darwin_semaphore.h new file mode 100644 index 0000000..3f03e41
- + 1 /* Copyright (C) 2000,02 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 Written by Gaël Le Mignot <address@hidden> 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public License as 7 published by the Free Software Foundation; either version 2 of the 8 License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public 16 License along with the GNU C Library; see the file COPYING.LIB. If not, 17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 Boston, MA 02111-1307, USA. */ 19 20 // This implementation is based on libsem http://lists.debian.org/debian-devel/2004/08/msg00612.html 21 22 #ifndef _SEMAPHORE_H_ 23 #define _SEMAPHORE_H_ 24 25 /* Caller must not include <semaphore.h> */ 26 27 #include <pthread.h> 28 29 struct __local_sem_t 30 { 31 unsigned int count; 32 pthread_mutex_t count_lock; 33 pthread_cond_t count_cond; 34 }; 35 36 typedef struct compat_sem { 37 unsigned int id; 38 union { 39 struct __local_sem_t local; 40 } __data; 41 } compat_sem_t; 42 43 #define COMPAT_SEM_VALUE_MAX ((int32_t)32767) 44 45 int compat_sem_init(compat_sem_t *sem, int pshared, unsigned int value); 46 int compat_sem_destroy(compat_sem_t *sem); 47 int compat_sem_getvalue(compat_sem_t *sem, unsigned int *value); 48 int compat_sem_post(compat_sem_t *sem); 49 int compat_sem_timedwait(compat_sem_t *sem, const struct timespec *abs_timeout); 50 int compat_sem_trywait(compat_sem_t *sem); 51 int compat_sem_wait(compat_sem_t *sem); 52 53 54 /* Redefine semaphores. Caller must not include <semaphore.h> */ 55 56 typedef compat_sem_t sem_t; 57 58 #define sem_init(s, p, v) compat_sem_init(s, p, v) 59 #define sem_destroy(s) compat_sem_destroy(s) 60 #define sem_getvalue(s, v) compat_sem_getvalue(s, v) 61 #define sem_post(s) compat_sem_post(s) 62 #define sem_timedwait(s, t) compat_sem_timedwait(s, t) 63 #define sem_trywait(s) compat_sem_trywait(s) 64 #define sem_wait(s) compat_sem_wait(s) 65 66 #define SEM_VALUE_MAX COMPAT_SEM_VALUE_MAX 67 68 69 #endif /* semaphore.h */ -
configure.ac
diff --git a/configure.ac b/configure.ac index 1cf48b3..f737b41 100644
a b 1 AC_INIT(sshfs-fuse, 2.3 )1 AC_INIT(sshfs-fuse, 2.3.0) 2 2 AM_INIT_AUTOMAKE 3 3 AM_CONFIG_HEADER(config.h) 4 4 5 5 AC_PROG_CC 6 6 AM_PROG_CC_C_O 7 CFLAGS="$CFLAGS -Wall -W "7 CFLAGS="$CFLAGS -Wall -W -mmacosx-version-min=10.5" 8 8 LIBS= 9 9 AC_SEARCH_LIBS(dlsym, [dl]) 10 10 sshnodelay_libs=$LIBS -
sshfs.c
diff --git a/sshfs.c b/sshfs.c index 22bda6b..9698c74 100644
a b 20 20 #include <string.h> 21 21 #include <stdint.h> 22 22 #include <errno.h> 23 #ifdef __APPLE__ 24 #include <darwin_semaphore.h> 25 #else 23 26 #include <semaphore.h> 27 #endif 24 28 #include <pthread.h> 25 29 #include <netdb.h> 26 30 #include <signal.h> … … 35 39 #include <netinet/in.h> 36 40 #include <netinet/tcp.h> 37 41 #include <glib.h> 42 #ifdef __APPLE__ 43 #include <libgen.h> 44 #include <strings.h> 45 #endif 38 46 39 47 #include "cache.h" 40 48 … … 118 126 119 127 #define SSHNODELAY_SO "sshnodelay.so" 120 128 129 #ifdef __APPLE__ 130 131 #ifndef LIBDIR 132 #define LIBDIR "/usr/local/lib" 133 #endif 134 135 static char sshfs_program_path[PATH_MAX] = { 0 }; 136 137 #endif 138 121 139 struct buffer { 122 140 uint8_t *p; 123 141 size_t len; … … struct sshfs_file { 167 185 int connver; 168 186 int modifver; 169 187 int refs; 188 #ifdef __APPLE__ 189 pthread_mutex_t file_lock; 190 #endif 170 191 }; 171 192 172 193 struct sshfs { … … struct sshfs { 207 228 int server_version; 208 229 unsigned remote_uid; 209 230 unsigned local_uid; 231 #ifdef __APPLE__ 232 unsigned remote_gid; 233 unsigned local_gid; 234 #endif 210 235 int remote_uid_detected; 211 236 unsigned blksize; 212 237 char *progname; … … static int buf_get_attrs(struct buffer *buf, struct stat *stbuf, int *flagsp) 661 686 } 662 687 } 663 688 689 #ifdef __APPLE__ 690 if (sshfs.remote_uid_detected) { 691 if (uid == sshfs.remote_uid) 692 uid = sshfs.local_uid; 693 if (gid == sshfs.remote_gid) 694 gid = sshfs.local_gid; 695 } 696 #else 664 697 if (sshfs.remote_uid_detected && uid == sshfs.remote_uid) 665 698 uid = sshfs.local_uid; 699 #endif 666 700 667 701 memset(stbuf, 0, sizeof(struct stat)); 668 702 stbuf->st_mode = mode; … … static void ssh_add_arg(const char *arg) 765 799 #ifdef SSH_NODELAY_WORKAROUND 766 800 static int do_ssh_nodelay_workaround(void) 767 801 { 802 #ifdef __APPLE__ 803 char *oldpreload = getenv("DYLD_INSERT_LIBRARIES"); 804 #else 768 805 char *oldpreload = getenv("LD_PRELOAD"); 806 #endif 769 807 char *newpreload; 770 808 char sopath[PATH_MAX]; 771 809 int res; 772 810 811 #ifdef __APPLE__ 812 char *sshfs_program_path_base = NULL; 813 if (!sshfs_program_path[0]) { 814 goto nobundle; 815 } 816 sshfs_program_path_base = dirname(sshfs_program_path); 817 if (!sshfs_program_path_base) { 818 goto nobundle; 819 } 820 snprintf(sopath, sizeof(sopath), "%s/%s", sshfs_program_path_base, 821 SSHNODELAY_SO); 822 res = access(sopath, R_OK); 823 if (res == -1) { 824 goto nobundle; 825 } 826 goto pathok; 827 nobundle: 828 #endif 773 829 snprintf(sopath, sizeof(sopath), "%s/%s", LIBDIR, SSHNODELAY_SO); 774 830 res = access(sopath, R_OK); 775 831 if (res == -1) { … … static int do_ssh_nodelay_workaround(void) 794 850 return -1; 795 851 } 796 852 } 853 #ifdef __APPLE__ 854 pathok: 855 #endif 797 856 798 857 newpreload = g_strdup_printf("%s%s%s", 799 858 oldpreload ? oldpreload : "", 800 859 oldpreload ? " " : "", 801 860 sopath); 802 861 862 #ifdef __APPLE__ 863 if (!newpreload || setenv("DYLD_INSERT_LIBRARIES", newpreload, 1) == -1) 864 fprintf(stderr, "warning: failed set DYLD_INSERT_LIBRARIES for ssh nodelay workaround\n"); 865 #else 803 866 if (!newpreload || setenv("LD_PRELOAD", newpreload, 1) == -1) { 804 867 fprintf(stderr, "warning: failed set LD_PRELOAD " 805 868 "for ssh nodelay workaround\n"); 806 869 } 870 #endif 807 871 g_free(newpreload); 808 872 return 0; 809 873 } … … static void sftp_detect_uid() 1500 1564 1501 1565 sshfs.remote_uid = stbuf.st_uid; 1502 1566 sshfs.local_uid = getuid(); 1567 #ifdef __APPLE__ 1568 sshfs.remote_gid = stbuf.st_gid; 1569 sshfs.local_gid = getgid(); 1570 #endif 1503 1571 sshfs.remote_uid_detected = 1; 1504 1572 DEBUG("remote_uid = %i\n", sshfs.remote_uid); 1505 1573 … … static int sshfs_chown(const char *path, uid_t uid, gid_t gid) 2120 2188 buf_init(&buf, 0); 2121 2189 buf_add_path(&buf, path); 2122 2190 buf_add_uint32(&buf, SSH_FILEXFER_ATTR_UIDGID); 2191 #ifdef __APPLE__ 2192 if (sshfs.remote_uid_detected) { 2193 if (uid == sshfs.local_uid) 2194 uid = sshfs.remote_uid; 2195 if (gid == sshfs.local_gid) 2196 gid = sshfs.remote_gid; 2197 } 2198 #endif 2123 2199 buf_add_uint32(&buf, uid); 2124 2200 buf_add_uint32(&buf, gid); 2125 2201 err = sftp_request(SSH_FXP_SETSTAT, &buf, SSH_FXP_STATUS, NULL); … … static int sshfs_open_common(const char *path, mode_t mode, 2203 2279 sf = g_new0(struct sshfs_file, 1); 2204 2280 list_init(&sf->write_reqs); 2205 2281 pthread_cond_init(&sf->write_finished, NULL); 2282 #ifdef __APPLE__ 2283 pthread_mutex_init(&sf->file_lock, NULL); 2284 #endif 2206 2285 /* Assume random read after open */ 2207 2286 sf->is_seq = 0; 2208 2287 sf->refs = 1; … … static int sshfs_open_common(const char *path, mode_t mode, 2236 2315 } 2237 2316 2238 2317 if (!err) { 2318 #ifdef __APPLE__ 2319 if (cache_enabled) 2320 cache_add_attr(path, &stbuf, wrctr); 2321 #else 2239 2322 cache_add_attr(path, &stbuf, wrctr); 2323 #endif 2240 2324 buf_finish(&sf->handle); 2241 2325 fi->fh = (unsigned long) sf; 2242 2326 } else { 2327 #ifdef __APPLE__ 2328 if (cache_enabled) 2329 cache_invalidate(path); 2330 #else 2243 2331 cache_invalidate(path); 2332 #endif 2244 2333 g_free(sf); 2245 2334 } 2246 2335 buf_free(&buf); … … static int sshfs_fsync(const char *path, int isdatasync, 2295 2384 2296 2385 static void sshfs_file_put(struct sshfs_file *sf) 2297 2386 { 2387 #ifdef __APPLE__ 2388 pthread_mutex_lock(&sf->file_lock); 2389 #endif 2298 2390 sf->refs--; 2391 #ifdef __APPLE__ 2392 if (!sf->refs) { 2393 pthread_mutex_unlock(&sf->file_lock); 2394 g_free(sf); 2395 } else { 2396 pthread_mutex_unlock(&sf->file_lock); 2397 } 2398 #else 2299 2399 if (!sf->refs) 2300 2400 g_free(sf); 2401 #endif 2301 2402 } 2302 2403 2303 2404 static void sshfs_file_get(struct sshfs_file *sf) 2304 2405 { 2406 #ifdef __APPLE__ 2407 pthread_mutex_lock(&sf->file_lock); 2408 #endif 2305 2409 sf->refs++; 2410 #ifdef __APPLE__ 2411 pthread_mutex_unlock(&sf->file_lock); 2412 #endif 2306 2413 } 2307 2414 2308 2415 static int sshfs_release(const char *path, struct fuse_file_info *fi) … … static int read_password(void) 3076 3183 perror("Failed to allocate locked page for password"); 3077 3184 return -1; 3078 3185 } 3186 #ifdef __APPLE__ 3187 if (mlock(sshfs.password, size) != 0) { 3188 memset(sshfs.password, 0, size); 3189 munmap(sshfs.password, size); 3190 sshfs.password = NULL; 3191 perror("Failed to allocate locked page for password"); 3192 return -1; 3193 } 3194 #endif /* __APPLE__ */ 3079 3195 3080 3196 /* Don't use fgets() because password might stay in memory */ 3081 3197 for (n = 0; n < max_password; n++) { … … static void set_ssh_command(void) 3123 3239 replace_arg(&sshfs.ssh_args.argv[0], 3124 3240 sshfs.ssh_command); 3125 3241 } else { 3126 if (fuse_opt_insert_arg(&sshfs.ssh_args, i, 3242 if (fuse_opt_insert_arg(&sshfs.ssh_args, i, 3127 3243 sshfs.ssh_command) == -1) 3128 3244 _exit(1); 3129 3245 } … … static int ssh_connect(void) 3227 3343 return 0; 3228 3344 } 3229 3345 3230 int main(int argc, char *argv[] )3346 int main(int argc, char *argv[], __unused char *envp[], char **exec_path) 3231 3347 { 3348 #ifdef __APPLE__ 3349 if (!realpath(*exec_path, sshfs_program_path)) { 3350 memset(sshfs_program_path, 0, PATH_MAX); 3351 } 3352 #endif 3232 3353 int res; 3233 3354 struct fuse_args args = FUSE_ARGS_INIT(argc, argv); 3234 3355 char *tmp; … … int main(int argc, char *argv[]) 3236 3357 const char *sftp_server; 3237 3358 int libver; 3238 3359 3360 #ifdef __APPLE__ 3361 /* Until this gets fixed somewhere else. */ 3362 g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE); 3363 #endif /* __APPLE__ */ 3239 3364 g_thread_init(NULL); 3240 3365 3241 3366 sshfs.blksize = 4096; … … int main(int argc, char *argv[]) 3243 3368 sshfs.max_write = 65536; 3244 3369 sshfs.nodelay_workaround = 1; 3245 3370 sshfs.nodelaysrv_workaround = 0; 3371 #ifdef __APPLE__ 3372 sshfs.rename_workaround = 1; 3373 #else 3246 3374 sshfs.rename_workaround = 0; 3375 #endif /* __APPLE__ */ 3247 3376 sshfs.truncate_workaround = 0; 3248 3377 sshfs.buflimit_workaround = 1; 3249 3378 sshfs.ssh_ver = 2; … … int main(int argc, char *argv[]) 3257 3386 ssh_add_arg("-a"); 3258 3387 ssh_add_arg("-oClearAllForwardings=yes"); 3259 3388 3389 #ifdef __APPLE__ 3390 sshfs.detect_uid = 1; 3391 #endif 3392 3260 3393 if (fuse_opt_parse(&args, &sshfs, sshfs_opts, sshfs_opt_proc) == -1 || 3261 3394 parse_workarounds() == -1) 3262 3395 exit(1); -
new file sshfs.xcodeproj/project.pbxproj
diff --git a/sshfs.xcodeproj/project.pbxproj b/sshfs.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b114fe3
- + 1 // !$*UTF8*$! 2 { 3 archiveVersion = 1; 4 classes = { 5 }; 6 objectVersion = 46; 7 objects = { 8 9 /* Begin PBXBuildFile section */ 10 DE0F21EB139A7AFF003CBAC9 /* sshfs.c in Sources */ = {isa = PBXBuildFile; fileRef = DE0F21EA139A7AFF003CBAC9 /* sshfs.c */; }; 11 DE0F21EF139A7B0A003CBAC9 /* cache.c in Sources */ = {isa = PBXBuildFile; fileRef = DE0F21ED139A7B0A003CBAC9 /* cache.c */; }; 12 DE0F21F1139A7B11003CBAC9 /* sshnodelay.c in Sources */ = {isa = PBXBuildFile; fileRef = DE0F21F0139A7B11003CBAC9 /* sshnodelay.c */; }; 13 DE37D32813CF7B660027D6F9 /* darwin_semaphore.c in Sources */ = {isa = PBXBuildFile; fileRef = DE37D32413CF7B660027D6F9 /* darwin_semaphore.c */; }; 14 DE37D32913CF7B660027D6F9 /* fuse_opt.c in Sources */ = {isa = PBXBuildFile; fileRef = DE37D32613CF7B660027D6F9 /* fuse_opt.c */; }; 15 /* End PBXBuildFile section */ 16 17 /* Begin PBXCopyFilesBuildPhase section */ 18 DE0F21D3139A7ABB003CBAC9 /* CopyFiles */ = { 19 isa = PBXCopyFilesBuildPhase; 20 buildActionMask = 2147483647; 21 dstPath = /usr/share/man/man1/; 22 dstSubfolderSpec = 0; 23 files = ( 24 ); 25 runOnlyForDeploymentPostprocessing = 1; 26 }; 27 /* End PBXCopyFilesBuildPhase section */ 28 29 /* Begin PBXFileReference section */ 30 DE0F21D5139A7ABB003CBAC9 /* sshfs */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = sshfs; sourceTree = BUILT_PRODUCTS_DIR; }; 31 DE0F21E9139A7AFF003CBAC9 /* sshfs.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = sshfs.1; sourceTree = "<group>"; }; 32 DE0F21EA139A7AFF003CBAC9 /* sshfs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sshfs.c; sourceTree = "<group>"; }; 33 DE0F21ED139A7B0A003CBAC9 /* cache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cache.c; sourceTree = "<group>"; }; 34 DE0F21EE139A7B0A003CBAC9 /* cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cache.h; sourceTree = "<group>"; }; 35 DE0F21F0139A7B11003CBAC9 /* sshnodelay.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sshnodelay.c; sourceTree = "<group>"; }; 36 DE0F21F2139A7B1D003CBAC9 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; }; 37 DE0F21FC139B1EC3003CBAC9 /* configure.ac */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = configure.ac; sourceTree = "<group>"; }; 38 DE0F21FE139B1ECB003CBAC9 /* Makefile.am */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Makefile.am; sourceTree = "<group>"; }; 39 DE37D32413CF7B660027D6F9 /* darwin_semaphore.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = darwin_semaphore.c; sourceTree = "<group>"; }; 40 DE37D32513CF7B660027D6F9 /* darwin_semaphore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = darwin_semaphore.h; sourceTree = "<group>"; }; 41 DE37D32613CF7B660027D6F9 /* fuse_opt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fuse_opt.c; sourceTree = "<group>"; }; 42 DE37D32713CF7B660027D6F9 /* fuse_opt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fuse_opt.h; sourceTree = "<group>"; }; 43 /* End PBXFileReference section */ 44 45 /* Begin PBXFrameworksBuildPhase section */ 46 DE0F21D2139A7ABB003CBAC9 /* Frameworks */ = { 47 isa = PBXFrameworksBuildPhase; 48 buildActionMask = 2147483647; 49 files = ( 50 ); 51 runOnlyForDeploymentPostprocessing = 0; 52 }; 53 /* End PBXFrameworksBuildPhase section */ 54 55 /* Begin PBXGroup section */ 56 DE0F21CA139A7ABB003CBAC9 = { 57 isa = PBXGroup; 58 children = ( 59 DE37D32313CF7B660027D6F9 /* compat */, 60 DE0F21FE139B1ECB003CBAC9 /* Makefile.am */, 61 DE0F21FC139B1EC3003CBAC9 /* configure.ac */, 62 DE0F21F2139A7B1D003CBAC9 /* config.h */, 63 DE0F21F0139A7B11003CBAC9 /* sshnodelay.c */, 64 DE0F21ED139A7B0A003CBAC9 /* cache.c */, 65 DE0F21EE139A7B0A003CBAC9 /* cache.h */, 66 DE0F21E9139A7AFF003CBAC9 /* sshfs.1 */, 67 DE0F21EA139A7AFF003CBAC9 /* sshfs.c */, 68 DE0F21D6139A7ABB003CBAC9 /* Products */, 69 ); 70 sourceTree = "<group>"; 71 }; 72 DE0F21D6139A7ABB003CBAC9 /* Products */ = { 73 isa = PBXGroup; 74 children = ( 75 DE0F21D5139A7ABB003CBAC9 /* sshfs */, 76 ); 77 name = Products; 78 sourceTree = "<group>"; 79 }; 80 DE37D32313CF7B660027D6F9 /* compat */ = { 81 isa = PBXGroup; 82 children = ( 83 DE37D32413CF7B660027D6F9 /* darwin_semaphore.c */, 84 DE37D32513CF7B660027D6F9 /* darwin_semaphore.h */, 85 DE37D32613CF7B660027D6F9 /* fuse_opt.c */, 86 DE37D32713CF7B660027D6F9 /* fuse_opt.h */, 87 ); 88 path = compat; 89 sourceTree = "<group>"; 90 }; 91 /* End PBXGroup section */ 92 93 /* Begin PBXNativeTarget section */ 94 DE0F21D4139A7ABB003CBAC9 /* sshfs */ = { 95 isa = PBXNativeTarget; 96 buildConfigurationList = DE0F21DE139A7ABB003CBAC9 /* Build configuration list for PBXNativeTarget "sshfs" */; 97 buildPhases = ( 98 DE0F21D1139A7ABB003CBAC9 /* Sources */, 99 DE0F21D2139A7ABB003CBAC9 /* Frameworks */, 100 DE0F21D3139A7ABB003CBAC9 /* CopyFiles */, 101 ); 102 buildRules = ( 103 ); 104 dependencies = ( 105 ); 106 name = sshfs; 107 productName = sshfs; 108 productReference = DE0F21D5139A7ABB003CBAC9 /* sshfs */; 109 productType = "com.apple.product-type.tool"; 110 }; 111 /* End PBXNativeTarget section */ 112 113 /* Begin PBXProject section */ 114 DE0F21CC139A7ABB003CBAC9 /* Project object */ = { 115 isa = PBXProject; 116 buildConfigurationList = DE0F21CF139A7ABB003CBAC9 /* Build configuration list for PBXProject "sshfs" */; 117 compatibilityVersion = "Xcode 3.2"; 118 developmentRegion = English; 119 hasScannedForEncodings = 0; 120 knownRegions = ( 121 en, 122 ); 123 mainGroup = DE0F21CA139A7ABB003CBAC9; 124 productRefGroup = DE0F21D6139A7ABB003CBAC9 /* Products */; 125 projectDirPath = ""; 126 projectRoot = ""; 127 targets = ( 128 DE0F21D4139A7ABB003CBAC9 /* sshfs */, 129 ); 130 }; 131 /* End PBXProject section */ 132 133 /* Begin PBXSourcesBuildPhase section */ 134 DE0F21D1139A7ABB003CBAC9 /* Sources */ = { 135 isa = PBXSourcesBuildPhase; 136 buildActionMask = 2147483647; 137 files = ( 138 DE0F21EB139A7AFF003CBAC9 /* sshfs.c in Sources */, 139 DE0F21EF139A7B0A003CBAC9 /* cache.c in Sources */, 140 DE0F21F1139A7B11003CBAC9 /* sshnodelay.c in Sources */, 141 DE37D32813CF7B660027D6F9 /* darwin_semaphore.c in Sources */, 142 DE37D32913CF7B660027D6F9 /* fuse_opt.c in Sources */, 143 ); 144 runOnlyForDeploymentPostprocessing = 0; 145 }; 146 /* End PBXSourcesBuildPhase section */ 147 148 /* Begin XCBuildConfiguration section */ 149 DE0F21DC139A7ABB003CBAC9 /* Debug */ = { 150 isa = XCBuildConfiguration; 151 buildSettings = { 152 ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 153 GCC_C_LANGUAGE_STANDARD = gnu99; 154 GCC_OPTIMIZATION_LEVEL = 0; 155 GCC_PREPROCESSOR_DEFINITIONS = DEBUG; 156 GCC_SYMBOLS_PRIVATE_EXTERN = NO; 157 GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 158 GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 159 GCC_WARN_ABOUT_RETURN_TYPE = YES; 160 GCC_WARN_UNUSED_VARIABLE = YES; 161 MACOSX_DEPLOYMENT_TARGET = 10.6; 162 ONLY_ACTIVE_ARCH = YES; 163 SDKROOT = macosx; 164 }; 165 name = Debug; 166 }; 167 DE0F21DD139A7ABB003CBAC9 /* Release */ = { 168 isa = XCBuildConfiguration; 169 buildSettings = { 170 ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 171 GCC_C_LANGUAGE_STANDARD = gnu99; 172 GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 173 GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 174 GCC_WARN_ABOUT_RETURN_TYPE = YES; 175 GCC_WARN_UNUSED_VARIABLE = YES; 176 MACOSX_DEPLOYMENT_TARGET = 10.6; 177 SDKROOT = macosx; 178 }; 179 name = Release; 180 }; 181 DE0F21DF139A7ABB003CBAC9 /* Debug */ = { 182 isa = XCBuildConfiguration; 183 buildSettings = { 184 ALWAYS_SEARCH_USER_PATHS = NO; 185 COPY_PHASE_STRIP = NO; 186 GCC_DYNAMIC_NO_PIC = NO; 187 GCC_ENABLE_OBJC_EXCEPTIONS = YES; 188 MACOSX_DEPLOYMENT_TARGET = 10.5; 189 PRODUCT_NAME = "$(TARGET_NAME)"; 190 }; 191 name = Debug; 192 }; 193 DE0F21E0139A7ABB003CBAC9 /* Release */ = { 194 isa = XCBuildConfiguration; 195 buildSettings = { 196 ALWAYS_SEARCH_USER_PATHS = NO; 197 COPY_PHASE_STRIP = YES; 198 DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 199 GCC_ENABLE_OBJC_EXCEPTIONS = YES; 200 MACOSX_DEPLOYMENT_TARGET = 10.5; 201 PRODUCT_NAME = "$(TARGET_NAME)"; 202 }; 203 name = Release; 204 }; 205 /* End XCBuildConfiguration section */ 206 207 /* Begin XCConfigurationList section */ 208 DE0F21CF139A7ABB003CBAC9 /* Build configuration list for PBXProject "sshfs" */ = { 209 isa = XCConfigurationList; 210 buildConfigurations = ( 211 DE0F21DC139A7ABB003CBAC9 /* Debug */, 212 DE0F21DD139A7ABB003CBAC9 /* Release */, 213 ); 214 defaultConfigurationIsVisible = 0; 215 defaultConfigurationName = Release; 216 }; 217 DE0F21DE139A7ABB003CBAC9 /* Build configuration list for PBXNativeTarget "sshfs" */ = { 218 isa = XCConfigurationList; 219 buildConfigurations = ( 220 DE0F21DF139A7ABB003CBAC9 /* Debug */, 221 DE0F21E0139A7ABB003CBAC9 /* Release */, 222 ); 223 defaultConfigurationIsVisible = 0; 224 defaultConfigurationName = Release; 225 }; 226 /* End XCConfigurationList section */ 227 }; 228 rootObject = DE0F21CC139A7ABB003CBAC9 /* Project object */; 229 } -
new file sshfs.xcodeproj/project.xcworkspace/contents.xcworkspacedata
diff --git a/sshfs.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/sshfs.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..3adcdb4
- + 1 <?xml version="1.0" encoding="UTF-8"?> 2 <Workspace 3 version = "1.0"> 4 <FileRef 5 location = "self:sshfs.xcodeproj"> 6 </FileRef> 7 </Workspace> -
sshnodelay.c
diff --git a/sshnodelay.c b/sshnodelay.c index 7518089..efe393c 100644
a b 5 5 #include <netinet/in.h> 6 6 #include <netinet/tcp.h> 7 7 8 #ifdef __APPLE__ 9 10 int custom_connect(int sock, const struct sockaddr *addr, socklen_t addrlen); 11 12 typedef struct interpose_s { 13 void *new_func; 14 void *orig_func; 15 } interpose_t; 16 17 static const interpose_t interposers[] \ 18 __attribute__ ((section("__DATA, __interpose"))) = { 19 { (void *)custom_connect, (void *)connect }, 20 }; 21 22 int custom_connect(int sock, const struct sockaddr *addr, socklen_t addrlen) 23 { 24 int res = connect(sock, addr, addrlen); 25 if (!res && addr->sa_family == AF_INET) { 26 int opt = 1; 27 setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt)); 28 } 29 return res; 30 } 31 32 #else 33 8 34 int connect(int sock, const struct sockaddr *addr, socklen_t addrlen) 9 35 { 10 36 int (*next_connect)(int, const struct sockaddr *, socklen_t) = … … int connect(int sock, const struct sockaddr *addr, socklen_t addrlen) 16 42 } 17 43 return res; 18 44 } 45 46 #endif