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

Function __syscall_ftruncate64

system/lib/wasmfs/syscalls.cpp:1294–1307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1292}
1293
1294int __syscall_ftruncate64(int fd, off_t size) {
1295 auto openFile = wasmFS.getFileTable().locked().getEntry(fd);
1296 if (!openFile) {
1297 return -EBADF;
1298 }
1299 auto ret = doTruncate(openFile->locked().getFile(), size);
1300 // XXX It is not clear from the docs why ftruncate would differ from
1301 // truncate here. However, on Linux this definitely happens, and the old
1302 // FS matches that as well, so do the same here.
1303 if (ret == -EACCES) {
1304 ret = -EINVAL;
1305 }
1306 return ret;
1307}
1308
1309static bool isTTY(std::shared_ptr<File>& file) {
1310 // TODO: Full TTY support. For now, just see stdin/out/err as terminals and

Callers 1

_wasmfs_ftruncateFunction · 0.85

Calls 4

getEntryMethod · 0.80
doTruncateFunction · 0.70
lockedMethod · 0.45
getFileMethod · 0.45

Tested by

no test coverage detected