Patch needed for xattr to build properly on Solaris, with Studio compilers.
Merged as of 0.7.6.
diff --git a/xattr/lib.py b/xattr/lib.py
index 0466d30..390c333 100644
--- a/xattr/lib.py
+++ b/xattr/lib.py
@@ -29,12 +29,13 @@ lib = ffi.verify("""
#include "Python.h"
#ifdef __FreeBSD__
#include <sys/extattr.h>
-#elif defined(__SUN__) || defined(__sun__) || defined(sun)
+#elif defined(__SUN__) || defined(__sun__) || defined(__sun)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
+#include <alloca.h>
#else
#include <sys/xattr.h>
#endif
@@ -59,7 +60,7 @@ static void convert_bsd_list(char *namebuf, size_t size)
while(offset < size) {
int length = (int) namebuf[offset];
memmove(namebuf+offset, namebuf+offset+1, length);
- namebuf[offset+length] = '\0';
+ namebuf[offset+length] = '\\0';
offset += length+1;
}
}
@@ -260,7 +261,7 @@ static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options)
return rv;
}
-#elif defined(__SUN__) || defined(__sun__) || defined(sun)
+#elif defined(__SUN__) || defined(__sun__) || defined(__sun)
/* Solaris 9 and later compatibility API */
#define XATTR_XATTR_NOFOLLOW 0x0001
@@ -268,6 +269,9 @@ static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options)
#define XATTR_XATTR_REPLACE 0x0004
#define XATTR_XATTR_NOSECURITY 0x0008
+#define XATTR_CREATE 0x1
+#define XATTR_REPLACE 0x2
+
#ifndef u_int32_t
#define u_int32_t uint32_t
#endif
@@ -429,7 +433,7 @@ static ssize_t xattr_xflistxattr(int xfd, char *namebuf, size_t size, int option
snprintf((char *)(namebuf + nsize), esize + 1,
entry->d_name);
}
- nsize += esize + 1; /* +1 for \0 */
+ nsize += esize + 1; /* +1 for \\0 */
}
closedir(dirp);
return nsize;
@@ -438,7 +442,7 @@ static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options)
{
int xfd;
- xfd = openat(fd, ".", O_RDONLY);
+ xfd = openat(fd, ".", O_RDONLY | O_XATTR);
return xattr_xflistxattr(xfd, namebuf, size, options);
}
@@ -716,7 +720,7 @@ def _flistxattr(fd, options=0):
flistxattr(fd, options=0) -> str
"""
res = lib.xattr_flistxattr(fd, ffi.NULL, 0, options)
- if res == 1:
+ if res == -1:
raise error()
buf = ffi.new("char[]", res)
res = lib.xattr_flistxattr(fd, buf, res, options)