aboutsummaryrefslogtreecommitdiff
path: root/libbb/copy_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/copy_file.c')
-rw-r--r--libbb/copy_file.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index 07564afd0..636fbdc1d 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -172,22 +172,21 @@ int copy_file(const char *source, const char *dest, int flags)
if (ENABLE_FEATURE_PRESERVE_HARDLINKS) {
char *link_name;
- if (!FLAGS_DEREF
- && is_in_ino_dev_hashtable(&source_stat, &link_name)
- ) {
- if (link(link_name, dest) < 0) {
- ovr = retry_overwrite(dest, flags);
- if (ovr <= 0)
- return ovr;
+ if (!FLAGS_DEREF) {
+ link_name = is_in_ino_dev_hashtable(&source_stat);
+ if (link_name) {
if (link(link_name, dest) < 0) {
- bb_perror_msg("cannot create link '%s'", dest);
- return -1;
+ ovr = retry_overwrite(dest, flags);
+ if (ovr <= 0)
+ return ovr;
+ if (link(link_name, dest) < 0) {
+ bb_perror_msg("cannot create link '%s'", dest);
+ return -1;
+ }
}
+ return 0;
}
- return 0;
}
- // TODO: probably is_in_.. and add_to_...
- // can be combined: find_or_add_...
add_to_ino_dev_hashtable(&source_stat, dest);
}