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

Linux 6.18.37 · Userspace API / Media / Media Controller

media open()

Media device를 여는 access mode, side effect와 오류를 정의합니다.

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

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

1. 요약·해설

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

요약·해설

media-func-open.rst:1-65

`open()`은 device configuration을 바꾸지 않습니다. Read-only descriptor로 configuration 변경을 시도하면 `EBADF`가 발생합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: MC
3
4 .. _media-func-open:
5
6 ************
7 media open()
8 ************
9
10 Name
11 ====
12
13 media-open - Open a media 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 either ``O_RDONLY`` or ``O_RDWR``.
32 Other flags have no effect.
33
34 Description
35 ===========
36
37 To open a media device applications call :c:func:`open()` with the
38 desired device name. The function has no side effects; the device
39 configuration remain unchanged.
40
41 When the device is opened in read-only mode, attempts to modify its
42 configuration will result in an error, and ``errno`` will be set to
43 EBADF.
44
45 Return Value
46 ============
47
48 :c:func:`open()` returns the new file descriptor on success. On error,
49 -1 is returned, and ``errno`` is set appropriately. Possible error codes
50 are:
51
52 EACCES
53 The requested access to the file is not allowed.
54
55 EMFILE
56 The process already has the maximum number of files open.
57
58 ENFILE
59 The system limit on the total number of open files has been reached.
60
61 ENOMEM
62 Insufficient kernel memory was available.
63
64 ENXIO
65 No device corresponding to this device special file exists.
66

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는 영향을 주지 않습니다.

open() access mode
Mode효과
O_RDONLY읽기 전용, configuration 변경 시 EBADF
O_RDWR읽기·쓰기, 허용된 configuration 변경 가능

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-44

Application은 원하는 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`를 알맞게 설정합니다.

open() error code
errno의미
EACCES요청한 file access가 허용되지 않음
EMFILEProcess가 이미 열 수 있는 최대 file 수에 도달함
ENFILESystem 전체 open file 수 제한에 도달함
ENOMEM사용 가능한 Kernel memory가 부족함
ENXIODevice special file에 대응하는 device가 없음

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.