I'm taking a course in operating systems and we work in Linux (Red hat 8.0). I'm trying to implement a file open,close tracker that will save for every process a history of files it opens and closes. I expected sys_open,close to also accept the process id and that I could use that to access the history of the process that initiated the call and update it (making the update part of the sysopen,close functions). However, these functions don't accept the pid as a parameter, so I'm a bit lost as to how to associate opening/closing files to the process that initiated that. My only guess is that since at any given time there's only one active process, that its meta-data must be global in some way, but I have no idea where or how to find it. Any advice would be appreciated.
+2
A:
Do you intend to do this in kernel space? Given that you were looking directly at sys_open etc, which sit in kernel space, IIRC, you can use the current pointer to see the current
process's pid (current->pid
).
abyx
2009-11-02 14:25:01
I think I misunderstood his question. Somehow I got the idea that he wanted to keep it out of the kernel.
Tim Post
2009-11-02 14:34:24
@tinkertim - or maybe I misunderstood... We'll wait and see :)
abyx
2009-11-02 14:35:03
No you are correct, I wanted this to be in kernel space. Thanks.
Epsilon Vector
2009-11-02 16:34:54