xref: /linux/Documentation/userspace-api/media/mediactl/media-func-open.rst (revision 95298d63c67673c654c08952672d016212b26054)
1.. Permission is granted to copy, distribute and/or modify this
2.. document under the terms of the GNU Free Documentation License,
3.. Version 1.1 or any later version published by the Free Software
4.. Foundation, with no Invariant Sections, no Front-Cover Texts
5.. and no Back-Cover Texts. A copy of the license is included at
6.. Documentation/userspace-api/media/fdl-appendix.rst.
7..
8.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9
10.. _media-func-open:
11
12************
13media open()
14************
15
16Name
17====
18
19media-open - Open a media device
20
21
22Synopsis
23========
24
25.. code-block:: c
26
27    #include <fcntl.h>
28
29
30.. c:function:: int open( const char *device_name, int flags )
31    :name: mc-open
32
33Arguments
34=========
35
36``device_name``
37    Device to be opened.
38
39``flags``
40    Open flags. Access mode must be either ``O_RDONLY`` or ``O_RDWR``.
41    Other flags have no effect.
42
43
44Description
45===========
46
47To open a media device applications call :ref:`open() <media-func-open>` with the
48desired device name. The function has no side effects; the device
49configuration remain unchanged.
50
51When the device is opened in read-only mode, attempts to modify its
52configuration will result in an error, and ``errno`` will be set to
53EBADF.
54
55
56Return Value
57============
58
59:ref:`open() <func-open>` returns the new file descriptor on success. On error,
60-1 is returned, and ``errno`` is set appropriately. Possible error codes
61are:
62
63EACCES
64    The requested access to the file is not allowed.
65
66EMFILE
67    The process already has the maximum number of files open.
68
69ENFILE
70    The system limit on the total number of open files has been reached.
71
72ENOMEM
73    Insufficient kernel memory was available.
74
75ENXIO
76    No device corresponding to this device special file exists.
77