1 .\" SPDX-License-Identifier: BSD-2-Clause
3 .\" Copyright (c) 2019 Rick Macklem
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .Nd kernel copy of a byte range from one file to another
47 .Fa "unsigned int flags"
60 It may do this using a file system specific technique if
64 are on the same file system.
69 refer to the same file, the byte ranges defined by
70 the input file offset, output file offset and
75 argument must be opened for reading and the
77 argument must be opened for writing, but not
89 respectively will be used and updated by
90 the number of bytes copied.
97 the byte offset pointed to by
101 respectively will be used/updated and the file offset for
105 respectively will not be affected.
110 This system call attempts to maintain holes in the output file for
111 the byte range being copied.
112 However, this does not always work well.
113 It is recommended that sparse files be copied in a loop using
118 arguments and this system call for the
121 For best performance, call
126 It is interruptible on most file systems,
127 so there is no penalty for using very large len values, even SSIZE_MAX.
130 If it succeeds, the call returns the number of bytes copied, which can be fewer
133 Returning fewer bytes than
135 does not necessarily indicate that EOF was reached.
136 However, a return of zero for a non-zero
138 argument indicates that the offset for
142 should be used in a loop until copying of the desired byte range has been
144 If an error has occurred, a \-1 is returned and the error code is placed in
156 is not open for reading or
158 is not open for writing, or opened for writing with
164 refer to the same file.
166 If the copy exceeds the process's file size limit or the maximum file size
171 A signal interrupted the system call
172 before it could be completed.
173 This may happen for files on some NFS mounts.
174 When this happens, the values pointed to by
178 are reset to the initial values for the system call.
183 refer to the same file and the byte ranges overlap or
187 An I/O error occurred while reading/writing the files.
189 Corrupted data was detected while reading from a file system.
195 refers to a directory.
197 File system that stores
206 system call is expected to be compatible with the Linux system call of