Skip to content

Commit

Permalink
Add expected error code for fd_prestat_dir_name
Browse files Browse the repository at this point in the history
In the case that the user provides a buffer which is too small to fit
the directory name, it makes more sense to return EINVAL rather than
ENAMETOOLONG. ENAMETOOLONG has the speficic connotation that a path was
longer than the maximum size permitted by the OS - that doesn't really
match this error condition. We're keeping both error codes for now since
we don't specify in the docs what error code should be returned.
  • Loading branch information
zoraaver authored and loganek committed Oct 3, 2023
1 parent 4451fbe commit 2ea824c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/rust/src/bin/dir_fd_op_failures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ unsafe fn test_fd_dir_ops(dir_fd: wasi::Fd) {
.expect("failed to find preopen directory");

let mut pr_name = vec![];
let r = wasi::fd_prestat_dir_name(pr_fd, pr_name.as_mut_ptr(), 0);
assert_eq!(r, Err(wasi::ERRNO_NAMETOOLONG));
assert_errno!(
wasi::fd_prestat_dir_name(pr_fd, pr_name.as_mut_ptr(), 0)
.expect_err("fd_prestat_dir_name error"),
wasi::ERRNO_INVAL,
wasi::ERRNO_NAMETOOLONG
);

// Test that passing a larger than necessary buffer works correctly
let mut pr_name = vec![0; pr_name_len + 1];
Expand Down

0 comments on commit 2ea824c

Please sign in to comment.