sysdeps/managarm: convert sys_getcwd to helix_ng
@@ -535,43 +535,26 @@ int sys_fdatasync(int) {
int sys_getcwd(char *buffer, size_t size) {
SignalGuard sguard;
- HelAction actions[4];
- globalQueue.trim();
managarm::posix::CntRequest<MemoryAllocator> req(getSysdepsAllocator());
req.set_request_type(managarm::posix::CntReqType::GETCWD);
req.set_size(size);
- frg::string<MemoryAllocator> ser(getSysdepsAllocator());
- req.SerializeToString(&ser);
- actions[0].type = kHelActionOffer;
- actions[0].flags = kHelItemAncillary;
- actions[1].type = kHelActionSendFromBuffer;
- actions[1].flags = kHelItemChain;
- actions[1].buffer = ser.data();
- actions[1].length = ser.size();
- actions[2].type = kHelActionRecvInline;
- actions[2].flags = kHelItemChain;
- actions[3].type = kHelActionRecvToBuffer;
- actions[3].flags = 0;
- actions[3].buffer = buffer;
- actions[3].length = size;
- HEL_CHECK(helSubmitAsync(getPosixLane(), actions, 4,
- globalQueue.getQueue(), 0, 0));
-
- auto element = globalQueue.dequeueSingle();
- auto offer = parseHandle(element);
- auto send_req = parseSimple(element);
- auto recv_resp = parseInline(element);
- auto recv_path = parseInline(element);
+ auto [offer, send_req, recv_resp, recv_path] = exchangeMsgsSync(
+ getPosixLane(),
+ helix_ng::offer(
+ helix_ng::sendBragiHeadOnly(req, getSysdepsAllocator()),
+ helix_ng::recvInline(),
+ helix_ng::recvBuffer(buffer, size))
+ );
- HEL_CHECK(offer->error);
- HEL_CHECK(send_req->error);
- HEL_CHECK(recv_resp->error);
- HEL_CHECK(recv_path->error);
+ HEL_CHECK(offer.error());
+ HEL_CHECK(send_req.error());
+ HEL_CHECK(recv_resp.error());
+ HEL_CHECK(recv_path.error());
managarm::posix::SvrResponse<MemoryAllocator> resp(getSysdepsAllocator());
- resp.ParseFromArray(recv_resp->data, recv_resp->length);
+ resp.ParseFromArray(recv_resp.data(), recv_resp.length());
__ensure(resp.error() == managarm::posix::Errors::SUCCESS);
if(static_cast<size_t>(resp.size()) >= size)
return ERANGE;
