FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
ns_relocate::anonymous_namespace{relocate.hpp} Namespace Reference

Functions

Value< void > relocate_impl (char **argv, uint32_t offset, fs::path const &path_file_self)
 Relocate the binary (by copying it) from the image.
 

Variables

constexpr std::array< const char *, 403 > const arr_busybox_applet
 

Function Documentation

◆ relocate_impl()

Value< void > ns_relocate::anonymous_namespace{relocate.hpp}::relocate_impl ( char ** argv,
uint32_t offset,
fs::path const & path_file_self )
inlinenodiscard

Relocate the binary (by copying it) from the image.

The binary is copied from the image to the instance directory, for an execve to be performed. This is done to free the main flatimage file to mount the filesystems.

Parameters
argvArgument vector passed to the main program
offsetOffset to the reserved space, past the elf and appended binaries
path_file_selfPath to the current executable binary
Returns
Nothing on success, or the respective error

Lambda function to write a binary by reading its ELF header offset

Extracts a binary from the flatimage by reading its ELF header to determine size, and writes it to the specified path. Skips if the file already exists.

Parameters
path_fileDestination path for the extracted binary
offset_endCurrent end offset in the source file
Returns
Value<std::pair<uint64_t,uint64_t>> Pair of (begin_offset, end_offset) for the next binary, or error

Lambda function to write a binary by reading size metadata at a specific offset

Reads a uint64_t size value at the specified offset, then extracts that many bytes to write the binary to the specified path. Skips if the file already exists.

Parameters
file_binaryInput stream positioned in the source flatimage file
path_fileDestination path for the extracted binary
offset_endCurrent end offset in the source file
Returns
Value<std::pair<uint64_t,uint64_t>> Pair of (begin_offset, end_offset) for the next binary, or error

Definition at line 85 of file relocate.hpp.

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

Variable Documentation

◆ arr_busybox_applet

std::array<const char*,403> const ns_relocate::anonymous_namespace{relocate.hpp}::arr_busybox_applet
constexpr

Definition at line 38 of file relocate.hpp.