Re: [NEWBIE] Is it legal for open() to return -EBUSY?

Santosh Sivaraj <[email protected]> Wed, 27 Sep 2017 13:39:25 +0530
Newsgroups gmane.linux.newbie
Message-ID <[email protected]>
* Zheng Lv <[email protected]> wrote (on 2017-09-26 10:45:39 +0000):

> In LDD3, Chapter 6, Section "Restricting Access to a Single User at a Time", the example code returns -EBUSY when the chardev is in use by another user. However, I "man 3p open" and "man 2 open", finding that ERRORS section of either manual didn't mention about EBUSY.
> 
> I would like to ask if it's legal for open() to return -EBUSY.

Yes, it is legal. Many drivers return EBUSY when they are only supposed to be
opened once. Probably some vga/drm/audio drivers etc. The `open` man page is
mostly directed towards (filesystem) files and directories, so all kinds of
errors are not covered.

Imagine a case where a device requires a interrupt line that can't be shared, in
which case EBUSY would be the right thing to return.

Thanks,
Santosh
> 
> Zheng Lv
> --
> To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
> the body of a message to [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs

-- 
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs