|
1 Patch needed for xattr to build properly on Solaris, with Studio compilers. |
|
2 |
|
3 Merged as of 0.7.6. |
|
4 |
|
5 diff --git a/xattr/lib.py b/xattr/lib.py |
|
6 index 0466d30..390c333 100644 |
|
7 --- a/xattr/lib.py |
|
8 +++ b/xattr/lib.py |
|
9 @@ -29,12 +29,13 @@ lib = ffi.verify(""" |
|
10 #include "Python.h" |
|
11 #ifdef __FreeBSD__ |
|
12 #include <sys/extattr.h> |
|
13 -#elif defined(__SUN__) || defined(__sun__) || defined(sun) |
|
14 +#elif defined(__SUN__) || defined(__sun__) || defined(__sun) |
|
15 #include <sys/types.h> |
|
16 #include <sys/stat.h> |
|
17 #include <fcntl.h> |
|
18 #include <unistd.h> |
|
19 #include <dirent.h> |
|
20 +#include <alloca.h> |
|
21 #else |
|
22 #include <sys/xattr.h> |
|
23 #endif |
|
24 @@ -59,7 +60,7 @@ static void convert_bsd_list(char *namebuf, size_t size) |
|
25 while(offset < size) { |
|
26 int length = (int) namebuf[offset]; |
|
27 memmove(namebuf+offset, namebuf+offset+1, length); |
|
28 - namebuf[offset+length] = '\0'; |
|
29 + namebuf[offset+length] = '\\0'; |
|
30 offset += length+1; |
|
31 } |
|
32 } |
|
33 @@ -260,7 +261,7 @@ static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options) |
|
34 return rv; |
|
35 } |
|
36 |
|
37 -#elif defined(__SUN__) || defined(__sun__) || defined(sun) |
|
38 +#elif defined(__SUN__) || defined(__sun__) || defined(__sun) |
|
39 |
|
40 /* Solaris 9 and later compatibility API */ |
|
41 #define XATTR_XATTR_NOFOLLOW 0x0001 |
|
42 @@ -268,6 +269,9 @@ static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options) |
|
43 #define XATTR_XATTR_REPLACE 0x0004 |
|
44 #define XATTR_XATTR_NOSECURITY 0x0008 |
|
45 |
|
46 +#define XATTR_CREATE 0x1 |
|
47 +#define XATTR_REPLACE 0x2 |
|
48 + |
|
49 #ifndef u_int32_t |
|
50 #define u_int32_t uint32_t |
|
51 #endif |
|
52 @@ -429,7 +433,7 @@ static ssize_t xattr_xflistxattr(int xfd, char *namebuf, size_t size, int option |
|
53 snprintf((char *)(namebuf + nsize), esize + 1, |
|
54 entry->d_name); |
|
55 } |
|
56 - nsize += esize + 1; /* +1 for \0 */ |
|
57 + nsize += esize + 1; /* +1 for \\0 */ |
|
58 } |
|
59 closedir(dirp); |
|
60 return nsize; |
|
61 @@ -438,7 +442,7 @@ static ssize_t xattr_flistxattr(int fd, char *namebuf, size_t size, int options) |
|
62 { |
|
63 int xfd; |
|
64 |
|
65 - xfd = openat(fd, ".", O_RDONLY); |
|
66 + xfd = openat(fd, ".", O_RDONLY | O_XATTR); |
|
67 return xattr_xflistxattr(xfd, namebuf, size, options); |
|
68 } |
|
69 |
|
70 @@ -716,7 +720,7 @@ def _flistxattr(fd, options=0): |
|
71 flistxattr(fd, options=0) -> str |
|
72 """ |
|
73 res = lib.xattr_flistxattr(fd, ffi.NULL, 0, options) |
|
74 - if res == 1: |
|
75 + if res == -1: |
|
76 raise error() |
|
77 buf = ffi.new("char[]", res) |
|
78 res = lib.xattr_flistxattr(fd, buf, res, options) |