<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/bin/cp, branch stable/14</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=stable%2F14</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=stable%2F14'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2026-02-15T08:58:34Z</updated>
<entry>
<title>cp: Expect EINTR while copying</title>
<updated>2026-02-15T08:58:34Z</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2026-02-11T16:24:46Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=a9ac7da4c0c3907e21a5634a2338878eb9b33453'/>
<id>urn:sha1:a9ac7da4c0c3907e21a5634a2338878eb9b33453</id>
<content type='text'>
Both copy_file_range() and copy_fallback() can be interrupted before
they have read anything at all, in which case they return -1 and set
errno to EINTR.  If that happens, we should retry, not fail.

PR:		293028
MFC after:	1 week
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D55167

(cherry picked from commit 7aa30669d6e04444b8ad1e4863a6e674fcac4afc)
</content>
</entry>
<entry>
<title>cp: Simplify sameness checks</title>
<updated>2025-10-09T12:20:52Z</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2025-10-07T16:23:39Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=74fa49276487afc174ff3299a034e063cd947399'/>
<id>urn:sha1:74fa49276487afc174ff3299a034e063cd947399</id>
<content type='text'>
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D52926

(cherry picked from commit 95de78614a57733807c28c05125ed0636309d88b)
</content>
</entry>
<entry>
<title>cp: Improve error messages.</title>
<updated>2025-04-20T08:00:29Z</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2025-04-15T17:57:28Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=57235a9b51587a0d4aefe5de96da409239c5ff90'/>
<id>urn:sha1:57235a9b51587a0d4aefe5de96da409239c5ff90</id>
<content type='text'>
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude, markj
Differential Revision:	https://reviews.freebsd.org/D49841

(cherry picked from commit 7622e2d21a22f7af65a7145f91ef34179bb6ee03)
</content>
</entry>
<entry>
<title>cp: Clarify an obscure comment.</title>
<updated>2024-04-24T22:11:56Z</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2024-04-17T01:36:22Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=760720469681a2119b4537a6603337834317383b'/>
<id>urn:sha1:760720469681a2119b4537a6603337834317383b</id>
<content type='text'>
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44805

(cherry picked from commit 64d6925d1901637125f9f739282e72c992657dc8)

cp: Additional sanity check.

Once we've successfully opened the file we've been asked to copy, check
that it's of the same type as FTS told us it was.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude, markj
Differential Revision:	https://reviews.freebsd.org/D44806

(cherry picked from commit 9075d4cfad5b339aabdf8033623a2164898c2786)

cp: Use warnc().

MFC after:	1 week
Sponsored by:	Klara, Inc.

(cherry picked from commit f070188c3ad6b87ee9ce220b21718333d1bd9d52)
</content>
</entry>
<entry>
<title>cp: Remove useless ssize_t cast</title>
<updated>2024-04-18T18:16:57Z</updated>
<author>
<name>Collin Funk</name>
<email>collin.funk1@gmail.com</email>
</author>
<published>2024-02-13T02:52:58Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=74b1a9ccf9a7eab1d4c4c0e4ffc2e901bc040e48'/>
<id>urn:sha1:74b1a9ccf9a7eab1d4c4c0e4ffc2e901bc040e48</id>
<content type='text'>
Both wcount and wresid are ssize_t so this cast is not needed. Just
remove it so the code is easier to read.

Signed-off-by:	Collin Funk &lt;collin.funk1@gmail.com&gt;
Reviewed by:	emaste, zlei
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1116

(cherry picked from commit 8b864151856fbba97fed16b1200248cf9f6f3ccf)
</content>
</entry>
<entry>
<title>cp: Improved conformance when copying directories.</title>
<updated>2024-04-08T10:10:41Z</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2024-04-01T17:28:58Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=2ad8333c653432a187ccea8c6b2de4a35eb6d0ff'/>
<id>urn:sha1:2ad8333c653432a187ccea8c6b2de4a35eb6d0ff</id>
<content type='text'>
* When copying a directory, if the destination exists and is not a
  directory, we would previously emit an error message and exit.  The
  correct behavior according to POSIX is to emit an error message and
  continue without descending further into the source directory.

* When copying a directory, if the destination does not exist and we
  fail to create it, we would previously emit an error message and
  exit.  The correct behavior according to POSIX is to emit an error
  message and continue.  Whether to descend further into the source
  directory is explicitly left unspecified; GNU cp does not, which
  seems to me to be the safer and less surprising option, so let's not
  either.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D44577

