简体   繁体   English

将 kernel 模块头导出到用户空间

[英]Export kernel module headers to userspace

I am writing a Linux kernel module which need to export some header files to userspace.我正在编写一个 Linux kernel 模块,它需要将一些 header 文件导出到用户空间。

I am wondering if there is any standard method which use Kernel package to do required sanitation of headers (For example something like "$(MAKE) -C $(KERNELDIR) M=$(PWD) headers_install" if exist).我想知道是否有任何标准方法使用 Kernel package 对标头进行必要的清理(例如,如果存在类似“$(MAKE) -C $(KERNELDIR) M=$(PWD) headers_install”)。

Should i take care of headers manually?我应该手动处理标题吗? Any suggestion?有什么建议吗?

You can do it by adding 'header-y=' to one of the Kbuild under /include/uapi您可以通过将 'header-y=' 添加到 /include/uapi 下的 Kbuild 之一来做到这一点

There is no such functionality out of the box because most kernel modules which need something like that come with an extra "devel" package which contains the (cleaned) header files and probably a shared library to talk to the module.开箱即用没有这样的功能,因为大多数需要类似功能的 kernel 模块都带有一个额外的“开发”package,其中包含(已清理的)Z099FB995346F31C749F6E40DB0F395EZ 文件和共享库文件。

As for cleaning your headers, I suggest to split the header files into a generic part (which you export) and an internal part (which only the kernel module can see).至于清理标题,我建议将 header 文件拆分为通用部分(您导出)和内部部分(只有 kernel 模块可以看到)。 typedef is your friend. typedef是你的朋友。

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

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