summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-07-03 20:57:31 +0000
committerJim Meyering <jim@meyering.net>1998-07-03 20:57:31 +0000
commit698a43f3632f8fd67f8bd3df880f50cfdce4eaab (patch)
tree1ba652469cdbe8abe9eb253ceed939177ee7c412
parentdef9c2bf0b13346d3f316d0e73f3ce4c62262c9d (diff)
downloadcoreutils-698a43f3632f8fd67f8bd3df880f50cfdce4eaab.tar.xz
(SAME_INODE): New macro.
Use it to replace open-coded equivalents.
-rw-r--r--src/copy.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/copy.c b/src/copy.c
index e3aa5ae85..e161a3950 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -41,6 +41,10 @@
or if the target system doesn't support file ownership. */ \
&& ((errno != EPERM && errno != EINVAL) || x->myeuid == 0))
+#define SAME_INODE(Sb_1, Sb_2) \
+ ((Sb_1).st_ino == (Sb_2).st_ino \
+ && (Sb_1).st_dev == (Sb_2).st_dev)
+
struct dir_list
{
struct dir_list *parent;
@@ -428,8 +432,7 @@ copy_internal (const char *src_path, const char *dst_path,
/* The destination file exists already. */
- same = (src_sb.st_ino == dst_sb.st_ino
- && src_sb.st_dev == dst_sb.st_dev);
+ same = (SAME_INODE (src_sb, dst_sb));
#ifdef S_ISLNK
/* If we're preserving symlinks (--no-dereference) and either
@@ -451,8 +454,7 @@ copy_internal (const char *src_path, const char *dst_path,
struct stat src2_sb;
if (stat (dst_path, &dst2_sb) == 0
&& stat (src_path, &src2_sb) == 0
- && src2_sb.st_ino == dst2_sb.st_ino
- && src2_sb.st_dev == dst2_sb.st_dev)
+ && SAME_INODE (src2_sb, dst2_sb))
{
same = 1;
}
@@ -678,8 +680,7 @@ copy_internal (const char *src_path, const char *dst_path,
not_current_dir = (!STREQ (".", dst_parent)
&& stat (".", &dot_sb) == 0
&& stat (dst_parent, &dst_parent_sb) == 0
- && (dot_sb.st_dev != dst_parent_sb.st_dev
- || dot_sb.st_ino != dst_parent_sb.st_ino));
+ && !SAME_INODE (dot_sb, dst_parent_sb));
free (dst_parent);
if (not_current_dir)