From 967ee551040f57259e7d7a930b412c0c57e28e45 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Sat, 5 Jan 2008 22:32:51 +0000 Subject: [PATCH] Fix a bug where we would get a stat failure on dead symlinks. (should have used lstat all over the place) Optimise performance by removing two needless stat calls. svn path=/main/branches/prefix/; revision=9149 --- src/chpathtool.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/chpathtool.c b/src/chpathtool.c index d7af4bfd2..4a2247db9 100644 --- a/src/chpathtool.c +++ b/src/chpathtool.c @@ -293,11 +293,6 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) { return(-1); } /* fix permissions */ - if (stat(src, &s) != 0) { - fprintf(stderr, "cannot stat %s: %s\n", - src, strerror(errno)); - return(-1); - } if (chmod(trg, s.st_mode) != 0) { fprintf(stderr, "failed to set permissions of %s: %s\n", trg, strerror(errno)); @@ -365,12 +360,6 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) { return(-1); } - /* fix permissions */ - if (stat(src, &s) != 0) { - fprintf(stderr, "cannot stat %s: %s\n", - src, strerror(errno)); - return(-1); - } #ifdef HAVE_LCHOWN if (lchown(trg, s.st_uid, s.st_gid) != 0) { fprintf(stderr, "failed to set ownership of %s: %s\n", @@ -388,7 +377,7 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) { closedir(d); /* fix permissions/ownership etc. */ - if (stat(src, &s) != 0) { + if (lstat(src, &s) != 0) { fprintf(stderr, "cannot stat %s: %s\n", src, strerror(errno)); return(-1); } @@ -467,7 +456,7 @@ int main(int argc, char **argv) { return(-1); } - if (stat(argv[o + 1], &file) != 0) { + if (lstat(argv[o + 1], &file) != 0) { fprintf(stderr, "unable to stat %s: %s\n", argv[o + 1], strerror(errno)); return(-1); -- 2.26.2