From: Wayne Davison Date: Sun, 10 Oct 2021 16:20:13 +0000 (-0700) Subject: Change do_lchmod() back to a swtich with some better ENOTSUP & ENOSYS logic. X-Git-Tag: v3.2.4pre1~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0d1b48893ab764f2c632abf0c94ef8d39312dfd0;p=thirdparty%2Frsync.git Change do_lchmod() back to a swtich with some better ENOTSUP & ENOSYS logic. --- diff --git a/syscall.c b/syscall.c index abb00575..048cbd3b 100644 --- a/syscall.c +++ b/syscall.c @@ -231,13 +231,22 @@ int do_open(const char *pathname, int flags, mode_t mode) #ifdef HAVE_CHMOD int do_chmod(const char *path, mode_t mode) { + static int switch_step = 0; int code; if (dry_run) return 0; RETURN_ERROR_IF_RO_OR_LO; + switch (switch_step) { #ifdef HAVE_LCHMOD - if ((code = lchmod(path, mode & CHMOD_BITS)) < 0 && errno == ENOTSUP) +#include "case_N.h" + if ((code = lchmod(path, mode & CHMOD_BITS)) == 0) + break; + if (errno == ENOSYS) + switch_step++; + else if (errno != ENOTSUP) + break; #endif - { + +#include "case_N.h" if (S_ISLNK(mode)) { # if defined HAVE_SETATTRLIST struct attrlist attrList; @@ -252,6 +261,7 @@ int do_chmod(const char *path, mode_t mode) # endif } else code = chmod(path, mode & CHMOD_BITS); /* DISCOURAGED FUNCTION */ + break; } if (code != 0 && (preserve_perms || preserve_executability)) return code;