FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
ns_filesystems::ns_layers::Layers Class Reference

Manages external DwarFS layer files and directories for the filesystem controller. More...

#include <layers.hpp>

Public Member Functions

Value< void > push (fs::path const &path)
 Adds a layer from a file or directory path.
 
Value< void > push_from_var (std::string_view var)
 Loads layers from a colon-separated environment variable.
 
std::vector< Layer > const & get_layers () const
 Retrieves the collected layer file paths with offsets.
 
void push_binary (fs::path const &path_file_binary, uint64_t offset)
 Scans a binary file for embedded DwarFS filesystems.
 

Detailed Description

Manages external DwarFS layer files and directories for the filesystem controller.

Provides a unified interface for collecting layer files from both individual file paths and directories. Supports the FIM_LAYERS environment variable which accepts a colon-separated list of paths that can be files or directories.

Directory Scanning:

  • Non-recursive (only scans direct children)
  • Alphabetical order within each directory
  • Validates files as DwarFS filesystems

File Processing:

  • Direct file paths are validated and added immediately
  • Invalid files are skipped with a warning
Examples
/flatimage/src/filesystems/layers.hpp.

Definition at line 59 of file layers.hpp.

Member Function Documentation

◆ get_layers()

std::vector< Layer > const & ns_filesystems::ns_layers::Layers::get_layers ( ) const
inline

Retrieves the collected layer file paths with offsets.

Returns the final list of validated layer files with their offsets in the order they were added. This is used by the filesystem controller to mount layers sequentially.

Returns
const reference to vector of (path, offset) pairs
Examples
/flatimage/src/filesystems/layers.hpp.

Definition at line 174 of file layers.hpp.

Here is the caller graph for this function:

◆ push()

Value< void > ns_filesystems::ns_layers::Layers::push ( fs::path const & path)
inlinenodiscard

Adds a layer from a file or directory path.

Automatically detects whether the path is a file or directory and processes accordingly:

  • File: Validates and adds directly
  • Directory: Scans for layer files and adds them alphabetically
Parameters
pathFilesystem path (file or directory)
Returns
Value<void> Success or error
Examples
/flatimage/src/filesystems/layers.hpp.

Definition at line 119 of file layers.hpp.

Here is the caller graph for this function:

◆ push_binary()

void ns_filesystems::ns_layers::Layers::push_binary ( fs::path const & path_file_binary,
uint64_t offset )
inline

Scans a binary file for embedded DwarFS filesystems.

Reads a binary file from the given offset, looking for concatenated DwarFS filesystems. Each filesystem is prefixed with an 8-byte size field. Appends found filesystems to the layers collection with their respective offsets.

Format:

  • 8 bytes: filesystem size (int64_t)
  • N bytes: DwarFS filesystem data
  • (repeats for additional filesystems)
Parameters
path_file_binaryPath to the binary file to scan
offsetInitial offset in bytes where scanning begins
Returns
Value<void> Success or error
Examples
/flatimage/src/filesystems/layers.hpp.

Definition at line 195 of file layers.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_from_var()

Value< void > ns_filesystems::ns_layers::Layers::push_from_var ( std::string_view var)
inlinenodiscard

Loads layers from a colon-separated environment variable.

Processes environment variables like FIM_LAYERS which contain colon-separated paths. Each path can be either a file or directory. Performs shell expansion on variable values before processing.

Processing Steps:

  1. Retrieves environment variable value
  2. Performs word expansion (variables, subshells)
  3. Splits on ':' delimiter
  4. Processes each path via push()
Parameters
varName of environment variable to read (e.g., "FIM_LAYERS")
Returns
Value<void> Success or error
Examples
/flatimage/src/filesystems/layers.hpp.

Definition at line 148 of file layers.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: