diff options
-rw-r--r-- | xlators/storage/posix/src/posix-handle.c | 20 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 2 |
2 files changed, 16 insertions, 6 deletions
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c index bc34e3e5dba..5c50d413640 100644 --- a/xlators/storage/posix/src/posix-handle.c +++ b/xlators/storage/posix/src/posix-handle.c @@ -741,6 +741,7 @@ posix_handle_hard(xlator_t *this, const char *oldpath, uuid_t gfid, char *newpath = NULL; struct stat newbuf; int ret = -1; + gf_boolean_t link_exists = _gf_false; MAKE_HANDLE_ABSPATH(newpath, this, gfid); @@ -762,11 +763,15 @@ posix_handle_hard(xlator_t *this, const char *oldpath, uuid_t gfid, ret = sys_link(oldpath, newpath); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, errno, P_MSG_HANDLE_CREATE, - "link %s -> %s" - "failed ", - oldpath, newpath); - return -1; + if (errno != EEXIST) { + gf_msg(this->name, GF_LOG_WARNING, errno, P_MSG_HANDLE_CREATE, + "link %s -> %s" + "failed ", + oldpath, newpath); + return -1; + } else { + link_exists = _gf_true; + } } ret = sys_lstat(newpath, &newbuf); @@ -775,6 +780,11 @@ posix_handle_hard(xlator_t *this, const char *oldpath, uuid_t gfid, "lstat on %s failed", newpath); return -1; } + if ((link_exists) && (!S_ISREG(newbuf.st_mode))) { + gf_msg(this->name, GF_LOG_ERROR, EINVAL, P_MSG_HANDLE_CREATE, + "%s - Expected regular file", newpath); + return -1; + } } if (newbuf.st_ino != oldbuf->st_ino || newbuf.st_dev != oldbuf->st_dev) { diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 99ee094c114..1200692db4e 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -962,7 +962,7 @@ posix_gfid_set(xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req, if (sys_lstat(path, &stat) != 0) { ret = -1; gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_LSTAT_FAILED, - "lsatat on %s failed", path); + "lstat on %s failed", path); goto out; } |