MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / fdRead

Method fdRead

lib/host/wasi/inode-linux.cpp:475–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473}
474
475WasiExpect<void> INode::fdRead(Span<Span<uint8_t>> IOVs,
476 __wasi_size_t &NRead) const noexcept {
477 iovec SysIOVs[kIOVMax];
478 size_t SysIOVsSize = 0;
479 for (auto &IOV : IOVs) {
480 SysIOVs[SysIOVsSize].iov_base = IOV.data();
481 SysIOVs[SysIOVsSize].iov_len = IOV.size();
482 ++SysIOVsSize;
483 }
484
485 if (auto Res = ::readv(Fd, SysIOVs, SysIOVsSize); unlikely(Res < 0)) {
486 return WasiUnexpect(fromErrNo(errno));
487 } else {
488 NRead = EndianValue(static_cast<__wasi_size_t>(Res)).le();
489 }
490
491 return {};
492}
493
494// Due to the unfortunate design of wasi::fd_readdir, It's nearly impossible to
495// provide a correct implementation. The below implementation is just a

Callers

nothing calls this directly

Calls 7

unlikelyFunction · 0.85
WasiUnexpectFunction · 0.85
EndianValueClass · 0.85
leMethod · 0.80
fromErrNoFunction · 0.70
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected