Avoid reading ACL/xattr info on filetypes not being copied.
[rsync/rsync.git] / xattrs.c
index df1a2a1..3a7cb25 100644 (file)
--- a/xattrs.c
+++ b/xattrs.c
@@ -33,6 +33,9 @@ extern int am_generator;
 extern int read_only;
 extern int list_only;
 extern int preserve_xattrs;
 extern int read_only;
 extern int list_only;
 extern int preserve_xattrs;
+extern int preserve_links;
+extern int preserve_devices;
+extern int preserve_specials;
 extern int checksum_seed;
 
 #define RSYNC_XAL_INITIAL 5
 extern int checksum_seed;
 
 #define RSYNC_XAL_INITIAL 5
@@ -285,18 +288,24 @@ int get_xattr(const char *fname, stat_x *sxp)
        sxp->xattr = new(item_list);
        *sxp->xattr = empty_xattr;
 
        sxp->xattr = new(item_list);
        *sxp->xattr = empty_xattr;
 
-#ifdef NO_SPECIAL_XATTRS
-       if (IS_SPECIAL(sxp->st.st_mode))
-               return 0;
+       if (S_ISREG(sxp->st.st_mode) || S_ISDIR(sxp->st.st_mode)) {
+               /* Everyone supports this. */
+       } else if (S_ISLNK(sxp->st.st_mode)) {
+#ifndef NO_SYMLINK_XATTRS
+               if (!preserve_links)
 #endif
 #endif
-#ifdef NO_DEVICE_XATTRS
-       if (IS_DEVICE(sxp->st.st_mode))
-               return 0;
+                       return 0;
+       } else if (IS_SPECIAL(sxp->st.st_mode)) {
+#ifndef NO_SPECIAL_XATTRS
+               if (!preserve_specials)
 #endif
 #endif
-#ifdef NO_SYMLINK_XATTRS
-       if (S_ISLNK(sxp->st.st_mode))
-               return 0;
+                       return 0;
+       } else if (IS_DEVICE(sxp->st.st_mode)) {
+#ifndef NO_DEVICE_XATTRS
+               if (!preserve_devices)
 #endif
 #endif
+                       return 0;
+       }
 
        if (rsync_xal_get(fname, sxp->xattr) < 0) {
                free_xattr(sxp);
 
        if (rsync_xal_get(fname, sxp->xattr) < 0) {
                free_xattr(sxp);