tags 339037 fixed-upstream
thanks

Hello Avery,

> If you read the LEASES section of fcntl(2), it explains that open() with
> O_NONBLOCK could cause open to return EWOULDBLOCK.  This is not explained
> anywhere on the open() page; open() has many possible return codes, none
> of which are EWOULDBLOCK.  (There is a comment about opening fifos in
> nonblocking mode, but the error code description implies that this would
> return ENXIO, not EWOULDBLOCK.)

Thanks.  In open.2, I have added the following text:

       EWOULDBLOCK
              The O_NONBLOCK flag was specified, and an incom-
              patible   lease   was  held  on  the  file  (see
              fcntl(2)).

> Also, the fcntl(2) page doesn't say whether opening a leased file with
> O_NONBLOCK will actually request the lease to be broken or not.  

It explains a sequence of steps, which include the lease being
broken.  Those steps occur independently of O_NONBLOCK.  The
man page does pretty much imply that IMO.  But I do agree that
things could be stated a little more verbosely.

> It appears you *have* to open in blocking mode in order to 
> open a leased file at all,

Yes.

> but that's not clear from the description.

Again, I would say that's fairly clear from the man page:
if the open() call returns (i.e., fails) with EWOULDBLOCK, 
then clearly the file was not opened.  But again, it might 
help to add a little more text.

> It wouldn't be so bad to open in blocking mode since a lease is 
> guaranteed
> to be broken after a certain timeout.  But a naive implementation would
> introduce a security hole since the file might be replaced by surprise
> with a FIFO, which has no open timeout at all.

I do not understand this last piece.

In fcntl.2, I removed the phrase that you referred to that
specified O_NONBLOCK.  Later in the description, I added
this new text:

       If the lease breaker's blocked open() or truncate()  is
       interrupted  by  a signal handler, then the system call
       fails with the error EINTR, but the other  steps  still
       occur  as  described  above.   If  the lease breaker is
       killed by a signal while blocked  in  open()  or  trun-
       cate(),  then  the other steps still occur as described
       above.  If the lease breaker specifies  the  O_NONBLOCK
       flag  when  calling  open(),  then the call immediately
       fails with the error EWOULDBLOCK, but the  other  steps
       still occur as described above.

These changes will appear in man-pages-2.14.

Cheers,

Michael

-- 
Michael Kerrisk
maintainer of Linux man pages Sections 2, 3, 4, 5, and 7 

Want to help with man page maintenance?  Grab the latest
tarball at ftp://ftp.win.tue.nl/pub/linux-local/manpages/
and grep the source files for 'FIXME'.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to