Arion 1.0.2-alpha
A high-performance C++ framework for emulating executable binaries.
 
Loading...
Searching...
No Matches
arion::FileSystemManager Class Reference

This class is used to emulate interactions with the rootfs specified by user. More...

#include <file_system_manager.hpp>

Public Member Functions

 FileSystemManager (std::weak_ptr< Arion > arion, std::string fs_path, std::string cwd_path)
 
std::string get_fs_path ()
 
std::string get_cwd_path ()
 
void set_cwd_path (std::string cwd_path)
 
void add_file_entry (int target_fd, std::shared_ptr< ARION_FILE > file, bool safe=true)
 
bool has_file_entry (int target_fd)
 
void rm_file_entry (int target_fd)
 
std::shared_ptr< ARION_FILEget_arion_file (int target_fd)
 
bool is_in_fs (std::string path)
 
std::string to_fs_path (std::string path)
 

Static Public Member Functions

static std::unique_ptr< FileSystemManagerinitialize (std::weak_ptr< Arion > arion, std::string fs_path, std::string cwd_path)
 
static std::string find_fd_path (int fd)
 

Public Attributes

std::map< int, std::shared_ptr< ARION_FILE > > files
 A map identifying an open file given its UNIX file descriptor.
 

Private Member Functions

bool can_access_file (std::string path)
 

Private Attributes

std::weak_ptr< Arionarion
 The Arion instance used for emulation.
 
std::string fs_path
 Path to the user specified rootfs.
 
std::string cwd_path
 Path to the user specifed current working directory.
 
std::unique_ptr< ProcFSManagerprocfs
 Used to emulate the behavior of the procfs filesystem.
 

Detailed Description

This class is used to emulate interactions with the rootfs specified by user.

Constructor & Destructor Documentation

◆ FileSystemManager()

arion::FileSystemManager::FileSystemManager ( std::weak_ptr< Arion arion,
std::string  fs_path,
std::string  cwd_path 
)

Builder for FileSystemManager instances.

Parameters
[in]arionThe Arion instance used for emulation.
[in]fs_pathPath to the user specified rootfs.
[in]cwd_pathPath to the user specifed current working directory.

Member Function Documentation

◆ add_file_entry()

void arion::FileSystemManager::add_file_entry ( int  target_fd,
std::shared_ptr< ARION_FILE file,
bool  safe = true 
)

Inserts a new open file to the "files" vector.

Parameters
[in]target_fdThe UNIX file descriptor for the new file, in the emulation context.
[in]fileThe new file to be inserted.
[in]safeIf true, additional checks are performed to make sure the file can be inserted safely.

◆ can_access_file()

bool arion::FileSystemManager::can_access_file ( std::string  path)
private

Checks whether a given path can be accessed by the user or not, based on his rights.

Parameters
[in]pathThe path whose accessibility is to be checked.
Returns
True if the user is allowed to access the given path.

◆ find_fd_path()

static std::string arion::FileSystemManager::find_fd_path ( int  fd)
static

Converts a file descriptor from the emulator context (not the emulation one) into its corresponding system path.

Parameters
[in]fdThe file descriptor to convert.
Returns
The retrieved system path.

◆ get_arion_file()

std::shared_ptr< ARION_FILE > arion::FileSystemManager::get_arion_file ( int  target_fd)

Retrieves an ARION_FILE instance from a UNIX file descriptor from the emulation context.

Parameters
[in]target_fdThe UNIX file descriptor.
Returns
The retrieved ARION_FILE.

◆ get_cwd_path()

std::string arion::FileSystemManager::get_cwd_path ( )

Retrieves the user specified path to the current working directory.

Returns
Path to the current working directory.

◆ get_fs_path()

std::string arion::FileSystemManager::get_fs_path ( )

Retrieves the user specified path to rootfs.

Returns
Path to the rootfs.

◆ has_file_entry()

bool arion::FileSystemManager::has_file_entry ( int  target_fd)

Checks whether the "files" vector contains a given file descriptor.

Parameters
[in]target_fdThe UNIX file descriptor.
Returns
True if the "files" vector contains the file descriptor.

◆ initialize()

static std::unique_ptr< FileSystemManager > arion::FileSystemManager::initialize ( std::weak_ptr< Arion arion,
std::string  fs_path,
std::string  cwd_path 
)
static

Instanciates and initializes new FileSystemManager objects with some parameters.

Parameters
[in]arionThe Arion instance used for emulation.
[in]fs_pathPath to the user specified rootfs.
[in]cwd_pathPath to the user specifed current working directory.
Returns
A new FileSystemManager instance.

◆ is_in_fs()

bool arion::FileSystemManager::is_in_fs ( std::string  path)

Checks whether the given path exists and belongs to the user specified rootfs.

Parameters
[in]Thepath to check.
Returns
True if the given path exists and belongs to the user specified rootfs.

◆ rm_file_entry()

void arion::FileSystemManager::rm_file_entry ( int  target_fd)

Removes a file entry from the "files" vector.

Parameters
[in]target_fdThe UNIX file descriptor of the file to be removed.

◆ set_cwd_path()

void arion::FileSystemManager::set_cwd_path ( std::string  cwd_path)

Defines path to the current working directory.

Parameters
[in]cwd_pathPath to the new current working directory.

◆ to_fs_path()

std::string arion::FileSystemManager::to_fs_path ( std::string  path)

Converts a given path from the emulation context into its absolute representation inside the user specified rootfs.

Parameters
[in]pathThe path to be converted.
Returns
The converted path which belongs to the rootfs.

Member Data Documentation

◆ arion

std::weak_ptr<Arion> arion::FileSystemManager::arion
private

The Arion instance used for emulation.

◆ cwd_path

std::string arion::FileSystemManager::cwd_path
private

Path to the user specifed current working directory.

◆ files

std::map<int, std::shared_ptr<ARION_FILE> > arion::FileSystemManager::files

A map identifying an open file given its UNIX file descriptor.

◆ fs_path

std::string arion::FileSystemManager::fs_path
private

Path to the user specified rootfs.

◆ procfs

std::unique_ptr<ProcFSManager> arion::FileSystemManager::procfs
private

Used to emulate the behavior of the procfs filesystem.


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