How to create a virtual device in linux?

假装没事ソ 提交于 2019-12-06 04:39:10

问题


My question is pretty much the same as - How to create a virtual file? except I want to do it in Linux instead. I imagine what I need to do is create a virtual device and point the application logging to that device. I'd like to write the device in python or ruby or something else interpreted, if possible.


回答1:


check out named pipes http://en.wikipedia.org/wiki/Named_pipe




回答2:


Use mknod. You can create a socket file which your apps can write too. And your logging app would connect to the socket to read from it.




回答3:


Mocking usb devices using umockdev

Umockdev is a linux based application which record the behaviour as well as properties of hardware and run the software independent of actual hardware it is running on. Hardware devices can be simulated in virtual environments without disturbing the whole system.It currently supports sysfs, uevents, basic support for /dev devices, and recording/mocking usbdevfs ioctls (for PtP/MTP devices).

umockdev home page

source code and examples



来源:https://stackoverflow.com/questions/6125811/how-to-create-a-virtual-device-in-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!