|
|
12a457 |
From b4c2715028ff0a28da97510f521bfb670b3b2777 Mon Sep 17 00:00:00 2001
|
|
|
12a457 |
From: Susant Palai <spalai@redhat.com>
|
|
|
12a457 |
Date: Wed, 25 Nov 2015 05:07:03 -0500
|
|
|
12a457 |
Subject: [PATCH 08/26] posix: fix posix_fgetxattr to return the correct error
|
|
|
12a457 |
|
|
|
12a457 |
posix_fgetxattr used to not updating op_ret
|
|
|
12a457 |
and op_errno (initialized to -1 and ENOENT respectively)
|
|
|
12a457 |
on success cases. Hence, it can return ENOENT even if all
|
|
|
12a457 |
the opertions were sucessful.
|
|
|
12a457 |
|
|
|
12a457 |
BUG: 1319634
|
|
|
12a457 |
Change-Id: I8ec4bab6f405b2fdf91fe386e960b603d4fbc3a8
|
|
|
12a457 |
Signed-off-by: Susant Palai <spalai@redhat.com>
|
|
|
12a457 |
Reviewed-on: http://review.gluster.org/12745
|
|
|
12a457 |
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
12a457 |
Tested-by: Gluster Build System <jenkins@build.gluster.com>
|
|
|
12a457 |
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
|
|
|
12a457 |
Signed-off-by: Susant Palai <spalai@redhat.com>
|
|
|
12a457 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/70312
|
|
|
12a457 |
Reviewed-by: Nithya Balachandran <nbalacha@redhat.com>
|
|
|
12a457 |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
12a457 |
Tested-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
12a457 |
---
|
|
|
12a457 |
xlators/storage/posix/src/posix.c | 26 +++++++++++++++++++++++---
|
|
|
12a457 |
1 files changed, 23 insertions(+), 3 deletions(-)
|
|
|
12a457 |
|
|
|
12a457 |
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
|
|
|
12a457 |
index 761bc4e..512af41 100644
|
|
|
12a457 |
--- a/xlators/storage/posix/src/posix.c
|
|
|
12a457 |
+++ b/xlators/storage/posix/src/posix.c
|
|
|
12a457 |
@@ -4447,7 +4447,7 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
|
|
|
12a457 |
fd_t *fd, const char *name, dict_t *xdata)
|
|
|
12a457 |
{
|
|
|
12a457 |
int32_t op_ret = -1;
|
|
|
12a457 |
- int32_t op_errno = ENOENT;
|
|
|
12a457 |
+ int32_t op_errno = EINVAL;
|
|
|
12a457 |
struct posix_fd * pfd = NULL;
|
|
|
12a457 |
int _fd = -1;
|
|
|
12a457 |
int32_t list_offset = 0;
|
|
|
12a457 |
@@ -4469,6 +4469,7 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
|
|
|
12a457 |
|
|
|
12a457 |
ret = posix_fd_ctx_get (fd, this, &pfd;;
|
|
|
12a457 |
if (ret < 0) {
|
|
|
12a457 |
+ op_ret = -1;
|
|
|
12a457 |
op_errno = -ret;
|
|
|
12a457 |
gf_msg (this->name, GF_LOG_WARNING, op_errno, P_MSG_PFD_NULL,
|
|
|
12a457 |
"pfd is NULL from fd=%p", fd);
|
|
|
12a457 |
@@ -4480,15 +4481,21 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
|
|
|
12a457 |
/* Get the total size */
|
|
|
12a457 |
dict = dict_new ();
|
|
|
12a457 |
if (!dict) {
|
|
|
12a457 |
+ op_ret = -1;
|
|
|
12a457 |
+ op_errno = ENOMEM;
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
if (name && !strcmp (name, GLUSTERFS_OPEN_FD_COUNT)) {
|
|
|
12a457 |
ret = dict_set_uint32 (dict, (char *)name, 1);
|
|
|
12a457 |
- if (ret < 0)
|
|
|
12a457 |
+ if (ret < 0) {
|
|
|
12a457 |
+ op_ret = -1;
|
|
|
12a457 |
+ size = -1;
|
|
|
12a457 |
+ op_errno = ENOMEM;
|
|
|
12a457 |
gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
12a457 |
P_MSG_DICT_SET_FAILED, "Failed to set "
|
|
|
12a457 |
"dictionary value for %s", name);
|
|
|
12a457 |
+ }
|
|
|
12a457 |
goto done;
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
@@ -4496,8 +4503,11 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
|
|
|
12a457 |
strlen (GLUSTERFS_GET_OBJECT_SIGNATURE)) == 0) {
|
|
|
12a457 |
op_ret = posix_fdget_objectsignature (_fd, dict);
|
|
|
12a457 |
if (op_ret < 0) {
|
|
|
12a457 |
+ gf_msg (this->name, GF_LOG_ERROR, 0, 0,
|
|
|
12a457 |
+ "posix_fdget_objectsignature failed");
|
|
|
12a457 |
op_errno = -op_ret;
|
|
|
12a457 |
op_ret = -1;
|
|
|
12a457 |
+ size = -1;
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
goto done;
|
|
|
12a457 |
@@ -4517,6 +4527,7 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
|
|
|
12a457 |
#endif
|
|
|
12a457 |
size = sys_fgetxattr (_fd, key, NULL, 0);
|
|
|
12a457 |
if (size == -1) {
|
|
|
12a457 |
+ op_ret = -1;
|
|
|
12a457 |
op_errno = errno;
|
|
|
12a457 |
if (errno == ENODATA || errno == ENOATTR) {
|
|
|
12a457 |
gf_msg_debug (this->name, 0, "fgetxattr failed"
|
|
|
12a457 |
@@ -4533,6 +4544,7 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
|
|
|
12a457 |
value = GF_CALLOC (size + 1, sizeof(char), gf_posix_mt_char);
|
|
|
12a457 |
if (!value) {
|
|
|
12a457 |
op_ret = -1;
|
|
|
12a457 |
+ op_errno = ENOMEM;
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
}
|
|
|
12a457 |
size = sys_fgetxattr (_fd, key, value, size);
|
|
|
12a457 |
@@ -4545,20 +4557,25 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
|
|
|
12a457 |
GF_FREE (value);
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
}
|
|
|
12a457 |
+
|
|
|
12a457 |
value [size] = '\0';
|
|
|
12a457 |
op_ret = dict_set_dynptr (dict, key, value, size);
|
|
|
12a457 |
if (op_ret < 0) {
|
|
|
12a457 |
+ op_errno = -op_ret;
|
|
|
12a457 |
+ op_ret = -1;
|
|
|
12a457 |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
12a457 |
P_MSG_DICT_SET_FAILED, "dict set operation "
|
|
|
12a457 |
"on key %s failed", key);
|
|
|
12a457 |
GF_FREE (value);
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
}
|
|
|
12a457 |
+
|
|
|
12a457 |
goto done;
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
size = sys_flistxattr (_fd, NULL, 0);
|
|
|
12a457 |
if (size == -1) {
|
|
|
12a457 |
+ op_ret = -1;
|
|
|
12a457 |
op_errno = errno;
|
|
|
12a457 |
if ((errno == ENOTSUP) || (errno == ENOSYS)) {
|
|
|
12a457 |
GF_LOG_OCCASIONALLY (gf_posix_xattr_enotsup_log,
|
|
|
12a457 |
@@ -4580,7 +4597,8 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
|
|
|
12a457 |
|
|
|
12a457 |
list = alloca (size + 1);
|
|
|
12a457 |
if (!list) {
|
|
|
12a457 |
- op_errno = errno;
|
|
|
12a457 |
+ op_ret = -1;
|
|
|
12a457 |
+ op_errno = ENOMEM;
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
@@ -4626,6 +4644,8 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
|
|
|
12a457 |
|
|
|
12a457 |
op_ret = dict_set_dynptr (dict, key, value, size);
|
|
|
12a457 |
if (op_ret) {
|
|
|
12a457 |
+ op_errno = -op_ret;
|
|
|
12a457 |
+ op_ret = -1;
|
|
|
12a457 |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
12a457 |
P_MSG_DICT_SET_FAILED, "dict set operation "
|
|
|
12a457 |
"failed on key %s", key);
|
|
|
12a457 |
--
|
|
|
12a457 |
1.7.1
|
|
|
12a457 |
|