From 06f0081406da031cdcaf12064fcc988e27990b0f Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Tue, 23 Jan 2007 16:43:01 +0000 Subject: [PATCH] Don't overwrite files that already exist. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2472 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- src/vclone.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/vclone.c b/src/vclone.c index 26d70dd..a9d2b2e 100644 --- a/src/vclone.c +++ b/src/vclone.c @@ -132,7 +132,11 @@ visitDirEntry(struct dirent const *ent) char dst_path_buf[ENSC_PI_APPSZ(dst_path, src_path)]; PathInfo_append(&dst_path, &src_path, dst_path_buf); - if (S_ISREG(f_stat.st_mode) && Unify_isIUnlinkable(src_d_path.d) == unifyBUSY) { + + /* skip files that already exist */ + if (access(dst_path.d, F_OK)!=-1) + res = 0; + else if (S_ISREG(f_stat.st_mode) && Unify_isIUnlinkable(src_d_path.d) == unifyBUSY) { Elink(src_d_path.d, dst_path.d); res = 0; } @@ -141,11 +145,10 @@ visitDirEntry(struct dirent const *ent) perror(ENSC_WRAPPERS_PREFIX "Unify_copy()"); exit(wrapper_exit_code); } - if (S_ISDIR(f_stat.st_mode)) - res = visitDir(dirname, &f_stat); - else - res = 0; + res = 0; } + if (S_ISDIR(f_stat.st_mode)) + res = visitDir(dirname, &f_stat); } return res; -- 1.8.1.5