file_operations Question, how do i know if a process that opened a file for writing has decided to c

Posted by djTeller on Stack Overflow See other posts from Stack Overflow or by djTeller
Published on 2010-05-11T18:10:35Z Indexed on 2010/05/11 22:24 UTC
Read the original article Hit count: 232

Hi Kernel Gurus,

I'm currently writing a simple "multicaster" module.

Only one process can open a proc filesystem file for writing, and the rest can open it for reading. To do so i use the inode_operation .permission callback, I check the operation and when i detect someone open a file for writing I set a flag ON.

i need a way to detect if a process that opened a file for writing has decided to close the file so i can set the flag OFF, so someone else can open for writing.

Currently in case someone is open for writing i save the current->pid of that process and when the .close callback is called I check if that process is the one I saved earlier.

Is there a better way to do that? Without saving the pid, perhaps checking the files that the current process has opened and it's permission...

Thanks!

© Stack Overflow or respective owner

Related posts about linux-kernel

Related posts about kernel-programming