MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / __wasi_fd_sync

Function __wasi_fd_sync

system/lib/wasmfs/syscalls.cpp:303–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303__wasi_errno_t __wasi_fd_sync(__wasi_fd_t fd) {
304 auto openFile = wasmFS.getFileTable().locked().getEntry(fd);
305 if (!openFile) {
306 return __WASI_ERRNO_BADF;
307 }
308
309 // Nothing to flush for anything but a data file, but also not an error either
310 // way. TODO: in the future we may want syncing of directories.
311 auto dataFile = openFile->locked().getFile()->dynCast<DataFile>();
312 if (dataFile) {
313 auto ret = dataFile->locked().flush();
314 assert(ret <= 0);
315 // Translate to WASI standard of positive return codes.
316 return -ret;
317 }
318
319 return __WASI_ERRNO_SUCCESS;
320}
321
322int __syscall_fdatasync(int fd) {
323 // TODO: Optimize this to avoid unnecessarily flushing unnecessary metadata.

Callers 2

fsyncFunction · 0.85
__syscall_fdatasyncFunction · 0.85

Calls 5

getEntryMethod · 0.80
assertFunction · 0.50
lockedMethod · 0.45
getFileMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected