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