> I've encountered this problem before, too. What is the "One True Way"
> to do this cleanly? In other words, if you want to do a calculation
> once every time someone runs "cat /proc/foo", what is the cleanest way
> to do that? The solution we came up with was to check the file offset
> and only do the calculation if offset == 0, which seems pretty
> hackish.
I've tried it and... it works ! :)
Many many thanks :)
In the meantime, I've also followed Tommy Reynolds' advice to not modify
global state variables within read_procmem. I've intercepted a syscall which
does the calculation (I've used the open syscall since it allowed me to
increase the counter by just running vi on any file ;) ) and put it into a
buffer which is dumped when the /proc entry is read. Works great that way too.
By the way, as the final module will intercept syscalls like open, creat,
close, link, unlink, mkdir, etc. , I'm wondering if there'll be a dramatic
negative impact on file operations performance. Is there any efficient method
to measure this ?
In any case, thanks for all the help you gave me :)
Regards,
Laurent Sinitambirivoutin
laurent@augias.org
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Feb 28 2002 - 21:00:40 EST