summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/glusterfs.h4
-rw-r--r--xlators/storage/posix/src/posix.c36
2 files changed, 38 insertions, 2 deletions
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 622651b4c9e..56fbbaff249 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -249,7 +249,9 @@ typedef enum {
typedef enum {
GF_XATTROP_ADD_ARRAY,
- GF_XATTROP_ADD_ARRAY64
+ GF_XATTROP_ADD_ARRAY64,
+ GF_XATTROP_OR_ARRAY,
+ GF_XATTROP_AND_ARRAY
} gf_xattrop_flags_t;
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 64cfca0c023..9e23c4b721b 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3081,9 +3081,31 @@ posix_print_xattr (dict_t *this,
static void
__add_array (int32_t *dest, int32_t *src, int count)
{
+ int i = 0;
+ int32_t destval = 0;
+ for (i = 0; i < count; i++) {
+ destval = ntoh32 (dest[i]);
+ if (destval == 0xffffffff)
+ continue;
+ dest[i] = hton32 (destval + ntoh32 (src[i]));
+ }
+}
+
+static void
+__or_array (int32_t *dest, int32_t *src, int count)
+{
+ int i = 0;
+ for (i = 0; i < count; i++) {
+ dest[i] = hton32 (ntoh32 (dest[i]) | ntoh32 (src[i]));
+ }
+}
+
+static void
+__and_array (int32_t *dest, int32_t *src, int count)
+{
int i = 0;
for (i = 0; i < count; i++) {
- dest[i] = hton32 (ntoh32 (dest[i]) + ntoh32 (src[i]));
+ dest[i] = hton32 (ntoh32 (dest[i]) & ntoh32 (src[i]));
}
}
@@ -3205,6 +3227,18 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
v->len / 8);
break;
+ case GF_XATTROP_OR_ARRAY:
+ __or_array ((int32_t *) array,
+ (int32_t *) trav->value->data,
+ trav->value->len / 4);
+ break;
+
+ case GF_XATTROP_AND_ARRAY:
+ __and_array ((int32_t *) array,
+ (int32_t *) trav->value->data,
+ trav->value->len / 4);
+ break;
+
default:
gf_log (this->name, GF_LOG_ERROR,
"Unknown xattrop type (%d) on %s. Please send "