Create ProcFS entry in /proc/net

☆樱花仙子☆ 提交于 2019-12-06 13:15:55

In recent kernels you won't find create_proc_entry() anymore, it's been removed completely. Take a look at https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=80e928f7ebb958f4d79d4099d1c5c0a015a23b93. So, you need to use proc_create(). And, pass ->proc_net as parent directory entry. Take a look at this: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/ipv4/proc.c#n479, this will give you a clear idea.

If you're not using a latest kernel, then you might have create_proc_entry(), therefore might consider using create_proc_entry(), rather proc_create(). But, I think it's best if you cope with current approach. Cause you won't get support for create_proc_entry() with latest kernels.

I think the way to do it is :

proc_file = create_proc_entry("test", 0644, init_net.proc_net);

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