diff options
-rw-r--r-- | AUTHORS | 9 | ||||
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | FAQ | 263 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | cache.c | 8 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | sshfs.1.in | 2 | ||||
-rw-r--r-- | sshfs.c | 46 |
8 files changed, 343 insertions, 11 deletions
@@ -16,11 +16,18 @@ Contributors (autogenerated list) Alan Jenkins <alan.christopher.jenkins@gmail.com> Alexander Neumann <alexander@bumpern.de> Benjamin Fleischer <fleiben@gmail.com> +Berserker <berserker.troll@yandex.com> +Bill Zissimopoulos <billziss@navimatics.com> Chris Wolfe <cwolfe@chromium.org> -Google Inc. +gala <gala132@users.noreply.github.com> +George Vlahavas <vlahavas@gmail.com> Julio Merino <jmmv@google.com> +Julio Merino <jmmv@meroh.net> Mike Kelly <mike@pair.com> Miklos Szeredi <miklos@szeredi.hu> +Miklos Szeredi <mszeredi@suse.cz> Nikolaus Rath <Nikolaus@rath.org> Percy Jahn <email@percyjahn.de> Qais Patankar <qaisjp@gmail.com> +Rian Hunter <rian@alum.mit.edu> +Zoltan Kuscsik <zoltan.kuscsik@linaro.org> @@ -1,5 +1,17 @@ -Draft notes for upcoming release --------------------------------- +Release 2.9 (2017-04-17) +------------------------ + +* Improved support for Cygwin. +* Various small bugfixes. + +Release 2.8 (2016-06-22) +------------------------ + +* Added support for the "fsync" extension. +* Fixed a build problem with bitbake + +Release 2.7 (2016-03-01) +------------------------ * Integrated osxfuse's copy of sshfs, which means that sshfs now works on OS X out of the box. @@ -8,12 +20,12 @@ Draft notes for upcoming release * Added -o cache_clean_interval=N and -o cache_min_clean_interval=N options to let users tune the cleaning behavior of the cache. -Release 2.7 (2015-01-28) +Release 2.6 (2015-01-28) ------------------------ * New maintainer (Nikolaus Rath <Nikolaus@rath.org>) -Release 2.6 (2014-01-14) +Release 2.5 (2014-01-14) ------------------------ * Some performance improvements for large directories. @@ -0,0 +1,263 @@ +SSHFS FAQ +========= + +1. I've found a bug and there's no solution in this FAQ, what + should I do? +2. Advantage of sshfs over NFS and Samba +3. Create the device node +4. mv fails with "Operation not permitted" +5. cvs fails with "cvs [status aborted]: cannot get working + directory: No such file or directory" in a sshfs mounted directory +6. Changes on the server are not immediately visible in the + mounted directory. +7. Configuring the ssh connection +8. What are the no_readahead and sshfs_sync options for? +9. Why does df return strange values on partitions mounted via + sshfs? +10. How do I specify the remote mount point (since the example + defaults to the home directory) +11. sshfs hangs after a while +12. Following symlinks on the server side +13. Making absolute symlinks work +14. Mounting as root +15. Exporting via NFS +16. Automatical mounting using /etc/fstab +17. Why does SVN (etc...) fail with permission denied? +18. Why does SVN (etc...) fail to rename files? +19. Is there some neat way to do it in reverse? +20. Might it be reasonable to disallow loops? +21. How to mount through an intermediary ssh server, eg: + localhost -> A -> B; mount B from localhost +22. Alternative Solution +23. I seem to have successfully mounted a remote directory, but + performing an `ls -l` on the directory above the mount point shows + the mount point's attributes as `? ? ? ? ? ?`. Nothing shows up in + the directory either. What am I doing wrong? + +-------------------------------------------------------------------------- + +1. I've found a bug and there's no solution in this FAQ, what should I do? + + Please report the bug in the Github issue tracker: + https://github.com/libfuse/sshfs/issues + + Also logs with debugging output can be useful for diagnosing the + problem. Try running sshfs with the following options: + sshfs -odebug,sshfs_debug,loglevel=debug ... + + Doing strace on the application which fails may also sometimes help: + strace -f -o /tmp/strace application args ... + + Note that large messages (over 40k) will be rejected from the mailing + list. So try to keep the logs as short as possible. + + +2. Advantage of sshfs over NFS and Samba + + Users can mount remote resources they already have ssh access to, + without requiring the remote machine to export the resource. + + The remote resource can be mounted when it is needed in a location + that is convenient for the user at that time, without needing to rely + on a central, root-controlled file system table. + + Automatic mounting, if desired, can be added to a shell script such as + .bashrc (provided authentication is done using RSA/DSA keys). + + Resources can be mounted over slow and unreliable (distant) + connections. + +3. Create the device node + + If you don't use udev, you may get this error message: + + fusermount: failed to open /dev/fuse: No such device or address + + Before loading the fuse kernel module, create the device node + manually: + + mknod -m 666 /dev/fuse c 10 229 + +4. mv fails with "Operation not permitted". + + Use -o workaround=rename (requires sshfs version >= 1.3). + +5. cvs fails with "cvs status aborted?: cannot get working directory: No such + file or directory" in a sshfs mounted directory + + Use the -oreaddir_ino option. Example: + sshfs -oreaddir_ino hostname:remote_dir mount_point + +6. Changes on the server are not immediately visible in the mounted directory. + + By default, sshfs caches things for 20 seconds, use -o cache_timeout=N + to change the default cache timeout (in seconds) or -o cache=no for + disabling the cache. + + You can also control cache timeouts for directory listing etc with + -o cache_stat_timeout=N, + -o cache_dir_timout=N, and + -o cache_link_timout=N. + +7. Configuring the ssh connection + + In addition to flags like -C, -p, and -o SSHOPT...=, you may find it + easier to edit your /.ssh/config file. You can add an entry with any + customization you want, test it with ssh, and finally use it with + sshfs. As a bonus, you get a short mnemonic for your configuration. + +8. What are the no_readahead and sshfs_sync options for? + + These disable read and write optimizations respectively. They don't + really make sense unless you're doing something special. + +9. Why does df return strange values on partitions mounted via sshfs? + + Because the SFTP protocol doesn't have a statfs operation this is + currently not possible to display proper usage on remote partition. + +10. How do I specfy the remote mount point (since the example defaults to the + home directory) + + The example shows: + sshfs hostname: mountpoint + + To specify a remote mount point use: + sshfs hostname:remotemountpoint mountpoint + + This might be obvious to others, but I ended up looking up the + interface to sftp to see if I could learn how to specify the remote + mount point, then thought about the way that scp specifies the remote + directory, and it worked. + +11. sshfs hangs after a while + + Mounting works fine, I can use the files in Mountpoint as good as any + other files on my system, but after bit of time, changing nothing on + the remote files sshfs crashes. This means, I can not cd into the + Mountpoint (xterm hangs, nautilus hangs... every program trying to + access the Mountpoint gets stuck, and won't return). + + Solution: add + ServerAliveInterval 15 + + in your .ssh/config (or use -o ServerAliveInterval=15 on the sshfs + command line but I did not test that solution). This will force the + ssh connection to stay alive even if you have no activity. + +12. Following symlinks on the server side + + The -o follow_symlinks option will enable this. + +13. Making absolute symlinks work + + Use the -o transform_symlinks option, which will transform absolute + symlinks (ones which point somewhere inside the mount) into relative + ones. + +14. Mounting as root + + Generally it's not possible to use an sshfs mount as a "real" + filesystem shared between multiple users. Some of this functionality + can be enabled with the -o allow_other and -o default_permissions + options, but files will not be created with the correct ownership, + etc... + +15. Exporting via NFS + + Use the userspace NFS daemon http://sourceforge.net/projects/unfs + +16. Automatical mounting using /etc/fstab + + A line in /etc/fstab has the following format: + sshfs#USERNAME@REMOTE_HOST:REMOTE_PATH MOUNT_POINT fuse SSHFS_OPTIONS 0 0 + + eg. + sshfs#guest@guest.login.com:data /mnt/guest fuse \ + uid=1003,gid=100,umask=0,allow_other 0 0 + +17. Why does SVN (etc...) fail with permission denied? + + This is a bug that happens when an application creates a read-only + file opened for writing (e.g. open("foo", O_WRONLY|O_CREAT, 0444)) + + It has been fixed in sshfs version 1.3, but also requires FUSE version + >=2.5.X and Linux kernel version >=2.6.15. + +18. Why does SVN (etc...) fail to rename files? + + $ svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs + svn: Can't move 'kdelibs/.svn/tmp/entries' to 'kdelibs/.svn/entries': + Operation not permitted + + The reason is that SFTP protocol version 3 (which is implemented by + OpenSSH's sftp-server) defines the rename operation slightly + differently than POSIX. The difference is that renaming to an existing + file or directory will fail instead of atomically replacing the old + file. + + The -o workaround=rename option will try to emulate POSIX rename + semantics, but it cannot guarantee atomicity. In most of the cases + this doesn't matter, and things will work fine with this option. + +19. Is there some neat way to do it in reverse? + + You want to mount a USB thumb drive onto a file server that is rather + remote. + + Assuming this is difficult because the laptop with the thumb drive is + sitting behind NAT, firewalls, etc. then you need to create a + port-forward: + client$ ssh -R 2222:localhost:22 server + server$ sshfs -p 2222 localhost:/media/usb1 myusb1 + + (Now, is there is there a smarter way that does not involve port + opening login permissions in an undesireable direction?) + +20. Might it be reasonable to disallow loops? + + sshfs localhost:/mnt /mnt + + This seems to produce undesirable results. --JoshuaRodman + +21. How to mount through an intermediary ssh server, eg: localhost -> A -> B; + mount B from localhost + + Start by mounting the folder you need that is on "a" to a folder on + "b" then mount the new folder that is on "a" to a folder on localhost. + + IE: (These are NOT real commands, but a sequence of steps. + A mounts B:/home/x on /mnt/Bx + localhost mounts A:/mnt/Bx on ~/mydir + +22. Alternative Solution: + + 1) Create a shell script to wrap the tunneling of one ssh command over + another, + $ cat >Atunnel <<EOF + #!/bin/bash + ssh -q A ssh -q "$@" + EOF + $ chmod u+x Atunnel + + N.B. make sure to put this somewhere on your path. 2) sshfs mount as + normal but using this script as the ssh command. + $ sshfs -o ssh_command='Atunnel' B: ~/mydir + +23. I seem to have successfully mounted a remote directory, but performing an + `ls -l` on the directory above the mount point shows the mount point's + attributes as `? ? ? ? ? ?`. Nothing shows up in the directory either. What + am I doing wrong? + + You probably specified a remote path with the tilde (~) in it. This + doesn't seem to work. Instead, specify an absolute remote path: + sshfs username@remote.host:/home/username/whatever my/mount + + What options do i use to make playing media files (music) over sshfs more + efficient? + + MacFUSE doesn't seem to let me move files from one directory to another. It + first asks for my local user password (i.e. the password on my Macbook Pro) + and then produces the error message "The operation cannot be completed + because one or more required items cannot be found. (Error code -120). + diff --git a/Makefile.am b/Makefile.am index f003bae..3d8f9cb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ sshfs.1: sshfs.1.in $(AM_V_GEN)sed \ -e 's,__IDMAP_DEFAULT__,$(IDMAP_DEFAULT),g' \ -e 's,__UNMOUNT_COMMAND__,$(UNMOUNT_COMMAND),g' \ - <sshfs.1.in >sshfs.1.tmp || exit 1; \ + <$(srcdir)/sshfs.1.in >sshfs.1.tmp || exit 1; \ mv sshfs.1.tmp sshfs.1 if SSH_NODELAY_SO @@ -523,6 +523,10 @@ static void cache_unity_fill(struct fuse_cache_operations *oper, cache_oper->ftruncate = oper->oper.ftruncate; cache_oper->fgetattr = oper->oper.fgetattr; #endif +#if FUSE_VERSION >= 29 + cache_oper->flag_nullpath_ok = oper->oper.flag_nullpath_ok; + cache_oper->flag_nopath = oper->oper.flag_nopath; +#endif } static void cache_fill(struct fuse_cache_operations *oper, @@ -548,6 +552,10 @@ static void cache_fill(struct fuse_cache_operations *oper, cache_oper->ftruncate = oper->oper.ftruncate ? cache_ftruncate : NULL; cache_oper->fgetattr = oper->oper.fgetattr ? cache_fgetattr : NULL; #endif +#if FUSE_VERSION >= 29 + cache_oper->flag_nullpath_ok = 0; + cache_oper->flag_nopath = 0; +#endif } diff --git a/configure.ac b/configure.ac index a91ec3f..f33bb1b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(sshfs, 2.6) +AC_INIT(sshfs, 2.9) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([foreign subdir-objects]) AM_CONFIG_HEADER(config.h) @@ -44,7 +44,7 @@ fi AM_CONDITIONAL(SSH_NODELAY_SO, test "$enable_sshnodelay" = "yes") export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH -PKG_CHECK_MODULES(SSHFS, [fuse >= 2.3 glib-2.0 gthread-2.0]) +PKG_CHECK_MODULES([SSHFS], [fuse >= 2.3 glib-2.0 gthread-2.0]) have_fuse_opt_parse=no oldlibs="$LIBS" LIBS="$LIBS $SSHFS_LIBS" @@ -141,8 +141,6 @@ path to sftp server or subsystem (default: sftp) .TP \fB\-o\fR directport=PORT directly connect to PORT bypassing ssh -\fB\-o\fR slave -communicate over stdin and stdout bypassing network .TP \fB\-o\fR slave communicate over stdin and stdout bypassing network @@ -11,7 +11,9 @@ #include <fuse.h> #include <fuse_opt.h> +#if !defined(__CYGWIN__) #include <fuse_lowlevel.h> +#endif #ifdef __APPLE__ # include <fuse_darwin.h> #endif @@ -118,6 +120,7 @@ #define SFTP_EXT_POSIX_RENAME "posix-rename@openssh.com" #define SFTP_EXT_STATVFS "statvfs@openssh.com" #define SFTP_EXT_HARDLINK "hardlink@openssh.com" +#define SFTP_EXT_FSYNC "fsync@openssh.com" #define PROTO_VERSION 3 @@ -273,6 +276,7 @@ struct sshfs { int ext_posix_rename; int ext_statvfs; int ext_hardlink; + int ext_fsync; mode_t mnt_mode; struct fuse_operations *op; @@ -1548,6 +1552,9 @@ static int sftp_init_reply_ok(struct buffer *buf, uint32_t *version) if (strcmp(ext, SFTP_EXT_HARDLINK) == 0 && strcmp(extdata, "1") == 0) sshfs.ext_hardlink = 1; + if (strcmp(ext, SFTP_EXT_FSYNC) == 0 && + strcmp(extdata, "1") == 0) + sshfs.ext_fsync = 1; } while (buf2.len < buf2.size); buf_free(&buf2); } @@ -2632,8 +2639,25 @@ static int sshfs_flush(const char *path, struct fuse_file_info *fi) static int sshfs_fsync(const char *path, int isdatasync, struct fuse_file_info *fi) { + int err; (void) isdatasync; - return sshfs_flush(path, fi); + + if (err = sshfs_flush(path, fi)) + return err; + + if (!sshfs.ext_fsync) + return err; + + { + struct buffer buf; + struct sshfs_file *sf = get_sshfs_file(fi); + buf_init(&buf, 0); + buf_add_string(&buf, SFTP_EXT_FSYNC); + buf_add_buf(&buf, &sf->handle); + err = sftp_request(SSH_FXP_EXTENDED, &buf, SSH_FXP_STATUS, NULL); + buf_free(&buf); + return err; + } } static void sshfs_file_put(struct sshfs_file *sf) @@ -3351,6 +3375,10 @@ static struct fuse_cache_operations sshfs_oper = { .ftruncate = sshfs_ftruncate, .fgetattr = sshfs_fgetattr, #endif +#if FUSE_VERSION >= 29 + .flag_nullpath_ok = 1, + .flag_nopath = 1, +#endif }, .cache_getdir = sshfs_getdir, }; @@ -3967,6 +3995,14 @@ int main(int argc, char *argv[]) parse_workarounds() == -1) exit(1); +#if FUSE_VERSION >= 29 + // These workarounds require the "path" argument. + if (sshfs.truncate_workaround || sshfs.fstat_workaround) { + sshfs_oper.oper.flag_nullpath_ok = 0; + sshfs_oper.oper.flag_nopath = 0; + } +#endif + if (sshfs.idmap == IDMAP_USER) sshfs.detect_uid = 1; else if (sshfs.idmap == IDMAP_FILE) { @@ -4079,7 +4115,9 @@ int main(int argc, char *argv[]) char *mountpoint; int multithreaded; int foreground; +#if !defined(__CYGWIN__) struct stat st; +#endif res = fuse_parse_cmdline(&args, &mountpoint, &multithreaded, &foreground); @@ -4091,20 +4129,26 @@ int main(int argc, char *argv[]) foreground = 1; } +#if !defined(__CYGWIN__) res = stat(mountpoint, &st); if (res == -1) { perror(mountpoint); exit(1); } sshfs.mnt_mode = st.st_mode; +#elif defined(__CYGWIN__) + sshfs.mnt_mode = S_IFDIR | 0755; +#endif ch = fuse_mount(mountpoint, &args); if (!ch) exit(1); +#if !defined(__CYGWIN__) res = fcntl(fuse_chan_fd(ch), F_SETFD, FD_CLOEXEC); if (res == -1) perror("WARNING: failed to set FD_CLOEXEC on fuse device"); +#endif sshfs.op = cache_init(&sshfs_oper); fuse = fuse_new(ch, &args, sshfs.op, |