fstat(fd:i32, stat_buf) -> i32
| 177 | |
| 178 | // fstat(fd:i32, stat_buf) -> i32 |
| 179 | static 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 |
| 196 | static std::vector<Value> fs_unlink(Stack& stack) { |