From 1bb9bb67022cd5c4eed127b920a6c2f5dd00b3e1 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Fri, 13 Oct 2017 23:01:43 -0400 Subject: fcopy fix: remove warnings for private-bin python* on Arch Linux --- src/fcopy/main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 assert(destname); mode &= 07777; + // don't copy the file if it is already there + struct stat s; + if (stat(destname, &s) == 0) + return; + // open source int src = open(srcname, O_RDONLY); if (src < 0) { @@ -113,10 +118,18 @@ void copy_link(const char *target, const char *linkpath, mode_t mode, uid_t uid, (void) mode; (void) uid; (void) gid; + + // if the link is already there, don't create it + struct stat s; + if (stat(linkpath, &s) == 0) + return; + char *rp = realpath(target, NULL); if (rp) { - if (symlink(rp, linkpath) == -1) + if (symlink(rp, linkpath) == -1) { + free(rp); goto errout; + } free(rp); } else @@ -129,6 +142,7 @@ errout: } + static int first = 1; static int fs_copydir(const char *infname, const struct stat *st, int ftype, struct FTW *sftw) { (void) st; -- cgit v1.2.3-54-g00ecf