1

I'm now studying proc file system. I now know that read_proc_t function is called when the proofs file is read, and so for write_proc_t function when the proofs file is written to. But I also find the file_operaitons* field in the definition of proc_dir_entry, and this example code (http://linux.die.net/lkmpg/x810.html).

So I'm confused that what would happen if I provide both implementations of read_proc_t function and the read function in file_operations structure? Which has the precedence over the other? Could one be overwritten by the other? Thanks very much.

nrek
  • 271
  • 3
  • 11

1 Answers1

6

When you register proc-entry, proc_register() checks if you specify proc_fops. If you don't, it will set default file operations for procfs. Default operations calls your proc_read and proc_write. So, if you specify proc_fops by yourself, proc_read and proc_write members will not be called.

In linux-3.10 there aren't such things as write_proc_t and read_proc_t. proc_dir_entry has no members read_proc and write_proc. Instead, only proc_fops is used.

Alexey Shmalko
  • 3,678
  • 1
  • 19
  • 35
  • Thanks very much rasen! Could you please tell where to get such information, like from the source code, the man page, other documentations, etc. Because I've searched the web, but it seems little useful information I could get. Thanks again! – nrek Jul 21 '13 at 21:18