summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 06b5cedcb12..f4dcc70a2ab 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -214,16 +214,25 @@ _posix_xattr_get_set (dict_t *xattr_req,
if (!value)
return;
- sys_lgetxattr (filler->real_path, key, value,
- xattr_size);
+ xattr_size = sys_lgetxattr (filler->real_path, key,
+ value, xattr_size);
+ if (xattr_size <= 0) {
+ gf_log (filler->this->name, GF_LOG_WARNING,
+ "getxattr failed. path: %s, key: %s",
+ filler->real_path, key);
+ GF_FREE (value);
+ return;
+ }
value[xattr_size] = '\0';
ret = dict_set_bin (filler->xattr, key,
value, xattr_size);
- if (ret < 0)
+ if (ret < 0) {
gf_log (filler->this->name, GF_LOG_DEBUG,
"dict set failed. path: %s, key: %s",
filler->real_path, key);
+ GF_FREE (value);
+ }
}
}
out:
@@ -235,14 +244,17 @@ int
posix_fill_gfid_path (xlator_t *this, const char *path, struct iatt *iatt)
{
int ret = 0;
+ ssize_t size = 0;
if (!iatt)
return 0;
- ret = sys_lgetxattr (path, GFID_XATTR_KEY, iatt->ia_gfid, 16);
+ size = sys_lgetxattr (path, GFID_XATTR_KEY, iatt->ia_gfid, 16);
/* Return value of getxattr */
- if ((ret == 16) || (ret == -1))
+ if ((size == 16) || (size == -1))
ret = 0;
+ else
+ ret = size;
return ret;
}
@@ -252,14 +264,17 @@ int
posix_fill_gfid_fd (xlator_t *this, int fd, struct iatt *iatt)
{
int ret = 0;
+ ssize_t size = 0;
if (!iatt)
return 0;
- ret = sys_fgetxattr (fd, GFID_XATTR_KEY, iatt->ia_gfid, 16);
+ size = sys_fgetxattr (fd, GFID_XATTR_KEY, iatt->ia_gfid, 16);
/* Return value of getxattr */
- if ((ret == 16) || (ret == -1))
+ if ((size == 16) || (size == -1))
ret = 0;
+ else
+ ret = size;
return ret;
}
@@ -443,6 +458,7 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req)
void *uuid_req = NULL;
uuid_t uuid_curr;
int ret = 0;
+ ssize_t size = 0;
struct stat stat = {0, };
@@ -452,8 +468,8 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req)
if (sys_lstat (path, &stat) != 0)
goto out;
- ret = sys_lgetxattr (path, GFID_XATTR_KEY, uuid_curr, 16);
- if (ret == 16) {
+ size = sys_lgetxattr (path, GFID_XATTR_KEY, uuid_curr, 16);
+ if (size == 16) {
ret = 0;
goto verify_handle;
}