Skip to content

Commit 303126b

Browse files
g-raudNikratio
authored andcommitted
New workaround renamexdev to enable moving files across remote filesystems
sshfs.rst: update the documentation.
1 parent f0a0cc2 commit 303126b

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

sshfs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ struct sshfs {
214214
struct fuse_args ssh_args;
215215
char *workarounds;
216216
int rename_workaround;
217+
int renamexdev_workaround;
217218
int truncate_workaround;
218219
int buflimit_workaround;
219220
int unrel_append;
@@ -446,6 +447,8 @@ static struct fuse_opt workaround_opts[] = {
446447
SSHFS_OPT("none", fstat_workaround, 0),
447448
SSHFS_OPT("rename", rename_workaround, 1),
448449
SSHFS_OPT("norename", rename_workaround, 0),
450+
SSHFS_OPT("renamexdev", renamexdev_workaround, 1),
451+
SSHFS_OPT("norenamexdev", renamexdev_workaround, 0),
449452
SSHFS_OPT("truncate", truncate_workaround, 1),
450453
SSHFS_OPT("notruncate", truncate_workaround, 0),
451454
SSHFS_OPT("buflimit", buflimit_workaround, 1),
@@ -2333,6 +2336,8 @@ static int sshfs_rename(const char *from, const char *to, unsigned int flags)
23332336
}
23342337
}
23352338
}
2339+
if (err == -EPERM && sshfs.renamexdev_workaround)
2340+
err = -EXDEV;
23362341
return err;
23372342
}
23382343

@@ -3365,6 +3370,7 @@ static void usage(const char *progname)
33653370
" -o workaround=LIST colon separated list of workarounds\n"
33663371
" none no workarounds enabled\n"
33673372
" [no]rename fix renaming to existing file (default: off)\n"
3373+
" [no]renamexdev fix moving across filesystems (default: off)\n"
33683374
" [no]truncate fix truncate for old servers (default: off)\n"
33693375
" [no]buflimit fix buffer fillup bug in server (default: on)\n"
33703376
" [no]fstat always use stat() instead of fstat() (default: off)\n"
@@ -3851,6 +3857,7 @@ int main(int argc, char *argv[])
38513857
#else
38523858
sshfs.rename_workaround = 0;
38533859
#endif
3860+
sshfs.renamexdev_workaround = 0;
38543861
sshfs.truncate_workaround = 0;
38553862
sshfs.buflimit_workaround = 1;
38563863
sshfs.ssh_ver = 2;

sshfs.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ Options
107107

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

230232

233+
Permission denied when moving files across remote filesystems
234+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235+
236+
Most SFTP servers return only a generic "failure" when failing to rename
237+
across filesystem boundaries (EXDEV). sshfs normally converts this generic
238+
failure to a permission denied error (EPERM). If the option ``-o
239+
workaround=renamexdev`` is given, generic failures will be considered EXDEV
240+
errors which will make programs like `mv(1)` attempt to actually move the
241+
file after the failed rename.
242+
243+
231244
SSHFS hangs
232245
~~~~~~~~~~~
233246

0 commit comments

Comments
 (0)