implicit declaration of function 'create_proc_entry'

狂风中的少年 提交于 2020-01-01 04:05:49

问题


I'm trying to use the create_proc_entry() function to create a directory under /proc. When I try to compile the code, I get the following error: implicit declaration of function 'create_proc_entry' .

These are the headers I have included in my .c file:

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/vmalloc.h>
#include <linux/uaccess.h>

The kernel version on the machine I'm trying to compile for is: 3.10.33-g7954807-dirty

Am i missing any headers necessary to call this method? Or is the method deprecated in my version of the kernel?


回答1:


/proc filesystem has been refactored in 3.10, the function you are looking for has been removed, you should use the full featured proc_create function family. Note that the signatures are different.

3.10 version: http://lxr.free-electrons.com/source/include/linux/proc_fs.h?v=3.10

3.9 version: http://lxr.free-electrons.com/source/include/linux/proc_fs.h?v=3.9

You can find greater explanation of using full featured /proc functions in the book Linux Device Drivers 4, or, if you want shorter solution, check this link (https://github.com/jesstess/ldd4/blob/master/scull/main.c) where you can see how the struct file_operations has been used. You do not have to setup to all fields of the struct.



来源:https://stackoverflow.com/questions/26808325/implicit-declaration-of-function-create-proc-entry

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