← Documents Documentation/userspace-api/media/cec/cec-func-open.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / CEC

CEC open()

CEC device open mode, O_NONBLOCK 의미, configuration side effect와 오류 code를 설명합니다.

Source pathDocumentation/userspace-api/media/cec/cec-func-open.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

cec-func-open.rst:1-74

CEC device는 `O_RDWR`로 열며 `O_NONBLOCK`은 receive·event·transmit·adapter 설정 ioctl의 대기 동작을 바꿉니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: CEC
3
4 .. _cec-func-open:
5
6 **********
7 cec open()
8 **********
9
10 Name
11 ====
12
13 cec-open - Open a cec device
14
15 Synopsis
16 ========
17
18 .. code-block:: c
19
20 #include <fcntl.h>
21
22 .. c:function:: int open( const char *device_name, int flags )
23
24 Arguments
25 =========
26
27 ``device_name``
28 Device to be opened.
29
30 ``flags``
31 Open flags. Access mode must be ``O_RDWR``.
32
33 When the ``O_NONBLOCK`` flag is given, the
34 :ref:`CEC_RECEIVE <CEC_RECEIVE>` and :ref:`CEC_DQEVENT <CEC_DQEVENT>` ioctls
35 will return the ``EAGAIN`` error code when no message or event is available, and
36 ioctls :ref:`CEC_TRANSMIT <CEC_TRANSMIT>`,
37 :ref:`CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>` and
38 :ref:`CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
39 all return 0.
40
41 Other flags have no effect.
42
43 Description
44 ===========
45
46 To open a cec device applications call :c:func:`open()` with the
47 desired device name. The function has no side effects; the device
48 configuration remain unchanged.
49
50 When the device is opened in read-only mode, attempts to modify its
51 configuration will result in an error, and ``errno`` will be set to
52 EBADF.
53
54 Return Value
55 ============
56
57 :c:func:`open()` returns the new file descriptor on success. On error,
58 -1 is returned, and ``errno`` is set appropriately. Possible error codes
59 include:
60
61 ``EACCES``
62 The requested access to the file is not allowed.
63
64 ``EMFILE``
65 The process already has the maximum number of files open.
66
67 ``ENFILE``
68 The system limit on the total number of open files has been reached.
69
70 ``ENOMEM``
71 Insufficient kernel memory was available.
72
73 ``ENODEV``
74 Device not found or was removed.
75

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

이름과 선언

1-21

`cec-open`은 CEC device를 엽니다. `<fcntl.h>`를 포함하며 함수 원형은 `int open(const char *device_name, int flags)`입니다.

.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: CEC

.. _cec-func-open:

**********
cec open()
**********

Name
====

cec-open - Open a cec device

Synopsis
========

.. code-block:: c

    #include <fcntl.h>

인자와 open flag

22-43

`device_name`은 열 device의 이름이고 access mode는 `O_RDWR`여야 합니다.

`O_NONBLOCK`을 주면 message나 event가 없을 때 `CEC_RECEIVE`와 `CEC_DQEVENT` ioctl이 `EAGAIN`을 반환합니다.

nonblocking mode에서 `CEC_TRANSMIT`, `CEC_ADAP_S_PHYS_ADDR`, `CEC_ADAP_S_LOG_ADDRS` ioctl은 모두 0을 반환합니다.

그 밖의 open flag는 효과가 없습니다.

open flag 의미
항목설명
device_name열 CEC device
필수 access modeO_RDWR
O_NONBLOCK receive·event없으면 EAGAIN
O_NONBLOCK transmit·설정CEC_TRANSMIT과 두 ADAP_S ioctl이 0 반환
다른 flag효과 없음

CEC API가 특별히 해석하는 access mode와 nonblocking 동작입니다.

.. c:function:: int open( const char *device_name, int flags )

Arguments
=========

``device_name``
    Device to be opened.

``flags``
    Open flags. Access mode must be ``O_RDWR``.

    When the ``O_NONBLOCK`` flag is given, the
    :ref:`CEC_RECEIVE <CEC_RECEIVE>` and :ref:`CEC_DQEVENT <CEC_DQEVENT>` ioctls
    will return the ``EAGAIN`` error code when no message or event is available, and
    ioctls :ref:`CEC_TRANSMIT <CEC_TRANSMIT>`,
    :ref:`CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>` and
    :ref:`CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
    all return 0.

    Other flags have no effect.

Description

동작

44-53

응용 프로그램은 원하는 device name으로 `open()`을 호출합니다. 이 호출 자체에는 side effect가 없으며 device configuration도 바뀌지 않습니다.

device를 read-only mode로 열고 configuration을 바꾸려 하면 오류가 발생하고 `errno`가 `EBADF`로 설정됩니다.

===========

To open a cec device applications call :c:func:`open()` with the
desired device name. The function has no side effects; the device
configuration remain unchanged.

When the device is opened in read-only mode, attempts to modify its
configuration will result in an error, and ``errno`` will be set to
EBADF.

반환값

54-59

성공하면 새 file descriptor를 반환합니다. 오류이면 -1을 반환하고 `errno`를 적절히 설정합니다.

Return Value
============

:c:func:`open()` returns the new file descriptor on success. On error,
-1 is returned, and ``errno`` is set appropriately. Possible error codes
include:

오류 code

60-74

`EACCES`는 요청한 file 접근이 허용되지 않음을 뜻합니다. `EMFILE`은 process가 이미 최대 file 수를 열었음을, `ENFILE`은 시스템 전체 open file 한도에 도달했음을 뜻합니다.

`ENOMEM`은 사용 가능한 kernel memory가 부족함을, `ENODEV`는 device를 찾을 수 없거나 제거됐음을 뜻합니다.

open() 오류
항목설명
EACCES요청한 접근이 허용되지 않음
EMFILEprocess별 open file 한도
ENFILE시스템 전체 open file 한도
ENOMEMkernel memory 부족
ENODEVdevice 없음 또는 제거됨

resource 한도와 device 상태를 구분합니다.


``EACCES``
    The requested access to the file is not allowed.

``EMFILE``
    The process already has the maximum number of files open.

``ENFILE``
    The system limit on the total number of open files has been reached.

``ENOMEM``
    Insufficient kernel memory was available.

``ENODEV``
    Device not found or was removed.