I want to create a file under a /proc/driver
directory. I would like to use a macro like proc_root_driver
(or something else provided) rather than use "driver/MODULE_NAME" explicitly. I use create_proc_entry
:
struct proc_dir_entry *simpleproc_fops_entry;
simpleproc_fops_entry = create_proc_entry(MODULE_NAME, 0400, NULL /* proc_root_dir */);
After googling, I found suggestion to use proc_root_driver
, but when I use it, I get the error
proc_root_driver undeclared in this function
And also, proc_root_driver
is not available in linux/proc_fs.h.
I have tried to declare structure like this:
struct proc_dir_entry proc_root;
struct proc_dir_entry *proc_root_driver = &proc_root;
The compilation errors gone, but the file didn't appear under /proc/driver
or /proc
. How can I make create an entry in /proc
?
Looking at proc_fs.h, proc_root_driver is defined as :
so long as CONFIG_PROC_FS is enabled. If you have CONFIG_PROC_FS selected when you configure your kernel, you should be able to use it as you suggested yourself i.e. :
If this does not work, check that you have CONFIG_PROC_FS set. To make sure, you can compile your source file with the -E option and check that the create_proc_entry call includes a non NULL parameter as the last parameter. If it is NULL, or the call is not there at all, then CONFIG_PROC_FS is not enabled.
Then you can find the
/proc/driver/XX
entry.Compile this driver. If it compiles sucessfully, then you will see
/proc/ayyaz
.