<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/bin/cp/utils.c, branch release/13.2.0</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=release%2F13.2.0</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=release%2F13.2.0'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2023-02-09T20:32:56Z</updated>
<entry>
<title>cp: Add tests involving sparse files.</title>
<updated>2023-02-09T20:32:56Z</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2023-02-01T20:06:24Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=d6d22a4530f9c55fc7a48deaf19d2ba7047bff1a'/>
<id>urn:sha1:d6d22a4530f9c55fc7a48deaf19d2ba7047bff1a</id>
<content type='text'>
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38290

(cherry picked from commit 822fa7ae1e3e7ed277e47e6de355387e524c6ee4)

cp: Simplify the common case.

* The allocated buffer is only used in the fallback case, so move it
  there.  The argument for passing it in from the caller was that if
  malloc(3) were to fail, we'd want it to fail before we started
  copying anything, but firstly, it was already not in the right place
  to ensure that, and secondly, malloc(3) never fails (except in very
  contrived circumstances, such as an unreasonable RLIMIT_AS or
  RLIMIT_DATA).

* Remove the mmap(2) option.  It is almost never beneficial,
  especially when the alternative is copy_file_range(2), and it adds
  needless complexity and indentation.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	rmacklem, mav
Differential Revision:	https://reviews.freebsd.org/D38291

(cherry picked from commit 6c85042afcbbf4cd0fb7e7c03226c7249081e690)

cp: Minor code cleanup.

* Fix includes in utils.c, cf. style(9).
* Fix type mismatch: readlink(2) returns ssize_t, not int.
* It is not necessary to set errno to 0 as fts_read(3) already does it.

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

(cherry picked from commit cb96a0ef0040fa7968245ab203ab70a7ed2d275d)

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 week
Sponsored by:	Klara, Inc.
Reviewed by:	cracauer
Differential Revision:	https://reviews.freebsd.org/D38414

(cherry picked from commit 8b418c83d175fde3b1f65210509ddcf2ac248d9f)
</content>
</entry>
<entry>
<title>cp: Fix build without VM_AND_BUFFER_CACHE_SYNCHRONIZED.</title>
<updated>2022-09-06T00:51:02Z</updated>
<author>
<name>Alexander Motin</name>
<email>mav@FreeBSD.org</email>
</author>
<published>2022-08-30T14:51:21Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=e1ce45abcfa78e77fec77eb6f326358edfb12dfd'/>
<id>urn:sha1:e1ce45abcfa78e77fec77eb6f326358edfb12dfd</id>
<content type='text'>
It allows to not use mmap() for small files, which is not helpful
in case of ZFS.  Should be no functional change.

MFC after:	1 week

(cherry picked from commit 35b7759c05cbc65c06d87141da79f0f80af0f458)
</content>
</entry>
<entry>
<title>cp: fix indentation</title>
<updated>2021-05-05T08:35:02Z</updated>
<author>
<name>Baptiste Daroussin</name>
<email>bapt@FreeBSD.org</email>
</author>
<published>2021-01-26T09:52:22Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=a3b7f912600b62ebd1740b44c96a9d8fa35b8ca6'/>
<id>urn:sha1:a3b7f912600b62ebd1740b44c96a9d8fa35b8ca6</id>
<content type='text'>
No functional changes

(cherry picked from commit 45b252fc9182b96342b8a598f271e49c20cbfe40)
</content>
</entry>
<entry>
<title>cp(1): fix performance issue for large non-sparse file copies</title>
<updated>2021-01-03T00:58:43Z</updated>
<author>
<name>Rick Macklem</name>
<email>rmacklem@FreeBSD.org</email>
</author>
<published>2021-01-03T00:58:43Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=c98a764c681f8b70812a9f13a6e61c96aa1a69d2'/>
<id>urn:sha1:c98a764c681f8b70812a9f13a6e61c96aa1a69d2</id>
<content type='text'>
PR252358 reported a serious performance problem when
copying a large non-sparse file on a UFS file system.
This problem seems to have been caused by a large
number of SEEK_HOLE operations, with one done
for each copy_file_range(2) call.

This patch modifies cp(1) to use a large (SSIZE_MAX)
len argument, reducing the number of system calls
and resolving the performance issue.

