Skip to content

Commit

Permalink
Don't support fd sync flags
Browse files Browse the repository at this point in the history
It's not yet clear whether these flags should be added to the standard
so disallow use of them for the time being. See
WebAssembly/wasi-filesystem#98 for more
details. These changes are also necessary to ensure the rust WASI tests
pass since they assert that path_open returns ENOTSUP when passing
O_DSYNC/O_RSYNC/O_SYNC.
  • Loading branch information
zoraaver committed Sep 21, 2023
1 parent 47daaee commit 33532ec
Showing 1 changed file with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1901,31 +1901,20 @@ wasmtime_ssp_path_open(wasm_exec_env_t exec_env, struct fd_table *curfds,
needed_base |= __WASI_RIGHT_PATH_FILESTAT_SET_SIZE;
}

// It's not clear whether we want to support these flags in the standard
// yet: https://github.com/WebAssembly/wasi-filesystem/issues/98 so disable
// them in the meanwhile.
if (((fs_flags & __WASI_FDFLAG_DSYNC) != 0)
|| ((fs_flags & __WASI_FDFLAG_RSYNC) != 0)
|| ((fs_flags & __WASI_FDFLAG_SYNC) != 0)) {
return __WASI_ENOTSUP;
}

// Convert file descriptor flags.
if ((fs_flags & __WASI_FDFLAG_APPEND) != 0)
noflags |= O_APPEND;
if ((fs_flags & __WASI_FDFLAG_DSYNC) != 0) {
#ifdef O_DSYNC
noflags |= O_DSYNC;
#else
noflags |= O_SYNC;
#endif
needed_inheriting |= __WASI_RIGHT_FD_DATASYNC;
}
if ((fs_flags & __WASI_FDFLAG_NONBLOCK) != 0)
noflags |= O_NONBLOCK;
if ((fs_flags & __WASI_FDFLAG_RSYNC) != 0) {
#ifdef O_RSYNC
noflags |= O_RSYNC;
#else
noflags |= O_SYNC;
#endif
needed_inheriting |= __WASI_RIGHT_FD_SYNC;
}
if ((fs_flags & __WASI_FDFLAG_SYNC) != 0) {
noflags |= O_SYNC;
needed_inheriting |= __WASI_RIGHT_FD_SYNC;
}
if (write && (noflags & (O_APPEND | O_TRUNC)) == 0)
needed_inheriting |= __WASI_RIGHT_FD_SEEK;

Expand Down

0 comments on commit 33532ec

Please sign in to comment.