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.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 8457905d3c1..85005e07b14 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -2130,20 +2130,31 @@ posix_fetch_signature_xattr (char *real_path,
int32_t ret = 0;
char *memptr = NULL;
ssize_t xattrsize = 0;
+ char val_buf[2048] = {0,};
+ gf_boolean_t have_val = _gf_false;
- xattrsize = sys_lgetxattr (real_path, key, NULL, 0);
- if ((xattrsize == -1) && ((errno == ENOATTR) || (errno == ENODATA)))
- return 0;
- if (xattrsize == -1)
- goto error_return;
-
+ xattrsize = sys_lgetxattr (real_path, key, val_buf,
+ sizeof(val_buf) - 1);
+ if (xattrsize >= 0) {
+ have_val = _gf_true;
+ } else {
+ if (errno == ERANGE)
+ xattrsize = sys_lgetxattr (real_path, key, NULL, 0);
+ if ((errno == ENOATTR) || (errno == ENODATA))
+ return 0;
+ if (xattrsize == -1)
+ goto error_return;
+ }
memptr = GF_CALLOC (xattrsize + 1, sizeof (char), gf_posix_mt_char);
if (!memptr)
goto error_return;
- ret = sys_lgetxattr (real_path, key, memptr, xattrsize);
- if (ret == -1)
- goto freemem;
-
+ if (have_val) {
+ memcpy (memptr, val_buf, xattrsize);
+ } else {
+ ret = sys_lgetxattr (real_path, key, memptr, xattrsize);
+ if (ret == -1)
+ goto freemem;
+ }
ret = dict_set_dynptr (xattr, (char *)key, memptr, xattrsize);
if (ret)
goto freemem;