RE: Prevent a process from opening a file more than once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




From: kernelnewbies-bounces@xxxxxxxxxxxxxxxxx
[mailto:kernelnewbies-bounces@xxxxxxxxxxxxxxxxx] On Behalf Of Venkatram
Tummala
Sent: Tuesday, September 27, 2011 5:31 PM
To: Mulyadi Santosa
Cc: kernelnewbies
Subject: Re: Prevent a process from opening a file more than once

On Tue, Sep 27, 2011 at 5:22 PM, Mulyadi Santosa
<mulyadi.santosa@xxxxxxxxx> wrote:
Hi :)

On Wed, Sep 28, 2011 at 06:56, Venkatram Tummala
<venkatram867@xxxxxxxxx> wrote:
> 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.

When you say "I need to prevent a process from opening the file more
than once.", do you mean a single process opening the file, closing it
and then opening it again would be disallowed? Or do you mean that a
single process opening the file, keeping it open and then opening it
again under another fd would be disallowed?

How about multiple threads within the same process? Are they treated as
the same process by these rules?




_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux