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 8295a2d commit e22fd66
Showing 1 changed file with 11 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2041,32 +2041,18 @@ wasmtime_ssp_path_open(
needed_base |= __WASI_RIGHT_PATH_FILESTAT_SET_SIZE;
}

// 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;
// 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;
}
if (write && (noflags & (O_APPEND | O_TRUNC)) == 0)

// Convert file descriptor flags.
if (write
&& !((fs_flags & __WASI_FDFLAG_APPEND) || (__WASI_O_TRUNC & oflags)))
needed_inheriting |= __WASI_RIGHT_FD_SEEK;

struct path_access pa;
Expand Down

0 comments on commit e22fd66

Please sign in to comment.