Thread (12 messages) 12 messages, 6 authors, 2011-09-28

Prevent a process from opening a file more than once

From: Mulyadi Santosa <hidden>
Date: 2011-09-28 00:35:01

On Wed, Sep 28, 2011 at 07:30, Venkatram Tummala [off-list ref] wrote:
On Tue, Sep 27, 2011 at 5:22 PM, Mulyadi Santosa [off-list ref]
wrote:
quoted
Hi :)

On Wed, Sep 28, 2011 at 06:56, Venkatram Tummala [off-list ref]
wrote:
quoted
Hi All,
I have a simple device driver which creates a /dev/XYZ file. I need to
prevent a process from opening the file more than once. However,
multiple
processes can open the file simultaneously. Is there any any elegant way
to
do this other than checking all opened files in the process ?
Uhm, keep a reference count and increment it on every file open in
your module? How does that sound?
Well, which refcount should i use? I can't use the refcount in the file
object as the file objects passed to me are different each time the file is
opened in the process.
Sorry, I mean something that traps everytime that file is opened and
increase a count. Thinking a while, inotify might do the job perfectly
IMHO....

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help