]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Avoid an unnecessary `stat' when using --dereference.
authorJim Meyering <jim@meyering.net>
Sun, 31 Dec 2000 08:29:17 +0000 (08:29 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 31 Dec 2000 08:29:17 +0000 (08:29 +0000)
(same_file_ok): Use stat only if lstat reported that
the file was a symbolic link.

src/copy.c

index a875892ed3622fde3f997521be7dca20de44e8cd..f1d527cb1839b7388bae7d1b465df9118bd88ddf 100644 (file)
@@ -512,9 +512,17 @@ same_file_ok (const char *src_path, const struct stat *src_sb,
 
   if (x->xstat == lstat)
     {
-      if (stat (dst_path, &tmp_dst_sb)
-         || stat (src_path, &tmp_src_sb)
-         || ! SAME_INODE (tmp_src_sb, tmp_dst_sb))
+      if ( ! S_ISLNK (src_sb_link->st_mode))
+       tmp_src_sb = *src_sb_link;
+      else if (stat (src_path, &tmp_src_sb))
+       return 1;
+
+      if ( ! S_ISLNK (dst_sb_link->st_mode))
+       tmp_dst_sb = *dst_sb_link;
+      else if (stat (dst_path, &tmp_dst_sb))
+       return 1;
+
+      if ( ! SAME_INODE (tmp_src_sb, tmp_dst_sb))
        return 1;
 
       /* FIXME: shouldn't this be testing whether we're making symlinks?  */