File System

The OpenHarmony LiteOS-M kernel supports File Allocation Table file system (FATFS) and LittleFS file systems. Like the OpenHarmony LiteOS-A kernel, the OpenHarmony LiteOS-M kernel provides POSIX over the virtual file system (VFS) to ensure interface consistency. However, the VFS of the LiteOS-M kernel is light due to insufficient resources and does not provide advanced functions (such as pagecache). Therefore, the VFS of the LiteOS-M kernel implements only API standardization and adaptation. The file systems handle specific transactions. The following table lists the functions supported by the file systems.

Table 1 Function list

Function

API

Description

FATFS

LITTLEFS

File management

open

Opens a file.

Supported

Supported

close

Closes a file.

Supported

Supported

read

Reads a file.

Supported

Supported

write

Writes data to a file.

Supported

Supported

lseek

Sets the file offset.

Supported

Supported

unlink

Deletes a file.

Supported

Supported

rename

Renames a file.

Supported

Supported

fstat

Obtains file information based on the file handle.

Supported

Supported

stat

Obtains file information based on the file path name.

Supported

Supported

fsync

Saves file updates to a storage device.

Supported

Supported

Directory management

mkdir

Creates a directory.

Supported

Supported

opendir

Opens a directory.

Supported

Supported

readdir

Reads the content of a directory.

Supported

Supported

closedir

Closes a directory.

Supported

Supported

rmdir

Deletes a directory.

Supported

Supported

Partition management

mount

Mounts a partition.

Supported

Supported

umount

Unmounts a partition.

Supported

Supported

umount2

Forcibly unmounts a partition using the MNT_FORCE parameter.

Supported

Not supported

statfs

Obtains partition information.

Supported

Not supported