요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: MC
.. _media-func-open:
************
media open()
************
Name
====
media-open - Open a media 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 either ``O_RDONLY`` or ``O_RDWR``.
Other flags have no effect.
Description
===========
To open a media 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
are:
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.
ENXIO
No device corresponding to this device special file exists.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
이름과 선언
1-23`media-open`은 media device를 엽니다. `<fcntl.h>`를 include하고 `int open(const char *device_name, int flags)` 형식으로 호출합니다.
#include <fcntl.h>
int open(const char *device_name, int flags);
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: MC
.. _media-func-open:
************
media open()
************
Name
====
media-open - Open a media device
Synopsis
========
.. code-block:: c
#include <fcntl.h>
.. c:function:: int open( const char *device_name, int flags )
Arguments와 access mode
24-33`device_name`은 열 device를 지정합니다.
`flags`는 open flag입니다. Access mode는 `O_RDONLY` 또는 `O_RDWR`여야 하며 다른 flag는 영향을 주지 않습니다.
Media device를 읽기 전용 또는 읽기·쓰기 mode로 엽니다.
Arguments
=========
``device_name``
Device to be opened.
``flags``
Open flags. Access mode must be either ``O_RDONLY`` or ``O_RDWR``.
Other flags have no effect.
Device 열기와 side effect
34-44Application은 원하는 device 이름으로 `open()`을 호출하여 media device를 엽니다. 함수에는 side effect가 없고 device configuration은 바뀌지 않습니다.
Device를 read-only mode로 열었을 때 configuration을 변경하려 하면 오류가 발생하고 `errno`는 `EBADF`로 설정됩니다.
Description
===========
To open a media 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.
반환값과 오류
45-65성공하면 `open()`은 새 file descriptor를 반환합니다. 오류가 발생하면 -1을 반환하고 `errno`를 알맞게 설정합니다.
Media device를 열 때 명시된 오류입니다.
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
are:
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.
ENXIO
No device corresponding to this device special file exists.
요약·해설
media-func-open.rst:1-65`open()`은 device configuration을 바꾸지 않습니다. Read-only descriptor로 configuration 변경을 시도하면 `EBADF`가 발생합니다.