Skip to content

Commit

Permalink
translation/Protocol: add packet BIND_MOUNT_RW_EXEC
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Feb 6, 2025
1 parent 8856341 commit c5322e1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/translation/Parser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3902,6 +3902,7 @@ TranslateParser::HandleRegularPacket(TranslationCommand command,
case TranslationCommand::EXPAND_BIND_MOUNT_EXEC:
case TranslationCommand::BIND_MOUNT_FILE:
case TranslationCommand::WRITE_FILE:
case TranslationCommand::BIND_MOUNT_RW_EXEC:
#if TRANSLATION_ENABLE_SPAWN
if (ns_options != nullptr &&
mount_list != ns_options->mount.mounts.before_begin()) {
Expand Down Expand Up @@ -4400,6 +4401,15 @@ TranslateParser::HandleRegularPacket(TranslationCommand command,
#else
break;
#endif

case TranslationCommand::BIND_MOUNT_RW_EXEC:
#if TRANSLATION_ENABLE_SPAWN
previous_command = command;
HandleBindMount(string_payload, false, true, true);
return;
#else
break;
#endif
}

throw FmtRuntimeError("unknown translation packet: {}", (unsigned)command);
Expand Down
5 changes: 5 additions & 0 deletions src/translation/Protocol.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,11 @@ enum class TranslationCommand : uint16_t {
* by a null byte.
*/
SYMLINK = 269,

/**
* Combination of #BIND_MOUNT_RW and #BIND_MOUNT_EXEC.
*/
BIND_MOUNT_RW_EXEC = 270,
};

struct TranslationHeader {
Expand Down
9 changes: 9 additions & 0 deletions src/translation/server/Response.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,15 @@ public:
return *this;
}

template<typename S, typename T>
auto BindMountRwExec(S &&source, T &&target) noexcept {
response.StringPacket(TranslationCommand::BIND_MOUNT_RW_EXEC,
std::forward<S>(source),
std::string_view{"", 1},
std::forward<T>(target));
return *this;
}

template<typename S, typename T>
auto BindMountFile(S &&source, T &&target) noexcept {
response.StringPacket(TranslationCommand::BIND_MOUNT_FILE,
Expand Down

0 comments on commit c5322e1

Please sign in to comment.