dnx RTOS 2.2.0 "Eagle"
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
File Systems Development

Introduction

The file systems are used to store regular, device-like, and FIFO files. Some file systems do not support special files, e.g. pipes and devices, because is not possible to handle this kind of files (e.g. on the FAT) in the particular file system. In the system there are few file systems:

  • ramfs – the file system is a general usage file system that store files in the RAM. This file system is used by the system by default,
  • devfs – the file system is used only to handle devices, it is much faster than ramfs, but does not provide many features,
  • procfs – the file system is a special file system that provides the system information in form of the files,
  • fatfs – the file system is used to read all storages that contains FAT12, FAT16, and FAT32 file systems.
  • eefs – the file system is used for small devices e.g. 24CXX memory. File system requires small amount of memory and have size limitation (up to around 16 MiB).
  • romfs - file system is used to store read-only files and directories directly from res directory to microcontroller memory. This file system uses small amount of memory and can be used to easily copy files to microcontroller at build procedure.

As we can see, each file system has special role in the system. In this case, manage of the file systems must be the same for file that can comes from different sources. To achieve this requirement the system has implemented core component called VFS. The VFS is a kind of router that translates the user’s path to the specified file system. The usage of files for the user is transparent; the user do not care about real file position.

As mentioned above, each file system must be connected to the VFS. To do this, the file systems must have the same interfaces. Thus, any file system can be mounted easily by the VFS. File systems are similar to driver modules, because single file system can handle many source files that contains specified file system format (e.g. FAT, ext2, etc).

Library

All functions supported by operating system accessible from file systems are stored in the "fs/fs.h" library.

Interface

The interface functions are created by macros, thanks this the name of file system functions are hidden and known only by the system.

File System Registration

A new file system is automatically added to the system if simple requirements are met:

  • folder with file system is created in the ./src/system/fs directory,
  • at least one source file is created in folder and contain file system API functions,
  • Makefile script is added to created folder.
Note
One can use ./tools/addfilesystem.sh script to create file system template. It is the easiest way to create own file system.

File System Source File

#include "fs/fs.h"
{
// ..
}
API_FS_...(...)
{
// ...
}
...

Makefile

# Makefile for GNU make
CSRC_CORE += fs/examplefs/examplefs.c
CSRC_CORE += fs/examplefs/examplefs_x.c

File System Configuration

For created file system the configuration can be added. In this case user should add new entries in ./config/filesystems directory. Existing configurations are good example how to do this.