xref: /OK3568_Linux_fs/kernel/Documentation/userspace-api/media/mediactl/media-func-open.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2*4882a593Smuzhiyun.. c:namespace:: MC
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun.. _media-func-open:
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun************
7*4882a593Smuzhiyunmedia open()
8*4882a593Smuzhiyun************
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunName
11*4882a593Smuzhiyun====
12*4882a593Smuzhiyun
13*4882a593Smuzhiyunmedia-open - Open a media device
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunSynopsis
16*4882a593Smuzhiyun========
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun.. code-block:: c
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun    #include <fcntl.h>
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun.. c:function:: int open( const char *device_name, int flags )
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunArguments
25*4882a593Smuzhiyun=========
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun``device_name``
28*4882a593Smuzhiyun    Device to be opened.
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun``flags``
31*4882a593Smuzhiyun    Open flags. Access mode must be either ``O_RDONLY`` or ``O_RDWR``.
32*4882a593Smuzhiyun    Other flags have no effect.
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunDescription
35*4882a593Smuzhiyun===========
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunTo open a media device applications call :c:func:`open()` with the
38*4882a593Smuzhiyundesired device name. The function has no side effects; the device
39*4882a593Smuzhiyunconfiguration remain unchanged.
40*4882a593Smuzhiyun
41*4882a593SmuzhiyunWhen the device is opened in read-only mode, attempts to modify its
42*4882a593Smuzhiyunconfiguration will result in an error, and ``errno`` will be set to
43*4882a593SmuzhiyunEBADF.
44*4882a593Smuzhiyun
45*4882a593SmuzhiyunReturn Value
46*4882a593Smuzhiyun============
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun:c:func:`open()` returns the new file descriptor on success. On error,
49*4882a593Smuzhiyun-1 is returned, and ``errno`` is set appropriately. Possible error codes
50*4882a593Smuzhiyunare:
51*4882a593Smuzhiyun
52*4882a593SmuzhiyunEACCES
53*4882a593Smuzhiyun    The requested access to the file is not allowed.
54*4882a593Smuzhiyun
55*4882a593SmuzhiyunEMFILE
56*4882a593Smuzhiyun    The process already has the maximum number of files open.
57*4882a593Smuzhiyun
58*4882a593SmuzhiyunENFILE
59*4882a593Smuzhiyun    The system limit on the total number of open files has been reached.
60*4882a593Smuzhiyun
61*4882a593SmuzhiyunENOMEM
62*4882a593Smuzhiyun    Insufficient kernel memory was available.
63*4882a593Smuzhiyun
64*4882a593SmuzhiyunENXIO
65*4882a593Smuzhiyun    No device corresponding to this device special file exists.
66