User space defined file descriptor (Linux)

强颜欢笑 提交于 2019-12-11 02:20:07

问题


Is it possible (specifically in Linux) to make a file descriptor from user-provided functions like the following?

ssize_t (*write)(int fd, const void *buf, size_t count);
ssize_t (*read)(int fd, void *buf, size_t count);

(and maybe some more functions, like close() and/or something for polling)

It should look for the OS as a normal FD number, but be handled by the user-provided callbacks (as above) rather than by the OS itself.

The reason why I ask is to know whether it is possible to implement this feature suggestion in user-space (e.g. in Glibc) without modifying the kernel: https://bugzilla.kernel.org/show_bug.cgi?id=135401

来源:https://stackoverflow.com/questions/38467736/user-space-defined-file-descriptor-linux

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