Part 1
요약·해설
Globally unique type ID, fs_register·fs_unregister, fs_mount_t declaration과 FATFS·LittleFS sample을 설명합니다.
Virtual Filesystem Switch
Mount points
FATFS · LittleFS
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
A8DDFFF3303D27A0461FD4ECB04BC9370BA53301802C4107840E6AB30FA27657
.. _file_system_api:
File Systems
############
Zephyr RTOS Virtual Filesystem Switch (VFS) allows applications to mount multiple
file systems at different mount points (e.g., ``/fatfs`` and ``/lfs``). The
mount point data structure contains all the necessary information required
to instantiate, mount, and operate on a file system. The File system Switch
decouples the applications from directly accessing an individual file system's
specific API or internal functions by introducing file system registration
mechanisms.
In Zephyr, any file system implementation or library can be plugged into or
pulled out through a file system registration API. Each file system
implementation must have a globally unique integer identifier; use
:c:macro:`FS_TYPE_EXTERNAL_BASE` to avoid clashes with in-tree identifiers.
.. code-block:: c
int fs_register(int type, const struct fs_file_system_t *fs);
int fs_unregister(int type, const struct fs_file_system_t *fs);
Zephyr RTOS supports multiple instances of a file system by making use of
the mount point as the disk volume name, which is used by the file system library
while formatting or mounting a disk.
A file system is declared as:
.. code-block:: c
static struct fs_mount_t mp = {
.type = FS_FATFS,
.mnt_point = FATFS_MNTP,
.fs_data = &fat_fs,
};
where
- ``FS_FATFS`` is the file system type like FATFS or LittleFS.
- ``FATFS_MNTP`` is the mount point where the file system will be mounted.
- ``fat_fs`` is the file system data which will be used by fs_mount() API.
Samples
*******
Samples for the VFS are mainly supplied in ``samples/subsys/fs``, although various examples of the
VFS usage are provided as important functionalities in samples for different subsystems.
Here is the list of samples worth looking at:
- ``samples/subsys/fs/fat_fs`` is an example of FAT file system usage with SDHC media;
- ``samples/subsys/shell/fs`` is an example of Shell fs subsystem, using internal flash partition
formatted to LittleFS;
- ``samples/subsys/usb/mass/`` example of USB Mass Storage device that uses FAT FS driver with RAM
or SPI connected FLASH, or LittleFS in flash, depending on the sample configuration.
API Reference
*************
.. doxygengroup:: file_system_api
Part 3
한국어 전문 번역
Zephyr RTOS Virtual Filesystem Switch(VFS)는 application이 서로 다른 mount point, 예를 들어 /fatfs와 /lfs에 여러 file system을 mount할 수 있게 합니다. Mount point data structure에는 file system instance를 만들고 mount하고 조작하는 데 필요한 정보가 모두 들어 있습니다. File System Switch는 file system registration mechanism을 제공해 application이 각 file system의 전용 API나 internal function에 직접 의존하지 않게 합니다.
Zephyr에서는 어떤 file system implementation이나 library도 registration API로 넣거나 뺄 수 있습니다. 각 implementation에는 전역에서 유일한 integer identifier가 필요합니다. In-tree identifier와 충돌하지 않으려면 FS_TYPE_EXTERNAL_BASE를 사용합니다.
int fs_register(int type, const struct fs_file_system_t *fs);
int fs_unregister(int type, const struct fs_file_system_t *fs);
Zephyr RTOS는 mount point를 disk volume name으로 사용해 같은 file system의 여러 instance를 지원합니다. File system library는 disk를 format하거나 mount할 때 이 이름을 사용합니다.
File system mount는 다음과 같이 선언합니다.
static struct fs_mount_t mp = {
.type = FS_FATFS,
.mnt_point = FATFS_MNTP,
.fs_data = &fat_fs,
};
FS_FATFS는 FATFS나 LittleFS 같은 file system type입니다.FATFS_MNTP는 file system을 mount할 mount point입니다.fat_fs는fs_mount()API가 사용할 file system data입니다.
Samples
VFS sample은 주로 samples/subsys/fs에 있으며, 다른 subsystem sample에서도 핵심 기능으로 VFS를 사용하는 예를 찾을 수 있습니다. 특히 다음 sample을 살펴볼 만합니다.
samples/subsys/fs/fat_fs: SDHC media에서 FAT file system을 사용하는 예입니다.samples/subsys/shell/fs: internal flash partition을 LittleFS로 format해 사용하는 Shell fs subsystem 예입니다.samples/subsys/usb/mass/: configuration에 따라 RAM·SPI-connected flash의 FAT FS driver 또는 flash의 LittleFS를 사용하는 USB Mass Storage device 예입니다.
API Reference
VFS 등록, mount, file·directory operation 관련 API는 file_system_api Doxygen group에 정의돼 있습니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.