本文介绍了如何从用户空间与Linux内核模块进行通信,而不会在新节点上乱扔/dev呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从用户空间与内核模块进行通信的方式有哪些?通过通信,我的意思是在内核模块和用户空间进程之间发送信息和命令.

What are the ways to communicate with a kernel module from user space? By communication i mean sending information and commands between the kernel module and a user space process.

我目前知道两种方式:

  1. 在已发布的设备节点上打开/关闭/读取/写入/ioctl.
  2. 读取/写入已导出并挂钩的/proc文件.

更具体地讲,有人可以建议与实际上不驱动任何硬件的内核模块通信的最佳方法吗,因此不应该用仅用于ioctl调用的存根节点乱扔/dev吗?我最需要检查其各种状态变量,并向其发送带有请求类型标记的数据块,以查看请求是否成功.

More specifically, can someone advice the best way to communicate with a kernel module that does not actually drives any hardware and therefore should not be littering /dev with stub nodes that exists solely for ioctl calls? I mostly need to check its various status variables and send it a block of data with a request type tag and see if the request succeeded.

推荐答案

Netlink套接字被设计出于这种要求...

Netlink sockets are designed for that kind of requirements, too...

另请参见

  • man 7 netlink
  • libnl - Netlink library
  • The libnl Archives

这篇关于如何从用户空间与Linux内核模块进行通信,而不会在新节点上乱扔/dev呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 20:17