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)
172 if (ENABLE_FEATURE_PRESERVE_HARDLINKS) { 172 if (ENABLE_FEATURE_PRESERVE_HARDLINKS) {
173 char *link_name; 173 char *link_name;
174 174
175 if (!FLAGS_DEREF 175 if (!FLAGS_DEREF) {
176 && is_in_ino_dev_hashtable(&source_stat, &link_name) 176 link_name = is_in_ino_dev_hashtable(&source_stat);
177 ) { 177 if (link_name) {
178 if (link(link_name, dest) < 0) {
179 ovr = retry_overwrite(dest, flags);
180 if (ovr <= 0)
181 return ovr;
182 if (link(link_name, dest) < 0) { 178 if (link(link_name, dest) < 0) {
183 bb_perror_msg("cannot create link '%s'", dest); 179 ovr = retry_overwrite(dest, flags);
184 return -1; 180 if (ovr <= 0)
181 return ovr;
182 if (link(link_name, dest) < 0) {
183 bb_perror_msg("cannot create link '%s'", dest);
184 return -1;
185 }
185 } 186 }
187 return 0;
186 } 188 }
187 return 0;
188 } 189 }
189 // TODO: probably is_in_.. and add_to_...
190 // can be combined: find_or_add_...
191 add_to_ino_dev_hashtable(&source_stat, dest); 190 add_to_ino_dev_hashtable(&source_stat, dest);
192 } 191 }
193 192