-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
555: wasi filesystem rewrite + implementation of many syscalls r=MarkMcCaskey a=MarkMcCaskey This lets the go compiler print its help text... The rest of symlink code to follow... This PR also does a major refactor of the file system code. So we'll have to add more tests to be sure we didn't break anything Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: Mark McCaskey <[email protected]>
- Loading branch information
Showing
42 changed files
with
1,197 additions
and
598 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ fn test_fs_sandbox_test() { | |
"fs_sandbox_test", | ||
vec![], | ||
vec![], | ||
vec![], | ||
"../../wasitests/fs_sandbox_test.out" | ||
); | ||
} |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ fn test_hello() { | |
"hello", | ||
vec![], | ||
vec![], | ||
vec![], | ||
"../../wasitests/hello.out" | ||
); | ||
} |
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 |
---|---|---|
|
@@ -13,3 +13,6 @@ mod fseek; | |
mod hello; | ||
mod mapdir; | ||
mod quine; | ||
mod readlink; | ||
mod wasi_sees_virtual_root; | ||
mod writing; |
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,14 @@ | ||
#[test] | ||
fn test_readlink() { | ||
assert_wasi_output!( | ||
"../../wasitests/readlink.wasm", | ||
"readlink", | ||
vec![], | ||
vec![( | ||
".".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet") | ||
),], | ||
vec![], | ||
"../../wasitests/readlink.out" | ||
); | ||
} |
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,24 @@ | ||
#[test] | ||
fn test_wasi_sees_virtual_root() { | ||
assert_wasi_output!( | ||
"../../wasitests/wasi_sees_virtual_root.wasm", | ||
"wasi_sees_virtual_root", | ||
vec![], | ||
vec![ | ||
( | ||
"act1".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1") | ||
), | ||
( | ||
"act2".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act2") | ||
), | ||
( | ||
"act1-again".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1") | ||
), | ||
], | ||
vec![], | ||
"../../wasitests/wasi_sees_virtual_root.out" | ||
); | ||
} |
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,24 @@ | ||
#[test] | ||
fn test_writing() { | ||
assert_wasi_output!( | ||
"../../wasitests/writing.wasm", | ||
"writing", | ||
vec![], | ||
vec![ | ||
( | ||
"act1".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1") | ||
), | ||
( | ||
"act2".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act2") | ||
), | ||
( | ||
"act1-again".to_string(), | ||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1") | ||
), | ||
], | ||
vec![], | ||
"../../wasitests/writing.out" | ||
); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Args: | ||
// dir: . | ||
|
||
use std::fs; | ||
use std::io::{Read, Seek, SeekFrom, Write}; | ||
use std::path::*; | ||
|
Binary file not shown.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
is dir: false | ||
filetype: false true false | ||
file info: 456 | ||
file info: 476 |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Args: | ||
// dir: . | ||
|
||
use std::fs; | ||
use std::io::Read; | ||
|
||
|
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 |
---|---|---|
@@ -1 +1 @@ | ||
create_dir | ||
|
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
"./act3" | ||
"./act4" | ||
"./act5" | ||
"./bookmarks" |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Args: | ||
// dir: . | ||
|
||
use std::fs; | ||
use std::io::Read; | ||
|
||
|
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Args: | ||
// dir: . | ||
|
||
use std::fs; | ||
use std::io::Read; | ||
|
||
|
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,4 @@ | ||
../act1/scene2.txt | ||
SCENE II. A room of state in the castle. | ||
|
||
Enter KING CLAUDIUS, QUEEN GERTRUDE, HAMLET, POLONIUS, LAERTES, VOLTIMAND, CORNELI |
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,21 @@ | ||
// Args: | ||
// mapdir: .:wasitests/test_fs/hamlet | ||
use std::io::Read; | ||
|
||
fn main() { | ||
#[cfg(not(target_os = "wasi"))] | ||
std::env::set_current_dir("wasitests/test_fs/hamlet").unwrap(); | ||
|
||
let sym_link_path = "bookmarks/2019-07-16"; | ||
|
||
let link_path = std::fs::read_link(sym_link_path).unwrap(); | ||
println!("{}", link_path.to_string_lossy()); | ||
|
||
let mut some_contents = std::fs::File::open(sym_link_path).unwrap(); | ||
|
||
let mut buffer = [0; 128]; | ||
|
||
assert_eq!(some_contents.read(&mut buffer).unwrap(), 128); | ||
let str_val = std::str::from_utf8(&buffer[..]).unwrap(); | ||
println!("{}", str_val); | ||
} |
Binary file not shown.
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 @@ | ||
../act1/scene2.txt |
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,13 @@ | ||
"/act1" | ||
"/act1-again" | ||
"/act2" | ||
"/act1" | ||
"/act1-again" | ||
"/act2" | ||
"/act1" | ||
"/act1-again" | ||
"/act2" | ||
"/act1" | ||
"/act1-again" | ||
"/act2" | ||
ROOT IS SAFE |
Oops, something went wrong.