linux - 拼接系统调用,传递给管道的是什么?数据或行踪信息?

标签 linux linux-kernel system-calls splice

我知道有了拼接,我们都可以留在内核中。但我不确定传递给管道的是数据还是行踪信息。

编辑 1: 谢谢@vinayak,现在我知道实际上有数据复制到管道缓冲区和从管道缓冲区复制。但是,我只是想知道为什么我们不能只将行踪和长度信息传递给管道?

  • 在同一个进程中,地址空间是一样的
  • 在不同的进程之间,如果管道缓冲区是线性映射的,它也可以工作。如果不是,我们可以使用 DMA 地址。

最佳答案

refer here

A splice() is a system call mechanism to do i/o from one file to another file in kernel space without doing copying from/to user space.It is a way of improving I/O performance. The splice system call avoids all data copy from user space to kernel space & vice versa. It reads from the specified offset from the input file & writes to a pipe in the kernel space. There is no copying of data to user space.Then it can be called to write the data from the pipe to the output file at the specified/current offset.

splice() works by using the pipe buffer mechanism to open a file descriptor for a data source and another for a data sink then by using splice() it can join the two together. In other words, splice() work on a kernel buffer that the user has control over and moves data to/from the buffer from/to an arbitrary file descriptor. Specifying offset with pipe is an error as usual. If no offset is specified with an input/output file descriptor then the current offset will be assumed to be the offset specified. Currently one of the file descriptor must be pipe otherwise it is an error.

关于linux - 拼接系统调用,传递给管道的是什么?数据或行踪信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17268826/

相关文章:

python - 如何从 OpenVPN 中提取客户端证书信息?

linux - 使用 shell 脚本运行配置单元查询

linux - 使用 sed 替换行 block

在启动过程的早期调试内核

linux - 是否允许 sysfs 二进制属性返回多页数据?

linux - 在 LINUX 上将 Tomcat 作为服务启动

linux - 从文件系统中查找路由器固件的 linux 内核版本

c 和 LD_PRELOAD。 open 和 open64 调用被拦截,但 stat64 未被拦截

自定义 Linux 内核系统调用包装函数

将数据从内核空间复制到用户空间