From: Jim Meyering Date: Sat, 30 Sep 2000 09:39:41 +0000 (+0000) Subject: (change_file_mode): Perform the chmod even if the X-Git-Tag: TEXTUTILS-2_0_8~91 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=f8e66794d9d9eec73710934d012ba8ccf5f0848e;p=thirdparty%2Fcoreutils.git (change_file_mode): Perform the chmod even if the file mode permission bits are the same as those that should be set. Omitting the chmod call would be alright with minimal 1003.1e DS17 ACLs, but eventually there will be other permissions in addition to rwx. E.g., add and delete for directories, and something analogous to NT's take ownership permission. --- diff --git a/src/chmod.c b/src/chmod.c index 2e2cbaad1b..6e6bd903c3 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -137,6 +137,8 @@ change_file_mode (const char *file, const struct mode_change *changes, struct stat file_stats; mode_t newmode; int errors = 0; + int fail; + int saved_errno; if (lstat (file, &file_stats)) { @@ -161,24 +163,19 @@ change_file_mode (const char *file, const struct mode_change *changes, newmode = mode_adjust (file_stats.st_mode, changes); - if (newmode != (file_stats.st_mode & CHMOD_MODE_BITS)) - { - int fail = chmod (file, newmode); - int saved_errno = errno; + fail = chmod (file, newmode); + saved_errno = errno; - if (verbosity == V_high || (verbosity == V_changes_only && !fail)) - describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED)); + if (verbosity == V_high || (verbosity == V_changes_only && !fail)) + describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED)); - if (fail) - { - if (force_silent == 0) - error (0, saved_errno, _("changing permissions of %s"), - quote (file)); - errors = 1; - } + if (fail) + { + if (force_silent == 0) + error (0, saved_errno, _("changing permissions of %s"), + quote (file)); + errors = 1; } - else if (verbosity == V_high) - describe_change (file, newmode, CH_NO_CHANGE_REQUESTED); if (recurse && S_ISDIR (file_stats.st_mode)) errors |= change_dir_mode (file, changes, &file_stats);