简体   繁体   English

我们如何在linux中创建“特殊”文件,如/ dev / random?

[英]How can we create 'special' files, like /dev/random, in linux?

In Linux file system, there are files such as /dev/zero and /dev/random which are not real files on hard disk. 在Linux文件系统中,有/ dev / zero和/ dev / random等文件,这些文件不是硬盘上的真实文件。

Is there any way that we can create a similar file and tell it to get ouput from executing a program? 有什么方法可以创建一个类似的文件并告诉它从执行程序获得输出?

For example, can I create file, say /tmp/tarfile, such that any program reading it actually gets the output from the execution of a different program (/usr/bin/tar ...)? 例如,我可以创建文件,比如/ tmp / tarfile,这样任何读取它的程序实际上都会从执行不同的程序(/ usr / bin / tar ...)获得输出吗?

可以创建这样的文件/程序,但是需要创建一个特殊的文件系统才能将钩子插入VFS,以便可以检测和正确处理访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM