18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
28c2ecf20Sopenharmony_ci.. c:namespace:: MC
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci.. _media-func-open:
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci************
78c2ecf20Sopenharmony_cimedia open()
88c2ecf20Sopenharmony_ci************
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciName
118c2ecf20Sopenharmony_ci====
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cimedia-open - Open a media device
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciSynopsis
168c2ecf20Sopenharmony_ci========
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci.. code-block:: c
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci    #include <fcntl.h>
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci.. c:function:: int open( const char *device_name, int flags )
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciArguments
258c2ecf20Sopenharmony_ci=========
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci``device_name``
288c2ecf20Sopenharmony_ci    Device to be opened.
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci``flags``
318c2ecf20Sopenharmony_ci    Open flags. Access mode must be either ``O_RDONLY`` or ``O_RDWR``.
328c2ecf20Sopenharmony_ci    Other flags have no effect.
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciDescription
358c2ecf20Sopenharmony_ci===========
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ciTo open a media device applications call :c:func:`open()` with the
388c2ecf20Sopenharmony_cidesired device name. The function has no side effects; the device
398c2ecf20Sopenharmony_ciconfiguration remain unchanged.
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciWhen the device is opened in read-only mode, attempts to modify its
428c2ecf20Sopenharmony_ciconfiguration will result in an error, and ``errno`` will be set to
438c2ecf20Sopenharmony_ciEBADF.
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ciReturn Value
468c2ecf20Sopenharmony_ci============
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci:c:func:`open()` returns the new file descriptor on success. On error,
498c2ecf20Sopenharmony_ci-1 is returned, and ``errno`` is set appropriately. Possible error codes
508c2ecf20Sopenharmony_ciare:
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciEACCES
538c2ecf20Sopenharmony_ci    The requested access to the file is not allowed.
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ciEMFILE
568c2ecf20Sopenharmony_ci    The process already has the maximum number of files open.
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ciENFILE
598c2ecf20Sopenharmony_ci    The system limit on the total number of open files has been reached.
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ciENOMEM
628c2ecf20Sopenharmony_ci    Insufficient kernel memory was available.
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ciENXIO
658c2ecf20Sopenharmony_ci    No device corresponding to this device special file exists.
66