[Yunq] Add support for empty requests and responses.
This commit is contained in:
parent
6d108f6965
commit
cc4b5bd811
11 changed files with 91 additions and 22 deletions
|
|
@ -8,7 +8,9 @@
|
|||
|
||||
|
||||
|
||||
|
||||
glcr::ErrorCode VFSClient::open(const OpenFileRequest& request, File& response) {
|
||||
|
||||
uint64_t buffer_size = kBufferSize;
|
||||
uint64_t cap_size = kCapBufferSize;
|
||||
|
||||
|
|
@ -17,7 +19,10 @@ glcr::ErrorCode VFSClient::open(const OpenFileRequest& request, File& response)
|
|||
buffer_.WriteAt<uint64_t>(8, 0);
|
||||
|
||||
cap_buffer_.Reset();
|
||||
|
||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||
|
||||
|
||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||
|
||||
z_cap_t reply_port_cap;
|
||||
|
|
@ -33,8 +38,10 @@ glcr::ErrorCode VFSClient::open(const OpenFileRequest& request, File& response)
|
|||
// Check Response Code.
|
||||
RET_ERR(buffer_.At<uint64_t>(8));
|
||||
|
||||
|
||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||
|
||||
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ class VFSClient {
|
|||
z_cap_t Capability() { return endpoint_; }
|
||||
|
||||
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode open(const OpenFileRequest& request, File& response);
|
||||
|
||||
|
||||
private:
|
||||
z_cap_t endpoint_;
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ void OpenFileRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint
|
|||
// Parse options.
|
||||
auto options_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 1));
|
||||
|
||||
options_.Resize(options_pointer.length);
|
||||
options_.Resize(options_pointer.length / sizeof(uint64_t));
|
||||
for (uint64_t i = offset + options_pointer.offset;
|
||||
i < offset + options_pointer.offset + (sizeof(uint64_t) * options_pointer.length);
|
||||
i < offset + options_pointer.offset + options_pointer.length;
|
||||
i += sizeof(uint64_t)) {
|
||||
options_.PushBack(bytes.At<uint64_t>(i));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class OpenFileRequest {
|
|||
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
glcr::String path() const { return path_; }
|
||||
const glcr::String& path() const { return path_; }
|
||||
void set_path(const glcr::String& value) { path_ = value; }
|
||||
const glcr::Vector<uint64_t>& options() const { return options_; }
|
||||
void add_options(const uint64_t& value) { options_.PushBack(value); }
|
||||
|
|
@ -40,11 +40,11 @@ class File {
|
|||
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
glcr::String path() const { return path_; }
|
||||
const glcr::String& path() const { return path_; }
|
||||
void set_path(const glcr::String& value) { path_ = value; }
|
||||
uint64_t attrs() const { return attrs_; }
|
||||
const uint64_t& attrs() const { return attrs_; }
|
||||
void set_attrs(const uint64_t& value) { attrs_ = value; }
|
||||
z_cap_t mem_cap() const { return mem_cap_; }
|
||||
const z_cap_t& mem_cap() const { return mem_cap_; }
|
||||
void set_mem_cap(const z_cap_t& value) { mem_cap_ = value; }
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Generated file -- DO NOT MODIFY.
|
||||
#include "example.yunq.server.h"
|
||||
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <zcall.h>
|
||||
|
||||
namespace {
|
||||
|
|
@ -87,12 +87,19 @@ glcr::ErrorCode VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
|||
|
||||
switch(method_select) {
|
||||
case 0: {
|
||||
|
||||
|
||||
OpenFileRequest yunq_request;
|
||||
File yunq_response;
|
||||
|
||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||
|
||||
|
||||
|
||||
File yunq_response;
|
||||
|
||||
|
||||
|
||||
RET_ERR(Handleopen(yunq_request, yunq_response));
|
||||
|
||||
|
||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/thread.h>
|
||||
#include <mammoth/proc/thread.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "example.yunq.h"
|
||||
|
|
@ -21,9 +21,11 @@ class VFSServerBase {
|
|||
[[nodiscard]] Thread RunServer();
|
||||
|
||||
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode Handleopen(const OpenFileRequest&, File&) = 0;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
z_cap_t endpoint_;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue