Skip to content

Commit

Permalink
New workaround renamexdev to enable moving files across remote filesy…
Browse files Browse the repository at this point in the history
…stems

sshfs.rst: update the documentation.
  • Loading branch information
g-raud authored and Nikratio committed Mar 28, 2018
1 parent f0a0cc2 commit 303126b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sshfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ struct sshfs {
struct fuse_args ssh_args;
char *workarounds;
int rename_workaround;
int renamexdev_workaround;
int truncate_workaround;
int buflimit_workaround;
int unrel_append;
Expand Down Expand Up @@ -446,6 +447,8 @@ static struct fuse_opt workaround_opts[] = {
SSHFS_OPT("none", fstat_workaround, 0),
SSHFS_OPT("rename", rename_workaround, 1),
SSHFS_OPT("norename", rename_workaround, 0),
SSHFS_OPT("renamexdev", renamexdev_workaround, 1),
SSHFS_OPT("norenamexdev", renamexdev_workaround, 0),
SSHFS_OPT("truncate", truncate_workaround, 1),
SSHFS_OPT("notruncate", truncate_workaround, 0),
SSHFS_OPT("buflimit", buflimit_workaround, 1),
Expand Down Expand Up @@ -2333,6 +2336,8 @@ static int sshfs_rename(const char *from, const char *to, unsigned int flags)
}
}
}
if (err == -EPERM && sshfs.renamexdev_workaround)
err = -EXDEV;
return err;
}

Expand Down Expand Up @@ -3365,6 +3370,7 @@ static void usage(const char *progname)
" -o workaround=LIST colon separated list of workarounds\n"
" none no workarounds enabled\n"
" [no]rename fix renaming to existing file (default: off)\n"
" [no]renamexdev fix moving across filesystems (default: off)\n"
" [no]truncate fix truncate for old servers (default: off)\n"
" [no]buflimit fix buffer fillup bug in server (default: on)\n"
" [no]fstat always use stat() instead of fstat() (default: off)\n"
Expand Down Expand Up @@ -3851,6 +3857,7 @@ int main(int argc, char *argv[])
#else
sshfs.rename_workaround = 0;
#endif
sshfs.renamexdev_workaround = 0;
sshfs.truncate_workaround = 0;
sshfs.buflimit_workaround = 1;
sshfs.ssh_ver = 2;
Expand Down
13 changes: 13 additions & 0 deletions sshfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ Options

:rename: Emulate overwriting an existing file by deleting and
renaming.
:renamexdev: Make rename fail with EXDEV instead of the default EPERM
to allow moving files across remote filesystems.
:truncate: Work around servers that don't support truncate by
coping the whole file, truncating it locally, and sending it
back.
Expand Down Expand Up @@ -228,6 +230,17 @@ removed it, but before SSHFS had the time to rename the old file. In
this case, the rename will still fail.


Permission denied when moving files across remote filesystems
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Most SFTP servers return only a generic "failure" when failing to rename
across filesystem boundaries (EXDEV). sshfs normally converts this generic
failure to a permission denied error (EPERM). If the option ``-o
workaround=renamexdev`` is given, generic failures will be considered EXDEV
errors which will make programs like `mv(1)` attempt to actually move the
file after the failed rename.


SSHFS hangs
~~~~~~~~~~~

Expand Down

0 comments on commit 303126b

Please sign in to comment.