Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New workaround renamexdev to enable moving files across remote FS #118

Merged
merged 1 commit into from
Mar 28, 2018

Conversation

g-raud
Copy link
Contributor

@g-raud g-raud commented Mar 20, 2018

This is a fix that closes #100 (in the style of workaround as nothing better can be done it seems).

The change simply catches EPERM in sshfs_rename() and substitutes EXDEV.

@g-raud g-raud force-pushed the workaround-rename-xdev branch 2 times, most recently from e93df06 to 7a1d210 Compare March 20, 2018 11:59
Copy link
Contributor

@Nikratio Nikratio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! Just some small nitpicks to address.

sshfs.c Outdated
SSHFS_OPT("buflimit", buflimit_workaround, 1),
SSHFS_OPT("nobuflimit", buflimit_workaround, 0),
SSHFS_OPT("fstat", fstat_workaround, 1),
SSHFS_OPT("nofstat", fstat_workaround, 0),
FUSE_OPT_END
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all these spurious changes.

sshfs.rst Outdated
Permission denied when moving files across remote filesystems
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SSH servers return a generic error when failing to rename across filesystem
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add "some" (unless this is actually standard behavior, in that case please provide a link to the standard)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from the code (none of the 8 defined SSH_FX_* return codes describe EXDEV) and from the web at https://winscp.net/eng/docs/sftp_codes "Most SSH/SFTP servers support only SFTP version 3 that defines only codes 0 to 8." (Note that even amongst the "extended" error codes none describe EXDEV). So I changed it to "Most SSH servers".

sshfs.rst Outdated
SSH servers return a generic error when failing to rename across filesystem
boundaries (EXDEV). sshfs normally considers it a permission denied error
(EPERM). If the option `-o workaround=renamexdev` is given, generic failures
will be considered EXDEV errors which will make a move program attempt to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use "programs like mv" instead of "a move program"

@g-raud
Copy link
Contributor Author

g-raud commented Mar 21, 2018

You may consider enabling the workaround by default, similarly to what commit 91c1f2b ("Map SSH2_FX_FAILURE to ENOTEMPTY for rmdir") did whereas rmdir(3) can fail with many different error conditions.

@Nikratio Nikratio merged commit 303126b into libfuse:master Mar 28, 2018
@g-raud g-raud deleted the workaround-rename-xdev branch March 29, 2018 19:31
@bjornfor
Copy link

What does this workaround mean? That the real fix is patching the OpenSSH SFTP server? What are the downsides to the sshfs workaround? (I just hit this issue on my system and wonder what the best way forward is.)

@Nikratio
Copy link
Contributor

Well, it means that sshfs will translate EPERM to EXDEV, so if the real problem is truly EPERM, you will get an incorrect error code. And yes, a better fix would be for the server to return EXDEV :-)

@g-raud
Copy link
Contributor Author

g-raud commented Aug 14, 2018 via email

@bjornfor
Copy link

Thanks for the info.

I found this patch interesting: openssh/openssh-portable@f7fa706. Unless I'm reading it wrong, openssh can be built with (undocumented) -DEXDEV flag since 2008, doing "the right thing" (IMHO) all by itself.

I realise that I don't even know what, in terms of syscalls, mv(1) does when it is asked to cross a filesystem boudary. I just found it odd that sshfs didn't operate transparently, like being able to "mv" files across filesystems in the same way as within filesystems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mv fails with EPERM when moving a file between different remote FS's
3 participants