요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
Mount options
binderfs.rst:28-41Instance별 max와 initial-user-namespace 전용 global statistics를 설명합니다.
Device allocation
binderfs.rst:42-63BINDER_CTL_ADD ioctl과 struct binder_device로 이름·major/minor를 교환합니다.
Device deletion
binderfs.rst:64-75일반 node는 unlink할 수 있지만 binder-control은 mount 수명과 함께합니다.
Feature probing
binderfs.rst:76-87features directory의 file 존재와 값으로 driver capability를 확인합니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
The Android binderfs Filesystem
===============================
Android binderfs is a filesystem for the Android binder IPC mechanism. It
allows to dynamically add and remove binder devices at runtime. Binder devices
located in a new binderfs instance are independent of binder devices located in
other binderfs instances. Mounting a new binderfs instance makes it possible
to get a set of private binder devices.
Mounting binderfs
-----------------
Android binderfs can be mounted with::
mkdir /dev/binderfs
mount -t binder binder /dev/binderfs
at which point a new instance of binderfs will show up at ``/dev/binderfs``.
In a fresh instance of binderfs no binder devices will be present. There will
only be a ``binder-control`` device which serves as the request handler for
binderfs. Mounting another binderfs instance at a different location will
create a new and separate instance from all other binderfs mounts. This is
identical to the behavior of e.g. ``devpts`` and ``tmpfs``. The Android
binderfs filesystem can be mounted in user namespaces.
Options
-------
max
binderfs instances can be mounted with a limit on the number of binder
devices that can be allocated. The ``max=<count>`` mount option serves as
a per-instance limit. If ``max=<count>`` is set then only ``<count>`` number
of binder devices can be allocated in this binderfs instance.
stats
Using ``stats=global`` enables global binder statistics.
``stats=global`` is only available for a binderfs instance mounted in the
initial user namespace. An attempt to use the option to mount a binderfs
instance in another user namespace will return a permission error.
Allocating binder Devices
-------------------------
.. _ioctl: http://man7.org/linux/man-pages/man2/ioctl.2.html
To allocate a new binder device in a binderfs instance a request needs to be
sent through the ``binder-control`` device node. A request is sent in the form
of an `ioctl() <ioctl_>`_.
What a program needs to do is to open the ``binder-control`` device node and
send a ``BINDER_CTL_ADD`` request to the kernel. Users of binderfs need to
tell the kernel which name the new binder device should get. By default a name
can only contain up to ``BINDERFS_MAX_NAME`` chars including the terminating
zero byte.
Once the request is made via an `ioctl() <ioctl_>`_ passing a ``struct
binder_device`` with the name to the kernel it will allocate a new binder
device and return the major and minor number of the new device in the struct
(This is necessary because binderfs allocates a major device number
dynamically.). After the `ioctl() <ioctl_>`_ returns there will be a new
binder device located under /dev/binderfs with the chosen name.
Deleting binder Devices
-----------------------
.. _unlink: http://man7.org/linux/man-pages/man2/unlink.2.html
.. _rm: http://man7.org/linux/man-pages/man1/rm.1.html
Binderfs binder devices can be deleted via `unlink() <unlink_>`_. This means
that the `rm() <rm_>`_ tool can be used to delete them. Note that the
``binder-control`` device cannot be deleted since this would make the binderfs
instance unusable. The ``binder-control`` device will be deleted when the
binderfs instance is unmounted and all references to it have been dropped.
Binder features
---------------
Assuming an instance of binderfs has been mounted at ``/dev/binderfs``, the
features supported by the binder driver can be located under
``/dev/binderfs/features/``. The presence of individual files can be tested
to determine whether a particular feature is supported by the driver.
Example::
cat /dev/binderfs/features/oneway_spam_detection
1
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
BinderFS 개요와 mount
1-27이 GPL-2.0 문서는 Android binder IPC mechanism을 위한 BinderFS filesystem을 설명합니다. Runtime에 binder device를 동적으로 추가·제거할 수 있고, 새 BinderFS instance의 device는 다른 instance의 device와 독립적입니다. 따라서 새 instance를 mount하면 private binder-device set을 얻을 수 있습니다.
BinderFS는 다음처럼 `/dev/binderfs`에 mount합니다.
Android binderfs can be mounted with::
mkdir /dev/binderfs
mount -t binder binder /dev/binderfs
새 instance에는 일반 binder device가 없고 BinderFS request handler인 `binder-control`만 있습니다. 다른 위치에 mount하면 `devpts`, `tmpfs`처럼 다른 mount와 분리된 새 instance가 생깁니다. BinderFS는 user namespace 안에서도 mount할 수 있습니다.
Mount마다 독립된 binder-control과 device namespace를 만듭니다.
BinderFS mount option
28-41Instance별 device limit와 global statistic 접근 범위입니다.
`stats=global`을 다른 user namespace의 BinderFS mount에 사용하면 permission error를 반환합니다.
Binder device 할당
42-63새 binder device를 할당하려면 `binder-control` device node를 통해 `ioctl()` request를 보냅니다. Program은 node를 open하고 kernel에 `BINDER_CTL_ADD` request를 보내며 새 device의 이름을 전달합니다. 이름은 terminating zero byte를 포함해 기본적으로 `BINDERFS_MAX_NAME` characters까지 가능합니다.
이름을 담은 `struct binder_device`를 `ioctl()`로 넘기면 kernel이 새 binder device를 할당하고, BinderFS가 major device number를 동적으로 할당하므로 새 device의 major/minor number를 같은 struct에 반환합니다. `ioctl()`이 끝나면 선택한 이름의 device가 `/dev/binderfs` 아래에 나타납니다.
Control node request와 동적 device-number 반환 순서입니다.
Binder device 삭제
64-75BinderFS의 binder device는 `unlink()`로 삭제할 수 있으므로 `rm` tool도 사용할 수 있습니다. 그러나 `binder-control`을 삭제하면 instance를 사용할 수 없게 되므로 삭제할 수 없습니다.
`binder-control`은 BinderFS instance를 unmount하고 모든 reference가 사라질 때 삭제됩니다.
일반 device와 control node의 수명 규칙이 다릅니다.
Binder feature 탐지
76-87`/dev/binderfs`에 mount했다고 가정하면 binder driver가 지원하는 feature는 `/dev/binderfs/features/` 아래에서 확인합니다. 개별 file의 존재 여부로 특정 feature 지원을 판정할 수 있습니다.
Example::
cat /dev/binderfs/features/oneway_spam_detection
1
Feature file이 존재하고 1을 반환하는 예입니다.
Mount and isolation
binderfs.rst:1-27Mount마다 private binder device namespace와 binder-control을 만듭니다.