aboutsummaryrefslogtreecommitdiff
path: root/bin/chmod
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2000-07-29 22:16:55 +0000
committerPeter Wemm <peter@FreeBSD.org>2000-07-29 22:16:55 +0000
commit1510e9e7c66dbda1355ffcb6078cfe9bd340a60f (patch)
tree4737d7977f94286bc830d50429086c3e6d57d86b /bin/chmod
parentdb3c6b6b22c1cd5652ab394469d0bbfe2e3f9e5b (diff)
downloadsrc-1510e9e7c66dbda1355ffcb6078cfe9bd340a60f.tar.gz
src-1510e9e7c66dbda1355ffcb6078cfe9bd340a60f.zip
Optimize out no-op chmod() syscalls.
Notes
Notes: svn path=/head/; revision=64013
Diffstat (limited to 'bin/chmod')
-rw-r--r--bin/chmod/chmod.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/chmod/chmod.c b/bin/chmod/chmod.c
index a8ec2d92dfd7..395bee14c983 100644
--- a/bin/chmod/chmod.c
+++ b/bin/chmod/chmod.c
@@ -72,6 +72,7 @@ main(argc, argv)
int Hflag, Lflag, Pflag, Rflag, ch, fflag, fts_options, hflag, rval;
int vflag;
char *ep, *mode;
+ int newmode;
set = NULL;
omode = 0;
@@ -191,8 +192,10 @@ done: argv += optind;
default:
break;
}
- if (chmod(p->fts_accpath, oct ? omode :
- getmode(set, p->fts_statp->st_mode)) && !fflag) {
+ newmode = oct ? omode : getmode(set, p->fts_statp->st_mode);
+ if ((newmode & ALLPERMS) == (p->fts_statp->st_mode & ALLPERMS))
+ continue;
+ if (chmod(p->fts_accpath, newmode) && !fflag) {
warn("%s", p->fts_path);
rval = 1;
} else {