1#ifndef ARION_FS_MANAGER_HPP
2#define ARION_FS_MANAGER_HPP
42 ARION_FILE(
int fd, std::string path,
int flags, mode_t mode) : fd(fd), path(path), flags(flags), mode(mode) {};
48 : fd(arion_f->fd), path(arion_f->path), flags(arion_f->flags), mode(arion_f->mode), blocking(arion_f->blocking),
49 saved_off(arion_f->saved_off) {};
55 : fd(arion_f->fd), path(arion_f->path), flags(arion_f->flags), mode(arion_f->mode), blocking(arion_f->blocking),
56 saved_off(arion_f->saved_off) {};
76 static const inline std::regex
PROCFS_REGEX = std::regex(R
"(^/proc/([0-9]+|self)/([^/]+)$)");
127 std::map<int, std::shared_ptr<ARION_FILE>>
files;
135 static std::unique_ptr<FileSystemManager>
initialize(std::weak_ptr<Arion>
arion, std::string fs_path,
136 std::string cwd_path);
This class is used to emulate interactions with the rootfs specified by user.
Definition file_system_manager.hpp:108
std::map< int, std::shared_ptr< ARION_FILE > > files
A map identifying an open file given its UNIX file descriptor.
Definition file_system_manager.hpp:127
bool is_in_fs(std::string path)
std::string cwd_path
Path to the user specifed current working directory.
Definition file_system_manager.hpp:115
bool has_file_entry(int target_fd)
std::weak_ptr< Arion > arion
The Arion instance used for emulation.
Definition file_system_manager.hpp:111
static std::string find_fd_path(int fd)
std::string fs_path
Path to the user specified rootfs.
Definition file_system_manager.hpp:113
std::unique_ptr< ProcFSManager > procfs
Used to emulate the behavior of the procfs filesystem.
Definition file_system_manager.hpp:117
static std::unique_ptr< FileSystemManager > initialize(std::weak_ptr< Arion > arion, std::string fs_path, std::string cwd_path)
void set_cwd_path(std::string cwd_path)
std::string get_cwd_path()
void add_file_entry(int target_fd, std::shared_ptr< ARION_FILE > file, bool safe=true)
std::string to_fs_path(std::string path)
bool can_access_file(std::string path)
std::shared_ptr< ARION_FILE > get_arion_file(int target_fd)
FileSystemManager(std::weak_ptr< Arion > arion, std::string fs_path, std::string cwd_path)
std::string get_fs_path()
void rm_file_entry(int target_fd)
This class is used to emulate the behavior of the procfs filesystem.
Definition file_system_manager.hpp:73
ProcFSManager(std::weak_ptr< Arion > arion)
Definition file_system_manager.hpp:91
std::string convert(std::string path)
std::weak_ptr< Arion > arion
The Arion instance used for emulation.
Definition file_system_manager.hpp:78
static const std::regex PROCFS_REGEX
This regex is used to check whether a file path is located inside the system procfs.
Definition file_system_manager.hpp:76
bool is_procfs_path(std::string path)
static std::unique_ptr< ProcFSManager > initialize(std::weak_ptr< Arion > arion)
#define ARION_EXPORT
Defines which symbols should be exported from the library.
Definition global_defs.hpp:13
Definition arch_x86-64.hpp:11
std::vector< BYTE > serialize_arion_file(ARION_FILE *arion_f)
ARION_FILE * deserialize_arion_file(std::vector< BYTE > srz_file)
Stores attributes related to a file which was opened during emulation.
Definition file_system_manager.hpp:18
int flags
Flags which were used to open the file (like in "open" syscall).
Definition file_system_manager.hpp:24
ARION_FILE(int fd, std::string path, int flags, mode_t mode)
Definition file_system_manager.hpp:42
ARION_FILE(std::shared_ptr< ARION_FILE > arion_f)
Definition file_system_manager.hpp:47
ARION_FILE(ARION_FILE *arion_f)
Definition file_system_manager.hpp:54
mode_t mode
Mode which was used to open the file (like in "open" syscall).
Definition file_system_manager.hpp:26
std::string path
Path to the file.
Definition file_system_manager.hpp:22
int fd
The UNIX file descriptor.
Definition file_system_manager.hpp:20
ARION_FILE()
Definition file_system_manager.hpp:34