I was asked this question in an interview. You are writing a PCI driver and you want to export the hardware-related information to the /proc filesystem. The interesting thing is that I searched the driver code and I couldn’t find any call related to /proc filesystem though actually the information is exported. Is it done automatically? What is the mechanism? Can anyone please explain?
Share
One way to do it is for your driver to
implement a function that will get called whenever a process reads the corresponding /proc entry with the following signature:
register your function by passing its pointer to
create_proc_read_entry(), which accepts the name of the /proc entry as a string among other things:When your driver unloads, it should remove the entry with
remove_proc_entry()