Hi,
I'm currently trying to write a somewhat modified device driver and what I need to do is instead of using the default read/write functions for the file_operations struct, I need to use my own read and write.
I was able to successfully point the file operations structure to my own read and write functions using the syntax:
Code:
static struct file_operations my_fops = {
.read = my_read,
.write = my_write
};
These register fine and my functions get called. But there's one main problem, I really don't want to rewrite a whole new read/write function since all I need to do is add one additional section of code to the function at the top to simply modify the buffer, so I don't need to redo the whole read/write.
Is there a way for me to, after entering my functions for read/write (my_read, my_write) and modifying the buffer, then call the default read/write file_operations functions to do the read/write for me simply with the modified buffer I made?
Since the file_operations struct automatically points to its default read and write functions I've been trying to find out what those functions were or where they were located so I could just call them myself but I'm having no luck. And once I make the file_operations struct point to my own read and write I have no idea how to find the read/write functions that were going to be used before I changed them.
Ideally, I'd like the code to look something like this:
Code:
static ssize_t my_read(struct file *filp, char *buffer, size_t count, loff_t *offset)
{
Modify buffer (change it's information/characters)
return default_read(filp, buffer, count, offset);
}
This seems like it is possible to me but I just can't find the default read and write functions to call them, does anyone know where they are or how to use them?
Thank you for any help