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
31 .Nd kernel copy of a byte range from one file to another
45 .Fa "unsigned int flags"
58 It may do this using a file system specific technique if
62 are on the same file system.
67 refer to the same file, the byte ranges defined by
68 the input file offset, output file offset and
73 argument must be opened for reading and the
75 argument must be opened for writing, but not
87 respectively will be used and updated by
88 the number of bytes copied.
95 the byte offset pointed to by
99 respectively will be used/updated and the file offset for
103 respectively will not be affected.
108 This system call attempts to maintain holes in the output file for
109 the byte range being copied.
110 However, this does not always work well.
111 It is recommended that sparse files be copied in a loop using
116 arguments and this system call for the
119 For best performance, call
124 It is interruptible on most file systems,
125 so there is no penalty for using very large len values, even SSIZE_MAX.
128 If it succeeds, the call returns the number of bytes copied, which can be fewer
131 Returning fewer bytes than
133 does not necessarily indicate that EOF was reached.
134 However, a return of zero for a non-zero
136 argument indicates that the offset for
140 should be used in a loop until copying of the desired byte range has been
142 If an error has occurred, a \-1 is returned and the error code is placed in
154 is not open for reading or
156 is not open for writing, or opened for writing with
162 refer to the same file.
164 If the copy exceeds the process's file size limit or the maximum file size
169 A signal interrupted the system call
170 before it could be completed.
171 This may happen for files on some NFS mounts.
172 When this happens, the values pointed to by
176 are reset to the initial values for the system call.
181 refer to the same file and the byte ranges overlap or
185 An I/O error occurred while reading/writing the files.
187 Corrupted data was detected while reading from a file system.
193 refers to a directory.
195 File system that stores
204 system call is expected to be compatible with the Linux system call of