From bf7b0b60b1710b19561a2f7c79c3be4d09842b2c Mon Sep 17 00:00:00 2001 From: Iblis Lin Date: Mon, 31 Jul 2017 11:25:07 +0800 Subject: posix: fix incorrect xattr list handling on FreeBSD Change-Id: I5be157259f0b665640aaa1eda68063bb19fd7b3d BUG: 1484246 Signed-off-by: Pellaeon Lin Signed-off-by: Jiffin Tony Thottan Reviewed-on: https://review.gluster.org/17917 Smoke: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Niels de Vos CentOS-regression: Gluster Build System --- libglusterfs/src/compat.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'libglusterfs/src/compat.c') diff --git a/libglusterfs/src/compat.c b/libglusterfs/src/compat.c index 621ff5f54c9..a27fe20ce64 100644 --- a/libglusterfs/src/compat.c +++ b/libglusterfs/src/compat.c @@ -535,6 +535,34 @@ out: #endif /* GF_SOLARIS_HOST_OS */ +#ifdef GF_BSD_HOST_OS +void +gf_extattr_list_reshape(char *bsd_list, ssize_t size) +{ + /* + * the format of bsd_list is + * attrattr... + * we try to reformat it as Linux's + * attr<\0>attr<\0>... + * */ + if (NULL == bsd_list || size <= 0) + return; + + size_t i = 0, j; + + while (i < size) { + size_t attr_len = bsd_list[i]; + + for (j = i; j < i+attr_len; ++j) + bsd_list[j] = bsd_list[j+1]; + bsd_list[j] = '\0'; + + i += attr_len + 1; + gf_msg_debug ("syscall", 0, "syscall debug: %lu", attr_len); + } +} +#endif /* GF_BSD_HOST_OS */ + #ifndef HAVE_STRNLEN size_t strnlen(const char *string, size_t maxlen) -- cgit