Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

implicit declaration of function 'create_proc_entry'

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?

like image 583
theNoobProgrammer Avatar asked Nov 07 '14 19:11

theNoobProgrammer


1 Answers

/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.

like image 179
Felipe Lavratti Avatar answered Sep 30 '22 02:09

Felipe Lavratti