(cherry picked from commit dd286b0dc187c351a9537a363840245d5505b15b)

cp: Correct the list of non-portable flags.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D44576

(cherry picked from commit aaa1806f68ef3102a9b888a03360f166b88618c8)
</content>
</entry>
<entry>
<title>cp: Add tests for hard link case.</title>
<updated>2024-01-17T18:28:22Z</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2023-12-13T21:31:05Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=d514cadacc50bfcdef76214b2499bcef464b324e'/>
<id>urn:sha1:d514cadacc50bfcdef76214b2499bcef464b324e</id>
<content type='text'>
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D43052

(cherry picked from commit 1fead66b64822f3f8106ad09bef0b9656836fa1a)

cp: Add tests for symbolic link case.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, allanjude
Differential 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 as
possible instead of constantly checking that they're not set and then
handling them at the end.  This also opens the door to changing the
failure logic at some future point (for instance, we might decide to
fall back to copying if `errno` indicates that the file system does not
support links).

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, allanjude
Differential 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 symlink
results 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 a
file to itself, or to a link to itself, or a link to its target.  Leave
the first part in basic_symlink, move the second part to a new test case
named samefile, and slightly expand both cases.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential 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 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential 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 dne
flag.  This means we don't need to re-check the conditions that would
have caused us to delete the file when we later need to decide whether
to create or replace it.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential 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 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, allanjude
Differential Revision:	https://reviews.freebsd.org/D43067

(cherry picked from commit 53fc8e190241233d94e183f8a39ec39f2154dfa8)
</content>
</entry>
<entry>
<title>cp: Add -N flag, inspired by NetBSD's similar flag</title>
<updated>2024-01-17T18:28:22Z</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-12-07T19:32:27Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=0fcf3a6235eefde0c31a4dc6e16241319468fad9'/>
<id>urn:sha1:0fcf3a6235eefde0c31a4dc6e16241319468fad9</id>
<content type='text'>
Add -N to supress copying of file flags when -p is specified (explicitly
or implicitly). Often times we don't care about the flags or wish to be
able to copy to NFS, and this comes in handy for that. FreeBSD's and
NetBSD's cp are somewhat different, so I had to reimplement all but one
of the patch hunks...

Obtained from:		NetBSD (cp.1 1.25, cp.c 1.37, utils.c 1.28 by elad)
Sponsored by:		Netflix

Differential Revision:	https://reviews.freebsd.org/D42673

(cherry picked from commit 5a52e3d00dd5e0209f6fcb1e41b5985191e6f4e7)

cp: Don't warn for chflags() failing with EOPNOTSUPP if flags == 0

From NetBSD's utils.c 1.5 importing importing BSDI change, with light
formatting changes:
    Author: cgd &lt;cgd@NetBSD.org&gt;
    Date:   Wed Feb 26 14:40:51 1997 +0000

    Patch from BSDI (via Keith Bostic):
    &gt;NFS doesn't support chflags; ignore errors unless there's reason
    &gt;to believe we're losing bits.  (Note, this still won't be right
    &gt;if the server supports flags and we were trying to *remove* flags
    &gt;on a file that we copied, i.e., that we didn't create.)

    CVS Info: utils.c 1.6

Obtained from:		NetBSD
Sponsored by:		Netflix

Differential Revision:	https://reviews.freebsd.org/D42674

(cherry picked from commit 3e7e3b5bdf902a375decc11b95179fd2fbc0da2a)
</content>
</entry>
<entry>
<title>Remove $FreeBSD$: one-line nroff pattern</title>
<updated>2023-08-16T17:55:15Z</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-08-16T17:55:15Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=b2c76c41be32f904179efed29c0ca04d53f3996c'/>
<id>urn:sha1:b2c76c41be32f904179efed29c0ca04d53f3996c</id>
<content type='text'>
Remove /^\.\\"\s*\$FreeBSD\$$\n/
</content>
</entry>
<entry>
<title>Remove $FreeBSD$: one-line sh pattern</title>
<updated>2023-08-16T17:55:03Z</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-08-16T17:55:03Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf'/>
<id>urn:sha1:d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf</id>
<content type='text'>
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
</content>
</entry>
</feed>
