sysdeps/managarm: convert sys_bind to helix_ng
@@ -55,45 +55,25 @@ int sys_bind(int fd, const struct sockaddr *addr_ptr, socklen_t addr_length) {
if (!handle)
return EBADF;
- HelAction actions[5];
- globalQueue.trim();
-
managarm::fs::CntRequest<MemoryAllocator> req(getSysdepsAllocator());
req.set_req_type(managarm::fs::CntReqType::PT_BIND);
- 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 = kHelActionImbueCredentials;
- actions[2].handle = kHelThisThread;
- actions[2].flags = kHelItemChain;
- actions[3].type = kHelActionSendFromBuffer;
- actions[3].flags = kHelItemChain;
- actions[3].buffer = const_cast<struct sockaddr *>(addr_ptr);
- actions[3].length = addr_length;
- actions[4].type = kHelActionRecvInline;
- actions[4].flags = 0;
- HEL_CHECK(helSubmitAsync(handle, actions, 5,
- globalQueue.getQueue(), 0, 0));
-
- auto element = globalQueue.dequeueSingle();
- auto offer = parseHandle(element);
- auto send_req = parseSimple(element);
- auto send_addr = parseSimple(element);
- auto recv_resp = parseInline(element);
-
- HEL_CHECK(offer->error);
- HEL_CHECK(send_req->error);
- HEL_CHECK(send_addr->error);
- HEL_CHECK(recv_resp->error);
+ auto [offer, send_req, send_creds, send_buf, recv_resp] = exchangeMsgsSync(
+ handle,
+ helix_ng::offer(
+ helix_ng::sendBragiHeadOnly(req, getSysdepsAllocator()),
+ helix_ng::imbueCredentials(),
+ helix_ng::sendBuffer(addr_ptr, addr_length),
+ helix_ng::recvInline())
+ );
+ HEL_CHECK(offer.error());
+ HEL_CHECK(send_req.error());
+ HEL_CHECK(send_creds.error());
+ HEL_CHECK(send_buf.error());
+ HEL_CHECK(recv_resp.error());
managarm::fs::SvrResponse<MemoryAllocator> resp(getSysdepsAllocator());
- resp.ParseFromArray(recv_resp->data, recv_resp->length);
+ resp.ParseFromArray(recv_resp.data(), recv_resp.length());
__ensure(resp.error() == managarm::fs::Errors::SUCCESS);
return 0;
}
