]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/ioctl_ficlonerange.2
ioctl_ficlonerange.2: srcfix
[thirdparty/man-pages.git] / man2 / ioctl_ficlonerange.2
CommitLineData
9eb18e17
DW
1.\" Copyright (C) 2016 Oracle. All rights reserved.
2.\"
3.\" %%%LICENSE_START(VERBATIM)
4.\" This program is free software; you can redistribute it and/or
5.\" modify it under the terms of the GNU General Public License as
6.\" published by the Free Software Foundation.
7.\"
8.\" This program is distributed in the hope that it would be useful,
9.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
10.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11.\" GNU General Public License for more details.
12.\"
13.\" You should have received a copy of the GNU General Public License
14.\" along with this program; if not, write the Free Software Foundation,
15.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16.\" %%%LICENSE_END
17.TH IOCTL-FICLONERANGE 2 2016-02-10 "Linux" "Linux Programmer's Manual"
18.SH NAME
19ioctl_ficlonerange, ioctl_ficlone \- share some the data of one file with another file
20.SH SYNOPSIS
21.br
22.B #include <sys/ioctl.h>
23.br
24.B #include <linux/fs.h>
25.sp
26.BI "int ioctl(int " dest_fd ", FICLONERANGE, struct file_clone_range * " arg );
27.br
28.BI "int ioctl(int " dest_fd ", FICLONE, int " src_fd );
29.SH DESCRIPTION
30If a filesystem supports files sharing physical storage between multiple
31files ("reflink"), this
32.BR ioctl (2)
33system call can be used to make some of the data in the
34.B src_fd
35file appear in the
36.B dest_fd
37file by sharing the underlying storage, which is faster than making a separate
1d691add
MK
38physical copy of the data.
39If a file write should occur to a shared region,
9eb18e17 40the filesystem must ensure that the changes remain private to the file being
1d691add
MK
41written.
42This behavior is commonly referred to as "copy on write".
9eb18e17
DW
43
44This ioctl reflinks up to
45.IR src_length
46bytes from file descriptor
47.IR src_fd
48at offset
49.IR src_offset
50into the file
51.IR dest_fd
52at offset
53.IR dest_offset ",
1d691add
MK
54provided that both are files.
55This information is conveyed in a structure of
9eb18e17
DW
56the following form:
57.in +4n
58.nf
59
60struct file_clone_range {
61 __s64 src_fd;
62 __u64 src_offset;
63 __u64 src_length;
64 __u64 dest_offset;
65};
66
67.fi
68.in
69Clones are atomic with regards to concurrent writes, so no locks need to be
70taken to obtain a consistent cloned copy.
71
72The FICLONE ioctl clones entire files.
73.SH RETURN VALUE
74On error, \-1 is returned, and
75.I errno
76is set to indicate the error.
77.PP
78.SH ERRORS
79Error codes can be one of, but are not limited to, the following:
80.TP
81.B EXDEV
82.IR dest_fd " and " src_fd
83are not on the same mounted filesystem.
84.TP
85.B EISDIR
86One of the files is a directory and the filesystem does not support shared
87regions in directories.
88.TP
89.B EINVAL
1d691add
MK
90The filesystem does not support reflinking the ranges of the given files.
91This error can also appear if either file descriptor represents
92a device, fifo, or socket.
93Disk filesystems generally require the offset and length arguments
94to be aligned to the fundamental block size.
95XFS and btrfs do not support
9eb18e17
DW
96overlapping reflink ranges in the same file.
97.TP
98.B EBADF
99.IR src_fd
100is not open for reading;
101.IR dest_fd
102is not open for writing or is open for append-only writes; or the filesystem
103which
104.IR src_fd
105resides on does not support reflink.
106.TP
107.B EPERM
108.IR dest_fd
109is immutable.
110.TP
111.B ETXTBSY
1d691add
MK
112One of the files is a swap file.
113Swap files cannot share storage.
9eb18e17
DW
114.TP
115.B EOPNOTSUPP
116This can appear if the filesystem does not support reflinking either file
117descriptor.
118.SH NOTES
119Because a copy on write operation requires the allocation of new storage, the
120.B fallocate (2)
121operation may un-share shared blocks to guarantee that subsequent writes will
122not fail because of lack of disk space.
123.SH CONFORMING TO
1d691add
MK
124This API is Linux-specific.
125This ioctl was previously known as
9eb18e17
DW
126.B BTRFS_IOC_CLONE_RANGE
127and was private to btrfs.
128.fi
129.in
130.SH SEE ALSO
131.BR ioctl (2)