-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
was/Stock: add MOUNT_LISTEN_STREAM support
- Loading branch information
1 parent
9f6f237
commit 7c4f437
Showing
8 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,20 @@ | |
// author: Max Kellermann <[email protected]> | ||
|
||
#include "Launch.hxx" | ||
#include "pool/tpool.hxx" | ||
#include "spawn/Interface.hxx" | ||
#include "spawn/ListenStreamSpawnStock.hxx" | ||
#include "spawn/Mount.hxx" | ||
#include "spawn/Prepared.hxx" | ||
#include "spawn/ChildOptions.hxx" | ||
#include "net/SocketDescriptor.hxx" | ||
#include "io/FdHolder.hxx" | ||
#include "AllocatorPtr.hxx" | ||
|
||
static auto | ||
WasLaunch(SpawnService &spawn_service, | ||
ListenStreamSpawnStock *listen_stream_spawn_stock, | ||
SharedLease &listen_stream_lease, | ||
const char *name, | ||
const char *executable_path, | ||
std::span<const char *const> args, | ||
|
@@ -23,6 +29,22 @@ WasLaunch(SpawnService &spawn_service, | |
p.stdout_fd = socket.output; | ||
p.stdin_fd = socket.input; | ||
|
||
const TempPoolLease tpool; | ||
if (p.ns.mount.mount_listen_stream.data() != nullptr) { | ||
if (listen_stream_spawn_stock == nullptr) | ||
throw std::runtime_error{"No ListenStreamSpawnStock"}; | ||
|
||
const AllocatorPtr alloc{tpool}; | ||
|
||
/* copy the mount list before editing it, which is | ||
currently a shallow copy pointing to inside the | ||
translation cache*/ | ||
p.ns.mount.mounts = Mount::CloneAll(alloc, p.ns.mount.mounts); | ||
|
||
listen_stream_lease = listen_stream_spawn_stock->Apply(alloc, | ||
p.ns.mount); | ||
} | ||
|
||
p.Append(executable_path); | ||
for (auto i : args) | ||
p.Append(i); | ||
|
@@ -38,6 +60,7 @@ WasLaunch(SpawnService &spawn_service, | |
|
||
WasProcess | ||
was_launch(SpawnService &spawn_service, | ||
ListenStreamSpawnStock *listen_stream_spawn_stock, | ||
const char *name, | ||
const char *executable_path, | ||
std::span<const char *const> args, | ||
|
@@ -50,7 +73,9 @@ was_launch(SpawnService &spawn_service, | |
process.input.SetNonBlocking(); | ||
process.output.SetNonBlocking(); | ||
|
||
process.handle = WasLaunch(spawn_service, name, executable_path, args, | ||
process.handle = WasLaunch(spawn_service, listen_stream_spawn_stock, | ||
process.listen_stream_lease, | ||
name, executable_path, args, | ||
options, std::move(stderr_fd), | ||
std::move(s.second)); | ||
return process; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters