diff options
author | Jim Meyering <jim@meyering.net> | 2001-05-12 08:04:44 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2001-05-12 08:04:44 +0000 |
commit | ba94ef5b1b58fad68d0c793bcd8b3bf89fb2dc53 (patch) | |
tree | 06f05c594688cb05f124e6a1d4cd8fe466a11c74 /src | |
parent | 1af93e3d71c952f5c464f6001943d50a766dd67b (diff) | |
download | coreutils-ba94ef5b1b58fad68d0c793bcd8b3bf89fb2dc53.tar.xz |
(mode_changed, change_file_mode):
There's no need to invoke both lstat and stat here, so call just
one of the two functions.
Diffstat (limited to 'src')
-rw-r--r-- | src/chmod.c | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/src/chmod.c b/src/chmod.c index dd3c42dcd..7605ca114 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -100,23 +100,13 @@ mode_changed (const char *file, mode_t old_mode) { struct stat new_stats; - if (lstat (file, &new_stats)) + if (stat (file, &new_stats)) { if (force_silent == 0) error (0, errno, _("getting new attributes of %s"), quote (file)); return 0; } -#ifdef S_ISLNK - if (S_ISLNK (new_stats.st_mode) - && stat (file, &new_stats)) - { - if (force_silent == 0) - error (0, errno, _("getting new attributes of %s"), quote (file)); - return 0; - } -#endif - return old_mode != new_stats.st_mode; } @@ -165,25 +155,16 @@ change_file_mode (const char *file, const struct mode_change *changes, int fail; int saved_errno; - if (lstat (file, &file_stats)) + if (deref_symlink ? stat (file, &file_stats) : lstat (file, &file_stats)) { if (force_silent == 0) error (0, errno, _("getting attributes of %s"), quote (file)); return 1; } + #ifdef S_ISLNK if (S_ISLNK (file_stats.st_mode)) - { - if (! deref_symlink) - return 0; - else - if (stat (file, &file_stats)) - { - if (force_silent == 0) - error (0, errno, _("getting attributes of %s"), quote (file)); - return 1; - } - } + return 0; #endif newmode = mode_adjust (file_stats.st_mode, changes); |