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