summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/storage/posix/src')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c31
-rw-r--r--xlators/storage/posix/src/posix.c2
-rw-r--r--xlators/storage/posix/src/posix.h4
3 files changed, 37 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 77affc45ae0..127ae287183 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -150,6 +150,37 @@ out:
return ret;
}
+int32_t
+posix_set_mode_in_dict (dict_t *in_dict, dict_t *out_dict,
+ struct iatt *in_stbuf)
+{
+ int ret = -1;
+ mode_t mode = 0;
+
+ if ((!in_dict) || (!in_stbuf) || (!out_dict)) {
+ goto out;
+ }
+
+ /* We need this only for files */
+ if (!(IA_ISREG (in_stbuf->ia_type))) {
+ ret = 0;
+ goto out;
+ }
+
+ /* Nobody asked for this */
+ if (!dict_get (in_dict, DHT_MODE_IN_XDATA_KEY)) {
+ ret = 0;
+ goto out;
+ }
+ mode = st_mode_from_ia (in_stbuf->ia_prot, in_stbuf->ia_type);
+
+ ret = dict_set_int32 (out_dict, DHT_MODE_IN_XDATA_KEY, mode);
+
+out:
+ return ret;
+}
+
+
static gf_boolean_t
posix_xattr_ignorable (char *key)
{
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 1fe6dec457f..93058811ff2 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -6159,7 +6159,9 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
if (!xdata_rsp) {
op_ret = -1;
op_errno = ENOMEM;
+ goto out;
}
+ posix_set_mode_in_dict (xdata, xdata_rsp, &stbuf);
out:
STACK_UNWIND_STRICT (xattrop, frame, op_ret, op_errno, xattr_rsp,
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index b63643d970b..92eda169d0b 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -352,4 +352,8 @@ posix_fdget_objectsignature (int, dict_t *);
gf_boolean_t
posix_is_bulk_removexattr (char *name, dict_t *dict);
+
+int32_t
+posix_set_mode_in_dict (dict_t *in_dict, dict_t *out_dict,
+ struct iatt *in_stbuf);
#endif /* _POSIX_H */