1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
$NetBSD: patch-ad,v 1.1 2005/10/31 05:11:41 minskim Exp $
--- aa.c.orig 2005-07-31 15:20:23.000000000 -0700
+++ aa.c
@@ -48,6 +48,9 @@
#include <sys/endian.h>
#endif
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#endif
#include <ctype.h>
@@ -534,7 +537,7 @@ readfile(aa_t *aa, aaent_t *aep, char *n
#ifdef HAVE_SETXATTR
/* set the external attributes */
static int
-ext_attr_set(aa_t *aa, aaent_t *aep, char *name);
+ext_attr_set(aa_t *aa, aaent_t *aep, char *name)
{
char *ap;
char *eq;
@@ -549,7 +552,11 @@ ext_attr_set(aa_t *aa, aaent_t *aep, cha
warn("WARNING: malformed attribute (%s) for \"%s\"", ap, name);
} else {
*eq = 0x0;
+#ifdef __APPLE__
+ if (setxattr(name, ap, eq + 1, (int)(nl - eq) - 1, 0, XATTR_CREATE) < 0) {
+#else
if (setxattr(name, ap, eq + 1, (int)(nl - eq) - 1, XATTR_CREATE) < 0) {
+#endif
warn("WARNING: can't setxattr (%s) for \"%s\"", ap, name);
}
*eq = '=';
@@ -927,9 +934,17 @@ ext_attr_get(aa_t *aa, aaent_t *aep, cha
int cc;
int vc;
+#ifdef __APPLE__
+ if ((cc = listxattr(path, keys, sizeof(keys), 0)) > 0) {
+#else
if ((cc = listxattr(path, keys, sizeof(keys))) > 0) {
+#endif
for (ac = 0, key = keys ; (int)(key - keys) < cc ; key += strlen(key)) {
+#ifdef __APPLE__
+ if ((vc = getxattr(path, key, val, sizeof(val), 0, 0)) < 0) {
+#else
if ((vc = getxattr(path, key, val, sizeof(val))) < 0) {
+#endif
warnx("file \"%s\" attribute \"%s\" is too long, skipping...", path, key);
} else {
ac += snprintf(&attrs[ac], sizeof(attrs) - ac, "%s=%s\n", key, val);
|