cp: Add tests for hard link case.MFC after: 1 weekSponsored by: Klara, Inc.Reviewed by: kevansDifferential Revision: https://reviews.freebsd.org/D43052(cherry picked from commit 1fead66b64822f
cp: Add tests for hard link case.MFC after: 1 weekSponsored by: Klara, Inc.Reviewed by: kevansDifferential Revision: https://reviews.freebsd.org/D43052(cherry picked from commit 1fead66b64822f3f8106ad09bef0b9656836fa1a)cp: Add tests for symbolic link case.MFC after: 1 weekSponsored by: Klara, Inc.Reviewed by: kevans, allanjudeDifferential Revision: https://reviews.freebsd.org/D43054(cherry picked from commit d3a8e9b43b4cef5b80e3845dfa8fd1fec6e568f9)cp: Refactor the core logic.Rewrite `copy_file()` so the lflag and sflag are handled as early aspossible instead of constantly checking that they're not set and thenhandling them at the end. This also opens the door to changing thefailure logic at some future point (for instance, we might decide tofall back to copying if `errno` indicates that the file system does notsupport links).MFC after: 1 weekSponsored by: Klara, Inc.Reviewed by: kevans, allanjudeDifferential Revision: https://reviews.freebsd.org/D43055(cherry picked from commit d002316fd7bf0b359ea2f5518f3c10f6ad89a9ac)cp: Split the basic_symlink test case in two.This test case tests two different things: first, that copying a symlinkresults in a file with the same contents as the target of the symlink,rather than a second symlink, and second, that cp will refuse to copy afile to itself, or to a link to itself, or a link to its target. Leavethe first part in basic_symlink, move the second part to a new test casenamed samefile, and slightly expand both cases.MFC after: 1 weekSponsored by: Klara, Inc.Reviewed by: kevansDifferential Revision: https://reviews.freebsd.org/D43062(cherry picked from commit ac56b9d83c75f548667912ffe422be6bd4f5c27e)cp: Move the flags around a bit.- The HLPR flags are grouped together at the beginning because they are the standard flags for programs using FTS. Move the N flag out from among them to its correct place in the sequence.- The Pflag variable isn't used outside main(), but moving it out lets us skip initialization and keeps it with its friends H, L and R.MFC after: 1 weekSponsored by: Klara, Inc.Reviewed by: kevansDifferential Revision: https://reviews.freebsd.org/D43063(cherry picked from commit 0f4467ce444b201468d2268958130f495951ca3c)cp: Further simplify the core logic.If the destination file exists but we decide unlink it, set the dneflag. This means we don't need to re-check the conditions that wouldhave caused us to delete the file when we later need to decide whetherto create or replace it.MFC after: 1 weekSponsored by: Klara, Inc.Reviewed by: kevansDifferential Revision: https://reviews.freebsd.org/D43064(cherry picked from commit 38509270663f336103273878cc8ddc88a225b9d8)cp: Move the -N flag in the manual page.This accidentally got left out of 0f4467ce444b.MFC after: 1 weekSponsored by: Klara, Inc.Reviewed by: kevans, allanjudeDifferential Revision: https://reviews.freebsd.org/D43067(cherry picked from commit 53fc8e190241233d94e183f8a39ec39f2154dfa8)
show more ...
Remove $FreeBSD$: one-line sh patternRemove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDThe SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catchup to that fact and revert to their recommended match of
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDThe SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catchup to that fact and revert to their recommended match of BSD-2-Clause.Discussed with: pfgMFC After: 3 daysSponsored by: Netflix
cp: Adjust the sparse file tests.* The sparsity check was ineffective: it compared the apparent size in bytes to the actual size in blocks. Instead, write a tool that reliably detects sparseness.
cp: Adjust the sparse file tests.* The sparsity check was ineffective: it compared the apparent size in bytes to the actual size in blocks. Instead, write a tool that reliably detects sparseness.* Some of the seq commands were missing an argument.* Based on empirical evidence, 1 MB holes are not necessarily large enough to be preserved by the underlying filesystem. Increase the hole size to 16 MB.MFC after: 1 weekSponsored by: Klara, Inc.Reviewed by: cracauerDifferential Revision: https://reviews.freebsd.org/D38414
cp: Add tests involving sparse files.MFC after: 1 weekSponsored by: Klara, Inc.Reviewed by: markjDifferential Revision: https://reviews.freebsd.org/D38290
cp: fix -R recursion detectionThe correct logic is a lot simpler than the previous iteration. Werecord the base fts_name to avoid having to worry about whether weneeded the root symlink name or
cp: fix -R recursion detectionThe correct logic is a lot simpler than the previous iteration. Werecord the base fts_name to avoid having to worry about whether weneeded the root symlink name or not (as applicable), then we can simplyshift all of that logic to after path translation to make it lessfragile.If we're copying to DNE, then we'll have swapped out the NULL root_statpointer and then attempted to recurse on it. The previously nonexistentdirectory shouldn't exist at all in the new structure, so just back outfrom that tree entirely and move on.The tests have been amended to indicate our expectations better withsubdirectory recursion. If we copy A to A/B, then we expect to copyeverything from A/B/* into A/B/A/B, with exception to the A that wecreate in A/B.Reviewed by: baptSponsored by: Klara, Inc.Differential Revision: https://reviews.freebsd.org/D34655
cp: Make -P work without -R as per POSIXAccording to POSIX, cp should allow the `-P` flag to work whether `-R`is specified or not. Currently, the `-P` option only works along with`-R`.PR: 199
cp: Make -P work without -R as per POSIXAccording to POSIX, cp should allow the `-P` flag to work whether `-R`is specified or not. Currently, the `-P` option only works along with`-R`.PR: 199466Reviewed by: kevansDifferential Revision: https://reviews.freebsd.org/D30012
cp: fix -R with linksThe traversal was previously not properly honoring -H/-L/-P. Notably,we should not have been resolving symlinks encountered during traversalwhen either -H or -P are specifie
cp: fix -R with linksThe traversal was previously not properly honoring -H/-L/-P. Notably,we should not have been resolving symlinks encountered during traversalwhen either -H or -P are specified.Sponsored by: Klara, Inc.Reviewed by: baptDifferential Revision: https://reviews.freebsd.org/D34063
cp: fix some cases with infinite recursionAs noted in the PR, cp -R has some surprising behavior. Typically, whenyou `cp -R foo bar` where both foo and bar exist, foo is cleanly copiedto foo/bar
cp: fix some cases with infinite recursionAs noted in the PR, cp -R has some surprising behavior. Typically, whenyou `cp -R foo bar` where both foo and bar exist, foo is cleanly copiedto foo/bar. When you `cp -R foo foo` (where foo clearly exists), cp(1)goes a little off the rails as it creates foo/foo, then discovers thatand creates foo/foo/foo, so on and so forth, until it eventually fails.POSIX doesn't seem to disallow this behavior, but it isn't very useful.GNU cp(1) will detect the recursion and squash it, but emit a message inthe process that it has done so.This change seemingly follows the GNU behavior, but it currently doesn'twarn about the situation -- the author feels that the final product isabout what one might expect from doing this and thus, doesn't need awarning. The author doesn't feel strongly about this.PR: 235438Reviewed by: baptSponsored by: Klara, Inc.Differential Revision: https://reviews.freebsd.org/D33944
cp: tests: fix weird 20 insertionThis slipped in at the last moment. =(
cp: add some basic testsThere are some tests available in the NetBSD test suite, but we don'tcurrently pass all of those; further investigation will go into that. Fornow, just add a basic test as
cp: add some basic testsThere are some tests available in the NetBSD test suite, but we don'tcurrently pass all of those; further investigation will go into that. Fornow, just add a basic test as well as a test that copies from /dev/null to afile.The /dev/null test confirms that the file gets created if it's empty, thenthat it truncates the file if it's non-empty. This matches some usage thatwas previously employed in the build and was replaced in r366042 by asimpler shell construct.I will also plan on coming back to expand these in due time.MFC after: 1 week