forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a missing increment in p1-to-p2 adapter
This commit fixes a bug in the WASIp1-to-WASIp2 adapter during `fd_prestat_dir_name` where an iterator variable was forgotten to be incremented. That means that getting the path for anything other than the first preopen didn't work correctly. Closes bytecodealliance#10058
- Loading branch information
1 parent
3ed4a63
commit d3afa6d
Showing
7 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::str; | ||
|
||
fn main() { | ||
dbg!(wasip2::filesystem::preopens::get_directories()); | ||
unsafe { | ||
let p3 = wasi::fd_prestat_get(3).unwrap(); | ||
let p4 = wasi::fd_prestat_get(4).unwrap(); | ||
let p5 = wasi::fd_prestat_get(5).unwrap(); | ||
assert_eq!(wasi::fd_prestat_get(6).err().unwrap(), wasi::ERRNO_BADF); | ||
|
||
assert_eq!(p3.u.dir.pr_name_len, 2); | ||
assert_eq!(p4.u.dir.pr_name_len, 2); | ||
assert_eq!(p5.u.dir.pr_name_len, 2); | ||
|
||
let mut buf = [0; 100]; | ||
|
||
wasi::fd_prestat_dir_name(3, buf.as_mut_ptr(), buf.len()).unwrap(); | ||
assert_eq!(str::from_utf8(&buf[..2]).unwrap(), "/a"); | ||
wasi::fd_prestat_dir_name(4, buf.as_mut_ptr(), buf.len()).unwrap(); | ||
assert_eq!(str::from_utf8(&buf[..2]).unwrap(), "/b"); | ||
wasi::fd_prestat_dir_name(5, buf.as_mut_ptr(), buf.len()).unwrap(); | ||
assert_eq!(str::from_utf8(&buf[..2]).unwrap(), "/c"); | ||
assert_eq!( | ||
wasi::fd_prestat_dir_name(6, buf.as_mut_ptr(), buf.len()), | ||
Err(wasi::ERRNO_BADF), | ||
); | ||
} | ||
// .. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters