Discussion:
What are equivalents of Linux ioctl functions FICLONE and FICLONERANGE ?
(too old to reply)
Yuri
2024-06-07 06:59:38 UTC
Permalink
On Linux files can be copied with:
ioctl(destFd, FICLONE, srcFd)


What would be the equivalent of this on FreeBSD?




Thanks,
Yuri
Stefan Esser
2024-06-07 09:48:47 UTC
Permalink
Post by Yuri
ioctl(destFd, FICLONE, srcFd)
What would be the equivalent of this on FreeBSD?
That would be copy_file_range(), but as on Linux, it does only
offer any benefit on filesystems that support copy-on-write or
potentially on network attached storage.

NFSv4 has recently gained support for server-side copies if
copy_file_range is used, for example. But UFS will fall back
to a normal copy operation.

ZFS should do this via block cloning, but that has not been
enabled by default, since it has a history of corrupted files
(and it is not clear, whether all border cases are covered in
the latest version).

Regards, STefan


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Dag-Erling Smørgrav
2024-06-08 05:36:45 UTC
Permalink
Post by Stefan Esser
Post by Yuri
ioctl(destFd, FICLONE, srcFd)
What would be the equivalent of this on FreeBSD?
That would be copy_file_range(), but as on Linux, it does only
offer any benefit on filesystems that support copy-on-write or
potentially on network attached storage.
Even without filesystem support, it still avoids copying the contents of
the file out to user space, so it's faster than a regular copy.

DES
--
Dag-Erling Smørgrav - ***@FreeBSD.org


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
David Chisnall
2024-06-08 08:01:52 UTC
Permalink
Post by Dag-Erling Smørgrav
Post by Stefan Esser
Post by Yuri
ioctl(destFd, FICLONE, srcFd)
What would be the equivalent of this on FreeBSD?
That would be copy_file_range(), but as on Linux, it does only
offer any benefit on filesystems that support copy-on-write or
potentially on network attached storage.
Even without filesystem support, it still avoids copying the contents of
the file out to user space, so it's faster than a regular copy.
Note that there is no in-kernel fallback path for if the file descriptor type does not support it. This means that you cannot use it, for example, for copies from an anonymous shared memory object to a regular file.

David

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...