23namespace fs = std::filesystem;
42 fs::path m_path_dir_upper;
43 fs::path m_path_dir_work;
44 std::vector<fs::path> m_vec_path_dir_layers;
48 , fs::path
const& path_dir_mount
49 , fs::path
const& path_dir_upper
50 , fs::path
const& path_dir_work
51 , fs::path
const& path_file_log
52 , std::vector<fs::path>
const& vec_path_dir_layers
69 , fs::path
const& path_dir_mount
70 , fs::path
const& path_dir_upper
71 , fs::path
const& path_dir_work
72 , fs::path
const& path_file_log
73 , std::vector<fs::path>
const& vec_path_dir_layers
76 , m_path_dir_upper(path_dir_upper)
77 , m_path_dir_work(path_dir_work)
78 , m_vec_path_dir_layers(vec_path_dir_layers)
80 this->
mount().discard(
"E::Could not mount overlayfs filesystem to '{}'", path_dir_mount);
94 auto path_file_overlayfs = Pop(
ns_env::search_path(
"overlayfs"),
"E::Could not find overlayfs in PATH");
96 uid_t user_id = getuid();
97 gid_t group_id = getgid();
100 std::string arg_lowerdir = m_vec_path_dir_layers
101 | std::views::reverse
102 | std::views::transform([](
auto&& e){
return e.string(); })
103 | std::views::join_with(std::string{
":"})
104 | std::ranges::to<std::string>();
105 arg_lowerdir =
"lowerdir=" + arg_lowerdir;
110 .
with_args(
"-o", std::format(
"squash_to_uid={}", user_id))
111 .
with_args(
"-o", std::format(
"squash_to_gid={}", group_id))
113 .
with_args(
"-o", std::format(
"upperdir={}", m_path_dir_upper.string()))
114 .
with_args(
"-o", std::format(
"workdir={}", m_path_dir_work.string()))
Filesystem(pid_t pid_to_die_for, std::filesystem::path const &path_dir_mount, std::filesystem::path const &path_file_log)
Construct a new Filesystem object.
Value< void > mount() override
Mounts the filesystem.
Overlayfs(pid_t pid_to_die_for, fs::path const &path_dir_mount, fs::path const &path_dir_upper, fs::path const &path_dir_work, fs::path const &path_file_log, std::vector< fs::path > const &vec_path_dir_layers)
Construct a new Overlayfs object.
Subprocess & with_die_on_pid(pid_t pid)
Configures the child process to die when the specified PID dies.
std::unique_ptr< Child > spawn()
Spawns (forks) the child process and begins execution.
Subprocess & with_stdio(Stream mode)
Sets the stdio redirection mode for the child process.
Subprocess & with_log_file(std::filesystem::path const &path)
Configures logging output for child process stdout/stderr.
Subprocess & with_args(Args &&... args)
Arguments forwarded as the process' arguments.
The base class for filesystems.
A library for operations on fuse filesystems.
A library for manipulating environment variables.
Value< fs::path > search_path(std::string const &query)
Search the directories in the PATH variable for the given input file name.
Base filesystem interface and abstraction.
FUSE-OverlayFS overlay filesystem implementation.
Value< fs::path > create_directories(fs::path const &p)
Creates directories recursively.
void wait_fuse(fs::path const &path_dir_filesystem)
Waits for the given directory to not be fuse.
Stream
Stream redirection modes for child process stdio.
Enhanced expected type with integrated logging capabilities.
A library to spawn sub-processes in linux.