Messages in this thread | | | Date | Thu, 02 Oct 1997 23:36:33 -0400 | From | Bill Hawes <> | Subject | Re: use counts for /proc modules |
| |
Philip Gladstone wrote: > I approached the problem in a different (and yet murky) way. I have > a _fill_inode function that is pointed to by the proc_dir_entry > structure. This gets called when someone cd's into the directory. I > increment the i_count counter in the inode and also do the > MOD_INC_USE_COUNT > (first time only). > > This takes care of processes going into the directory. > > On a regular basis (every 30 seconds), I check to see if the i_count is > back to 1. (which means that nobody is in the directory). If so, then I > do the MOD_DEC_USE_COUNT, and do an iput on the inode to release it.
Hi Philip, The fill_inode call looks like just the right hook for this function. How about if I add a second argument to fill_inode, 1 or 0, non-zero means increment your module count. I'll call the function again with second argument == 0 when the inode is going out of use, so you can decrement the module count. This will give you a much cleaner interface.
I don't see any problem with overloading fill_inode to have both a first-use and last-use call, and this will save having to add a new function pointer to the dir_entry structure.
If you're willing to use your module as a guinea pig, I can send a patch tomorrow.
Regards, Bill
| |