Re: [Fwd: Requests regarding sysfs documentation and USB]

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

 



On Mon, 12 Oct 2009, Michael Thayer wrote:

> On Fri, 2009-10-09 at 21:59 -0400, Alan Stern wrote:
> > On Sat, 10 Oct 2009, Michael Thayer wrote:
> > > Looks reasonable for our purposes.  One question though - you mention
> > > that "The patch does not guarantee exclusive access to these devices; it
> > > is still possible for more than one program to open the device file
> > > concurrently".  Is there a specific reason for this, or would it be
> > > something that could still be changed, or perhaps added as an option?
> > 
> > This was the subject of a discussion on LKML back at the time the patch 
> > was being written.  You might be able to find it in the archives.  The 
> > overall conclusion was that there already are mechanisms for this (like 
> > O_EXCL) and the kernel doesn't need to get involved any further.
> Did you mean http://lkml.org/lkml/2009/5/9/202 ?

Yes.  I seem to recall other people (not just Kay Sievers and Alan Cox)  
contributing to the discussion, if not to that particular email thread, 
but it was five months ago and my memory could be wrong.

>  I may have
> misunderstood something here (if so, my apologies), but I thought that
> use of O_EXCL for exclusive access to devices was a convention used by
> certain drivers (like the SCSI generic code) but not actually enforced
> by the generic kernel code.  Or did you add support of that flag
> somewhere I missed?

In fact O_EXCL is not a good example.  It applies only in conjunction
with O_CREAT -- it causes the open to fail if the file already exists.  
Better examples would be the F_SETLK fcntl, flock, or lockf.

Some of these are locks are advisory and some are mandatory; the 
behavior may depend on how the filesystem was originally mounted.  If 
you really want to be sure that no other processes can open a file, the 
best way is probably to remove the file's read and write permissions.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux