diff options
author | peter <peter@FreeBSD.org> | 2000-07-29 22:16:55 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2000-07-29 22:16:55 +0000 |
commit | d2e30b873135a6861b615104186773031877cda7 (patch) | |
tree | 8b464d4482101cf6618bbf603a5e60e576ffb745 /bin | |
parent | 16df36990f3116869fa8606fb3df4d2b8be845d6 (diff) | |
download | FreeBSD-src-d2e30b873135a6861b615104186773031877cda7.zip FreeBSD-src-d2e30b873135a6861b615104186773031877cda7.tar.gz |
Optimize out no-op chmod() syscalls.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/chmod/chmod.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/chmod/chmod.c b/bin/chmod/chmod.c index a8ec2d9..395bee1 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 { |