diff options
-rw-r--r-- | xlators/storage/posix/src/posix.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index b4b4a3cca72..cdfa437ab75 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -1902,6 +1902,8 @@ posix_rename (call_frame_t *frame, xlator_t *this, struct iatt postoldparent = {0, }; struct iatt prenewparent = {0, }; struct iatt postnewparent = {0, }; + char olddirid[64]; + char newdirid[64]; DECLARE_OLD_FS_ID_VAR; @@ -1952,6 +1954,27 @@ posix_rename (call_frame_t *frame, xlator_t *this, was_present = 0; } + if (was_present && IA_ISDIR(stbuf.ia_type) && !newloc->inode) { + gf_log (this->name, GF_LOG_WARNING, + "found directory at %s while expecting ENOENT", + real_newpath); + op_ret = -1; + op_errno = EEXIST; + goto out; + } + + if (was_present && IA_ISDIR(stbuf.ia_type) && + uuid_compare (newloc->inode->gfid, stbuf.ia_gfid)) { + gf_log (this->name, GF_LOG_WARNING, + "found directory %s at %s while renaming %s", + uuid_utoa_r (newloc->inode->gfid, olddirid), + real_newpath, + uuid_utoa_r (stbuf.ia_gfid, newdirid)); + op_ret = -1; + op_errno = EEXIST; + goto out; + } + op_ret = sys_rename (real_oldpath, real_newpath); if (op_ret == -1) { op_errno = errno; |