freebsd-dev/bin/cp
Kyle Evans f00f8b4fbd cp: fix -R recursion detection
The correct logic is a lot simpler than the previous iteration.  We
record the base fts_name to avoid having to worry about whether we
needed the root symlink name or not (as applicable), then we can simply
shift all of that logic to after path translation to make it less
fragile.

If we're copying to DNE, then we'll have swapped out the NULL root_stat
pointer and then attempted to recurse on it.  The previously nonexistent
directory shouldn't exist at all in the new structure, so just back out
from that tree entirely and move on.

The tests have been amended to indicate our expectations better with
subdirectory recursion.  If we copy A to A/B, then we expect to copy
everything from A/B/* into A/B/A/B, with exception to the A that we
create in A/B.

Reviewed by:	bapt
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D34655
2022-04-05 20:41:00 -05:00
..
tests cp: fix -R recursion detection 2022-04-05 20:41:00 -05:00
cp.1 cp: Make -P work without -R as per POSIX 2022-02-23 12:55:13 -06:00
cp.c cp: fix -R recursion detection 2022-04-05 20:41:00 -05:00
extern.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
Makefile cp: add some basic tests 2020-09-23 03:01:14 +00:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
utils.c cp: fix indentation 2021-01-27 12:18:45 +01:00