diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fcopy/main.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/fcopy/main.c b/src/fcopy/main.c index e7b4ffa8a..cbb551125 100644 --- a/src/fcopy/main.c +++ b/src/fcopy/main.c | |||
@@ -41,6 +41,11 @@ static void copy_file(const char *srcname, const char *destname, mode_t mode, ui | |||
41 | assert(destname); | 41 | assert(destname); |
42 | mode &= 07777; | 42 | mode &= 07777; |
43 | 43 | ||
44 | // don't copy the file if it is already there | ||
45 | struct stat s; | ||
46 | if (stat(destname, &s) == 0) | ||
47 | return; | ||
48 | |||
44 | // open source | 49 | // open source |
45 | int src = open(srcname, O_RDONLY); | 50 | int src = open(srcname, O_RDONLY); |
46 | if (src < 0) { | 51 | if (src < 0) { |
@@ -113,10 +118,18 @@ void copy_link(const char *target, const char *linkpath, mode_t mode, uid_t uid, | |||
113 | (void) mode; | 118 | (void) mode; |
114 | (void) uid; | 119 | (void) uid; |
115 | (void) gid; | 120 | (void) gid; |
121 | |||
122 | // if the link is already there, don't create it | ||
123 | struct stat s; | ||
124 | if (stat(linkpath, &s) == 0) | ||
125 | return; | ||
126 | |||
116 | char *rp = realpath(target, NULL); | 127 | char *rp = realpath(target, NULL); |
117 | if (rp) { | 128 | if (rp) { |
118 | if (symlink(rp, linkpath) == -1) | 129 | if (symlink(rp, linkpath) == -1) { |
130 | free(rp); | ||
119 | goto errout; | 131 | goto errout; |
132 | } | ||
120 | free(rp); | 133 | free(rp); |
121 | } | 134 | } |
122 | else | 135 | else |
@@ -129,6 +142,7 @@ errout: | |||
129 | } | 142 | } |
130 | 143 | ||
131 | 144 | ||
145 | |||
132 | static int first = 1; | 146 | static int first = 1; |
133 | static int fs_copydir(const char *infname, const struct stat *st, int ftype, struct FTW *sftw) { | 147 | static int fs_copydir(const char *infname, const struct stat *st, int ftype, struct FTW *sftw) { |
134 | (void) st; | 148 | (void) st; |