summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-09-30 09:39:41 +0000
committerJim Meyering <jim@meyering.net>2000-09-30 09:39:41 +0000
commitf8e66794d9d9eec73710934d012ba8ccf5f0848e (patch)
treeb969045ab51a5fd65fa33227834617373dd440a6 /src
parente2b45cb9fee871284cf3eb52f6152a6727e390ec (diff)
downloadcoreutils-f8e66794d9d9eec73710934d012ba8ccf5f0848e.tar.xz
(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.
Diffstat (limited to 'src')
-rw-r--r--src/chmod.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/chmod.c b/src/chmod.c
index 2e2cbaad1..6e6bd903c 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);