Results 1 to 2 of 2
I'm writing a kernel module that will create a directory in /proc and will dynamically create a set of files based on parameters passed in when the module is loaded. ...
- 02-26-2010 #1Just Joined!
- Join Date
- Feb 2010
- Posts
- 2
Filename in Kernel Module file_operations.read
I'm writing a kernel module that will create a directory in /proc and will dynamically create a set of files based on parameters passed in when the module is loaded. I want to have a single read function for all these files and then figure out which file it is from inside that function.
So if I do a `cat /proc/registers/2` I'd call procfs_read_registers and somehow figure out that I'm reading "2".
Dug through the kernel source but between that and the man pages I'm a bit lost.Code:static ssize_t procfs_read_registers( struct file *filp, char *buff, size_t len, loff_t *offset) { // Find File Name and write back the data for that register. } static const struct file_operations procfs_operations_registers = { .owner = THIS_MODULE, .open = procfs_open_registers, .read = procfs_read_registers, .release = procfs_read_registers, };
- 02-26-2010 #2Just Joined!
- Join Date
- Feb 2010
- Posts
- 2
Figured it out.
Code:filp->f_path.dentry->d_iname


Reply With Quote
