요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. 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>
.. 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
===========
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.
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:
``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.
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는 효과가 없습니다.
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를 찾을 수 없거나 제거됐음을 뜻합니다.
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.
요약·해설
cec-func-open.rst:1-74CEC device는 `O_RDWR`로 열며 `O_NONBLOCK`은 receive·event·transmit·adapter 설정 ioctl의 대기 동작을 바꿉니다.