mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-11 09:25:20 +00:00
Portably handle fd_advise
on directory fd (#2875)
This commit adds a check to `fd_advise`. If the fd is a directory, return `ebadf`. This brings iwasm in line with Wasmtime's behavior. WASI folks have stated that fd_advise should not work on directories as this is a Linux-specific behavior: https://github.com/bytecodealliance/wasmtime/issues/6505#issuecomment-1574122949
This commit is contained in:
parent
ac602bda32
commit
0b332d8987
|
@ -1155,6 +1155,11 @@ wasmtime_ssp_fd_advise(wasm_exec_env_t exec_env, struct fd_table *curfds,
|
|||
if (error != 0)
|
||||
return error;
|
||||
|
||||
if (fo->type == __WASI_FILETYPE_DIRECTORY) {
|
||||
fd_object_release(exec_env, fo);
|
||||
return __WASI_EBADF;
|
||||
}
|
||||
|
||||
error = os_fadvise(fo->file_handle, offset, len, advice);
|
||||
|
||||
fd_object_release(exec_env, fo);
|
||||
|
|
Loading…
Reference in New Issue
Block a user