[PATCH 04/12] misc: xilinx_sdfec: Add open, close and ioctl

Dragan Cvetic draganc at xilinx.com
Tue Mar 19 11:10:35 PDT 2019



> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd at arndb.de]
> Sent: Tuesday 19 March 2019 15:36
> To: Dragan Cvetic <draganc at xilinx.com>
> Cc: gregkh <gregkh at linuxfoundation.org>; Michal Simek <michals at xilinx.com>; Linux ARM <linux-arm-kernel at lists.infradead.org>;
> Derek Kiernan <dkiernan at xilinx.com>; Linux Kernel Mailing List <linux-kernel at vger.kernel.org>
> Subject: Re: [PATCH 04/12] misc: xilinx_sdfec: Add open, close and ioctl
> 
> On Tue, Mar 19, 2019 at 3:59 PM Dragan Cvetic <draganc at xilinx.com> wrote:
> > >
> > > > +       /* Only one open per device at a time */
> > > > +       if (!atomic_dec_and_test(&xsdfec->open_count)) {
> > > > +               atomic_inc(&xsdfec->open_count);
> > > > +               return -EBUSY;
> > > > +       }
> > >
> > > What is that limitation for? Is it worse to open it twice than
> > > to dup() or fork()?
> > >
> > The device can be opened only once.
> 
> What I mean here is that preventing the double open() is
> a fairly weak protection: it means you cannot have multiple
> 'struct file' pointers attached to the same inode, but you
> can still have the same 'struct file' being available to
> multiple processes.
> 
Could you please suggest the solution?
My intention was to prevent more than one process access the same device.

>          Arnd


Thanks
Dragan


More information about the linux-arm-kernel mailing list