diff options
author | makepost <makepost@firemail.cc> | 2019-06-10 16:29:10 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-06-21 01:52:55 -0500 |
commit | 47a8842e78e790912ec0493a594b0eb1e972ab25 (patch) | |
tree | af038711fb12b449f711a6ad80e439ae7590eb8f /toys/posix | |
parent | 66050d1a023b4fde1ff0e30a31f2b09437605f3d (diff) | |
download | toybox-47a8842e78e790912ec0493a594b0eb1e972ab25.tar.gz |
Fix cp -r dir/. symlink child.
Remove the existing link before trying to re-create, passing the test.
Add -p to the -r test as a regression guard, portage calls cp with both.
Diffstat (limited to 'toys/posix')
-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; |