了解LINUX_VERSION_CODE [英] understanding LINUX_VERSION_CODE

查看:556
本文介绍了了解LINUX_VERSION_CODE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在清洗一个内核模块,我在centos 7上再次测试我的LKM时发现问题.

Im wrinting a kernel module and i found a problem testing my LKM again centos 7.

uname -a print 3.10.0-123.13.2.el7.x86_64,我正在使用此内核头文件/usr/src/kernels/3.10.0-123.13.2.el7.x86_64/来编译我的KM并使用LINUX_VERSION_CODE定义我的代码段.

uname -a print 3.10.0-123.13.2.el7.x86_64, and i'm compiling my KM with this kernel-headers /usr/src/kernels/3.10.0-123.13.2.el7.x86_64/ and using LINUX_VERSION_CODE to define my code sections.

我的问题是,编译失败,因为内核标头包含在更多新内核版本中添加的代码,但是LINUX_VERSION_CODE返回3.10.

my problem is, the compilation fail because the kernel-headers include code added in more new kernel version but LINUX_VERSION_CODE returns 3.10.

例如,nf_hookfn在内核3.13中进行了修改,我的标头中已经进行了此修改.

for example, nf_hookfn was modify in kernel 3.13 and i have this modification already in my headers.

我该怎么办?

推荐答案

为此,Centos提供了一些有用的宏:

Centos provides some useful macro for that purpose:

#if RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(7,2)
//
#else
//
#endif

是的,Centos定制内核对最近的Linux内核进行了一些更改.

And yep, Centos custom kernel pull up some changes from recent Linux kernels.

这篇关于了解LINUX_VERSION_CODE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