HomeFreeBSD

cp: Simplify the common case.

Description

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

Details

Provenance
desAuthored on Feb 1 2023, 8:06 PM
Reviewer
rmacklem
Differential Revision
D38291: cp: Simplify the common case.
Parents
rG822fa7ae1e3e: cp: Add tests involving sparse files.
Branches
Unknown
Tags
Unknown