While here, convert the type of the "rcount" from "int"
to "ssize_t" so that it is consistent with that returned
by both read(2) and copy_file_range(2).

PR:	252358
Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D27937
</content>
</entry>
<entry>
<title>cp: fall back to read/write if copy_file_range fails</title>
<updated>2020-09-11T20:49:36Z</updated>
<author>
<name>Alan Somers</name>
<email>asomers@FreeBSD.org</email>
</author>
<published>2020-09-11T20:49:36Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=1ea95ba2317b2fe482da0ea1a3d132643a0705b8'/>
<id>urn:sha1:1ea95ba2317b2fe482da0ea1a3d132643a0705b8</id>
<content type='text'>
Even though copy_file_range has a file-system agnostic version, it still
fails on devfs (perhaps because the file descriptor is non-seekable?) In
that case, fallback to old-fashioned read/write. Fixes
"cp /dev/null /tmp/null"

PR:		249248
Reported by:	Michael Butler
Reviewed by:	mjg
MFC-With:	365549
Differential Revision:	https://reviews.freebsd.org/D26395
</content>
</entry>
<entry>
<title>cp: use copy_file_range(2)</title>
<updated>2020-09-10T02:48:55Z</updated>
<author>
<name>Alan Somers</name>
<email>asomers@FreeBSD.org</email>
</author>
<published>2020-09-10T02:48:55Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=c01816a97fd516359000b1f0635f320b77ec0b00'/>
<id>urn:sha1:c01816a97fd516359000b1f0635f320b77ec0b00</id>
<content type='text'>
This has three advantages over write(2)/read(2):

* Fewer context switches and data copies
* Mostly preserves a file's sparseness
* On some file systems (currently NFS 4.2) the file system will perform the
  copy in an especially efficient way.

Reviewed by:	rmacklem
MFC after:	2 weeks
Sponsored by:	Axcient
Differential Revision:	https://reviews.freebsd.org/D26377
</content>
</entry>
<entry>
<title>General further adoption of SPDX licensing ID tags.</title>
<updated>2017-11-20T19:49:47Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2017-11-20T19:49:47Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=8a16b7a18f5d0b031f09832fd7752fba717e2a97'/>
<id>urn:sha1:8a16b7a18f5d0b031f09832fd7752fba717e2a97</id>
<content type='text'>
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
</content>
</entry>
<entry>
<title>Renumber copyright clause 4</title>
<updated>2017-02-28T23:42:47Z</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2017-02-28T23:42:47Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=fbbd9655e5107c68e4e0146ff22b73d7350475bc'/>
<id>urn:sha1:fbbd9655e5107c68e4e0146ff22b73d7350475bc</id>
<content type='text'>
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann &lt;jschauma@stevens.edu&gt;
Pull Request:	https://github.com/freebsd/freebsd/pull/96
</content>
</entry>
<entry>
<title>Cleanup some style(9) issues.</title>
<updated>2015-06-08T19:24:18Z</updated>
<author>
<name>Bryan Drewery</name>
<email>bdrewery@FreeBSD.org</email>
</author>
<published>2015-06-08T19:24:18Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=724fd44827c1ef56378d1cf2828e1e9c1cfe0d0f'/>
<id>urn:sha1:724fd44827c1ef56378d1cf2828e1e9c1cfe0d0f</id>
<content type='text'>
- Whitespace.
- Comments.
- Wrap long lines.

MFC after:	2 weeks
X-MFC-with:	r284105,r284106
Sponsored by:	EMC / Isilon Storage Division
</content>
</entry>
<entry>
<title>Implement '-s' to copy as symlink, similar to the current -l link(2) handling.</title>
<updated>2015-06-07T06:30:25Z</updated>
<author>
<name>Bryan Drewery</name>
<email>bdrewery@FreeBSD.org</email>
</author>
<published>2015-06-07T06:30:25Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=7ea2450f4209652352fe1f6cc12f5b3b81cf4210'/>
<id>urn:sha1:7ea2450f4209652352fe1f6cc12f5b3b81cf4210</id>
<content type='text'>
This is also implemented in at least GNU coreutils cp.

While here also improve the '-l' handling to not open(2) the source file as
it does not actually need the descriptor.

Sponsored by:	EMC / Isilon Storage Division
</content>
</entry>
</feed>
