MCPcopy Create free account
hub / github.com/WasmVM/WasmVM / fs_fstat

Function fs_fstat

host/sysenv/sys_fs.cpp:179–193  ·  view source on GitHub ↗

fstat(fd:i32, stat_buf) -> i32

Source from the content-addressed store, hash-verified

177
178// fstat(fd:i32, stat_buf) -> i32
179static std::vector<Value> fs_fstat(Stack& stack) {
180 Frame& frame = stack.frames.top();
181 i32_t fd = std::get<i32_t>(frame.locals[0]);
182 i64_t stat_buf = get_ptr(frame.locals[1]);
183 FdEntry* e = fd_table.get(fd);
184 if(!e || e->is_dir) return {Value(i32_t(-EBADF))};
185 try {
186 stat_t st;
187 if(sys_fstat(e->os_fd, &st) != 0) return {Value(err_code())};
188 write_wasm_stat(stack, stat_buf, st);
189 return {Value(i32_t(0))};
190 } catch(...) {
191 return {Value(i32_t(-EFAULT))};
192 }
193}
194
195// unlink(path_ptr, path_len) -> i32
196static std::vector<Value> fs_unlink(Stack& stack) {

Callers

nothing calls this directly

Calls 6

get_ptrFunction · 0.85
ValueClass · 0.85
sys_fstatFunction · 0.85
err_codeFunction · 0.85
write_wasm_statFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected