哪些文件系统支持通过 Linux 的 splice(2) 进行拼接?
The man page for the splice
system call says that splice
may fail and set errno
to EINVAL
if:
Target file system doesn't support splicing; neither of the descriptors refers to a pipe; or offset given for non-seekable device
Which file systems support splicing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我原来的答案部分不正确,这是一个重大重写。
Linux 2.6.30.10 及更低版本
在 Linux 2.6.30.10 及更早版本中,当源或目标文件系统不支持拼接时,
splice
返回EINVAL
。以下是支持拼接的文件系统:详细信息如下。对拼接的支持在
do_splice_to( )
函数在“文件到管道”情况下和do_splice_from()
函数在“管道到文件”的情况下。这是通过检查相关的 struct file_operations 是否分别包含 .splice_read 或 .splice_write 来完成的。为了生成上述文件系统列表,我在fs/*/file.c
中查找了.splice_read
和.splice_write
。Linux 2.6.31 及更高版本
从 Linux 2.6.31 开始,所有文件系统都支持读取和写入模式下的拼接。
详细信息如下。当文件系统的
struct file_operations
中没有.splice_read
或.splice_write
时,将使用后备函数:default_file_splice_read
和default_file_splice_write
分别。请参阅do_splice_to()
和do_splice_from()
用于实现。注意:由于文档中列出的其他原因,EINVAL
仍可能被返回。My original answer was partially incorrect, this is a major rewrite.
Linux 2.6.30.10 and below
In Linux 2.6.30.10 and older,
splice
returnsEINVAL
when the source or target filesystem does not support splicing. Here are the filesystems that do support splicing:Details follow. Support for splicing in determined in the
do_splice_to()
function in the "file to pipe" case and in thedo_splice_from()
function in the "pipe to file" case. It is done by checking whether the relevantstruct file_operations
contains.splice_read
or.splice_write
, respectively. In order to produce the above lists of filesystems, I've greppedfs/*/file.c
for.splice_read
and.splice_write
.Linux 2.6.31 and above
Starting with Linux 2.6.31, all the filesystems support splicing both in read and write modes.
Details follow. When a filesystem does not have
.splice_read
or.splice_write
in itsstruct file_operations
, a fallback function is used:default_file_splice_read
anddefault_file_splice_write
, respectively. Seedo_splice_to()
anddo_splice_from()
for implementations. Note:EINVAL
may still be returned for other reasons listed in the documentation.根据这个< /a>,EXT3 可以。看来您可能对任何 FUSE 文件系统都不走运。
Accordding to this, EXT3 does. It seems that you might be out of luck with any FUSE file system.