Release of the fault-tolerant file system LittleFS 2.10

The release of the LittleFS 2.10 project has been published, developing a compact file system for embedded devices and microcontrollers. Initially, the file system was created by ARM for the Mbed OS operating system, but was later separated into its own project. The FS code is written in C and is distributed under the BSD license. The reference implementation of LittleFS is provided as a C library, on the basis of which a FUSE module and bindings for various programming languages have been created.

Features of LittleFS:

  • Low resource requirements and support for operation with limited RAM size. The LittleFS implementation uses only statically defined buffers (without dynamic memory allocation) and does not use recursive calls, which means that the amount of RAM consumed and the service structures of LittleFS on the storage device remain constant, regardless of what is recorded in the FS and the size of the storage.
  • Wear leveling mechanisms for Flash media that minimize the reuse of blocks and evenly distribute block erasure operations in Flash memory, where the controller does not provide a solution for this task.
  • Very high fault tolerance — the FS treats unexpected power loss (shutdown due to power disconnection) as normal and guarantees that the storage on disk remains intact at any point in time. To prevent data corruption and loss, a copy-on-write (COW) mechanism is employed, where changes do not overwrite information but are saved in a new location.
  • Atomicity of operations such as deletion and renaming, even in the case of power loss during their execution. Changes to a file are flushed to disk only after the sync or close call. Inconsistencies caused by operations that cannot be performed atomically are handled by a special deorphan handler, which traverses the entire FS tree after boot.
  • Support for POSIX-like functions for working with files and directories.

The contents of the files in LittleFS are represented by COW lists CTZ, providing a complexity level of O(1) for adding and O(nlogn) for reading. Block allocation is done by scanning the filesystem for used blocks within a fixed-size area, stored as a bit vector. To simplify scanning, all directories are part of a linked list that encompasses the entire filesystem. If an error occurs while writing a block, a new block is allocated and the data is transferred to it.

Among the changes in the new version of LittleFS:

  • The code for parsing file paths has been redesigned, bringing the behavior of the filesystem closer to POSIX systems and user expectations in situations such as path termination with a slash, handling empty paths, and navigating beyond the root of the filesystem.
  • Two new examples of block devices, ramcrc32bd and ramrsbd, have been added, implementing an error correction mechanism compatible with LittleFS. Currently, the LittleFS filesystem does not support error detection and correction, and these operations are handled at the block device level.
  • The lfs_mkdir function has been updated to support trailing slashes, so calling lfs_mkdir("a/") will no longer produce an error.
  • In the lfs_stat and lfs_getattr functions, an error will now be output when trailing slashes are used if the existing path in the filesystem is not a directory.
  • Attempting to open a file with a trailing slash in its name via the lfs_file_open function will now result in an error LFS_ERR_NOTDIR if the file is not a directory in the filesystem, LFS_ERR_ISDIR if the name refers to a directory in the filesystem, and LFS_O_CREAT if the file does not exist.
  • Attempting to access beyond the root filesystem, for example, lfs_stat("/../a"), will now result in an error.
  • Specifying an empty path is no longer synonymous with accessing the root directory, meaning that calling lfs_stat("") will result in an error.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster