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 If it succeeds, the call returns the number of bytes copied, which can be fewer
124 Returning fewer bytes than
126 does not necessarily indicate that EOF was reached.
127 However, a return of zero for a non-zero
129 argument indicates that the offset for
133 should be used in a loop until copying of the desired byte range has been
135 If an error has occurred, a \-1 is returned and the error code is placed in
147 is not open for reading or
149 is not open for writing, or opened for writing with
155 refer to the same file.
157 If the copy exceeds the process's file size limit or the maximum file size
162 A signal interrupted the system call
163 before it could be completed.
164 This may happen for files on some NFS mounts.
165 When this happens, the values pointed to by
169 are reset to the initial values for the system call.
174 refer to the same file and the byte ranges overlap or
178 An I/O error occurred while reading/writing the files.
180 Corrupted data was detected while reading from a file system.
186 refers to a directory.
188 File system that stores
197 system call is expected to be compatible with the Linux system call of