Skip to content

Commit

Permalink
Workaround for mkdir on existing directory (libfuse#242)
Browse files Browse the repository at this point in the history
Added a secondary check so if a mkdir request fails with EPERM an access request will be tried - returning EEXIST if the access was successful. This matches the correct behaviour expected by applications such as git.

Co-authored-by: Peter Belm <[email protected]>
  • Loading branch information
peterbelm and peter-belm-da committed Jan 19, 2021
1 parent 8059e2c commit dfd4cba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Unreleased Changes
--------------------------

* Added a secondary check so if a mkdir request fails with EPERM an access request will be
tried - returning EEXIST if the access was successful.
Fixes: https://github.com/libfuse/sshfs/issues/243


Release 3.7.1 (2020-11-09)
--------------------------

Expand Down
7 changes: 7 additions & 0 deletions sshfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,13 @@ static int sshfs_mkdir(const char *path, mode_t mode)
// Commutes with pending write(), so we can use any connection
err = sftp_request(get_conn(NULL, NULL), SSH_FXP_MKDIR, &buf, SSH_FXP_STATUS, NULL);
buf_free(&buf);

if (err == -EPERM) {
if (sshfs.op->access(path, R_OK) == 0) {
return -EEXIST;
}
}

return err;
}

Expand Down

0 comments on commit dfd4cba

Please sign in to comment.