Skip to content

Commit dfd4cba

Browse files
Workaround for mkdir on existing directory (#242)
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 <peter.belm@dataalchemist.co.uk>
1 parent 8059e2c commit dfd4cba

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

ChangeLog.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Unreleased Changes
2+
--------------------------
3+
4+
* Added a secondary check so if a mkdir request fails with EPERM an access request will be
5+
tried - returning EEXIST if the access was successful.
6+
Fixes: https://github.com/libfuse/sshfs/issues/243
7+
8+
19
Release 3.7.1 (2020-11-09)
210
--------------------------
311

sshfs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,6 +2377,13 @@ static int sshfs_mkdir(const char *path, mode_t mode)
23772377
// Commutes with pending write(), so we can use any connection
23782378
err = sftp_request(get_conn(NULL, NULL), SSH_FXP_MKDIR, &buf, SSH_FXP_STATUS, NULL);
23792379
buf_free(&buf);
2380+
2381+
if (err == -EPERM) {
2382+
if (sshfs.op->access(path, R_OK) == 0) {
2383+
return -EEXIST;
2384+
}
2385+
}
2386+
23802387
return err;
23812388
}
23822389

0 commit comments

Comments
 (0)