r/linuxdev • u/NotAHippo4 • Apr 10 '20
How to write to a proc file?
I need to make this linux kernel module where I am supposed to get the source and destination IP addresses of some docker containers and print them out in a file. I can capture IP addresses and print them out on the kernel log.
After hours of trying to figure out how to use proc_fs.h, I managed to find out how to create a proc_dir_entry . Now since, I am using netfilter.h to capture packets, I need the file to be written every time the hook function gets called. I found this function in proc_fs.h but I don't quite understand it:
typedef int (*proc_write_t)(struct file *, char *, size_t);
Is this function changing instances of int to some struct called proc_write_t composed of a file pointer, char pointer, and the size of what you are going to write?
View all comments
Show parent comment
1
u/NotAHippo4 Apr 11 '20
Also, I am reading about sysfs.h. Isnt the sysfs supposed to be used for actual devices or computer resources instead of simply files?