MCPcopy Create free account
hub / github.com/chyyuu/os_kernel_lab / main

Function main

user/src/bin/filetest_simple.rs:10–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9#[no_mangle]
10pub fn main() -> i32 {
11 let test_str = "Hello, world!";
12 let filea = "filea\0";
13 let fd = open(filea, OpenFlags::CREATE | OpenFlags::WRONLY);
14 assert!(fd > 0);
15 let fd = fd as usize;
16 write(fd, test_str.as_bytes());
17 close(fd);
18
19 let fd = open(filea, OpenFlags::RDONLY);
20 assert!(fd > 0);
21 let fd = fd as usize;
22 let mut buffer = [0u8; 100];
23 let read_len = read(fd, &mut buffer) as usize;
24 close(fd);
25
26 assert_eq!(test_str, core::str::from_utf8(&buffer[..read_len]).unwrap(),);
27 println!("file_test passed!");
28 0
29}

Callers

nothing calls this directly

Calls 5

openFunction · 0.85
writeFunction · 0.85
closeFunction · 0.85
readFunction · 0.85
as_bytesMethod · 0.80

Tested by

no test coverage detected