Can someone give me proc_create() example?
proc_create()
Earlier they used create_proc_entry() in the kernel but now they are using proc_create().
create_proc_entry()
This example will create a proc entry which enables reading access. I think you can enable other kinds of access by changing the mode argument passed to the function. I haven't passed a parent directory because there is no need to. The structure file_operations is where you setup your reading and writing callbacks.
mode
file_operations
struct proc_dir_entry *proc_file_entry; static const struct file_operations proc_file_fops = { .owner = THIS_MODULE, .open = open_callback, .read = read_callback, }; int __init init_module(void){ proc_file_entry = proc_create("proc_file_name", 0, NULL, &proc_file_fops); if(proc_file_entry == NULL) return -ENOMEM; return 0; }
You can check this example for more details: https://www.linux.com/learn/linux-training/37985-the-kernel-newbie-corner-kernel-debugging-using-proc-qsequenceq-files-part-1
2.1m questions
2.1m answers
60 comments
57.0k users