diff options
Diffstat (limited to 'toys')
-rw-r--r-- | toys/posix/cp.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c index e37b360d..681af025 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -252,7 +252,8 @@ static int cp_node(struct dirtree *try) // make symlink, or make block/char/fifo/socket if (S_ISLNK(try->st.st_mode) ? ((i = readlinkat0(tfd, try->name, toybuf, sizeof(toybuf))) && - !symlinkat(toybuf, cfd, catch)) + ((!unlinkat(cfd, catch, 0) || ENOENT == errno) && + !symlinkat(toybuf, cfd, catch))) : !mknodat(cfd, catch, try->st.st_mode, try->st.st_rdev)) { err = 0; |