Debian Codegraph @

upstream/debian-unstable/man2/UFFDIO_COPY.2const

raw
1 .\" Copyright 2016, International Business Machines Corp.
2 .\" Copyright 2016, Michael Kerrisk <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH UFFDIO_COPY 2const 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 UFFDIO_COPY
10 \-
11 atomically copy a continuous memory chunk into the userfault registered range
12 .SH LIBRARY
13 Standard C library
14 .RI ( libc ,\~ \-lc )
15 .SH SYNOPSIS
16 .nf
17 .BR "#include <linux/userfaultfd.h>" " /* Definition of " UFFD* " constants */"
18 .B #include <sys/ioctl.h>
19 .P
20 .BI "int ioctl(int " fd ", UFFDIO_COPY, struct uffdio_copy *" argp );
21 .P
22 .B #include <linux/userfaultfd.h>
23 .P
24 .fi
25 .EX
26 .B struct uffdio_copy {
27 .BR " __u64 dst;" " /* Destination of copy */"
28 .BR " __u64 src;" " /* Source of copy */"
29 .BR " __u64 len;" " /* Number of bytes to copy */"
30 .BR " __u64 mode;" " /* Flags controlling behavior of copy */"
31 .BR " __s64 copy;" " /* Number of bytes copied, or negated error */"
32 .B };
33 .EE
34 .SH DESCRIPTION
35 Atomically copy a continuous memory chunk into the userfault registered
36 range and optionally wake up the blocked thread.
37 .P
38 The following value may be bitwise ORed in
39 .I mode
40 to change the behavior of the
41 .B UFFDIO_COPY
42 operation:
43 .TP
44 .B UFFDIO_COPY_MODE_DONTWAKE
45 Do not wake up the thread that waits for page-fault resolution
46 .TP
47 .B UFFDIO_COPY_MODE_WP
48 Copy the page with read-only permission.
49 This allows the user to trap the next write to the page,
50 which will block and generate another write-protect userfault message.
51 This is used only when both
52 .B UFFDIO_REGISTER_MODE_MISSING
53 and
54 .B UFFDIO_REGISTER_MODE_WP
55 modes are enabled for the registered range.
56 .P
57 The
58 .I copy
59 field is used by the kernel to return the number of bytes
60 that was actually copied, or an error (a negated
61 .IR errno -style
62 value).
63 .\" FIXME Above: Why is the 'copy' field used to return error values?
64 .\" This should be explained in the manual page.
65 The
66 .I copy
67 field is output-only;
68 it is not read by the
69 .B UFFDIO_COPY
70 operation.
71 .SH RETURN VALUE
72 On success,
73 0 is returned.
74 In this case, the entire area was copied.
75 .P
76 On error, \-1 is returned and
77 .I errno
78 is set to indicate the error.
79 .SH ERRORS
80 .TP
81 .B EAGAIN
82 The number of bytes copied (i.e., the value returned in the
83 .I copy
84 field)
85 does not equal the value that was specified in the
86 .I len
87 field.
88 .TP
89 .B EINVAL
90 Either
91 .I dst
92 or
93 .I len
94 was not a multiple of the system page size, or the range specified by
95 .I src
96 and
97 .I len
98 or
99 .I dst
100 and
101 .I len
102 was invalid.
103 .TP
104 .B EINVAL
105 An invalid bit was specified in the
106 .I mode
107 field.
108 .TP
109 .BR ENOENT " (since Linux 4.11)"
110 The faulting process has changed
111 its virtual memory layout simultaneously with an outstanding
112 .B UFFDIO_COPY
113 operation.
114 .TP
115 .BR ENOSPC " (from Linux 4.11 until Linux 4.13)"
116 The faulting process has exited at the time of a
117 .B UFFDIO_COPY
118 operation.
119 .TP
120 .BR ESRCH " (since Linux 4.13)"
121 The faulting process has exited at the time of a
122 .B UFFDIO_COPY
123 operation.
124 .SH STANDARDS
125 Linux.
126 .SH HISTORY
127 Linux 4.3.
128 .SH EXAMPLES
129 See
130 .BR userfaultfd (2).
131 .SH SEE ALSO
132 .BR ioctl (2),
133 .BR ioctl_userfaultfd (2),
134 .BR userfaultfd (2)
135 .P
136 .I linux.git/\:Documentation/\:admin\-guide/\:mm/\:userfaultfd.rst