我在编译kernel
使用netlink函数的旧模块时遇到编译器错误.
int
init_module()
{
/* Initialize the Netlink kernel interface */
nl_sk = netlink_kernel_create(&init_net, 17, 0, recv_cmd, NULL, THIS_MODULE);
if(!nl_sk)
{
printk(KERN_INFO "failed to initialize system (error: 1001)\n");
return -ENOMEM;
}
....
Run Code Online (Sandbox Code Playgroud)
以前它工作正常,但现在我收到此错误.
error: too many arguments to function 'netlink_kernel_create'
Run Code Online (Sandbox Code Playgroud)
OS信息
uname -a
Linux ibrar-ahmed 3.8.0-17-generic #27-Ubuntu SMP Sun Apr 7 19:39:35 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
Jav*_*ack 13
只需更换
nl_sk = netlink_kernel_create(&init_net, 17, 0, recv_cmd, NULL, THIS_MODULE);
Run Code Online (Sandbox Code Playgroud)
以下内容
struct netlink_kernel_cfg cfg = {
.input = recv_cmd,
};
nl_sk = netlink_kernel_create(&init_net, 17, &cfg);
Run Code Online (Sandbox Code Playgroud)
它应该工作.我遇到了同样的问题.
那是因为在3.8中netlink_kernel_create原型已被更改:
netlink_kernel_create(struct net*net,int unit,struct netlink_kernel_cfg*cfg)
(和qv http://lxr.linux.no/linux+v3.8/include/linux/netlink.h#L48)
你别无选择,只能重写内核模块,删除那个额外的参数(THIS_MODULE),以及实现netlink_kernel_cfg结构.