c - 哪些文件系统支持通过 Linux 的 splice(2) 进行拼接?

标签 c linux filesystems splice zero-copy

man page for the splice system call表示 splice 可能会失败并将 errno 设置为 EINVAL 如果:

Target file system doesn't support splicing; neither of the descriptors refers to a pipe; or offset given for non-seekable device

哪些文件系统支持拼接?

最佳答案

我的原始答案部分不正确,这是一次重大重写。

Linux 2.6.30.10及以下

在 Linux 2.6.30.10 及更早版本中,splice 在源或目标文件系统不支持拼接时返回 EINVAL。以下是支持拼接的文件系统:

  • 在读取模式下:adfs、affs、afs、bfs、btrfs、coda、ecryptfs、exofs、ext2、ext3、ext4、fat、fuse、hpfs、jffs2、jfs、minix、nfs、 nilfs2、ntfs、ocfs2、omfs、qnx4、reiserfs、smbfs、sysv、ubifs、udf、ufs。
  • 写入模式:exofs、ext2、ext3、ext4、jfs、ocfs2、reiserfs、ubifs。

详情如下。 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_readdefault_file_splice_write,分别。参见 do_splice_to()do_splice_from()用于实现。注意:由于文档中列出的其他原因,EINVAL 可能仍会返回。

关于c - 哪些文件系统支持通过 Linux 的 splice(2) 进行拼接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3638657/

相关文章:

malloc() 和 free() 的 C 动态内存问题

linux - 使用dd从特定位置开始写入数据

linux - 如何使用sed删除带通配符的字符串

boost - 在 boost 文件系统中使用 directory_entry 时出错

c++ - 如果您链接到目标文件但不使用其任何代码,会发生什么情况?

c - 当我只有一个 4 字节的局部变量时,为什么堆栈在反汇编中增长了 16 个字节?

C 语言 - WHILE 循环的工作量超出了预期

linux - 避免 php artisan 队列 :work : Queue Driver - Redis or Database (Laravel 5. 4)

python - 在读取或写入文件系统时执行其他操作

actionscript-3 - Adobe AIR 和不同的操作系统文件系统