Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
session_devices.h
Go to the documentation of this file.
1
5#pragma once
6
7#ifndef BOOST_PROCESS_VERSION
8 #define BOOST_PROCESS_VERSION 1
9#endif
10
11#include <memory>
12#include <string>
13#include <system_error>
14#include <vector>
15
16#include <sys/types.h>
17
18#include <boost/filesystem/path.hpp>
19#include <boost/process/v1/child.hpp>
20#include <boost/process/v1/environment.hpp>
21#include <boost/process/v1/group.hpp>
22
23namespace platf::session_devices {
24
25 struct options_t {
28 bool devices {};
30 bool sound {};
31 };
32
34 bool available();
35
41 class plan_t {
42 public:
44 static std::unique_ptr<plan_t> isolate(const std::string &staging, options_t options);
45
47 static std::unique_ptr<plan_t> join(pid_t pid);
48
50 void apply() const noexcept;
51
52 plan_t();
53 ~plan_t();
54
55 struct op_t;
56
57 private:
58 std::string join_path;
59 std::string staging;
60 std::vector<op_t> ops;
61 };
62
64 boost::process::v1::child run_command(const plan_t *plan, const std::string &cmd, boost::filesystem::path &working_dir, const boost::process::v1::environment &env, FILE *file, std::error_code &ec, boost::process::v1::group *group);
65
74 class mirror_t {
75 public:
76 virtual ~mirror_t() = default;
77 };
78
80 std::unique_ptr<mirror_t> mirror(pid_t pid, const std::string &seat, bool hide_hid_gamepads = false);
81} // namespace platf::session_devices
Keeps a session's /dev holding its devices while they come and go.
Work done in a session's process between fork and exec.
static std::unique_ptr< plan_t > isolate(const std::string &staging, options_t options)
A new mount namespace with /dev built on the empty directory staging.
static std::unique_ptr< plan_t > join(pid_t pid)
The mount namespace of a running session process.
void apply() const noexcept
Child side; exits the child on failure.
std::unique_ptr< mirror_t > mirror(pid_t pid, const std::string &seat, bool hide_hid_gamepads)
Mirror into the /dev of pid's mount namespace; nullptr on failure.
bool sound
No /dev/snd; the session's audio server is its only way to sound.