Blame SOURCES/rsync-3.2.3-lchmod.patch

7f5a2e
diff --git a/syscall.c b/syscall.c
7f5a2e
index b9c3b4ef..11d10e4a 100644
7f5a2e
--- a/syscall.c
7f5a2e
+++ b/syscall.c
7f5a2e
@@ -227,27 +227,35 @@ int do_open(const char *pathname, int flags, mode_t mode)
7f5a2e
 #ifdef HAVE_CHMOD
7f5a2e
 int do_chmod(const char *path, mode_t mode)
7f5a2e
 {
7f5a2e
+	static int switch_step = 0;
7f5a2e
 	int code;
7f5a2e
 	if (dry_run) return 0;
7f5a2e
 	RETURN_ERROR_IF_RO_OR_LO;
7f5a2e
+	switch (switch_step) {
7f5a2e
 #ifdef HAVE_LCHMOD
7f5a2e
-	code = lchmod(path, mode & CHMOD_BITS);
7f5a2e
-#else
7f5a2e
-	if (S_ISLNK(mode)) {
7f5a2e
+#include "case_N.h"
7f5a2e
+		if ((code = lchmod(path, mode & CHMOD_BITS)) == 0 || errno != ENOTSUP)
7f5a2e
+			break;
7f5a2e
+		switch_step++;
7f5a2e
+#endif
7f5a2e
+
7f5a2e
+#include "case_N.h"
7f5a2e
+		if (S_ISLNK(mode)) {
7f5a2e
 # if defined HAVE_SETATTRLIST
7f5a2e
-		struct attrlist attrList;
7f5a2e
-		uint32_t m = mode & CHMOD_BITS; /* manpage is wrong: not mode_t! */
7f5a2e
+			struct attrlist attrList;
7f5a2e
+			uint32_t m = mode & CHMOD_BITS; /* manpage is wrong: not mode_t! */
7f5a2e
 
7f5a2e
-		memset(&attrList, 0, sizeof attrList);
7f5a2e
-		attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
7f5a2e
-		attrList.commonattr = ATTR_CMN_ACCESSMASK;
7f5a2e
-		code = setattrlist(path, &attrList, &m, sizeof m, FSOPT_NOFOLLOW);
7f5a2e
+			memset(&attrList, 0, sizeof attrList);
7f5a2e
+			attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
7f5a2e
+			attrList.commonattr = ATTR_CMN_ACCESSMASK;
7f5a2e
+			code = setattrlist(path, &attrList, &m, sizeof m, FSOPT_NOFOLLOW);
7f5a2e
 # else
7f5a2e
-		code = 1;
7f5a2e
+			code = 1;
7f5a2e
 # endif
7f5a2e
-	} else
7f5a2e
-		code = chmod(path, mode & CHMOD_BITS); /* DISCOURAGED FUNCTION */
7f5a2e
-#endif /* !HAVE_LCHMOD */
7f5a2e
+		} else
7f5a2e
+			code = chmod(path, mode & CHMOD_BITS); /* DISCOURAGED FUNCTION */
7f5a2e
+		break;
7f5a2e
+	}
7f5a2e
 	if (code != 0 && (preserve_perms || preserve_executability))
7f5a2e
 		return code;
7f5a2e
 	return 0;