^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) .. c:namespace:: MC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) .. _media-func-open:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) ************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) media open()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) ************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) media-open - Open a media device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Synopsis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <fcntl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) .. c:function:: int open( const char *device_name, int flags )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) Arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ``device_name``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) Device to be opened.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ``flags``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) Open flags. Access mode must be either ``O_RDONLY`` or ``O_RDWR``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) Other flags have no effect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) To open a media device applications call :c:func:`open()` with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) desired device name. The function has no side effects; the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) configuration remain unchanged.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) When the device is opened in read-only mode, attempts to modify its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) configuration will result in an error, and ``errno`` will be set to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) EBADF.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) Return Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) :c:func:`open()` returns the new file descriptor on success. On error,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) -1 is returned, and ``errno`` is set appropriately. Possible error codes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) EACCES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) The requested access to the file is not allowed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) EMFILE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) The process already has the maximum number of files open.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) ENFILE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) The system limit on the total number of open files has been reached.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) ENOMEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) Insufficient kernel memory was available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ENXIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) No device corresponding to this device special file exists.