how can I instruct a module when a process open's a device file


When I open a device file, the file count is 2 instead of being 1. How is this possible? Is any reference is created internally in the kernel?

After opening the file from the User space, my kernel module also opens the same file, making the file count 3. But when the User process cleansup, it will only decrement the file count by 2, since it is not aware of the file open by kernel. The device is not closed properly since there is still a reference on the file from Kernel.
It seems somehow the user process knows that it should decrement the file count by 2? How does it keep track of this count?
Is there any way to inform the user process that the file is referenced by kernel and to decrement the file count by 3 instead of 2, so that the cleanup is done properly?
I have seen the functions provided on file operations, it seems the only way is to read the file count and decrement it. Is there any other way to do this?

Any help will be appreciated...
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!