]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
cp: Add tests involving sparse files.
authorDag-Erling Smørgrav <des@FreeBSD.org>
Wed, 1 Feb 2023 20:06:24 +0000 (21:06 +0100)
committerDag-Erling Smørgrav <des@FreeBSD.org>
Thu, 9 Feb 2023 20:32:56 +0000 (21:32 +0100)
commitd6d22a4530f9c55fc7a48deaf19d2ba7047bff1a
tree40fea35cf6604b7a960e81e7ae1ae4974ac008aa
parentde00ef64eeb6940d5510c5f5e1ec80f8ef46e39e
cp: Add tests involving sparse files.

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)
bin/cp/Makefile
bin/cp/cp.c
bin/cp/tests/Makefile
bin/cp/tests/cp_test.sh
bin/cp/tests/sparse.c [new file with mode: 0644]
bin/cp/utils.c