7.2. File system development in barebox

The barebox file system support is based heavily on Linux.

Access to all file systems goes through the virtual file system layer, which provides uniform access to all mounted file systems under the same root.

As power-fail safe writing of file system couldn’t be guaranteed, most file systems supported by barebox are read-only. Safe writing is possible, however, via the Barebox State Framework.

For an up-to-date listing of writable filesystems, refer to the CONFIG_FS_WRITABLE Kconfig symbol.

7.2.1. Testing File systems

Nearly all file system operations have commands that directly exercise them:

Command

Operations

cat - concatenate file(s) to stdout

open, close, read

echo - echo args to console

create, write

sync - flush cached writes

flush

erase - erase flash memory

erase

protect - enable flash write protection

protect

md - memory display

lseek, memmap

rm - remove files

unlink

mkdir - make directories

mkdir

rmdir - remove empty directory(s)

rmdir

ln - create symlink (make a new name for a file)

symlink

readlink - read value of a symbolic link or canonical file name

readlink

opendir, readdir, closedir

stat - display file status

stat

truncate - truncate files to size

truncate

This leaves two specialized operations that can’t be easily tested via the shell:

  • discard_range: Advise that a range need not be preserved

  • ioctl: Issue device-specific output and input control commands

7.2.2. Unused metadata

barebox currently ignores ownership and permission information inside file systems as well as special nodes like FIFOs or sockets. When porting file systems, these parts can be omitted.

7.2.3. Background execution

Outside command context (i.e. in pollers and secondary barebox threads), virtual file system access is only permitted with ramfs.