226 lines
5.3 KiB
HTML
226 lines
5.3 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of IOCTL-FICLONERANGE</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>IOCTL-FICLONERANGE</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
ioctl_ficlonerange, ioctl_ficlone - share some the data of one file with another file
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<BR>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/sys/ioctl.h">sys/ioctl.h</A>></B>
|
|
|
|
<BR>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/linux/fs.h">linux/fs.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>int ioctl(int </B><I>dest_fd</I><B>, FICLONERANGE, struct file_clone_range *</B><I>arg</I><B>);</B>
|
|
|
|
<BR>
|
|
|
|
<B>int ioctl(int </B><I>dest_fd</I><B>, FICLONE, int </B><I>src_fd</I><B>);</B>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
If a filesystem supports files sharing physical storage between multiple
|
|
files ("reflink"), this
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl">ioctl</A></B>(2)
|
|
|
|
operation can be used to make some of the data in the
|
|
<I>src_fd</I>
|
|
|
|
file appear in the
|
|
<I>dest_fd</I>
|
|
|
|
file by sharing the underlying storage, which is faster than making a separate
|
|
physical copy of the data.
|
|
Both files must reside within the same filesystem.
|
|
If a file write should occur to a shared region,
|
|
the filesystem must ensure that the changes remain private to the file being
|
|
written.
|
|
This behavior is commonly referred to as "copy on write".
|
|
<P>
|
|
|
|
This ioctl reflinks up to
|
|
<I>src_length</I>
|
|
|
|
bytes from file descriptor
|
|
<I>src_fd</I>
|
|
|
|
at offset
|
|
<I>src_offset</I>
|
|
|
|
into the file
|
|
<I>dest_fd</I>
|
|
|
|
at offset
|
|
<I>dest_offset</I>,
|
|
|
|
provided that both are files.
|
|
If
|
|
<I>src_length</I>
|
|
|
|
is zero, the ioctl reflinks to the end of the source file.
|
|
This information is conveyed in a structure of
|
|
the following form:
|
|
<P>
|
|
|
|
|
|
|
|
struct file_clone_range {
|
|
<BR> __s64 src_fd;
|
|
<BR> __u64 src_offset;
|
|
<BR> __u64 src_length;
|
|
<BR> __u64 dest_offset;
|
|
};
|
|
|
|
|
|
<P>
|
|
|
|
Clones are atomic with regards to concurrent writes, so no locks need to be
|
|
taken to obtain a consistent cloned copy.
|
|
<P>
|
|
|
|
The
|
|
<B>FICLONE</B>
|
|
|
|
ioctl clones entire files.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On error, -1 is returned, and
|
|
<I>errno</I>
|
|
|
|
is set to indicate the error.
|
|
<P>
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
Error codes can be one of, but are not limited to, the following:
|
|
<DL COMPACT>
|
|
<DT id="1"><B>EBADF</B>
|
|
|
|
<DD>
|
|
<I>src_fd</I>
|
|
|
|
is not open for reading;
|
|
<I>dest_fd</I>
|
|
|
|
is not open for writing or is open for append-only writes;
|
|
or the filesystem which
|
|
<I>src_fd</I>
|
|
|
|
resides on does not support reflink.
|
|
<DT id="2"><B>EINVAL</B>
|
|
|
|
<DD>
|
|
The filesystem does not support reflinking the ranges of the given files.
|
|
This error can also appear if either file descriptor represents
|
|
a device, FIFO, or socket.
|
|
Disk filesystems generally require the offset and length arguments
|
|
to be aligned to the fundamental block size.
|
|
XFS and Btrfs do not support
|
|
overlapping reflink ranges in the same file.
|
|
<DT id="3"><B>EISDIR</B>
|
|
|
|
<DD>
|
|
One of the files is a directory and the filesystem does not support shared
|
|
regions in directories.
|
|
<DT id="4"><B>EOPNOTSUPP</B>
|
|
|
|
<DD>
|
|
This can appear if the filesystem does not support reflinking either file
|
|
descriptor, or if either file descriptor refers to special inodes.
|
|
<DT id="5"><B>EPERM</B>
|
|
|
|
<DD>
|
|
<I>dest_fd</I>
|
|
|
|
is immutable.
|
|
<DT id="6"><B>ETXTBSY</B>
|
|
|
|
<DD>
|
|
One of the files is a swap file.
|
|
Swap files cannot share storage.
|
|
<DT id="7"><B>EXDEV</B>
|
|
|
|
<DD>
|
|
<I>dest_fd</I> and <I>src_fd</I>
|
|
|
|
are not on the same mounted filesystem.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>VERSIONS</H2>
|
|
|
|
These ioctl operations first appeared in Linux 4.5.
|
|
They were previously known as
|
|
<B>BTRFS_IOC_CLONE</B>
|
|
|
|
and
|
|
<B>BTRFS_IOC_CLONE_RANGE</B>,
|
|
|
|
and were private to Btrfs.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
This API is Linux-specific.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
Because a copy-on-write operation requires the allocation of new storage, the
|
|
<B><A HREF="/cgi-bin/man/man2html?2+fallocate">fallocate</A></B>(2)
|
|
|
|
operation may unshare shared blocks to guarantee that subsequent writes will
|
|
not fail because of lack of disk space.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl">ioctl</A></B>(2)
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="8"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="9"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="10"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="11"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="12"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="13"><A HREF="#lbAG">VERSIONS</A><DD>
|
|
<DT id="14"><A HREF="#lbAH">CONFORMING TO</A><DD>
|
|
<DT id="15"><A HREF="#lbAI">NOTES</A><DD>
|
|
<DT id="16"><A HREF="#lbAJ">SEE ALSO</A><DD>
|
|
<DT id="17"><A HREF="#lbAK">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:33 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|