diff options
author | Jim Meyering <jim@meyering.net> | 2000-09-04 14:49:30 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-09-04 14:49:30 +0000 |
commit | b5545e03db4846ec4aee9867c8251dfa9455f158 (patch) | |
tree | 7c261e3eaf35ccc0e988570e1454042194aa5430 /src | |
parent | 4dfe280c99dd85870dae6a7c13d984dfeda1e4fe (diff) | |
download | coreutils-b5545e03db4846ec4aee9867c8251dfa9455f158.tar.xz |
(same_file_ok): Hoist a test.
Diffstat (limited to 'src')
-rw-r--r-- | src/copy.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/copy.c b/src/copy.c index 8b238680a..cd9b7ec1a 100644 --- a/src/copy.c +++ b/src/copy.c @@ -462,7 +462,8 @@ same_file_ok (const char *src_path, const struct stat *src_sb, } #if 0 - /* FIXME: remove or use */ + /* FIXME: use or remove */ + /* If we're making a backup, we'll detect the problem case in copy_reg because SRC_PATH will no longer exist. Allowing the test to be deferred lets cp do some useful things. @@ -473,7 +474,6 @@ same_file_ok (const char *src_path, const struct stat *src_sb, || S_ISLNK (dst_sb_link->st_mode)) return 1; - /* FIXME: explain */ if (x->dereference != DEREF_NEVER) return 1; #endif @@ -503,6 +503,13 @@ same_file_ok (const char *src_path, const struct stat *src_sb, } } + /* It's ok to remove a destination symlink. But that works only when we + unlink before opening the destination and when they're on the same + partition. */ + if (x->unlink_dest_before_opening + && S_ISLNK (dst_sb_link->st_mode)) + return src_sb_link->st_dev == src_sb_link->st_dev; + if (x->xstat == lstat) { static struct stat tmp_dst_sb; @@ -527,14 +534,6 @@ same_file_ok (const char *src_path, const struct stat *src_sb, dst_sb_no_link = dst_sb; } - /* FIXME: hoist this to precede if/else? */ - /* It's ok to remove a destination symlink. But that works only when we - unlink before opening the destination and when they're on the same - partition. */ - if (x->unlink_dest_before_opening - && S_ISLNK (dst_sb_link->st_mode)) - return src_sb_link->st_dev == src_sb_link->st_dev; - return 0; } |