[Gluster-devel] [PATCH BUG:361 3/3] OS X: getxattr() takes two additional arguments on Mac OS X

noah williamsson noah.williamsson at gmail.com
Mon Sep 27 20:29:13 UTC 2010


2010/9/27 Amar Tumballi <amar at gluster.com>:
> Even here, how about just calling 'sys_getxattr()' instead of getxattr()?
>
> Ref: 'libglusterfs/src/syscall.c'
>
> My apologies, I should have kept in mind about compatibility of posix calls
> while writing these lines..
>

Thanks, I didn't know about libglusterfs/src/syscall.c.

Below is a new patch, compile tested on Linux and verified against man
pages on Mac OS X and FreeBSD.


Signed-off-by: Noah Williamsson <noah.williamsson at gmail.com>
---
 libglusterfs/src/syscall.c                   |   24 ++++++++++++++++++++++++
 xlators/mgmt/glusterd/src/glusterd-handler.c |    4 ++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c
index e0d0b13..1e83924 100644
--- a/libglusterfs/src/syscall.c
+++ b/libglusterfs/src/syscall.c
@@ -307,6 +307,30 @@ sys_llistxattr (const char *path, char *list, size_t size)


 ssize_t
+sys_getxattr (const char *path, const char *name, void *value, size_t size)
+{
+
+#ifdef GF_LINUX_HOST_OS
+        return getxattr (path, name, value, size);
+#endif
+
+#ifdef GF_BSD_HOST_OS
+        return extattr_get_file (path, EXTATTR_NAMESPACE_USER, name, value,
+                                 size);
+#endif
+
+#ifdef GF_SOLARIS_HOST_OS
+        return solaris_getxattr (path, name, value, size);
+#endif
+
+#ifdef GF_DARWIN_HOST_OS
+        return getxattr (path, name, value, size, 0, 0);
+#endif
+
+}
+
+
+ssize_t
 sys_lgetxattr (const char *path, const char *name, void *value, size_t size)
 {

diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c
b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 0da46c5..6fc32b8 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -730,7 +730,7 @@ glusterd_check_and_rebalance (glusterd_volinfo_t
*volinfo, char *dir)

                 if (S_ISDIR (stbuf.st_mode)) {
                         /* Fix the layout of the directory */
-                        getxattr (full_path, "trusted.distribute.fix.layout",
+                        sys_getxattr (full_path,
"trusted.distribute.fix.layout",
                                   &value, 128);
                         continue;
                 }
@@ -859,7 +859,7 @@ glusterd_defrag_start (void *data)
         }

         /* Fix the root ('/') first */
-        getxattr (defrag->mount, "trusted.distribute.fix.layout", &value, 128);
+        sys_getxattr (defrag->mount, "trusted.distribute.fix.layout",
&value, 128);

         ret = glusterd_check_and_rebalance (volinfo, defrag->mount);

-- 
1.7.0.4


-- 
Best regards,
Noah Williamsson




More information about the Gluster-devel mailing list