| 1 | This patch makes the xattr functions skip devices and special files, |
| 2 | because OS X returns the wrong errno when getting/setting xattrs on |
| 3 | them (it returns EPERM instead of ENOTSUP). |
| 4 | |
| 5 | To 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 | |
| 11 | diff --git a/flist.c b/flist.c |
| 12 | --- a/flist.c |
| 13 | +++ b/flist.c |
| 14 | @@ -1408,6 +1408,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 | io_error |= IOERR_GENERAL; |
| 22 | diff --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 | @@ -864,6 +868,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 | } |