Moved the xattr-skipping on device/special files out of the
[rsync/rsync-patches.git] / osx-xattr-nodev.diff
CommitLineData
5ae2d14e
WD
1This patch makes the xattr functions skip devices and special files,
2because OS X returns the wrong errno when getting/setting xattrs on
3them (it returns EPERM instead of ENOTSUP).
4
5To use this patch, run these commands for a successful build:
6
7 patch -p1 <patches/osx-xattr-nodev.diff
8 ./configure (optional if already run)
9 make
10
11diff --git a/flist.c b/flist.c
12--- a/flist.c
13+++ b/flist.c
14@@ -1342,6 +1373,7 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
15 #endif
16 #ifdef SUPPORT_XATTRS
17 if (preserve_xattrs) {
18+ sx.st.st_mode = file->mode;
19 sx.xattr = NULL;
20 if (get_xattr(fname, &sx) < 0)
21 return NULL;
22diff --git a/xattrs.c b/xattrs.c
23--- a/xattrs.c
24+++ b/xattrs.c
25@@ -281,6 +281,10 @@ int get_xattr(const char *fname, stat_x *sxp)
26 {
27 sxp->xattr = new(item_list);
28 *sxp->xattr = empty_xattr;
29+
30+ if (IS_SPECIAL(sxp->st.st_mode) || IS_DEVICE(sxp->st.st_mode))
31+ return 0;
32+
33 if (rsync_xal_get(fname, sxp->xattr) < 0) {
34 free_xattr(sxp);
35 return -1;
36@@ -856,6 +860,11 @@ int set_xattr(const char *fname, const struct file_struct *file,
37 return -1;
38 }
39
40+ if (IS_SPECIAL(sxp->st.st_mode) || IS_DEVICE(sxp->st.st_mode)) {
41+ errno = ENOTSUP;
42+ return -1;
43+ }
44+
45 ndx = F_XATTR(file);
46 return rsync_xal_set(fname, lst + ndx, fnamecmp, sxp);
47 }